ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc
Revision: 1.4
Committed: Mon Aug 27 18:19:37 2012 UTC (12 years, 8 months ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.3: +16 -82 lines
Log Message:
Restructure analysis code with object selection done in OSUObjects.cc.

File Contents

# User Rev Content
1 ahart 1.1 #include "OSUT3Analysis/AnaTools/interface/OSUAnalysis.h"
2    
3     OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
4 ahart 1.2 // Retrieve parameters from the configuration file.
5 ahart 1.1 muons_ (cfg.getParameter<edm::InputTag> ("muons")),
6 ahart 1.4 muonCfg_ (cfg.getParameter<edm::ParameterSet> ("muonCfg"))
7 ahart 1.1 {
8 ahart 1.2 // Construct CutFlow objects. These store the results of cut decisions and
9     // handle filling cut flow histograms.
10     cuts_ = new CutFlow (hists1D_, fs_);
11 ahart 1.4 muonCuts_ = new CutFlow (hists1D_, fs_, "muon");
12 ahart 1.1
13 ahart 1.2 // Create additional histograms.
14     TH1::SetDefaultSumw2 ();
15     hists1D_["muonPhi"] = fs_->make<TH1D> ("muonPhi", ";#phi", 100, -5.0, 5.0);
16     hists1D_["muonEta"] = fs_->make<TH1D> ("muonEta", ";#eta", 100, -3.0, 3.0);
17 ahart 1.4 hists1D_["muonPt"] = fs_->make<TH1D> ("muonPt", ";p_{T} (GeV/c)", 100, 0.0, 300.0);
18 ahart 1.1 hists1D_["dimuonMass"] = fs_->make<TH1D> ("dimuonMass", ";m_{#mu^{+} #mu^{-}} (GeV/c^{2})", 90, 30.0, 120.0);
19     }
20    
21 ahart 1.2 OSUAnalysis::~OSUAnalysis ()
22 ahart 1.1 {
23 ahart 1.2 // Destroying the CutFlow objects causes the cut flow numbers to be printed
24     // to standard output, as well as time information.
25     delete cuts_;
26 ahart 1.4 delete muonCuts_;
27 ahart 1.1 }
28    
29     void
30     OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
31     {
32 ahart 1.2 // Retrieve necessary collections from the event.
33 ahart 1.1 edm::Handle<BNmuonCollection> muons;
34     event.getByLabel (muons_, muons);
35    
36 ahart 1.2 // Perform selection on objects within the event. The full collection should
37     // only be gone through once.
38 ahart 1.4 GoodMuonCollection goodMuons (muonCfg_, muons, muonCuts_);
39 ahart 1.2
40     // Calculate cut decisions and store the results in the CutFlow object, just
41     // like a map.
42 ahart 1.4 cuts_->at ("minMuons") = goodMuons.size () > 1;
43     cuts_->at ("oppositeSign") = cuts_->at ("minMuons") && goodMuons.leadMuon ()->charge * goodMuons.nextToLeadMuon ()->charge < 0;
44 ahart 1.1
45 ahart 1.2 // This causes the cut flow histograms to be filled.
46     cuts_->fillCutFlow ();
47 ahart 1.1
48 ahart 1.2 // Fill additional histograms while applying desired cuts.
49 ahart 1.4 if (cuts_->at ("minMuons") && cuts_->at ("oppositeSign"))
50 ahart 1.1 {
51 ahart 1.4 for (GoodMuonCollection::const_iterator goodMuon = goodMuons.begin (); goodMuon != goodMuons.end (); goodMuon++)
52 ahart 1.2 {
53 ahart 1.4 if (goodMuon->pass ("minPt"))
54     hists1D_["muonEta"]->Fill (goodMuon->eta);
55     if (goodMuon->pass ("maxEta"))
56     hists1D_["muonPt"]->Fill (goodMuon->pt);
57     if (goodMuon->pass ())
58     hists1D_["muonPhi"]->Fill (goodMuon->phi);
59 ahart 1.2 }
60 ahart 1.4 hists1D_["dimuonMass"]->Fill (goodMuons.dimuonMass ());
61 ahart 1.1 }
62     }
63    
64     DEFINE_FWK_MODULE(OSUAnalysis);