1 | #include "SampleAnalyzer/User/Analyzer/cms_hig_18_011.h"
|
---|
2 |
|
---|
3 | using namespace MA5;
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | // -----------------------------------------------------------------------------
|
---|
7 | // Initialize
|
---|
8 | // function called one time at the beginning of the analysis
|
---|
9 | // -----------------------------------------------------------------------------
|
---|
10 | bool cms_hig_18_011::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
|
---|
11 | {
|
---|
12 | Manager()->AddRegionSelection("mumubb");
|
---|
13 |
|
---|
14 | Manager()->AddCut("preselection");
|
---|
15 | Manager()->AddCut("finalselection");
|
---|
16 |
|
---|
17 | return true;
|
---|
18 | }
|
---|
19 |
|
---|
20 | // -----------------------------------------------------------------------------
|
---|
21 | // Finalize
|
---|
22 | // function called one time at the end of the analysis
|
---|
23 | // -----------------------------------------------------------------------------
|
---|
24 | void cms_hig_18_011::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
|
---|
25 | {
|
---|
26 | }
|
---|
27 |
|
---|
28 | // -----------------------------------------------------------------------------
|
---|
29 | // Execute
|
---|
30 | // function called each time one event is read
|
---|
31 | // -----------------------------------------------------------------------------
|
---|
32 |
|
---|
33 | // -----------------------------------------------------------------------------
|
---|
34 | // Directories of header files
|
---|
35 | //
|
---|
36 | // SampleFormat :: MA5_DIR//tools/SampleAnalyzer/Commons/DataFormat/SampleFormat.h
|
---|
37 | // EventFormat :: MA5_DIR//tools/SampleAnalyzer/Commons/DataFormat/EventFormat.h
|
---|
38 | // All other Rec, MC headers are in MA5_DIR//tools/SampleAnalyzer/Commons/DataFormat/REC_OR_MC_Header.h
|
---|
39 | //
|
---|
40 | // MA_Something like MALorentzVector are in MA5_DIR//tools/SampleAnalyzer/Commons/Vector
|
---|
41 | //
|
---|
42 | // Isolation, EFlow, Tagging information are in MA5_DIR//tools/SampleAnalyzer/Commons/Service
|
---|
43 | //
|
---|
44 | // Delphes cards are in MA5_DIR//tools/SampleAnalyzer/Interfaces/delphes/
|
---|
45 | // -----------------------------------------------------------------------------
|
---|
46 |
|
---|
47 | bool cms_hig_18_011::Execute(SampleFormat& sample, const EventFormat& event) {
|
---|
48 | // --- event weight --- //
|
---|
49 | double weight=1;
|
---|
50 | if(Configuration().IsNoEventWeight()) weight=1.;
|
---|
51 | else if(event.mc()->weight()!=0.) weight=event.mc()->weight();
|
---|
52 | else
|
---|
53 | {
|
---|
54 | WARNING << "Found one event with a zero weight. Skipping..." << endmsg;
|
---|
55 | return false;
|
---|
56 | }
|
---|
57 |
|
---|
58 | //the loop start
|
---|
59 | if(event.rec()==0) { return true;}
|
---|
60 |
|
---|
61 | // --- mumubb selection --- //
|
---|
62 | std::vector<const RecLeptonFormat*> MuMuCandidate;
|
---|
63 | for(unsigned int iMuon = 0; iMuon < event.rec()->muons().size(); iMuon++) {
|
---|
64 | const RecLeptonFormat* LeadingMuon = &(event.rec()->muons()[iMuon]);
|
---|
65 |
|
---|
66 | if (!(LeadingMuon->pt() > 20)) continue;
|
---|
67 | if (!(fabs(LeadingMuon->eta()) < 2.4)) continue;
|
---|
68 | if (!(pfIsolation(event, LeadingMuon) < .15)) continue;
|
---|
69 |
|
---|
70 | for(unsigned int jMuon = iMuon+1; jMuon < event.rec()->muons().size(); jMuon++) {
|
---|
71 | const RecLeptonFormat* SubleadingMuon = &(event.rec()->muons()[jMuon]);
|
---|
72 |
|
---|
73 | if (!(SubleadingMuon->pt() > 9)) continue;
|
---|
74 | if (!(fabs(SubleadingMuon->eta()) < 2.4)) continue;
|
---|
75 | if (!(pfIsolation(event, SubleadingMuon) < .15)) continue;
|
---|
76 |
|
---|
77 | if (!(LeadingMuon->charge()*SubleadingMuon->charge() < 0)) continue;
|
---|
78 |
|
---|
79 | double mass = (LeadingMuon->momentum()+SubleadingMuon->momentum()).M();
|
---|
80 | if (!( 19.5 < mass && mass < 63.5 )) continue;
|
---|
81 |
|
---|
82 | MuMuCandidate.push_back(LeadingMuon);
|
---|
83 | MuMuCandidate.push_back(SubleadingMuon);
|
---|
84 |
|
---|
85 | break;
|
---|
86 | }
|
---|
87 | if( MuMuCandidate.size() == 2 ) break;
|
---|
88 | }
|
---|
89 | bool MuonPairSelection = (MuMuCandidate.size() == 2);
|
---|
90 |
|
---|
91 | std::vector<const RecJetFormat*> bbCandidate;
|
---|
92 | if( MuonPairSelection ) {
|
---|
93 | for(unsigned int iJet = 0; iJet<event.rec()->jets().size(); iJet++) {
|
---|
94 | const RecJetFormat* LeadingJet = &(event.rec()->jets()[iJet]);
|
---|
95 |
|
---|
96 | if (!(LeadingJet->pt() > 20.)) continue;
|
---|
97 | if (!(fabs(LeadingJet->eta()) < 2.4)) continue;
|
---|
98 | if (!(MuonVeto(LeadingJet, MuMuCandidate))) continue;
|
---|
99 | if (!(LeadingJet->btag())) continue;
|
---|
100 |
|
---|
101 | for(unsigned int jJet = iJet+1; jJet<event.rec()->jets().size(); jJet++) {
|
---|
102 | const RecJetFormat* SubleadingJet = &(event.rec()->jets()[jJet]);
|
---|
103 |
|
---|
104 | if (!(SubleadingJet->pt() > 15)) continue;
|
---|
105 | if (!(fabs(SubleadingJet->eta()) < 2.4)) continue;
|
---|
106 | if (!(MuonVeto(SubleadingJet, MuMuCandidate))) continue;
|
---|
107 | if (!(SubleadingJet->btag())) continue;
|
---|
108 |
|
---|
109 | bbCandidate.push_back(LeadingJet);
|
---|
110 | bbCandidate.push_back(SubleadingJet);
|
---|
111 |
|
---|
112 | break;
|
---|
113 | }
|
---|
114 | if( bbCandidate.size() == 2 ) break;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | bool JetPairSelection = (bbCandidate.size() == 2);
|
---|
118 |
|
---|
119 |
|
---|
120 | // --- event reweight --- //
|
---|
121 | if( JetPairSelection ) {
|
---|
122 | weight *= (.81/.84)*(.81/.84);
|
---|
123 | weight *= (1 - (1 - TightBTagEff( bbCandidate[0] )/LooseBTagEff( bbCandidate[0] ))*(1 - TightBTagEff( bbCandidate[1] )/LooseBTagEff( bbCandidate[1] )));
|
---|
124 | }
|
---|
125 |
|
---|
126 | Manager()->InitializeForNewEvent(weight);
|
---|
127 |
|
---|
128 |
|
---|
129 | if(!Manager()->ApplyCut(MuonPairSelection&&JetPairSelection, "preselection")) return true;
|
---|
130 |
|
---|
131 |
|
---|
132 | // --- final selection --- //
|
---|
133 | MALorentzVector MET_p4 = event.rec()->MET().momentum();
|
---|
134 | double MET_Pt = MET_p4.Pt();
|
---|
135 |
|
---|
136 | bool METCut = (MET_Pt < 60);
|
---|
137 |
|
---|
138 | double Mass_bb = (bbCandidate[0]->momentum()+bbCandidate[1]->momentum()).M();
|
---|
139 | double Mass_MuMu = (MuMuCandidate[0]->momentum()+MuMuCandidate[1]->momentum()).M();
|
---|
140 | double Mass_MuMubb = (MuMuCandidate[0]->momentum()+MuMuCandidate[1]->momentum()+bbCandidate[0]->momentum()+bbCandidate[1]->momentum()).M();
|
---|
141 | double Mass_h = 125.18;
|
---|
142 | // --- Mass resolution --- //
|
---|
143 | // = From Gaussian fit = //
|
---|
144 | double Sigma_bb = 0.173*Mass_MuMu; // 1.5*sig fit
|
---|
145 | double Sigma_h = 9.66; // 1.5*sig fit
|
---|
146 | // ----------------------- //
|
---|
147 |
|
---|
148 | double Chi_bb = (Mass_bb - Mass_MuMu)/Sigma_bb;
|
---|
149 | double Chi_h = (Mass_MuMubb - Mass_h)/Sigma_h;
|
---|
150 | double Chi2_ = pow(Chi_bb,2) + pow(Chi_h,2);
|
---|
151 |
|
---|
152 | bool Chi2Cut = (Chi2_ < 5);
|
---|
153 |
|
---|
154 | if(!Manager()->ApplyCut(METCut&&Chi2Cut, "finalselection")) return true;
|
---|
155 |
|
---|
156 | return true;
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | double cms_hig_18_011::pfIsolation(const EventFormat& event, const RecLeptonFormat* Muon) {
|
---|
161 | double Isolation = 0.;
|
---|
162 |
|
---|
163 | MALorentzVector Muon_p4 = Muon->momentum();
|
---|
164 |
|
---|
165 | double ChargedHadronIso = PHYSICS->Isol->eflow->relIsolation(Muon, event.rec(), .4, 1., IsolationEFlow::TRACK_COMPONENT);
|
---|
166 | double NeutralHadronIso = PHYSICS->Isol->eflow->relIsolation(Muon, event.rec(), .4, 1., IsolationEFlow::NEUTRAL_COMPONENT);
|
---|
167 | double PhotonIso = PHYSICS->Isol->eflow->relIsolation(Muon, event.rec(), .4, 1., IsolationEFlow::PHOTON_COMPONENT);
|
---|
168 | Isolation = ChargedHadronIso + NeutralHadronIso + PhotonIso;
|
---|
169 |
|
---|
170 | return Isolation;
|
---|
171 | }
|
---|
172 |
|
---|
173 | bool cms_hig_18_011::MuonVeto(const RecJetFormat* Jet, std::vector<const RecLeptonFormat*> Muons) {
|
---|
174 | for(unsigned iMuon = 0; iMuon < Muons.size(); iMuon++) {
|
---|
175 | if( Jet->momentum().DeltaR( Muons[iMuon]->momentum() ) < 0.5 )
|
---|
176 | return false;
|
---|
177 | }
|
---|
178 | return true;
|
---|
179 | }
|
---|
180 |
|
---|
181 | double cms_hig_18_011::LooseBTagEff(const RecJetFormat* Jet) {
|
---|
182 | double out;
|
---|
183 | double pT = Jet->pt();
|
---|
184 | if( pT < 160 )
|
---|
185 | out = 0.4344 + 0.02069*pT - 0.0004429*pow(pT,2) + 5.137*pow(10,-6)*pow(pT,3) - 3.406*pow(10,-8)*pow(pT,4) + 1.285*pow(10,-10)*pow(pT,5) - 2.559*pow(10,-13)*pow(pT,6) + 2.084*pow(10,-16)*pow(pT,7);
|
---|
186 | else if( pT < 300 )
|
---|
187 | out = 0.714 + 0.002617*pT - 1.656*pow(10,-5)*pow(pT,2) + 4.767*pow(10,-8)*pow(pT,3) - 6.431*pow(10,-11)*pow(pT,4) + 3.287*pow(10,-14)*pow(pT,5);
|
---|
188 | else out = 0.872 - 6.885*pow(10,-5)*pT + 4.34*pow(10,-8)*pT*pT;
|
---|
189 |
|
---|
190 | out *= .81/.84;
|
---|
191 |
|
---|
192 | return out;
|
---|
193 | }
|
---|
194 |
|
---|
195 | double cms_hig_18_011::TightBTagEff(const RecJetFormat* Jet) {
|
---|
196 | double out;
|
---|
197 | double pT = Jet->pt();
|
---|
198 | if( pT < 50 )
|
---|
199 | out = -0.033 + 0.0225*pT - 0.00035*pow(pT,2) + 2.586*pow(10,-6)*pow(pT,3) - 9.096*pow(10,-9)*pow(pT,4) + 1.212*pow(10,-11)*pow(pT,5);
|
---|
200 | else if( pT < 160 )
|
---|
201 | out = 0.169 + 0.013*pT - 0.00019*pow(pT,2) + 1.373*pow(10,-6)*pow(pT,3) - 4.923*pow(10,-9)*pow(pT,4) + 6.87*pow(10,-12)*pow(pT,5);
|
---|
202 | else out = 0.62 - 0.00083*pT + 4.3078*pow(10,-7)*pow(pT,2);
|
---|
203 |
|
---|
204 | out *= .41/.50;
|
---|
205 |
|
---|
206 | return out;
|
---|
207 | }
|
---|
208 |
|
---|