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 Delphes.cpp
|
---|
12 | /// \brief executable for the Delphes
|
---|
13 |
|
---|
14 | #include "TChain.h"
|
---|
15 | #include "TApplication.h"
|
---|
16 | #include "TStopwatch.h"
|
---|
17 | #include "TFile.h"
|
---|
18 |
|
---|
19 | #include "ExRootTreeReader.h"
|
---|
20 | #include "ExRootTreeWriter.h"
|
---|
21 | #include "ExRootTreeBranch.h"
|
---|
22 |
|
---|
23 | #include "DataConverter.h"
|
---|
24 | #include "HEPEVTConverter.h"
|
---|
25 | #include "LHEFConverter.h"
|
---|
26 | #include "STDHEPConverter.h"
|
---|
27 |
|
---|
28 | #include "SmearUtil.h"
|
---|
29 | #include "BFieldProp.h"
|
---|
30 | #include "TriggerUtil.h"
|
---|
31 | #include "VeryForward.h"
|
---|
32 | #include "JetsUtil.h"
|
---|
33 | #include "FrogUtil.h"
|
---|
34 |
|
---|
35 | #include <vector>
|
---|
36 | #include <iostream>
|
---|
37 |
|
---|
38 | using namespace std;
|
---|
39 |
|
---|
40 | //------------------------------------------------------------------------------
|
---|
41 | void todo(string filename) {
|
---|
42 | ifstream infile(filename.c_str());
|
---|
43 | cout << "** TODO list ..." << endl;
|
---|
44 | while(infile.good()) {
|
---|
45 | string temp;
|
---|
46 | getline(infile,temp);
|
---|
47 | cout << "*" << temp << endl;
|
---|
48 | }
|
---|
49 | cout << "** done...\n";
|
---|
50 | }
|
---|
51 |
|
---|
52 | //------------------------------------------------------------------------------
|
---|
53 |
|
---|
54 | int main(int argc, char *argv[])
|
---|
55 | {
|
---|
56 | int appargc = 2;
|
---|
57 | char *appName= new char[20];
|
---|
58 | char *appOpt= new char[20];
|
---|
59 | sprintf(appName,"Delphes");
|
---|
60 | sprintf(appOpt,"-b");
|
---|
61 | char *appargv[] = {appName,appOpt};
|
---|
62 | TApplication app(appName, &appargc, appargv);
|
---|
63 | delete [] appName;
|
---|
64 | delete [] appOpt;
|
---|
65 |
|
---|
66 |
|
---|
67 | if(argc != 3 && argc != 4 && argc != 5) {
|
---|
68 | cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
|
---|
69 | cout << " input_list - list of files in Ntpl, StdHep of LHEF format," << endl;
|
---|
70 | cout << " output_file - output file." << endl;
|
---|
71 | cout << " detector_card - Datacard containing resolution variables for the detector simulation (optional) "<<endl;
|
---|
72 | cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
|
---|
73 | exit(1);
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 | cout << endl << endl;
|
---|
80 |
|
---|
81 | cout <<"*********************************************************************"<< endl;
|
---|
82 | cout <<"*********************************************************************"<< endl;
|
---|
83 | cout <<"** **"<< endl;
|
---|
84 | cout <<"** Welcome to **"<< endl;
|
---|
85 | cout <<"** **"<< endl;
|
---|
86 | cout <<"** **"<< endl;
|
---|
87 | cout <<"** .ddddddd- lL hH **"<< endl;
|
---|
88 | cout <<"** -Dd` `dD: Ll hH` **"<< endl;
|
---|
89 | cout <<"** dDd dDd eeee. lL .pp+pp Hh+hhh` -eeee- `sssss **"<< endl;
|
---|
90 | cout <<"** -Dd `DD ee. ee Ll .Pp. PP Hh. HH. ee. ee sSs **"<< endl;
|
---|
91 | cout <<"** dD` dDd eEeee: lL. pP. pP hH hH` eEeee:` -sSSSs. **"<< endl;
|
---|
92 | cout <<"** .Dd :dd eE. LlL PpppPP Hh Hh eE sSS **"<< endl;
|
---|
93 | cout <<"** dddddd:. eee+: lL. pp. hh. hh eee+ sssssS **"<< endl;
|
---|
94 | cout <<"** Pp **"<< endl;
|
---|
95 | cout <<"** **"<< endl;
|
---|
96 | cout <<"** Delphes, a framework for the fast simulation **"<< endl;
|
---|
97 | cout <<"** of a generic collider experiment **"<< endl;
|
---|
98 | cout <<"** **"<< endl;
|
---|
99 | cout <<"** --- Version 1.3beta of Delphes --- **"<< endl;
|
---|
100 | cout <<"** Last date of change: 29 January 2009 **"<< endl;
|
---|
101 | cout <<"** **"<< endl;
|
---|
102 | cout <<"** **"<< endl;
|
---|
103 | cout <<"** This package uses: **"<< endl;
|
---|
104 | cout <<"** ------------------ **"<< endl;
|
---|
105 | cout <<"** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **"<< endl;
|
---|
106 | cout <<"** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **"<< endl;
|
---|
107 | cout <<"** FROG: **"<< endl;
|
---|
108 | cout <<"** **"<< endl;
|
---|
109 | cout <<"**-----------------------------------------------------------------**"<< endl;
|
---|
110 | cout <<"** **"<< endl;
|
---|
111 | cout <<"** Main authors: **"<< endl;
|
---|
112 | cout <<"** ------------- **"<< endl;
|
---|
113 | cout <<"** **"<< endl;
|
---|
114 | cout <<"** Séverine Ovyn Xavier Rouby **"<< endl;
|
---|
115 | cout <<"** severine.ovyn@uclouvain.be xavier.rouby@cern **"<< endl;
|
---|
116 | cout <<"** Center for Particle Physics and Phenomenology (CP3) **"<< endl;
|
---|
117 | cout <<"** Universite Catholique de Louvain (UCL) **"<< endl;
|
---|
118 | cout <<"** Louvain-la-Neuve, Belgium **"<< endl;
|
---|
119 | cout <<"** **"<< endl;
|
---|
120 | cout <<"**-----------------------------------------------------------------**"<< endl;
|
---|
121 | cout <<"** **"<< endl;
|
---|
122 | cout <<"** Former Delphes versions and documentation can be found on : **"<< endl;
|
---|
123 | cout <<"** http://www.fynu.ucl.ac.be/delphes.html **"<< endl;
|
---|
124 | cout <<"** **"<< endl;
|
---|
125 | cout <<"** **"<< endl;
|
---|
126 | cout <<"** Disclaimer: this program is a beta version of Delphes and **"<< endl;
|
---|
127 | cout <<"** therefore comes without guarantees. Beware of errors and please **"<< endl;
|
---|
128 | cout <<"** give us your feedbacks about potential bugs **"<< endl;
|
---|
129 | cout <<"** **"<< endl;
|
---|
130 | cout <<"*********************************************************************"<< endl;
|
---|
131 | cout <<"*********************************************************************"<< endl;
|
---|
132 |
|
---|
133 | // 1. ********** initialisation ***********
|
---|
134 |
|
---|
135 | srand (time (NULL)); /* Initialisation du générateur */
|
---|
136 | TStopwatch globalwatch, loopwatch, triggerwatch, frogwatch;
|
---|
137 | globalwatch.Start();
|
---|
138 |
|
---|
139 |
|
---|
140 | //read the output TROOT file
|
---|
141 | string inputFileList(argv[1]), outputfilename(argv[2]);
|
---|
142 | if(outputfilename.find(".root") > outputfilename.length()) {
|
---|
143 | cout <<"** ERROR: 'output_file' should be a .root file. Exiting... **"<< endl;
|
---|
144 | exit(1);
|
---|
145 | }
|
---|
146 | //create output log-file name
|
---|
147 | string forLog = outputfilename;
|
---|
148 | string LogName = forLog.erase(forLog.find(".root"));
|
---|
149 | LogName = LogName+"_run.log";
|
---|
150 |
|
---|
151 | TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
|
---|
152 | outputFile->Close();
|
---|
153 |
|
---|
154 | string line;
|
---|
155 | ifstream infile(inputFileList.c_str());
|
---|
156 | infile >> line; // the first line determines the type of input files
|
---|
157 |
|
---|
158 | //read the datacard input file
|
---|
159 | string DetDatacard(""); //for detector smearing parameters
|
---|
160 | string TrigDatacard("data/trigger.dat"); //for trigger selection
|
---|
161 |
|
---|
162 | string lineCard1,lineCard2;
|
---|
163 | bool detecCard=false,trigCard=false;
|
---|
164 | if(argv[3])
|
---|
165 | {
|
---|
166 | ifstream infile1(argv[3]);
|
---|
167 | infile1 >> lineCard1; // the first line determines the type of input files
|
---|
168 | if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==true)
|
---|
169 | cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
|
---|
170 | else if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[3]; detecCard=true;}
|
---|
171 | else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==true)
|
---|
172 | cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
|
---|
173 | else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[3]; trigCard=true;}
|
---|
174 | }
|
---|
175 | if(argv[4])
|
---|
176 | {
|
---|
177 | ifstream infile2(argv[4]);
|
---|
178 | infile2 >> lineCard2; // the first line determines the type of input files
|
---|
179 | if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==true)
|
---|
180 | cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
|
---|
181 | else if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[4]; detecCard=true;}
|
---|
182 | else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==true)
|
---|
183 | cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
|
---|
184 | else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[4]; trigCard=true;}
|
---|
185 | }
|
---|
186 |
|
---|
187 | //Smearing information
|
---|
188 | RESOLution *DET = new RESOLution();
|
---|
189 | cout <<"** **"<< endl;
|
---|
190 | cout <<"** ####### Start reading DETECTOR parameters ####### **"<< endl;
|
---|
191 | cout << left << setw(40) <<"** Opening configuration card: "<<""
|
---|
192 | << left << setw(20) << DetDatacard <<""
|
---|
193 | << right << setw(9) <<" **"<<""<<endl;
|
---|
194 | DET->ReadDataCard(DetDatacard);
|
---|
195 | DET->Logfile(LogName);
|
---|
196 | cout << left << setw(42) <<"** Parameters summarised in file: "<<""
|
---|
197 | << left << setw(20) << LogName <<""
|
---|
198 | << right << setw(7) <<"**"<<""<<endl;
|
---|
199 | cout <<"** **"<< endl;
|
---|
200 |
|
---|
201 | //Trigger information
|
---|
202 | cout <<"** ########### Start reading TRIGGER card ########## **"<< endl;
|
---|
203 | if(trigCard==false)
|
---|
204 | {
|
---|
205 | cout <<"** WARNING: Datadard not found, use default card **" << endl;
|
---|
206 | TrigDatacard="data/trigger.dat";
|
---|
207 | }
|
---|
208 | TriggerTable *TRIGT = new TriggerTable();
|
---|
209 | TRIGT->TriggerCardReader(TrigDatacard.c_str());
|
---|
210 | TRIGT->PrintTriggerTable(LogName);
|
---|
211 | if(DET->FLAG_trigger == 1)
|
---|
212 | {
|
---|
213 | cout << left << setw(40) <<"** Opening configuration card: "<<""
|
---|
214 | << left << setw(20) << TrigDatacard <<""
|
---|
215 | << right << setw(9) <<" **"<<""<<endl;
|
---|
216 | cout <<"** **"<< endl;
|
---|
217 | }
|
---|
218 |
|
---|
219 | //Propagation of tracks in the B field
|
---|
220 | TrackPropagation *TRACP = new TrackPropagation(DET);
|
---|
221 | //TrackPropagation *TRACP = new TrackPropagation(DetDatacard);
|
---|
222 |
|
---|
223 | //Jet information
|
---|
224 | JetsUtil *JETRUN = new JetsUtil(DET);
|
---|
225 | //JetsUtil *JETRUN = new JetsUtil(DetDatacard);
|
---|
226 |
|
---|
227 | //VFD information
|
---|
228 | VeryForward * VFD = new VeryForward(DET);
|
---|
229 | //VeryForward * VFD = new VeryForward(DetDatacard);
|
---|
230 |
|
---|
231 | // data converters
|
---|
232 | DataConverter *converter=NULL;
|
---|
233 | cout <<"** **"<<endl;
|
---|
234 | cout <<"** ####### Start convertion to TRoot format ######## **"<< endl;
|
---|
235 |
|
---|
236 | if(strstr(line.c_str(),".hep"))
|
---|
237 | {
|
---|
238 | cout <<"** StdHEP file format detected **"<<endl;
|
---|
239 | cout <<"** This can take several minutes **"<< endl;
|
---|
240 | converter = new STDHEPConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
241 | }
|
---|
242 | else if(strstr(line.c_str(),".lhe"))
|
---|
243 | {
|
---|
244 | cout <<"** LHEF file format detected **"<<endl;
|
---|
245 | cout <<"** This can take several minutes **"<< endl;
|
---|
246 | converter = new LHEFConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
247 | }
|
---|
248 | else if(strstr(line.c_str(),".root"))
|
---|
249 | {
|
---|
250 | cout <<"** h2root file format detected **"<<endl;
|
---|
251 | cout <<"** This can take several minutes **"<< endl;
|
---|
252 | converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
253 | }
|
---|
254 | else {
|
---|
255 | cerr << left << setw(4) <<"** "<<""
|
---|
256 | << left << setw(63) << line.c_str() <<""
|
---|
257 | << right << setw(2) <<"**"<<endl;
|
---|
258 | cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
|
---|
259 | cout <<"** **"<< endl;
|
---|
260 | cout <<"*********************************************************************"<< endl;
|
---|
261 | return -1;};
|
---|
262 | cout <<"** Exiting conversion... **"<< endl;
|
---|
263 |
|
---|
264 | TChain chain("GEN");
|
---|
265 | chain.Add(outputfilename.c_str());
|
---|
266 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
|
---|
267 | const TClonesArray *branchGen = treeReader->UseBranch("Particle");
|
---|
268 |
|
---|
269 | TIter itGen((TCollection*)branchGen);
|
---|
270 |
|
---|
271 | //Output file : contents of the analysis object data
|
---|
272 | ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
|
---|
273 | ExRootTreeBranch *branchJet = treeWriter->NewBranch("Jet", TRootJet::Class());
|
---|
274 | ExRootTreeBranch *branchTauJet = treeWriter->NewBranch("TauJet", TRootTauJet::Class());
|
---|
275 | ExRootTreeBranch *branchElectron = treeWriter->NewBranch("Electron", TRootElectron::Class());
|
---|
276 | ExRootTreeBranch *branchMuon = treeWriter->NewBranch("Muon", TRootMuon::Class());
|
---|
277 | ExRootTreeBranch *branchPhoton = treeWriter->NewBranch("Photon", TRootPhoton::Class());
|
---|
278 | ExRootTreeBranch *branchTracks = treeWriter->NewBranch("Tracks", TRootTracks::Class());
|
---|
279 | ExRootTreeBranch *branchETmis = treeWriter->NewBranch("ETmis", TRootETmis::Class());
|
---|
280 | ExRootTreeBranch *branchCalo = treeWriter->NewBranch("CaloTower", TRootCalo::Class());
|
---|
281 | ExRootTreeBranch *branchZDC = treeWriter->NewBranch("ZDChits", TRootZdcHits::Class());
|
---|
282 | ExRootTreeBranch *branchRP220 = treeWriter->NewBranch("RP220hits", TRootRomanPotHits::Class());
|
---|
283 | ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootRomanPotHits::Class());
|
---|
284 |
|
---|
285 | TRootGenParticle *particle;
|
---|
286 | TRootETmis *elementEtmis;
|
---|
287 | TRootElectron *elementElec;
|
---|
288 | TRootMuon *elementMu;
|
---|
289 | TRootPhoton *elementPhoton;
|
---|
290 | TRootTracks *elementTracks;
|
---|
291 | TRootCalo *elementCalo;
|
---|
292 |
|
---|
293 | TLorentzVector genMomentum(0,0,0,0); // four-momentum at the vertex
|
---|
294 | TLorentzVector genMomentumBfield(0,0,0,0); // four-momentum at the exit of the tracks
|
---|
295 | TLorentzVector momentumCaloSegmentation(0,0,0,0); // four-momentum in the calo, after applying the calo segmentation
|
---|
296 | LorentzVector jetMomentum;
|
---|
297 |
|
---|
298 | vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
|
---|
299 | vector<fastjet::PseudoJet> sorted_jets;
|
---|
300 | vector<TLorentzVector> TrackCentral;
|
---|
301 | vector<PhysicsTower> towers;
|
---|
302 | vector<ParticleUtil> electron;
|
---|
303 | vector<ParticleUtil> muon;
|
---|
304 | vector<ParticleUtil> gamma;
|
---|
305 |
|
---|
306 | TSimpleArray<TRootGenParticle> NFCentralQ;
|
---|
307 | float iPhi=0,iEta=0;
|
---|
308 |
|
---|
309 |
|
---|
310 |
|
---|
311 | // 2. ********** Loop over all events ***********
|
---|
312 | Long64_t entry, allEntries = treeReader->GetEntries();
|
---|
313 | cout <<"** **"<<endl;
|
---|
314 | cout <<"** ####### Start fast detector simulation ######## **"<< endl;
|
---|
315 | cout << left << setw(52) <<"** Total number of events to run: "<<""
|
---|
316 | << left << setw(15) << allEntries <<""
|
---|
317 | << right << setw(2) <<"**"<<endl;
|
---|
318 |
|
---|
319 | loopwatch.Start();
|
---|
320 |
|
---|
321 | // loop on all events
|
---|
322 | for(entry = 0; entry < allEntries; ++entry)
|
---|
323 | {
|
---|
324 | TLorentzVector PTmis(0,0,0,0);
|
---|
325 | treeReader->ReadEntry(entry);
|
---|
326 | treeWriter->Clear();
|
---|
327 | if((entry % 100) == 0 && entry > 0 ) {
|
---|
328 | cout << left << setw(52) <<"** Processing element # "<<""
|
---|
329 | << left << setw(15) << entry <<""
|
---|
330 | << right << setw(2) <<"**"<<endl;
|
---|
331 | }
|
---|
332 |
|
---|
333 | electron.clear();
|
---|
334 | muon.clear();
|
---|
335 | gamma.clear();
|
---|
336 | NFCentralQ.Clear();
|
---|
337 |
|
---|
338 | TrackCentral.clear();
|
---|
339 | towers.clear();
|
---|
340 | input_particles.clear();
|
---|
341 |
|
---|
342 | // 2.1 Loop over all particles in event
|
---|
343 | itGen.Reset();
|
---|
344 | while( (particle = (TRootGenParticle*) itGen.Next()) ) {
|
---|
345 | int pid = abs(particle->PID);
|
---|
346 |
|
---|
347 |
|
---|
348 | // 2.1.1********************* preparation for the b-tagging
|
---|
349 | //// This subarray is needed for the B-jet algorithm
|
---|
350 | // optimization for speed : put first PID condition, then ETA condition, then either pt or status
|
---|
351 | if( (pid <= pB || pid == pGLUON) &&// is it a light quark or a gluon, i.e. is it one of these : u,d,c,s,b,g ?
|
---|
352 | fabs(particle->Eta) < DET->CEN_max_tracker &&
|
---|
353 | particle->Status != 1 &&
|
---|
354 | particle->PT > DET->PT_QUARKS_MIN ) {
|
---|
355 | NFCentralQ.Add(particle);
|
---|
356 | }
|
---|
357 |
|
---|
358 | // 2.1.2 ********************* central detector: keep only visible particles
|
---|
359 | // keeps only final particles, visible by the central detector, including the fiducial volume
|
---|
360 | // the ordering of conditions have been optimised for speed : put first the STATUS condition
|
---|
361 | if( (particle->Status == 1) &&
|
---|
362 | ((pid != pNU1) && (pid != pNU2) && (pid != pNU3)) &&
|
---|
363 | (fabs(particle->Eta) < DET->CEN_max_calo_fwd)
|
---|
364 | )
|
---|
365 | {
|
---|
366 | genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
|
---|
367 | genMomentumBfield = genMomentum;
|
---|
368 |
|
---|
369 | // 2.1.2.1 ********************* central detector: magnetic field
|
---|
370 | // genMomentumBfield is then changed with respect to the magnetic field
|
---|
371 | if(DET->FLAG_bfield==1) TRACP->Propagation(particle,genMomentumBfield);
|
---|
372 | float eta=fabs(genMomentumBfield.Eta());
|
---|
373 |
|
---|
374 |
|
---|
375 | // 2.1.2.2 ********************* central detector: smearing (calorimeters, muon chambers)
|
---|
376 | switch(pid) {
|
---|
377 |
|
---|
378 | case pE: // all electrons with eta < DET->MAX_CALO_FWD
|
---|
379 | DET->SmearElectron(genMomentumBfield);
|
---|
380 | if(genMomentumBfield.E()!=0 && eta < DET->CEN_max_tracker && genMomentumBfield.Pt() > DET->PTCUT_elec){
|
---|
381 | electron.push_back(ParticleUtil(genMomentumBfield,particle->PID));
|
---|
382 | }
|
---|
383 | break; // case pE
|
---|
384 | case pGAMMA: // all photons with eta < DET->MAX_CALO_FWD
|
---|
385 | DET->SmearElectron(genMomentumBfield);
|
---|
386 | if(genMomentumBfield.E()!=0 && eta < DET->CEN_max_tracker && genMomentumBfield.Pt() > DET->PTCUT_gamma) {
|
---|
387 | gamma.push_back(ParticleUtil(genMomentumBfield,particle->PID));
|
---|
388 | }
|
---|
389 | break; // case pGAMMA
|
---|
390 | case pMU: // all muons with eta < DET->MAX_MU
|
---|
391 | DET->SmearMu(genMomentumBfield);
|
---|
392 | if(genMomentumBfield.E()!=0 && eta < DET->CEN_max_mu && genMomentumBfield.Pt() > DET->PTCUT_muon){
|
---|
393 | muon.push_back(ParticleUtil(genMomentumBfield,particle->PID));
|
---|
394 | }
|
---|
395 | break; // case pMU
|
---|
396 | case pLAMBDA: // all lambdas with eta < DET->MAX_CALO_FWD
|
---|
397 | case pK0S: // all K0s with eta < DET->MAX_CALO_FWD
|
---|
398 | DET->SmearHadron(genMomentumBfield, 0.7);
|
---|
399 | break; // case hadron
|
---|
400 | default: // all other final particles with eta < DET->MAX_CALO_FWD
|
---|
401 | DET->SmearHadron(genMomentumBfield, 1.0);
|
---|
402 | break;
|
---|
403 | } // 2.1.2.2 switch (pid)
|
---|
404 |
|
---|
405 |
|
---|
406 | // 2.1.2.3 ********************* central detector: calotowers
|
---|
407 | // all final particles but muons and neutrinos
|
---|
408 | // for calorimetric towers and missing PT
|
---|
409 | int charge=Charge(pid);
|
---|
410 | if(genMomentumBfield.E() !=0 && pid != pMU) {
|
---|
411 | // in case the Bfield is not simulated, checks that charged particles have enough pt to reach the calos
|
---|
412 | if ( !DET->FLAG_bfield && charge!=0 && genMomentumBfield.Pt() <= DET->TRACK_ptmin ) { /* particules do not reach calos */ }
|
---|
413 | else { // particles reach calos
|
---|
414 | // applies the calo segmentation and returns iEta & iPhi
|
---|
415 | DET->BinEtaPhi(genMomentumBfield.Phi(), genMomentumBfield.Eta(), iPhi, iEta);
|
---|
416 | if(iEta != -100 && iPhi != -100) {
|
---|
417 | momentumCaloSegmentation.SetPtEtaPhiE(genMomentumBfield.Pt(),iEta,iPhi,genMomentumBfield.E());
|
---|
418 | elementCalo = (TRootCalo*) branchCalo->NewEntry();
|
---|
419 | elementCalo->Set(momentumCaloSegmentation);
|
---|
420 | PhysicsTower Tower(LorentzVector(momentumCaloSegmentation.Px(),momentumCaloSegmentation.Py(),momentumCaloSegmentation.Pz(),momentumCaloSegmentation.E()));
|
---|
421 | towers.push_back(Tower);
|
---|
422 | } // if iEta != -100
|
---|
423 | } // else : when particles reach the calos
|
---|
424 | } // 2.1.2.3 calotowers
|
---|
425 |
|
---|
426 |
|
---|
427 | // 2.1.2.4 ********************* central detector: tracks
|
---|
428 | // all final charged particles
|
---|
429 | if(
|
---|
430 | (genMomentumBfield.E()!=0) &&
|
---|
431 | (fabs(genMomentumBfield.Eta()) < DET->CEN_max_tracker) &&
|
---|
432 | (DET->FLAG_bfield || ( !DET->FLAG_bfield && genMomentumBfield.Pt() > DET->TRACK_ptmin )) &&
|
---|
433 | // if bfield not simulated, pt should be high enough to be taken into account
|
---|
434 | ((rand()%100) < DET->TRACK_eff) &&
|
---|
435 | (charge!=0)
|
---|
436 | )
|
---|
437 | {
|
---|
438 | elementTracks = (TRootTracks*) branchTracks->NewEntry();
|
---|
439 | elementTracks->Set(genMomentum); // fills px,py,pz,pt,e,eta,phi at vertex
|
---|
440 | elementTracks->Etaout = genMomentumBfield.Eta();
|
---|
441 | elementTracks->Phiout = genMomentumBfield.Phi();
|
---|
442 | // TODO!!! apply a smearing on the position of the origin of the track
|
---|
443 | // elementTracks->SetPosition(particle->X,particle->Y,particle->Z);
|
---|
444 | // uses the output of the bfield computation : Xout=... Yout=... Zout...
|
---|
445 | // TODO!!! elementTrakcs->SetPositionOut(Xout,Yout,Zout);
|
---|
446 | TrackCentral.push_back(genMomentum); // tracks at vertex!
|
---|
447 | } // 2.1.2.4 tracks
|
---|
448 |
|
---|
449 | } // 2.1.2 central detector
|
---|
450 |
|
---|
451 | // 2.1.3 ********************* forward detectors: zdc
|
---|
452 | if(DET->FLAG_vfd==1) {
|
---|
453 | VFD->ZDC(treeWriter,branchZDC,particle);
|
---|
454 | VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
|
---|
455 | }
|
---|
456 |
|
---|
457 | } // 2.1 while : loop on all particles of the event.
|
---|
458 |
|
---|
459 |
|
---|
460 |
|
---|
461 | // 2.2 ********** Output preparation & complex objects ***********
|
---|
462 |
|
---|
463 | // 2.2.1 ********************* sorting collections by decreasing pt
|
---|
464 | DET->SortedVector(electron);
|
---|
465 | for(unsigned int i=0; i < electron.size(); i++) {
|
---|
466 | elementElec = (TRootElectron*) branchElectron->NewEntry();
|
---|
467 | elementElec->Set(electron[i].Px(),electron[i].Py(),electron[i].Pz(),electron[i].E());
|
---|
468 | elementElec->Charge = sign(electron[i].PID());
|
---|
469 | elementElec->IsolFlag = DET->Isolation(electron[i].Phi(),electron[i].Eta(),TrackCentral,2.0);//isolation based on tracks
|
---|
470 | }
|
---|
471 | DET->SortedVector(muon);
|
---|
472 | for(unsigned int i=0; i < muon.size(); i++) {
|
---|
473 | elementMu = (TRootMuon*) branchMuon->NewEntry();
|
---|
474 | elementMu->Charge = sign(muon[i].PID());
|
---|
475 | elementMu->Set(muon[i].Px(),muon[i].Py(),muon[i].Pz(),muon[i].E());
|
---|
476 | elementMu->IsolFlag = DET->Isolation(muon[i].Phi(),muon[i].Eta(),TrackCentral,2.0);
|
---|
477 | }
|
---|
478 | DET->SortedVector(gamma);
|
---|
479 | for(unsigned int i=0; i < gamma.size(); i++) {
|
---|
480 | elementPhoton = (TRootPhoton*) branchPhoton->NewEntry();
|
---|
481 | elementPhoton->Set(gamma[i].Px(),gamma[i].Py(),gamma[i].Pz(),gamma[i].E());
|
---|
482 | }
|
---|
483 |
|
---|
484 | // 2.2.2 ************* computes the Missing Transverse Momentum
|
---|
485 | TLorentzVector Att(0.,0.,0.,0.);
|
---|
486 | for(unsigned int i=0; i < towers.size(); i++)
|
---|
487 | {
|
---|
488 | Att.SetPxPyPzE(towers[i].fourVector.px, towers[i].fourVector.py, towers[i].fourVector.pz, towers[i].fourVector.E);
|
---|
489 | if(fabs(Att.Eta()) < DET->CEN_max_calo_fwd)
|
---|
490 | {
|
---|
491 | PTmis = PTmis + Att;
|
---|
492 | // create a fastjet::PseudoJet with these components and put it onto
|
---|
493 | // back of the input_particles vector
|
---|
494 | input_particles.push_back(fastjet::PseudoJet(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E));
|
---|
495 | }
|
---|
496 | }
|
---|
497 | elementEtmis = (TRootETmis*) branchETmis->NewEntry();
|
---|
498 | elementEtmis->ET = (PTmis).Pt();
|
---|
499 | elementEtmis->Phi = (-PTmis).Phi();
|
---|
500 | elementEtmis->Px = (-PTmis).Px();
|
---|
501 | elementEtmis->Py = (-PTmis).Py();
|
---|
502 |
|
---|
503 | // 2.2.3 ************* B-tag, tau jets
|
---|
504 | sorted_jets=JETRUN->RunJets(input_particles);
|
---|
505 | JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ);
|
---|
506 | JETRUN->RunTauJets(treeWriter,branchTauJet,sorted_jets,towers, TrackCentral);
|
---|
507 |
|
---|
508 | treeWriter->Fill();
|
---|
509 | } // 2. Loop over all events ('for' loop)
|
---|
510 |
|
---|
511 | cout <<"** **"<< endl;
|
---|
512 | cout <<"** Exiting detector simulation... **"<< endl;
|
---|
513 |
|
---|
514 |
|
---|
515 | treeWriter->Write();
|
---|
516 | delete treeWriter;
|
---|
517 | loopwatch.Stop();
|
---|
518 |
|
---|
519 |
|
---|
520 |
|
---|
521 | // 3. ********** Trigger & Frog ***********
|
---|
522 | // 3.1 ************ running the trigger in case the FLAG trigger is put to 1 in the datacard
|
---|
523 | triggerwatch.Start();
|
---|
524 | if(DET->FLAG_trigger == 1)
|
---|
525 | {
|
---|
526 | cout <<"** **"<<endl;
|
---|
527 | cout <<"** ########### Start Trigger selection ########### **"<< endl;
|
---|
528 |
|
---|
529 | // input
|
---|
530 | TChain chainT("Analysis");
|
---|
531 | chainT.Add(outputfilename.c_str());
|
---|
532 | ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chainT);
|
---|
533 |
|
---|
534 | // output
|
---|
535 | TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
|
---|
536 | TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
|
---|
537 | TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
|
---|
538 | TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
|
---|
539 | TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
|
---|
540 | TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
|
---|
541 |
|
---|
542 | ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(outputfilename, "Trigger");
|
---|
543 | ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
|
---|
544 |
|
---|
545 |
|
---|
546 | Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
|
---|
547 | // loop on all entries
|
---|
548 | for(entryT = 0; entryT < allEntriesT; ++entryT) {
|
---|
549 | treeWriterT->Clear();
|
---|
550 | treeReaderT->ReadEntry(entryT);
|
---|
551 | TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
|
---|
552 | treeWriterT->Fill();
|
---|
553 | } // loop on all entries
|
---|
554 | cout <<"** Exiting trigger simulation... **"<< endl;
|
---|
555 |
|
---|
556 | treeWriterT->Write();
|
---|
557 | delete treeWriterT;
|
---|
558 | delete treeReaderT;
|
---|
559 | } // trigger
|
---|
560 | triggerwatch.Stop();
|
---|
561 |
|
---|
562 |
|
---|
563 | // 3.2 ************** FROG display
|
---|
564 | frogwatch.Start();
|
---|
565 | if(DET->FLAG_frog == 1) {
|
---|
566 | cout <<"** **"<<endl;
|
---|
567 | cout <<"** ################## Start FROG ################# **"<< endl;
|
---|
568 |
|
---|
569 | FrogDisplay *FROG = new FrogDisplay(DET);
|
---|
570 | FROG->BuildEvents(outputfilename);
|
---|
571 | FROG->BuildGeom();
|
---|
572 | delete FROG;
|
---|
573 | }
|
---|
574 | frogwatch.Stop();
|
---|
575 |
|
---|
576 |
|
---|
577 |
|
---|
578 |
|
---|
579 | // 4. ********** End & Exit ***********
|
---|
580 |
|
---|
581 | globalwatch.Stop();
|
---|
582 | cout <<"** **"<< endl;
|
---|
583 | cout <<"** ################## Time report ################# **"<< endl;
|
---|
584 | cout << left << setw(32) <<"** Time report for "<<""
|
---|
585 | << left << setw(15) << allEntries <<""
|
---|
586 | << right << setw(22) <<"events **"<<endl;
|
---|
587 | cout <<"** **"<< endl;
|
---|
588 | cout << left << setw(10) <<"**"<<""
|
---|
589 | << left << setw(15) <<"Time (s):"<<""
|
---|
590 | << right << setw(15) <<"CPU"<<""
|
---|
591 | << right << setw(15) <<"Real"<<""
|
---|
592 | << right << setw(14) <<"**"<<endl;
|
---|
593 | cout << left << setw(10) <<"**"<<""
|
---|
594 | << left << setw(15) <<" + Global:"<<""
|
---|
595 | << right << setw(15) <<globalwatch.CpuTime()<<""
|
---|
596 | << right << setw(15) <<globalwatch.RealTime()<<""
|
---|
597 | << right << setw(14) <<"**"<<endl;
|
---|
598 | cout << left << setw(10) <<"**"<<""
|
---|
599 | << left << setw(15) <<" + Events:"<<""
|
---|
600 | << right << setw(15) <<loopwatch.CpuTime()<<""
|
---|
601 | << right << setw(15) <<loopwatch.RealTime()<<""
|
---|
602 | << right << setw(14) <<"**"<<endl;
|
---|
603 | if(DET->FLAG_trigger == 1)
|
---|
604 | {
|
---|
605 | cout << left << setw(10) <<"**"<<""
|
---|
606 | << left << setw(15) <<" + Trigger:"<<""
|
---|
607 | << right << setw(15) <<triggerwatch.CpuTime()<<""
|
---|
608 | << right << setw(15) <<triggerwatch.RealTime()<<""
|
---|
609 | << right << setw(14) <<"**"<<endl;
|
---|
610 | }
|
---|
611 | if(DET->FLAG_frog == 1)
|
---|
612 | {
|
---|
613 | cout << left << setw(10) <<"**"<<""
|
---|
614 | << left << setw(15) <<" + Frog:"<<""
|
---|
615 | << right << setw(15) <<frogwatch.CpuTime()<<""
|
---|
616 | << right << setw(15) <<frogwatch.RealTime()<<""
|
---|
617 | << right << setw(14) <<"**"<<endl;
|
---|
618 |
|
---|
619 | }
|
---|
620 |
|
---|
621 | cout <<"** **"<< endl;
|
---|
622 | cout <<"** Exiting Delphes ... **"<< endl;
|
---|
623 | cout <<"** **"<< endl;
|
---|
624 | cout <<"*********************************************************************"<< endl;
|
---|
625 | cout <<"*********************************************************************"<< endl;
|
---|
626 |
|
---|
627 |
|
---|
628 | delete treeReader;
|
---|
629 | delete DET;
|
---|
630 | delete TRIGT;
|
---|
631 | delete TRACP;
|
---|
632 | delete JETRUN;
|
---|
633 | delete VFD;
|
---|
634 | delete converter;
|
---|
635 |
|
---|
636 | // todo("TODO");
|
---|
637 | }
|
---|