Fork me on GitHub

source: svn/trunk/src/SmearUtil.cc@ 45

Last change on this file since 45 was 44, checked in by severine ovyn, 16 years ago

add log file

File size: 32.2 KB
Line 
1/*
2 ---- Delphes ----
3 A Fast Simulator for general purpose LHC detector
4 S. Ovyn ~~~~ severine.ovyn@uclouvain.be
5
6 Center for Particle Physics and Phenomenology (CP3)
7 Universite Catholique de Louvain (UCL)
8 Louvain-la-Neuve, Belgium
9*/
10
11/// \file SmearUtil.cc
12/// \brief RESOLution class, and some generic definitions
13
14
15#include "interface/SmearUtil.h"
16#include "TRandom.h"
17
18#include <iostream>
19#include <sstream>
20#include <fstream>
21
22#include <cstdio>
23#include <cstdio>
24#include <TCanvas.h>
25#include <TLorentzVector.h>
26#include <string>
27#include <fstream>
28#include <istream>
29#include <iostream>
30#include <TMath.h>
31#include <vector>
32#include "TRandom.h"
33#include <cstdlib>
34#include <math.h>
35#include <time.h>
36
37#include <iostream>
38#include <iomanip>
39
40#include <iostream>
41#include <sstream>
42
43#include <fstream>
44#include <vector>
45
46using namespace std;
47
48//------------------------------------------------------------------------------
49
50RESOLution::RESOLution() {
51
52MAX_TRACKER = 2.5; // tracker coverage
53MAX_CALO_CEN = 3.0; // central calorimeter coverage
54MAX_CALO_FWD = 5.0; // forward calorimeter pseudorapidity coverage
55MAX_MU = 2.4; // muon chambers pseudorapidity coverage
56MIN_CALO_VFWD= 5.2; // very forward calorimeter (if any), like CASTOR
57MAX_CALO_VFWD= 6.6; // very forward calorimeter (if any), like CASTOR
58MIN_ZDC = 8.3; // zero-degree calorimeter, coverage
59
60ZDC_S = 140.; // ZDC distance to IP
61RP220_S = 220; // distance of the RP to the IP, in meters
62RP220_X = 0.002;// distance of the RP to the beam, in meters
63FP420_S = 420; // distance of the RP to the IP, in meters
64FP420_X = 0.004;// distance of the RP to the beam, in meters
65
66
67ELG_Scen = 0.028; // S term for central ECAL
68ELG_Ncen = 0.124 ; // N term for central ECAL
69ELG_Ccen = 0.0026 ; // C term for central ECAL
70ELG_Cfwd = 0.107 ; // S term for forward ECAL
71ELG_Sfwd = 2.084 ; // C term for forward ECAL
72ELG_Nfwd = 0.0 ; // N term for central ECAL
73
74HAD_Shcal = 0.91 ; // S term for central HCAL // hadronic calorimeter
75HAD_Nhcal = 0. ; // N term for central HCAL
76HAD_Chcal = 0.038 ; // C term for central HCAL
77HAD_Shf = 2.7 ; // S term for central HF // forward calorimeter
78HAD_Nhf = 0. ; // N term for central HF
79HAD_Chf = 0.13 ; // C term for central HF
80
81MU_SmearPt = 0.01 ;
82
83ELEC_pt = 10.0;
84MUON_pt = 10.0;
85JET_pt = 20.0;
86TAUJET_pt = 10.0;
87
88
89TAU_CONE_ENERGY = 0.15 ; // Delta R = radius of the cone // for "electromagnetic collimation"
90TAU_EM_COLLIMATION = 0.95;
91TAU_CONE_TRACKS= 0.4 ; //Delta R for tracker isolation for tau's
92PT_TRACK_TAU = 2.0 ; // GeV // 6 GeV ????
93
94
95PT_TRACKS_MIN = 0.9 ; // minimal pt needed to reach the calorimeter, in GeV
96PT_QUARKS_MIN = 2.0 ; // minimal pt needed by quarks to reach the tracker, in GeV (??????)
97TRACKING_EFF = 90;
98
99
100TAGGING_B = 40;
101MISTAGGING_C = 10;
102MISTAGGING_L = 1;
103
104
105CONERADIUS = 0.7; // generic jet radius ; not for tau's !!!
106JETALGO = 1; // 1 for Cone algorithm, 2 for MidPoint algorithm, 3 for SIScone algorithm, 4 for kt algorithm
107
108//General jet parameters
109SEEDTHRESHOLD = 1.0;
110OVERLAPTHRESHOLD = 0.75;
111
112// Define Cone algorithm.
113C_ADJACENCYCUT = 2;
114C_MAXITERATIONS = 100;
115C_IRATCH = 1;
116
117//Define MidPoint algorithm.
118M_CONEAREAFRACTION = 0.25;
119M_MAXPAIRSIZE = 2;
120M_MAXITERATIONS = 100;
121
122}
123
124//------------------------------------------------------------------------------
125void RESOLution::ReadDataCard(const string datacard) {
126
127 string temp_string;
128 istringstream curstring;
129
130 ifstream fichier_a_lire(datacard.c_str());
131 if(!fichier_a_lire.good()) {
132 cout << datacard << "Datadard " << datacard << " not found, use default values" << endl;
133 return;
134 }
135
136 while (getline(fichier_a_lire,temp_string)) {
137 curstring.clear(); // needed when using several times istringstream::str(string)
138 curstring.str(temp_string);
139 string varname;
140 float value;
141
142 if(strstr(temp_string.c_str(),"#")) { }
143 else if(strstr(temp_string.c_str(),"MAX_TRACKER")){curstring >> varname >> value; MAX_TRACKER = value;}
144 else if(strstr(temp_string.c_str(),"MAX_CALO_CEN")){curstring >> varname >> value; MAX_CALO_CEN = value;}
145 else if(strstr(temp_string.c_str(),"MAX_CALO_FWD")){curstring >> varname >> value; MAX_CALO_FWD = value;}
146 else if(strstr(temp_string.c_str(),"MAX_MU")){curstring >> varname >> value; MAX_MU = value;}
147 else if(strstr(temp_string.c_str(),"ELG_Scen")){curstring >> varname >> value; ELG_Scen = value;}
148 else if(strstr(temp_string.c_str(),"ELG_Ncen")){curstring >> varname >> value; ELG_Ncen = value;}
149 else if(strstr(temp_string.c_str(),"ELG_Ccen")){curstring >> varname >> value; ELG_Ccen = value;}
150 else if(strstr(temp_string.c_str(),"ELG_Sfwd")){curstring >> varname >> value; ELG_Sfwd = value;}
151 else if(strstr(temp_string.c_str(),"ELG_Cfwd")){curstring >> varname >> value; ELG_Cfwd = value;}
152 else if(strstr(temp_string.c_str(),"ELG_Nfwd")){curstring >> varname >> value; ELG_Nfwd = value;}
153 else if(strstr(temp_string.c_str(),"HAD_Shcal")){curstring >> varname >> value; HAD_Shcal = value;}
154 else if(strstr(temp_string.c_str(),"HAD_Nhcal")){curstring >> varname >> value; HAD_Nhcal = value;}
155 else if(strstr(temp_string.c_str(),"HAD_Chcal")){curstring >> varname >> value; HAD_Chcal = value;}
156 else if(strstr(temp_string.c_str(),"HAD_Shf")){curstring >> varname >> value; HAD_Shf = value;}
157 else if(strstr(temp_string.c_str(),"HAD_Nhf")){curstring >> varname >> value; HAD_Nhf = value;}
158 else if(strstr(temp_string.c_str(),"HAD_Chf")){curstring >> varname >> value; HAD_Chf = value;}
159 else if(strstr(temp_string.c_str(),"MU_SmearPt")){curstring >> varname >> value; MU_SmearPt = value;}
160 else if(strstr(temp_string.c_str(),"TAU_CONE_ENERGY")){curstring >> varname >> value; TAU_CONE_ENERGY = value;}
161 else if(strstr(temp_string.c_str(),"TAU_CONE_TRACKS")){curstring >> varname >> value; TAU_CONE_TRACKS = value;}
162 else if(strstr(temp_string.c_str(),"PT_TRACK_TAU")){curstring >> varname >> value; PT_TRACK_TAU = value;}
163 else if(strstr(temp_string.c_str(),"PT_TRACKS_MIN")){curstring >> varname >> value; PT_TRACKS_MIN = value;}
164 else if(strstr(temp_string.c_str(),"TAGGING_B")){curstring >> varname >> value; TAGGING_B = (int)value;}
165 else if(strstr(temp_string.c_str(),"MISTAGGING_C")){curstring >> varname >> value; MISTAGGING_C = (int)value;}
166 else if(strstr(temp_string.c_str(),"MISTAGGING_L")){curstring >> varname >> value; MISTAGGING_L = (int)value;}
167 else if(strstr(temp_string.c_str(),"CONERADIUS")){curstring >> varname >> value; CONERADIUS = value;}
168 else if(strstr(temp_string.c_str(),"JETALGO")){curstring >> varname >> value; JETALGO = (int)value;}
169 else if(strstr(temp_string.c_str(),"TRACKING_EFF")){curstring >> varname >> value; TRACKING_EFF = (int)value;}
170 else if(strstr(temp_string.c_str(),"ELEC_pt")){curstring >> varname >> value; ELEC_pt = value;}
171 else if(strstr(temp_string.c_str(),"MUON_pt")){curstring >> varname >> value; MUON_pt = value;}
172 else if(strstr(temp_string.c_str(),"JET_pt")){curstring >> varname >> value; JET_pt = value;}
173 else if(strstr(temp_string.c_str(),"TAUJET_pt")){curstring >> varname >> value; TAUJET_pt = value;}
174
175 }
176
177// General jet variables
178 SEEDTHRESHOLD = 1.0;
179 OVERLAPTHRESHOLD = 0.75;
180
181// Define Cone algorithm.
182 C_ADJACENCYCUT = 2;
183 C_MAXITERATIONS = 100;
184 C_IRATCH = 1;
185
186//Define MidPoint algorithm.
187 M_CONEAREAFRACTION = 0.25;
188 M_MAXPAIRSIZE = 2;
189 M_MAXITERATIONS = 100;
190
191//Define SISCone algorithm.
192 NPASS = 0;
193 PROTOJET_PTMIN = 0.0;
194
195
196}
197
198void RESOLution::Logfile(string LogName) {
199//void RESOLution::Logfile(string outputfilename) {
200
201 ofstream f_out(LogName.c_str());
202
203 f_out<<"#*********************************************************************"<<"\n";
204 f_out<<"# *"<<"\n";
205 f_out<<"# ---- DELPHES release 1.0 ---- *"<<"\n";
206 f_out<<"# *"<<"\n";
207 f_out<<"# A Fast Simulator for general purpose LHC detector *"<<"\n";
208 f_out<<"# Written by S. Ovyn and X. Rouby *"<<"\n";
209 f_out<<"# severine.ovyn@uclouvain.be *"<<"\n";
210 f_out<<"# *"<<"\n";
211 f_out<<"# http: *"<<"\n";
212 f_out<<"# *"<<"\n";
213 f_out<<"# Center for Particle Physics and Phenomenology (CP3) *"<<"\n";
214 f_out<<"# Universite Catholique de Louvain (UCL) *"<<"\n";
215 f_out<<"# Louvain-la-Neuve, Belgium *"<<"\n";
216 f_out<<"# *"<<"\n";
217 f_out<<"#....................................................................*"<<"\n";
218 f_out<<"# *"<<"\n";
219 f_out<<"# This package uses FastJet algorithm, *"<<"\n";
220 f_out<<"# Phys. Lett. B641 (2006) [hep-ph/0512210] *"<<"\n";
221 f_out<<"# *"<<"\n";
222 f_out<<"#....................................................................*"<<"\n";
223 f_out<<"# *"<<"\n";
224 f_out<<"# This file contains all the running parameters (detector and cuts) *"<<"\n";
225 f_out<<"# necessary to reproduce the detector simulation *"<<"\n";
226 f_out<<"# *"<<"\n";
227 f_out<<"#....................................................................*"<<"\n";
228 f_out<<"#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<"\n";
229 f_out<<"* *"<<"\n";
230 f_out<<"#******************************** *"<<"\n";
231 f_out<<"# Central detector caracteristics *"<<"\n";
232 f_out<<"#******************************** *"<<"\n";
233 f_out<<"* *"<<"\n";
234 f_out << left << setw(30) <<"* Maximum tracking system: "<<""
235 << left << setw(10) <<MAX_TRACKER <<""<< right << setw(15)<<"*"<<"\n";
236 f_out << left << setw(30) <<"* Maximum central calorimeter: "<<""
237 << left << setw(10) <<MAX_CALO_CEN <<""<< right << setw(15)<<"*"<<"\n";
238 f_out << left << setw(30) <<"* Maximum forward calorimeter: "<<""
239 << left << setw(10) <<MAX_CALO_FWD <<""<< right << setw(15)<<"*"<<"\n";
240 f_out << left << setw(30) <<"* Muon chambers coverage: "<<""
241 << left << setw(10) <<MAX_MU <<""<< right << setw(15)<<"*"<<"\n";
242 f_out<<"* *"<<"\n";
243 f_out<<"#************************************* *"<<"\n";
244 f_out<<"# Very forward detector caracteristics *"<<"\n";
245 f_out<<"#************************************* *"<<"\n";
246 f_out<<"* *"<<"\n";
247 f_out << left << setw(55) <<"* Minimum very forward calorimeter: "<<""
248 << left << setw(5) <<MIN_CALO_VFWD <<""<< right << setw(10)<<"*"<<"\n";
249 f_out << left << setw(55) <<"* Maximum very forward calorimeter: "<<""
250 << left << setw(5) <<MAX_CALO_VFWD <<""<< right << setw(10)<<"*"<<"\n";
251 f_out << left << setw(55) <<"* Distance of the ZDC to the IP, in meters: "<<""
252 << left << setw(5) <<ZDC_S <<""<< right << setw(10)<<"*"<<"\n";
253 f_out << left << setw(55) <<"* Distance of the RP to the IP, in meters: "<<""
254 << left << setw(5) <<RP220_S <<""<< right << setw(10)<<"*"<<"\n";
255 f_out << left << setw(55) <<"* Distance of the RP to the beam, in meters: "<<""
256 << left << setw(5) <<RP220_X <<""<< right << setw(10)<<"*"<<"\n";
257 f_out << left << setw(55) <<"* Distance of the RP to the IP, in meters: "<<""
258 << left << setw(5) <<FP420_S <<""<< right << setw(10)<<"*"<<"\n";
259 f_out << left << setw(55) <<"* Distance of the RP to the beam, in meters: "<<""
260 << left << setw(5) <<FP420_X <<""<< right << setw(10)<<"*"<<"\n";
261 f_out<<"* *"<<"\n";
262 f_out<<"#************************************ *"<<"\n";
263 f_out<<"# Electromagnetic smearing parameters *"<<"\n";
264 f_out<<"#************************************ *"<<"\n";
265 f_out<<"* *"<<"\n";
266 //# \sigma/E = C + N/E + S/\sqrt{E}
267 f_out << left << setw(30) <<"* S term for central ECAL: "<<""
268 << left << setw(30) <<ELG_Scen <<""<< right << setw(10)<<"*"<<"\n";
269 f_out << left << setw(30) <<"* N term for central ECAL: "<<""
270 << left << setw(30) <<ELG_Ncen <<""<< right << setw(10)<<"*"<<"\n";
271 f_out << left << setw(30) <<"* C term for central ECAL: "<<""
272 << left << setw(30) <<ELG_Ccen <<""<< right << setw(10)<<"*"<<"\n";
273 f_out << left << setw(30) <<"* S term for forward ECAL: "<<""
274 << left << setw(30) <<ELG_Sfwd <<""<< right << setw(10)<<"*"<<"\n";
275 f_out << left << setw(30) <<"* N term for forward ECAL: "<<""
276 << left << setw(30) <<ELG_Nfwd <<""<< right << setw(10)<<"*"<<"\n";
277 f_out << left << setw(30) <<"* C term for forward ECAL: "<<""
278 << left << setw(30) <<ELG_Cfwd <<""<< right << setw(10)<<"*"<<"\n";
279 f_out<<"* *"<<"\n";
280 f_out<<"#***************************** *"<<"\n";
281 f_out<<"# Hadronic smearing parameters *"<<"\n";
282 f_out<<"#***************************** *"<<"\n";
283 f_out<<"* *"<<"\n";
284 f_out << left << setw(30) <<"* S term for central HCAL: "<<""
285 << left << setw(30) <<HAD_Shcal <<""<< right << setw(10)<<"*"<<"\n";
286 f_out << left << setw(30) <<"* N term for central HCAL: "<<""
287 << left << setw(30) <<HAD_Nhcal <<""<< right << setw(10)<<"*"<<"\n";
288 f_out << left << setw(30) <<"* C term for central HCAL: "<<""
289 << left << setw(30) <<HAD_Chcal <<""<< right << setw(10)<<"*"<<"\n";
290 f_out << left << setw(30) <<"* S term for forward HCAL: "<<""
291 << left << setw(30) <<HAD_Shf <<""<< right << setw(10)<<"*"<<"\n";
292 f_out << left << setw(30) <<"* N term for forward HCAL: "<<""
293 << left << setw(30) <<HAD_Nhf <<""<< right << setw(10)<<"*"<<"\n";
294 f_out << left << setw(30) <<"* C term for forward HCAL: "<<""
295 << left << setw(30) <<HAD_Chf <<""<< right << setw(10)<<"*"<<"\n";
296 f_out<<"* *"<<"\n";
297 f_out<<"#*************************** *"<<"\n";
298 f_out<<"# Tracking system acceptance *"<<"\n";
299 f_out<<"#*************************** *"<<"\n";
300 f_out<<"* *"<<"\n";
301 f_out << left << setw(55) <<"* Minimal pT needed to reach the calorimeter [GeV]: "<<""
302 << left << setw(10) <<PT_TRACKS_MIN <<""<< right << setw(5)<<"*"<<"\n";
303 f_out << left << setw(55) <<"* Efficiency associated to the tracking: "<<""
304 << left << setw(10) <<TRACKING_EFF <<""<< right << setw(5)<<"*"<<"\n";
305 f_out<<"* *"<<"\n";
306 f_out<<"#************************* *"<<"\n";
307 f_out<<"# Muon smearing parameters *"<<"\n";
308 f_out<<"#************************* *"<<"\n";
309 f_out<<"* *"<<"\n";
310 //MU_SmearPt 0.01
311 f_out<<"* *"<<"\n";
312 f_out<<"#****************************** *"<<"\n";
313 f_out<<"# Tau-jet definition parameters *"<<"\n";
314 f_out<<"#****************************** *"<<"\n";
315 f_out<<"* *"<<"\n";
316 f_out << left << setw(45) <<"* Cone radius for calorimeter tagging: "<<""
317 << left << setw(5) <<TAU_CONE_ENERGY <<""<< right << setw(20)<<"*"<<"\n";
318 f_out << left << setw(45) <<"* Fraction of energy in the small cone: "<<""
319 << left << setw(5) <<TAU_EM_COLLIMATION*100 <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
320 f_out << left << setw(45) <<"* Cone radius for tracking tagging: "<<""
321 << left << setw(5) <<TAU_CONE_TRACKS <<""<< right << setw(20)<<"*"<<"\n";
322 f_out << left << setw(45) <<"* Minimum track pT [GeV]: "<<""
323 << left << setw(5) <<PT_TRACK_TAU <<""<< right << setw(20)<<"*"<<"\n";
324 f_out<<"* *"<<"\n";
325 f_out<<"#******************* *"<<"\n";
326 f_out<<"# Minimum pT's [GeV] *"<<"\n";
327 f_out<<"#******************* *"<<"\n";
328 f_out<<"* *"<<"\n";
329 f_out << left << setw(40) <<"* Minimum pT for electrons: "<<""
330 << left << setw(20) <<ELEC_pt <<""<< right << setw(10)<<"*"<<"\n";
331 f_out << left << setw(40) <<"* Minimum pT for muons: "<<""
332 << left << setw(20) <<MUON_pt <<""<< right << setw(10)<<"*"<<"\n";
333 f_out << left << setw(40) <<"* Minimum pT for jets: "<<""
334 << left << setw(20) <<JET_pt <<""<< right << setw(10)<<"*"<<"\n";
335 f_out << left << setw(40) <<"* Minimum pT for Tau-jets: "<<""
336 << left << setw(20) <<TAUJET_pt <<""<< right << setw(10)<<"*"<<"\n";
337 f_out<<"* *"<<"\n";
338 f_out<<"#*************************** *"<<"\n";
339 f_out<<"# B-tagging efficiencies [%] *"<<"\n";
340 f_out<<"#*************************** *"<<"\n";
341 f_out<<"* *"<<"\n";
342 f_out << left << setw(50) <<"* Efficiency to tag a \"b\" as a b-jet: "<<""
343 << left << setw(10) <<TAGGING_B <<""<< right << setw(10)<<"*"<<"\n";
344 f_out << left << setw(50) <<"* Efficiency to mistag a c-jet as a b-jet: "<<""
345 << left << setw(10) <<MISTAGGING_C <<""<< right << setw(10)<<"*"<<"\n";
346 f_out << left << setw(50) <<"* Efficiency to mistag a light jet as a b-jet: "<<""
347 << left << setw(10) <<MISTAGGING_L <<""<< right << setw(10)<<"*"<<"\n";
348 f_out<<"* *"<<"\n";
349 f_out<<"#*************** *"<<"\n";
350 f_out<<"# Jet definition *"<<"\n";
351 f_out<<"#*************** *"<<"\n";
352 f_out<<"* *"<<"\n";
353 switch(JETALGO) {
354 default:
355 case 1: {
356 f_out<<"* CDF JetClu jet algorithm with: *"<<"\n";
357 f_out << left << setw(40) <<"* - Seed threshold: "<<""
358 << left << setw(10) <<SEEDTHRESHOLD <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
359 f_out << left << setw(40) <<"* - Cone radius: "<<""
360 << left << setw(10) <<CONERADIUS <<""<< right << setw(20)<<"*"<<"\n";
361 f_out << left << setw(40) <<"* - Adjacency cut: "<<""
362 << left << setw(10) <<C_ADJACENCYCUT <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
363 f_out << left << setw(40) <<"* - Max iterations: "<<""
364 << left << setw(10) <<C_MAXITERATIONS <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
365 f_out << left << setw(40) <<"* - Iratch: "<<""
366 << left << setw(10) <<C_IRATCH <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
367 f_out << left << setw(40) <<"* - Overlap threshold: "<<""
368 << left << setw(10) <<OVERLAPTHRESHOLD <<""<< right << setw(20)<<"! not in datacard *"<<"\n";
369 }
370 break;
371 case 2: {
372 f_out<<"* CDF midpoint jet algorithm with: *"<<"\n";
373 f_out << left << setw(40) <<"* - Seed threshold: "<<""
374 << left << setw(20) <<SEEDTHRESHOLD <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
375 f_out << left << setw(40) <<"* - Cone radius: "<<""
376 << left << setw(20) <<CONERADIUS <<""<< right << setw(10)<<"*"<<"\n";
377 f_out << left << setw(40) <<"* - Cone area fraction:"<<""
378 << left << setw(20) <<M_CONEAREAFRACTION <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
379 f_out << left << setw(40) <<"* - Maximum pair size: "<<""
380 << left << setw(20) <<M_MAXPAIRSIZE <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
381 f_out << left << setw(40) <<"* - Max iterations: "<<""
382 << left << setw(20) <<M_MAXITERATIONS <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
383 f_out << left << setw(40) <<"* - Overlap threshold: "<<""
384 << left << setw(20) <<OVERLAPTHRESHOLD <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
385 }
386 break;
387 case 3: {
388 f_out<<"* SISCone jet algorithm with: *"<<"\n";
389 f_out << left << setw(40) <<"* - Cone radius: "<<""
390 << left << setw(20) <<CONERADIUS <<""<< right << setw(10)<<"*"<<"\n";
391 f_out << left << setw(40) <<"* - Overlap threshold: "<<""
392 << left << setw(20) <<OVERLAPTHRESHOLD <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
393 f_out << left << setw(40) <<"* - Number pass max: "<<""
394 << left << setw(20) <<NPASS <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
395 f_out << left << setw(40) <<"* - Minimum pT for protojet: "<<""
396 << left << setw(20) <<PROTOJET_PTMIN <<""<< right << setw(10)<<"! not in datacard *"<<"\n";
397 }
398 break;
399 case 4: {
400 f_out<<"* KT jet algorithm with: *"<<"\n";
401 f_out << left << setw(40) <<"* - Cone radius: "<<""
402 << left << setw(20) <<CONERADIUS <<""<< right << setw(10)<<"*"<<"\n";
403 }
404 break;
405 }
406 f_out<<"* *"<<"\n";
407 f_out<<"#....................................................................*"<<"\n";
408 f_out<<"#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<"\n";
409
410}
411
412// **********Provides the smeared TLorentzVector for the electrons********
413// Smears the electron energy, and changes the 4-momentum accordingly
414// different smearing if the electron is central (eta < 2.5) or forward
415void RESOLution::SmearElectron(TLorentzVector &electron) {
416 // the 'electron' variable will be changed by the function
417 float energy = electron.E(); // before smearing
418 float energyS = 0.0; // after smearing // \sigma/E = C + N/E + S/\sqrt{E}
419
420 if(fabs(electron.Eta()) < MAX_TRACKER) { // if the electron is inside the tracker
421 energyS = gRandom->Gaus(energy, sqrt(
422 pow(ELG_Ncen,2) +
423 pow(ELG_Ccen*energy,2) +
424 pow(ELG_Scen*sqrt(energy),2) ));
425 } else { // outside the tracker
426 energyS = gRandom->Gaus(energy, sqrt(
427 pow(ELG_Nfwd,2) +
428 pow(ELG_Cfwd*energy,2) +
429 pow(ELG_Sfwd*sqrt(energy),2) ) );
430 }
431 electron.SetPtEtaPhiE(energyS/cosh(electron.Eta()), electron.Eta(), electron.Phi(), energyS);
432 if(electron.E() < 0)electron.SetPxPyPzE(0,0,0,0); // no negative values after smearing !
433}
434
435
436// **********Provides the smeared TLorentzVector for the muons********
437// Smears the muon pT and changes the 4-momentum accordingly
438void RESOLution::SmearMu(TLorentzVector &muon) {
439 // the 'muon' variable will be changed by the function
440 float pt = muon.Pt(); // before smearing
441 float ptS = gRandom->Gaus(pt, MU_SmearPt*pt ); // after smearing // \sigma/E = C + N/E + S/\sqrt{E}
442
443 muon.SetPtEtaPhiE(ptS, muon.Eta(), muon.Phi(), ptS*cosh(muon.Eta()));
444
445 if(muon.E() < 0)muon.SetPxPyPzE(0,0,0,0); // no negative values after smearing !
446}
447
448
449// **********Provides the smeared TLorentzVector for the hadrons********
450// Smears the hadron 4-momentum
451void RESOLution::SmearHadron(TLorentzVector &hadron, const float frac)
452 // the 'hadron' variable will be changed by the function
453 // the 'frac' variable describes the long-living particles. Should be 0.7 for K0S and Lambda, 1. otherwise
454{
455 float energy = hadron.E(); // before smearing
456 float energyS = 0.0; // after smearing // \sigma/E = C + N/E + S/\sqrt{E}
457 float energy_ecal = (1.0 - frac)*energy; // electromagnetic calorimeter
458 float energy_hcal = frac*energy; // hadronic calorimeter
459 // frac takes into account the decay of long-living particles, that decay in the calorimeters
460 // some of the particles decay mostly in the ecal, some mostly in the hcal
461
462 float energyS1,energyS2;
463 if(fabs(hadron.Eta()) < MAX_CALO_CEN) {
464 energyS1 = gRandom->Gaus(energy_hcal, sqrt(
465 pow(HAD_Nhcal,2) +
466 pow(HAD_Chcal*energy_hcal,2) +
467 pow(HAD_Shcal*sqrt(energy_hcal),2) )) ;
468
469
470 energyS2 = gRandom->Gaus(energy_ecal, sqrt(
471 pow(ELG_Ncen,2) +
472 pow(ELG_Ccen*energy_ecal,2) +
473 pow(ELG_Scen*sqrt(energy_ecal),2) ) );
474
475 energyS = ((energyS1>0)?energyS1:0) + ((energyS2>0)?energyS2:0);
476 } else {
477 energyS = gRandom->Gaus(energy, sqrt(
478 pow(HAD_Nhf,2) +
479 pow(HAD_Chf*energy,2) +
480 pow(HAD_Shf*sqrt(energy),2) ));
481 }
482
483
484 hadron.SetPtEtaPhiE(energyS/cosh(hadron.Eta()),hadron.Eta(), hadron.Phi(), energyS);
485
486 if(hadron.E() < 0)hadron.SetPxPyPzE(0,0,0,0);
487}
488
489// **********Provides the energy in the cone of radius TAU_CONE_ENERGY for the tau identification********
490// to be taken into account, a calo tower should
491// 1) have a transverse energy \f$ E_T = \sqrt{E_X^2 + E_Y^2} \f$ above a given threshold
492// 2) be inside a cone with a radius R and the axis defined by (eta,phi)
493double RESOLution::EnergySmallCone(const vector<PhysicsTower> &towers, const float eta, const float phi) {
494 double Energie=0;
495 for(unsigned int i=0; i < towers.size(); i++) {
496 if(towers[i].fourVector.pt() < SEEDTHRESHOLD) continue;
497 if((DeltaR(phi,eta,towers[i].fourVector.phi(),towers[i].fourVector.eta()) < TAU_CONE_ENERGY)) {
498 Energie += towers[i].fourVector.E;
499 }
500 }
501 return Energie;
502}
503
504
505// **********Provides the number of tracks in the cone of radius TAU_CONE_TRACKS for the tau identification********
506// to be taken into account, a track should
507// 1) avec a transverse momentum \$f p_T \$ above a given threshold
508// 2) be inside a cone with a radius R and the axis defined by (eta,phi)
509// IMPORTANT REMARK !!!!!
510// previously, the argument 'phi' was before the argument 'eta'
511// this has been changed for consistency with the other functions
512// double check your running code that uses NumTracks !
513unsigned int RESOLution::NumTracks(const vector<TLorentzVector> &tracks, const float pt_track, const float eta, const float phi) {
514 unsigned int numtrack=0;
515 for(unsigned int i=0; i < tracks.size(); i++) {
516 if((tracks[i].Pt() < pt_track )||
517 (DeltaR(phi,eta,tracks[i].Phi(),tracks[i].Eta()) > TAU_CONE_TRACKS)
518 )continue;
519 numtrack++;
520 }
521 return numtrack;
522}
523
524
525//*** Returns the PID of the particle with the highest energy, in a cone with a radius CONERADIUS and an axis (eta,phi) *********
526//used by Btaggedjet
527///// Attention : bug removed => CONERADIUS/2 -> CONERADIUS !!
528int RESOLution::Bjets(const TSimpleArray<TRootGenParticle> &subarray, const float eta, const float phi) {
529 float emax=0;
530 int Ppid=0;
531 if(subarray.GetEntries()>0) {
532 for(int i=0; i < subarray.GetEntries();i++) { // should have pt>PT_JETMIN and a small cone radius (r<CONE_JET)
533 float genDeltaR = DeltaR(subarray[i]->Phi,subarray[i]->Eta,phi,eta);
534 if(genDeltaR < CONERADIUS && subarray[i]->E > emax) {
535 emax=subarray[i]->E;
536 Ppid=abs(subarray[i]->PID);
537 }
538 }
539 }
540 return Ppid;
541}
542
543
544//******************** Simulates the b-tagging efficiency for real bjet, or the misendentification for other jets****************
545bool RESOLution::Btaggedjet(const TLorentzVector &JET, const TSimpleArray<TRootGenParticle> &subarray) {
546 if( rand()%100 < (TAGGING_B+1) && Bjets(subarray,JET.Eta(),JET.Phi())==pB ) return true; // b-tag of b-jets is 40%
547 else if( rand()%100 < (MISTAGGING_C+1) && Bjets(subarray,JET.Eta(),JET.Phi())==pC ) return true; // b-tag of c-jets is 10%
548 else if( rand()%100 < (MISTAGGING_L+1) && Bjets(subarray,JET.Eta(),JET.Phi())!=0) return true; // b-tag of light jets is 1%
549 return false;
550}
551
552//***********************Isolation criteria***********************
553//****************************************************************
554bool RESOLution::Isolation(Float_t phi,Float_t eta,const vector<TLorentzVector> &tracks,float PT_TRACK2)
555{
556 bool isolated = false;
557 Float_t deltar=5000.; // Initial value; should be high; no further repercussion
558 // loop on all final charged particles, with p_t >2, close enough from the electron
559 for(unsigned int i=0; i < tracks.size(); i++)
560 {
561 if(tracks[i].Pt() < PT_TRACK2)continue;
562 Float_t genDeltaR = DeltaR(phi,eta,tracks[i].Phi(),tracks[i].Eta()); // slower to evaluate
563 if(
564 (genDeltaR > deltar) ||
565 (genDeltaR==0)
566 ) continue ;
567 deltar=genDeltaR;
568 }
569 if(deltar > 0.5)isolated = true; // returns the closest distance
570 return isolated;
571}
572
573
574//**************************** Returns the delta Phi ****************************
575float DeltaPhi(const float phi1, const float phi2) {
576 float deltaphi=phi1-phi2; // in here, -PI < phi < PI
577 if(fabs(deltaphi) > PI) deltaphi=2.*PI-fabs(deltaphi);// put deltaphi between 0 and PI
578 else deltaphi=fabs(deltaphi);
579
580 return deltaphi;
581}
582
583//**************************** Returns the delta R****************************
584float DeltaR(const float phi1, const float eta1, const float phi2, const float eta2) {
585 return sqrt(pow(DeltaPhi(phi1,phi2),2) + pow(eta1-eta2,2));
586}
587
588int sign(const int myint) {
589 if (myint >0) return 1;
590 else if (myint <0) return -1;
591 else return 0;
592}
593
594int sign(const float myfloat) {
595 if (myfloat >0) return 1;
596 else if (myfloat <0) return -1;
597 else return 0;
598}
599
600
601float Charge(const long int pid) {
602 // source: RPP chap 34 Monte Carlo Particle Numbering Scheme
603/* switch (abs(pid)) {
604 case 1: case 3: case 5: case 7: return (float) sign(pid)*(-1/3); break; // d, s, b, b'
605 case 2: case 4: case 6: case 8: return (float) sign(pid)*2/3; break; // u, c, t, t'
606
607 case 11: case 13: case 15: return (float) sign(pid)*(-1); break; // e, mu, tau
608 case 12: case 14: case 16: return (float) 0; break; // nu_e, nu_mu, nu_tau
609
610 case 9: case 21: case 22: case 23: case 25:
611 case 32: case 33: case 35: case 36: return (float) 0; break; // neutral gauge/higgs bosons
612 case 24: case 34: case 37: return (float) sign(pid); break; // charged gauge/higgs bosons
613 }
614*/
615 return 0;
616}
Note: See TracBrowser for help on using the repository browser.