ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc
Revision: 1.6
Committed: Fri Sep 7 19:54:58 2012 UTC (12 years, 8 months ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.5: +2 -2 lines
Log Message:
Don't pass a histogram map to the CutFlow constructor.

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 ahart 1.6 cuts_ = new CutFlow (fs_);
11     muonCuts_ = new CutFlow (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.5 // Destroying the CutFlow objects causes the cut flow numbers and time
24     // information to be printed to standard output.
25 ahart 1.2 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.5 // Perform selection on objects within the event while filling the cut flow
37     // object specific to this collection.
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.5 cuts_->at ("maxEta") = goodMuons.goodEtaSize () > 1;
43     cuts_->at ("minPt") = goodMuons.goodPtSize () > 1;
44     cuts_->at ("oppositeSign") = goodMuons.goodSize () > 1 && goodMuons.leadMuon ()->charge * goodMuons.nextToLeadMuon ()->charge < 0;
45 ahart 1.1
46 ahart 1.2 // This causes the cut flow histograms to be filled.
47     cuts_->fillCutFlow ();
48 ahart 1.1
49 ahart 1.2 // Fill additional histograms while applying desired cuts.
50 ahart 1.5 if (cuts_->at ("oppositeSign"))
51 ahart 1.1 {
52 ahart 1.4 for (GoodMuonCollection::const_iterator goodMuon = goodMuons.begin (); goodMuon != goodMuons.end (); goodMuon++)
53 ahart 1.2 {
54 ahart 1.4 if (goodMuon->pass ("minPt"))
55     hists1D_["muonEta"]->Fill (goodMuon->eta);
56     if (goodMuon->pass ("maxEta"))
57     hists1D_["muonPt"]->Fill (goodMuon->pt);
58     if (goodMuon->pass ())
59     hists1D_["muonPhi"]->Fill (goodMuon->phi);
60 ahart 1.2 }
61 ahart 1.4 hists1D_["dimuonMass"]->Fill (goodMuons.dimuonMass ());
62 ahart 1.1 }
63     }
64    
65     DEFINE_FWK_MODULE(OSUAnalysis);