ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc
Revision: 1.5
Committed: Tue Aug 28 13:54:58 2012 UTC (12 years, 8 months ago) by ahart
Content type: text/plain
Branch: MAIN
CVS Tags: mytag_0_0_0, V00-00-03
Changes since 1.4: +8 -7 lines
Log Message:
Update comments and break up minMuons cut.

File Contents

# Content
1 #include "OSUT3Analysis/AnaTools/interface/OSUAnalysis.h"
2
3 OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
4 // Retrieve parameters from the configuration file.
5 muons_ (cfg.getParameter<edm::InputTag> ("muons")),
6 muonCfg_ (cfg.getParameter<edm::ParameterSet> ("muonCfg"))
7 {
8 // Construct CutFlow objects. These store the results of cut decisions and
9 // handle filling cut flow histograms.
10 cuts_ = new CutFlow (hists1D_, fs_);
11 muonCuts_ = new CutFlow (hists1D_, fs_, "muon");
12
13 // 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 hists1D_["muonPt"] = fs_->make<TH1D> ("muonPt", ";p_{T} (GeV/c)", 100, 0.0, 300.0);
18 hists1D_["dimuonMass"] = fs_->make<TH1D> ("dimuonMass", ";m_{#mu^{+} #mu^{-}} (GeV/c^{2})", 90, 30.0, 120.0);
19 }
20
21 OSUAnalysis::~OSUAnalysis ()
22 {
23 // Destroying the CutFlow objects causes the cut flow numbers and time
24 // information to be printed to standard output.
25 delete cuts_;
26 delete muonCuts_;
27 }
28
29 void
30 OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
31 {
32 // Retrieve necessary collections from the event.
33 edm::Handle<BNmuonCollection> muons;
34 event.getByLabel (muons_, muons);
35
36 // Perform selection on objects within the event while filling the cut flow
37 // object specific to this collection.
38 GoodMuonCollection goodMuons (muonCfg_, muons, muonCuts_);
39
40 // Calculate cut decisions and store the results in the CutFlow object, just
41 // like a map.
42 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
46 // This causes the cut flow histograms to be filled.
47 cuts_->fillCutFlow ();
48
49 // Fill additional histograms while applying desired cuts.
50 if (cuts_->at ("oppositeSign"))
51 {
52 for (GoodMuonCollection::const_iterator goodMuon = goodMuons.begin (); goodMuon != goodMuons.end (); goodMuon++)
53 {
54 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 }
61 hists1D_["dimuonMass"]->Fill (goodMuons.dimuonMass ());
62 }
63 }
64
65 DEFINE_FWK_MODULE(OSUAnalysis);