3 |
|
OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) : |
4 |
|
// Retrieve parameters from the configuration file. |
5 |
|
muons_ (cfg.getParameter<edm::InputTag> ("muons")), |
6 |
< |
maxEta_ (cfg.getParameter<double> ("maxEta")), |
7 |
< |
minPt_ (cfg.getParameter<double> ("minPt")) |
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_, "muons"); |
10 |
> |
cuts_ = new CutFlow (fs_); |
11 |
> |
muonCuts_ = new CutFlow (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); |
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); |
20 |
– |
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); |
19 |
|
} |
20 |
|
|
21 |
|
OSUAnalysis::~OSUAnalysis () |
22 |
|
{ |
23 |
< |
// Destroying the CutFlow objects causes the cut flow numbers to be printed |
24 |
< |
// to standard output, as well as time information. |
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 |
33 |
|
edm::Handle<BNmuonCollection> muons; |
34 |
|
event.getByLabel (muons_, muons); |
35 |
|
|
36 |
< |
// Perform selection on objects within the event. The full collection should |
37 |
< |
// only be gone through once. |
38 |
< |
vector<BNmuonCollection::const_iterator> leadMuons; |
43 |
< |
selectLeadMuons (muons, leadMuons); |
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 ("minMuons") = leadMuons.size () == 2; |
43 |
< |
if (cuts_->at ("minMuons")) |
44 |
< |
{ |
50 |
< |
cuts_->at ("maxEta") = leadMuons.at (0)->eta < maxEta_ && leadMuons.at (1)->eta < maxEta_; |
51 |
< |
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; |
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 ("minMuons")) |
62 |
< |
{ |
63 |
< |
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 |
< |
{ |
84 |
< |
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 |
< |
} |
101 |
< |
} |
102 |
< |
} |
103 |
< |
|
104 |
< |
void |
105 |
< |
OSUAnalysis::selectLeadMuons (const edm::Handle<BNmuonCollection> &muons, vector<BNmuonCollection::const_iterator> &leadMuons) |
106 |
< |
{ |
107 |
< |
for (BNmuonCollection::const_iterator newMuon = muons->begin (); newMuon != muons->end (); newMuon++) |
50 |
> |
if (cuts_->at ("oppositeSign")) |
51 |
|
{ |
52 |
< |
vector<BNmuonCollection::const_iterator>::iterator muon; |
110 |
< |
for (muon = leadMuons.begin (); muon != leadMuons.end (); muon++) |
52 |
> |
for (GoodMuonCollection::const_iterator goodMuon = goodMuons.begin (); goodMuon != goodMuons.end (); goodMuon++) |
53 |
|
{ |
54 |
< |
if ((*muon)->pt < newMuon->pt) |
55 |
< |
break; |
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 |
< |
leadMuons.insert (muon, newMuon); |
61 |
> |
hists1D_["dimuonMass"]->Fill (goodMuons.dimuonMass ()); |
62 |
|
} |
117 |
– |
if (leadMuons.size () > 2) |
118 |
– |
leadMuons.resize (2); |
119 |
– |
} |
120 |
– |
|
121 |
– |
double |
122 |
– |
OSUAnalysis::dimuonMass (const BNmuonCollection::const_iterator &muon1, const BNmuonCollection::const_iterator &muon2) |
123 |
– |
{ |
124 |
– |
TLorentzVector muVec1 (muon1->px, muon1->py, muon1->pz, muon1->energy), |
125 |
– |
muVec2 (muon2->px, muon2->py, muon2->pz, muon2->energy); |
126 |
– |
|
127 |
– |
return (muVec1 + muVec2).M (); |
63 |
|
} |
64 |
|
|
65 |
|
DEFINE_FWK_MODULE(OSUAnalysis); |