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 |
|
|
maxEta_ (cfg.getParameter<double> ("maxEta")),
|
7 |
|
|
minPt_ (cfg.getParameter<double> ("minPt"))
|
8 |
|
|
{
|
9 |
ahart |
1.2 |
// Construct CutFlow objects. These store the results of cut decisions and
|
10 |
|
|
// handle filling cut flow histograms.
|
11 |
|
|
cuts_ = new CutFlow (hists1D_, fs_);
|
12 |
|
|
// muonCuts_ = new CutFlow (hists1D_, fs_, "muons");
|
13 |
ahart |
1.1 |
|
14 |
ahart |
1.2 |
// Create additional histograms.
|
15 |
|
|
TH1::SetDefaultSumw2 ();
|
16 |
|
|
hists1D_["muonPhi"] = fs_->make<TH1D> ("muonPhi", ";#phi", 100, -5.0, 5.0);
|
17 |
|
|
hists1D_["muonEta"] = fs_->make<TH1D> ("muonEta", ";#eta", 100, -3.0, 3.0);
|
18 |
ahart |
1.1 |
hists1D_["muonPT"] = fs_->make<TH1D> ("muonPt", ";p_{T} (GeV/c)", 100, 0.0, 300.0);
|
19 |
|
|
hists1D_["dimuonMass"] = fs_->make<TH1D> ("dimuonMass", ";m_{#mu^{+} #mu^{-}} (GeV/c^{2})", 90, 30.0, 120.0);
|
20 |
ahart |
1.2 |
hists1D_["backMuonPhi"] = fs_->make<TH1D> ("backMuonPhi", ";#phi", 100, -5.0, 5.0);
|
21 |
|
|
hists1D_["backMuonEta"] = fs_->make<TH1D> ("backMuonEta", ";#eta", 100, -3.0, 3.0);
|
22 |
|
|
hists1D_["backMuonPT"] = fs_->make<TH1D> ("backMuonPt", ";p_{T} (GeV/c)", 100, 0.0, 300.0);
|
23 |
|
|
hists1D_["backDimuonMass"] = fs_->make<TH1D> ("backDimuonMass", ";m_{#mu^{+} #mu^{-}} (GeV/c^{2})", 90, 30.0, 120.0);
|
24 |
ahart |
1.1 |
}
|
25 |
|
|
|
26 |
ahart |
1.2 |
OSUAnalysis::~OSUAnalysis ()
|
27 |
ahart |
1.1 |
{
|
28 |
ahart |
1.2 |
// Destroying the CutFlow objects causes the cut flow numbers to be printed
|
29 |
|
|
// to standard output, as well as time information.
|
30 |
|
|
delete cuts_;
|
31 |
ahart |
1.1 |
}
|
32 |
|
|
|
33 |
|
|
void
|
34 |
|
|
OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
|
35 |
|
|
{
|
36 |
ahart |
1.2 |
// Retrieve necessary collections from the event.
|
37 |
ahart |
1.1 |
edm::Handle<BNmuonCollection> muons;
|
38 |
|
|
event.getByLabel (muons_, muons);
|
39 |
|
|
|
40 |
ahart |
1.2 |
// Perform selection on objects within the event. The full collection should
|
41 |
|
|
// only be gone through once.
|
42 |
|
|
vector<BNmuonCollection::const_iterator> leadMuons;
|
43 |
|
|
selectLeadMuons (muons, leadMuons);
|
44 |
|
|
|
45 |
|
|
// Calculate cut decisions and store the results in the CutFlow object, just
|
46 |
|
|
// like a map.
|
47 |
|
|
cuts_->at ("minMuons") = leadMuons.size () == 2;
|
48 |
|
|
if (cuts_->at ("minMuons"))
|
49 |
|
|
{
|
50 |
ahart |
1.3 |
cuts_->at ("maxEta") = fabs (leadMuons.at (0)->eta) < maxEta_ && leadMuons.at (1)->eta < maxEta_;
|
51 |
ahart |
1.2 |
cuts_->at ("minPT") = leadMuons.at (0)->pt > minPt_ && leadMuons.at (1)->pt < minPt_;
|
52 |
|
|
cuts_->at ("oppositeSign") = leadMuons.at (0)->charge * leadMuons.at (1)->charge < 0;
|
53 |
|
|
}
|
54 |
|
|
else
|
55 |
|
|
cuts_->at ("maxEta") = cuts_->at ("minPT") = cuts_->at ("oppositeSign") = false;
|
56 |
ahart |
1.1 |
|
57 |
ahart |
1.2 |
// This causes the cut flow histograms to be filled.
|
58 |
|
|
cuts_->fillCutFlow ();
|
59 |
ahart |
1.1 |
|
60 |
ahart |
1.2 |
// Fill additional histograms while applying desired cuts.
|
61 |
|
|
if (cuts_->at ("minMuons"))
|
62 |
ahart |
1.1 |
{
|
63 |
ahart |
1.2 |
if (cuts_->at ("oppositeSign"))
|
64 |
|
|
{
|
65 |
|
|
if (cuts_->at ("minPT"))
|
66 |
|
|
{
|
67 |
|
|
hists1D_["muonEta"]->Fill (leadMuons.at (0)->eta);
|
68 |
|
|
hists1D_["muonEta"]->Fill (leadMuons.at (1)->eta);
|
69 |
|
|
}
|
70 |
|
|
if (cuts_->at ("maxEta"))
|
71 |
|
|
{
|
72 |
|
|
hists1D_["muonPT"]->Fill (leadMuons.at (0)->pt);
|
73 |
|
|
hists1D_["muonPT"]->Fill (leadMuons.at (1)->pt);
|
74 |
|
|
}
|
75 |
|
|
if (cuts_->at ("minPT") && cuts_->at ("maxEta"))
|
76 |
|
|
{
|
77 |
|
|
hists1D_["muonPhi"]->Fill (leadMuons.at (0)->phi);
|
78 |
|
|
hists1D_["muonPhi"]->Fill (leadMuons.at (1)->phi);
|
79 |
|
|
hists1D_["dimuonMass"]->Fill (dimuonMass (leadMuons.at (0), leadMuons.at (1)));
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
else
|
83 |
ahart |
1.1 |
{
|
84 |
ahart |
1.2 |
if (cuts_->at ("minPT"))
|
85 |
|
|
{
|
86 |
|
|
hists1D_["backMuonEta"]->Fill (leadMuons.at (0)->eta);
|
87 |
|
|
hists1D_["backMuonEta"]->Fill (leadMuons.at (1)->eta);
|
88 |
|
|
}
|
89 |
|
|
if (cuts_->at ("maxEta"))
|
90 |
|
|
{
|
91 |
|
|
hists1D_["backMuonPT"]->Fill (leadMuons.at (0)->pt);
|
92 |
|
|
hists1D_["backMuonPT"]->Fill (leadMuons.at (1)->pt);
|
93 |
|
|
}
|
94 |
|
|
if (cuts_->at ("minPT") && cuts_->at ("maxEta"))
|
95 |
|
|
{
|
96 |
|
|
hists1D_["backMuonPhi"]->Fill (leadMuons.at (0)->phi);
|
97 |
|
|
hists1D_["backMuonPhi"]->Fill (leadMuons.at (1)->phi);
|
98 |
|
|
hists1D_["backDimuonMass"]->Fill (dimuonMass (leadMuons.at (0), leadMuons.at (1)));
|
99 |
|
|
}
|
100 |
ahart |
1.1 |
}
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
void
|
105 |
ahart |
1.2 |
OSUAnalysis::selectLeadMuons (const edm::Handle<BNmuonCollection> &muons, vector<BNmuonCollection::const_iterator> &leadMuons)
|
106 |
ahart |
1.1 |
{
|
107 |
ahart |
1.2 |
for (BNmuonCollection::const_iterator newMuon = muons->begin (); newMuon != muons->end (); newMuon++)
|
108 |
ahart |
1.1 |
{
|
109 |
ahart |
1.2 |
vector<BNmuonCollection::const_iterator>::iterator muon;
|
110 |
|
|
for (muon = leadMuons.begin (); muon != leadMuons.end (); muon++)
|
111 |
|
|
{
|
112 |
|
|
if ((*muon)->pt < newMuon->pt)
|
113 |
|
|
break;
|
114 |
|
|
}
|
115 |
|
|
leadMuons.insert (muon, newMuon);
|
116 |
ahart |
1.1 |
}
|
117 |
ahart |
1.2 |
if (leadMuons.size () > 2)
|
118 |
|
|
leadMuons.resize (2);
|
119 |
ahart |
1.1 |
}
|
120 |
|
|
|
121 |
|
|
double
|
122 |
|
|
OSUAnalysis::dimuonMass (const BNmuonCollection::const_iterator &muon1, const BNmuonCollection::const_iterator &muon2)
|
123 |
|
|
{
|
124 |
ahart |
1.2 |
TLorentzVector muVec1 (muon1->px, muon1->py, muon1->pz, muon1->energy),
|
125 |
|
|
muVec2 (muon2->px, muon2->py, muon2->pz, muon2->energy);
|
126 |
ahart |
1.1 |
|
127 |
ahart |
1.2 |
return (muVec1 + muVec2).M ();
|
128 |
ahart |
1.1 |
}
|
129 |
|
|
|
130 |
|
|
DEFINE_FWK_MODULE(OSUAnalysis);
|