MA5SandBox: atlas_exot_2018_30.cpp

File atlas_exot_2018_30.cpp, 10.7 KB (added by Benjamin Fuks, 4 years ago)
Line 
1#include "SampleAnalyzer/User/Analyzer/atlas_exot_2018_30.h"
2using namespace MA5;
3using namespace std;
4
5
6template<typename T1, typename T2> std::vector<const T1*> Removal(std::vector<const T1*> &v1, std::vector<const T2*> &v2, const MAdouble64 &drmin) {
7 // Determining with objects should be removed
8 std::vector<bool> mask(v1.size(), false);
9 for (MAuint32 j=0; j<v1.size(); j++)
10 for (MAuint32 i=0; i<v2.size(); i++)
11 if (v2[i]->dr(v1[j]) < drmin) {
12 mask[j] = true;
13 break;
14 }
15
16 // Building the cleaned container
17 std::vector<const T1*> cleaned_v1;
18 for (MAuint32 i=0; i<v1.size(); i++)
19 if (!mask[i]) cleaned_v1.push_back(v1[i]);
20
21 return cleaned_v1;
22}
23
24// -----------------------------------------------------------------------------
25// Initialize
26// function called one time at the beginning of the analysis
27// -----------------------------------------------------------------------------
28bool atlas_exot_2018_30::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
29{
30 cout << "BEGIN Initialization" << endl;
31
32 INFO << " <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endmsg;
33 INFO << " <> Analysis: ATLAS-EXOT-2018-30, arXiv:1906.05609 <>" << endmsg;
34 INFO << " <> W' to single lepton + MET, 139 fb^-1 lumi (13 TeV) <>" << endmsg;
35 INFO << " <> Recast by: Kyungmin Park <>" << endmsg;
36 INFO << " <> Contact: jazzykm0110@uos.ac.kr <>" << endmsg;
37 INFO << " <> Based on MadAnalysis 5 v1.8.40 <>" << endmsg;
38 INFO << " <> For more information, see <>" << endmsg;
39 INFO << " <> http://madanalysis.irmp.ucl.ac.be/wiki/PublicAnalysisDatabase <>" << endmsg;
40 INFO << " <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endmsg;
41
42
43 // Declaration of the signal regions
44 Manager()->AddRegionSelection("SR_Electron_MT_130_400");
45 Manager()->AddRegionSelection("SR_Electron_MT_400_600");
46 Manager()->AddRegionSelection("SR_Electron_MT_600_1000");
47 Manager()->AddRegionSelection("SR_Electron_MT_1000_2000");
48 Manager()->AddRegionSelection("SR_Electron_MT_2000_3000");
49 Manager()->AddRegionSelection("SR_Electron_MT_3000_10000");
50 Manager()->AddRegionSelection("SR_Electron_MT_130_inf");
51
52 Manager()->AddRegionSelection("SR_Muon_MT_110_400");
53 Manager()->AddRegionSelection("SR_Muon_MT_400_600");
54 Manager()->AddRegionSelection("SR_Muon_MT_600_1000");
55 Manager()->AddRegionSelection("SR_Muon_MT_1000_2000");
56 Manager()->AddRegionSelection("SR_Muon_MT_2000_3000");
57 Manager()->AddRegionSelection("SR_Muon_MT_3000_10000");
58 Manager()->AddRegionSelection("SR_Muon_MT_110_inf");
59
60
61 // Cuts for each SR
62 std::string OneElec[] = { "SR_Electron_MT_130_400", "SR_Electron_MT_400_600", "SR_Electron_MT_600_1000", "SR_Electron_MT_1000_2000", "SR_Electron_MT_2000_3000", "SR_Electron_MT_3000_10000", "SR_Electron_MT_130_inf" };
63 std::string OneMuon[] = { "SR_Muon_MT_110_400", "SR_Muon_MT_400_600", "SR_Muon_MT_600_1000", "SR_Muon_MT_1000_2000", "SR_Muon_MT_2000_3000", "SR_Muon_MT_3000_10000", "SR_Muon_MT_110_inf" };
64
65 std::string MT_400_600[] = { "SR_Electron_MT_400_600", "SR_Muon_MT_400_600" };
66 std::string MT_600_1000[] = { "SR_Electron_MT_600_1000", "SR_Muon_MT_600_1000" };
67 std::string MT_1000_2000[] = { "SR_Electron_MT_1000_2000", "SR_Muon_MT_1000_2000" };
68 std::string MT_2000_3000[] = { "SR_Electron_MT_2000_3000", "SR_Muon_MT_2000_3000" };
69 std::string MT_3000_10000[] = { "SR_Electron_MT_3000_10000", "SR_Muon_MT_3000_10000" };
70
71 Manager()->AddCut("One Electron", OneElec);
72 Manager()->AddCut("One Muon", OneMuon);
73
74 Manager()->AddCut("Lepton Veto for Electrons", OneElec);
75 Manager()->AddCut("Lepton Veto for Muons", OneMuon);
76
77 Manager()->AddCut("$\\slashed{E}_T > 55$ [GeV]", OneMuon);
78 Manager()->AddCut("$\\slashed{E}_T > 65$ [GeV]", OneElec);
79 Manager()->AddCut("$M_T > 130$ [GeV]", OneElec);
80 Manager()->AddCut("$M_T > 110$ [GeV]", OneMuon);
81
82 Manager()->AddCut("$110 < M_T < 400$ [GeV]", OneMuon[0]);
83 Manager()->AddCut("$130 < M_T < 400$ [GeV]", OneElec[0]);
84 Manager()->AddCut("$400 < M_T < 600$ [GeV]", MT_400_600);
85 Manager()->AddCut("$600 < M_T < 1000$ [GeV]", MT_600_1000);
86 Manager()->AddCut("$1000 < M_T < 2000$ [GeV]", MT_1000_2000);
87 Manager()->AddCut("$2000 < M_T < 3000$ [GeV]", MT_2000_3000);
88 Manager()->AddCut("$3000 < M_T < 10000$ [GeV]", MT_3000_10000);
89
90
91 // Histogram declaration
92 //Manager()->AddHisto("MT > 110 GeV for Muon Channel", 50, 110, 7200, OneMuon[6]);
93 //Manager()->AddHisto("MT > 130 GeV for Electron Channel", 60, 130, 7200, OneElec[6]);
94
95 Manager()->AddHistoLogX("MT > 110 GeV for Muon Channel (finer log bins)", 100, 110, 7200, OneMuon[6]);
96 Manager()->AddHistoLogX("MT > 130 GeV for Electron Channel (finer log bins)", 120, 130, 7200, OneElec[6]);
97
98 Manager()->AddHistoLogX("MT > 110 GeV for Muon Channel (log bins)", 50, 110, 7200, OneMuon[6]);
99 Manager()->AddHistoLogX("MT > 130 GeV for Electron Channel (log bins)",60, 130, 7200, OneElec[6]);
100
101 cout << "END Initialization" << endl;
102 return true;
103}
104
105
106// -----------------------------------------------------------------------------
107// Finalize
108// function called one time at the end of the analysis
109// -----------------------------------------------------------------------------
110void atlas_exot_2018_30::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
111{
112 cout << "BEGIN Finalization" << endl;
113 // saving histos
114 cout << "END Finalization" << endl;
115}
116
117
118// -----------------------------------------------------------------------------
119// Execute
120// function called each time one event is read
121// -----------------------------------------------------------------------------
122bool atlas_exot_2018_30::Execute(SampleFormat& sample, const EventFormat& event)
123{
124 // Event weight
125 double myWeight;
126 if (Configuration().IsNoEventWeight()) myWeight = 1.;
127 else if (event.mc()->weight() != 0.) myWeight = event.mc()->weight();
128 else { return false; }
129 Manager()->InitializeForNewEvent(myWeight);
130
131 // Security for empty events
132 if (event.rec() == 0) return true;
133
134
135 // Muon
136 std::vector<const RecLeptonFormat*> SignalMuons, VetoedMuons;
137 for (unsigned int i=0; i<event.rec()->muons().size(); i++) {
138 const RecLeptonFormat *Muon = &(event.rec()->muons()[i]);
139
140 // Kinematics
141 double eta = Muon->abseta();
142 double pt = Muon->pt();
143
144 // Isolation
145 double iso_dR = std::min(10./pt, 0.3);
146 double iso_tracks = PHYSICS->Isol->eflow->relIsolation(Muon, event.rec(), iso_dR, 1., IsolationEFlow::TRACK_COMPONENT);
147 bool iso = (iso_tracks < 0.15);
148
149 // Signal Muons
150 if ( (0.1 < eta && eta < 1.01) || (1.1 < eta && eta < 2.4) ) {
151 if ( pt > 55. ) {
152 if ( iso ) { SignalMuons.push_back(Muon); continue; }
153 }
154 }
155
156 // Vetoed Muons
157 if ( pt > 20. ) { VetoedMuons.push_back(Muon); }
158 }
159
160
161 // Electron
162 std::vector<const RecLeptonFormat*> SignalElectrons, VetoedElectrons, VetoedElectronsDeltaR;
163 for (unsigned int i=0; i<event.rec()->electrons().size(); i++) {
164 const RecLeptonFormat *Elec = &(event.rec()->electrons()[i]);
165
166 // Kinematics
167 double eta = Elec->abseta();
168 double pt = Elec->pt();
169 double Et = Elec->et();
170
171 // Isolation
172 double iso_tracks = PHYSICS->Isol->eflow->relIsolation(Elec, event.rec(), 0.2, 0., IsolationEFlow::TRACK_COMPONENT);
173 double iso_all = PHYSICS->Isol->eflow->relIsolation(Elec, event.rec(), 0.2, 0., IsolationEFlow::ALL_COMPONENTS);
174 bool iso = (iso_tracks < 0.06 && iso_all < 0.06);
175
176 // Signal Electrons
177 if ( eta < 1.37 || ( 1.52 < eta && eta < 2.47 ) ) {
178 if ( Et > 65. && iso ) { SignalElectrons.push_back(Elec); continue; }
179 }
180
181 // Vetoed Electrons
182 if ( pt > 20. ) {
183 VetoedElectrons.push_back(Elec);
184 // additional condition for delta R
185 if ( SignalMuons.size() == 1 && SignalMuons[0]->dr(Elec) >= 0.1 ) { VetoedElectronsDeltaR.push_back(Elec); }
186 }
187 }
188
189
190 // Jet
191 std::vector<const RecJetFormat*> Jets;
192 for (unsigned int i=0; i<event.rec()->jets().size(); i++) {
193 const RecJetFormat *Jet = &(event.rec()->jets()[i]);
194 double eta = Jet->abseta();
195 double pt = Jet->pt();
196 if ( eta < 2.4 && pt > 20. ) { Jets.push_back(Jet); }
197 else if ( eta > 2.4 && pt > 30. ) { Jets.push_back(Jet); }
198 }
199 Jets = PHYSICS->Isol->JetCleaning(Jets, SignalElectrons, 0.1);
200
201
202 // MET & MT
203 double MET = event.rec()->MET().pt();
204
205 double Mt = 0;
206 if ( SignalElectrons.size() == 1 && SignalMuons.size() == 0) { Mt = sqrt(2*SignalElectrons[0]->pt()*MET*(1-cos(SignalElectrons[0]->dphi_0_pi(event.rec()->MET())))); }
207 else if ( SignalMuons.size() == 1 && SignalElectrons.size() == 0) { Mt = sqrt(2*SignalMuons[0]->pt()*MET*(1-cos(SignalMuons[0]->dphi_0_pi(event.rec()->MET())))); }
208
209
210 // Cuts
211 if (!Manager()->ApplyCut( SignalElectrons.size() == 1 && SignalMuons.size() == 0, "One Electron")) return true;
212 if (!Manager()->ApplyCut( SignalMuons.size() == 1 && SignalElectrons.size() == 0, "One Muon")) return true;
213
214 if (!Manager()->ApplyCut( VetoedElectrons.size() == 0 && VetoedMuons.size() == 0, "Lepton Veto for Electrons" )) return true;
215 if (!Manager()->ApplyCut( VetoedElectronsDeltaR.size() == 0 && VetoedMuons.size() == 0, "Lepton Veto for Muons" )) return true;
216
217 if (!Manager()->ApplyCut( MET > 55., "$\\slashed{E}_T > 55$ [GeV]")) return true;
218 if (!Manager()->ApplyCut( MET > 65., "$\\slashed{E}_T > 65$ [GeV]")) return true;
219 if (!Manager()->ApplyCut( Mt > 110., "$M_T > 110$ [GeV]")) return true;
220 if (!Manager()->ApplyCut( Mt > 130., "$M_T > 130$ [GeV]")) return true;
221
222 if (!Manager()->ApplyCut( Mt > 110. && Mt < 400., "$110 < M_T < 400$ [GeV]")) return true;
223 if (!Manager()->ApplyCut( Mt > 130. && Mt < 400., "$130 < M_T < 400$ [GeV]")) return true;
224 if (!Manager()->ApplyCut( Mt > 400. && Mt < 600., "$400 < M_T < 600$ [GeV]")) return true;
225 if (!Manager()->ApplyCut( Mt > 600. && Mt < 1000., "$600 < M_T < 1000$ [GeV]")) return true;
226 if (!Manager()->ApplyCut( Mt > 1000. && Mt < 2000., "$1000 < M_T < 2000$ [GeV]")) return true;
227 if (!Manager()->ApplyCut( Mt > 2000. && Mt < 3000., "$2000 < M_T < 3000$ [GeV]")) return true;
228 if (!Manager()->ApplyCut( Mt > 3000. && Mt < 10000., "$3000 < M_T < 10000$ [GeV]")) return true;
229
230
231 // Fill Histograms
232 //Manager()->FillHisto("MT > 110 GeV for Muon Channel", Mt);
233 //Manager()->FillHisto("MT > 130 GeV for Electron Channel", Mt);
234
235 Manager()->FillHisto("MT > 110 GeV for Muon Channel (finer log bins)", Mt);
236 Manager()->FillHisto("MT > 130 GeV for Electron Channel (finer log bins)", Mt);
237
238 Manager()->FillHisto("MT > 110 GeV for Muon Channel (log bins)", Mt);
239 Manager()->FillHisto("MT > 130 GeV for Electron Channel (log bins)", Mt);
240
241
242 return true;
243}