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 |
|
---|
17 | #include "Utilities/ExRootAnalysis/interface/ExRootTreeReader.h"
|
---|
18 | #include "Utilities/ExRootAnalysis/interface/ExRootTreeWriter.h"
|
---|
19 | #include "Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h"
|
---|
20 |
|
---|
21 | #include "H_BeamParticle.h"
|
---|
22 | #include "H_BeamLine.h"
|
---|
23 | #include "H_RomanPot.h"
|
---|
24 |
|
---|
25 | #include "interface/DataConverter.h"
|
---|
26 | #include "interface/HEPEVTConverter.h"
|
---|
27 | #include "interface/LHEFConverter.h"
|
---|
28 | #include "interface/STDHEPConverter.h"
|
---|
29 |
|
---|
30 | #include "interface/SmearUtil.h"
|
---|
31 | #include "Utilities/Fastjet/include/fastjet/PseudoJet.hh"
|
---|
32 | #include "Utilities/Fastjet/include/fastjet/ClusterSequence.hh"
|
---|
33 |
|
---|
34 | // get info on how fastjet was configured
|
---|
35 | #include "Utilities/Fastjet/include/fastjet/config.h"
|
---|
36 |
|
---|
37 | // make sure we have what is needed
|
---|
38 | #ifdef ENABLE_PLUGIN_SISCONE
|
---|
39 | # include "Utilities/Fastjet/plugins/SISCone/SISConePlugin.hh"
|
---|
40 | #endif
|
---|
41 | #ifdef ENABLE_PLUGIN_CDFCONES
|
---|
42 | # include "Utilities/Fastjet/plugins/CDFCones/CDFMidPointPlugin.hh"
|
---|
43 | # include "Utilities/Fastjet/plugins/CDFCones/CDFJetCluPlugin.hh"
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #include<vector>
|
---|
47 | #include<iostream>
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | //------------------------------------------------------------------------------
|
---|
54 | void todo(string filename) {
|
---|
55 | ifstream infile(filename.c_str());
|
---|
56 | cout << "** TODO list ..." << endl;
|
---|
57 | while(infile.good()) {
|
---|
58 | string temp;
|
---|
59 | getline(infile,temp);
|
---|
60 | cout << "*" << temp << endl;
|
---|
61 | }
|
---|
62 | cout << "** done...\n";
|
---|
63 | }
|
---|
64 |
|
---|
65 | //------------------------------------------------------------------------------
|
---|
66 |
|
---|
67 | int main(int argc, char *argv[])
|
---|
68 | {
|
---|
69 | int appargc = 2;
|
---|
70 | char *appName = "JetsSim";
|
---|
71 | char *appargv[] = {appName, "-b"};
|
---|
72 | TApplication app(appName, &appargc, appargv);
|
---|
73 |
|
---|
74 | if(argc != 4 && argc != 3) {
|
---|
75 | cout << " Usage: " << argv[0] << " input_file" << " output_file" << " data_card " << endl;
|
---|
76 | cout << " input_list - list of files in Ntpl, StdHep of LHEF format," << endl;
|
---|
77 | cout << " output_file - output file." << endl;
|
---|
78 | cout << " data_card - Datacard containing resolution variables for the detector simulation (optional) "<<endl;
|
---|
79 | exit(1);
|
---|
80 | }
|
---|
81 |
|
---|
82 | srand (time (NULL)); /* Initialisation du générateur */
|
---|
83 |
|
---|
84 | //read the input TROOT file
|
---|
85 | string inputFileList(argv[1]), outputfilename(argv[2]);
|
---|
86 | if(outputfilename.find(".root") > outputfilename.length() ) {
|
---|
87 | cout << "output_file should be a .root file!\n";
|
---|
88 | exit(1);
|
---|
89 | }
|
---|
90 | //create output log-file name
|
---|
91 | string forLog = outputfilename;
|
---|
92 | string LogName = forLog.erase(forLog.find(".root"));
|
---|
93 | LogName = LogName+"_run.log";
|
---|
94 |
|
---|
95 | TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
|
---|
96 | outputFile->Close();
|
---|
97 |
|
---|
98 | string line;
|
---|
99 | ifstream infile(inputFileList.c_str());
|
---|
100 | infile >> line; // the first line determines the type of input files
|
---|
101 |
|
---|
102 | //read the datacard input file
|
---|
103 | string DetDatacard("");
|
---|
104 | if(argc==4) DetDatacard =argv[3];
|
---|
105 | RESOLution *DET = new RESOLution();
|
---|
106 | DET->ReadDataCard(DetDatacard);
|
---|
107 | DET->Logfile(LogName);
|
---|
108 |
|
---|
109 | todo(LogName.c_str());
|
---|
110 |
|
---|
111 | DataConverter *converter=0;
|
---|
112 |
|
---|
113 | if(strstr(line.c_str(),".hep"))
|
---|
114 | {
|
---|
115 | cout<<"#**********************************************************************"<<endl;
|
---|
116 | cout<<"#********** StdHEP file format detected *************"<<endl;
|
---|
117 | cout<<"#*********** Starting convertion to TRoot format **************"<<endl;
|
---|
118 | cout<<"#**********************************************************************"<<endl;
|
---|
119 | converter = new STDHEPConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
120 | }
|
---|
121 | else if(strstr(line.c_str(),".lhe"))
|
---|
122 | {
|
---|
123 | cout<<"#**********************************************************************"<<endl;
|
---|
124 | cout<<"#*********** LHEF file format detected ************"<<endl;
|
---|
125 | cout<<"#*********** Starting convertion to TRoot format ************"<<endl;
|
---|
126 | cout<<"#**********************************************************************"<<endl;
|
---|
127 | converter = new LHEFConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
128 | }
|
---|
129 | else if(strstr(line.c_str(),".root"))
|
---|
130 | {
|
---|
131 | cout<<"#**********************************************************************"<<endl;
|
---|
132 | cout<<"#********** h2root file format detected *************"<<endl;
|
---|
133 | cout<<"#********** Starting convertion to TRoot format *************"<<endl;
|
---|
134 | cout<<"#**********************************************************************"<<endl;
|
---|
135 | converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list
|
---|
136 | }
|
---|
137 | else { cout << "*** " << line.c_str() << "\n*** file format not identified\n*** Exiting\n"; return -1;};
|
---|
138 |
|
---|
139 | TChain chain("GEN");
|
---|
140 | chain.Add(outputfilename.c_str());
|
---|
141 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
|
---|
142 | const TClonesArray *branchGen = treeReader->UseBranch("Particle");
|
---|
143 | TIter itGen((TCollection*)branchGen);
|
---|
144 |
|
---|
145 | //write the output root file
|
---|
146 | ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
|
---|
147 | ExRootTreeBranch *branchJet = treeWriter->NewBranch("Jet", TRootJet::Class());
|
---|
148 | ExRootTreeBranch *branchTauJet = treeWriter->NewBranch("TauJet", TRootTauJet::Class());
|
---|
149 | ExRootTreeBranch *branchElectron = treeWriter->NewBranch("Electron", TRootElectron::Class());
|
---|
150 | ExRootTreeBranch *branchMuon = treeWriter->NewBranch("Muon", TRootMuon::Class());
|
---|
151 | ExRootTreeBranch *branchPhoton = treeWriter->NewBranch("Photon", TRootPhoton::Class());
|
---|
152 | ExRootTreeBranch *branchTracks = treeWriter->NewBranch("Tracks", TRootTracks::Class());
|
---|
153 | ExRootTreeBranch *branchETmis = treeWriter->NewBranch("ETmis", TRootETmis::Class());
|
---|
154 | ExRootTreeBranch *branchCalo = treeWriter->NewBranch("CaloTower", TRootCalo::Class());
|
---|
155 | ExRootTreeBranch *branchZDC = treeWriter->NewBranch("ZDChits", TRootZdcHits::Class());
|
---|
156 | ExRootTreeBranch *branchRP220 = treeWriter->NewBranch("RP220hits", TRootRomanPotHits::Class());
|
---|
157 | ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootRomanPotHits::Class());
|
---|
158 |
|
---|
159 |
|
---|
160 | TRootGenParticle *particle;
|
---|
161 | TRootETmis *elementEtmis;
|
---|
162 | TRootElectron *elementElec;
|
---|
163 | TRootMuon *elementMu;
|
---|
164 | TRootPhoton *elementPhoton;
|
---|
165 | TRootJet *elementJet;
|
---|
166 | TRootTauJet *elementTauJet;
|
---|
167 | TRootTracks *elementTracks;
|
---|
168 | TRootCalo *elementCalo;
|
---|
169 | TRootZdcHits *elementZdc;
|
---|
170 | TRootRomanPotHits *elementRP220, *elementFP420;
|
---|
171 |
|
---|
172 | TLorentzVector genMomentum(0,0,0,0);
|
---|
173 | TLorentzVector genMomentumCalo(0,0,0,0);
|
---|
174 | LorentzVector jetMomentum;
|
---|
175 | vector<TLorentzVector> TrackCentral;
|
---|
176 | vector<PhysicsTower> towers;
|
---|
177 | vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
|
---|
178 | vector<fastjet::PseudoJet> inclusive_jets;
|
---|
179 | vector<fastjet::PseudoJet> sorted_jets;
|
---|
180 |
|
---|
181 | vector<TLorentzVector> electron;
|
---|
182 | vector<int> elecPID;
|
---|
183 | vector<TLorentzVector> muon;
|
---|
184 | vector<int> muonPID;
|
---|
185 | TSimpleArray<TRootGenParticle> NFCentralQ;
|
---|
186 |
|
---|
187 | //Initialisation of Hector
|
---|
188 | extern bool relative_energy;
|
---|
189 | relative_energy = true; // should always be true
|
---|
190 | extern int kickers_on;
|
---|
191 | kickers_on = 1; // should always be 1
|
---|
192 |
|
---|
193 | // user should provide : (1) optics file for each beamline, and IPname,
|
---|
194 | // and offset data (s,x) for optical elements
|
---|
195 | H_BeamLine* beamline1 = new H_BeamLine(1,500.);
|
---|
196 | beamline1->fill("data/LHCB1IR5_v6.500.tfs",1,"IP5");
|
---|
197 | beamline1->offsetElements(120,-0.097);
|
---|
198 | H_RomanPot * rp220_1 = new H_RomanPot("rp220_1",220,2000); // RP 220m, 2mm, beam 1
|
---|
199 | H_RomanPot * rp420_1 = new H_RomanPot("rp420_1",420,4000); // RP 420m, 4mm, beam 1
|
---|
200 | beamline1->add(rp220_1);
|
---|
201 | beamline1->add(rp420_1);
|
---|
202 |
|
---|
203 | H_BeamLine* beamline2 = new H_BeamLine(1,500.);
|
---|
204 | beamline2->fill("data/LHCB1IR5_v6.500.tfs",-1,"IP5");
|
---|
205 | beamline2->offsetElements(120,+0.097);
|
---|
206 | H_RomanPot * rp220_2 = new H_RomanPot("rp220_2",220,2000);// RP 220m, 2mm, beam 2
|
---|
207 | H_RomanPot * rp420_2 = new H_RomanPot("rp420_2",420,4000);// RP 420m, 4mm, beam 2
|
---|
208 | beamline2->add(rp220_2);
|
---|
209 | beamline2->add(rp420_2);
|
---|
210 |
|
---|
211 | // we will have four jet definitions, and the first three will be
|
---|
212 | // plugins
|
---|
213 | fastjet::JetDefinition jet_def;
|
---|
214 | fastjet::JetDefinition::Plugin * plugins;
|
---|
215 |
|
---|
216 | switch(DET->JETALGO) {
|
---|
217 | default:
|
---|
218 | case 1: {
|
---|
219 |
|
---|
220 | // set up a CDF midpoint jet definition
|
---|
221 | #ifdef ENABLE_PLUGIN_CDFCONES
|
---|
222 | plugins = new fastjet::CDFJetCluPlugin(DET->SEEDTHRESHOLD,DET->CONERADIUS,DET->C_ADJACENCYCUT,DET->C_MAXITERATIONS,DET->C_IRATCH,DET->OVERLAPTHRESHOLD);
|
---|
223 | jet_def = fastjet::JetDefinition(plugins);
|
---|
224 | #else
|
---|
225 | plugins = NULL;
|
---|
226 | #endif
|
---|
227 | }
|
---|
228 | break;
|
---|
229 |
|
---|
230 | case 2: {
|
---|
231 |
|
---|
232 | // set up a CDF midpoint jet definition
|
---|
233 | #ifdef ENABLE_PLUGIN_CDFCONES
|
---|
234 | plugins = new fastjet::CDFMidPointPlugin (DET->SEEDTHRESHOLD,DET->CONERADIUS,DET->M_CONEAREAFRACTION,DET->M_MAXPAIRSIZE,DET->M_MAXITERATIONS,DET->OVERLAPTHRESHOLD);
|
---|
235 | jet_def = fastjet::JetDefinition(plugins);
|
---|
236 | #else
|
---|
237 | plugins = NULL;
|
---|
238 | #endif
|
---|
239 | }
|
---|
240 | break;
|
---|
241 | case 3: {
|
---|
242 | // set up a siscone jet definition
|
---|
243 | #ifdef ENABLE_PLUGIN_SISCONE
|
---|
244 | plugins = new fastjet::SISConePlugin (DET->CONERADIUS,DET->OVERLAPTHRESHOLD,DET->NPASS, DET->PROTOJET_PTMIN);
|
---|
245 | jet_def = fastjet::JetDefinition(plugins);
|
---|
246 | #else
|
---|
247 | plugins = NULL;
|
---|
248 | #endif
|
---|
249 | }
|
---|
250 | break;
|
---|
251 |
|
---|
252 | case 4: {
|
---|
253 | jet_def = fastjet::JetDefinition(fastjet::kt_algorithm, DET->CONERADIUS);
|
---|
254 | //jet_defs[4] = fastjet::JetDefinition(fastjet::cambridge_algorithm,jet_radius);
|
---|
255 | //jet_defs[5] = fastjet::JetDefinition(fastjet::antikt_algorithm,jet_radius);
|
---|
256 | }
|
---|
257 | break;
|
---|
258 | }
|
---|
259 |
|
---|
260 | // Loop over all events
|
---|
261 | Long64_t entry, allEntries = treeReader->GetEntries();
|
---|
262 | cout << "** Chain contains " << allEntries << " events" << endl;
|
---|
263 | for(entry = 0; entry < allEntries; ++entry)
|
---|
264 | {
|
---|
265 | TLorentzVector PTmis(0,0,0,0);
|
---|
266 | treeReader->ReadEntry(entry);
|
---|
267 | treeWriter->Clear();
|
---|
268 | if((entry % 100) == 0 && entry > 0 ) cout << "** Processing element # " << entry << endl;
|
---|
269 |
|
---|
270 | electron.clear();
|
---|
271 | muon.clear();
|
---|
272 | elecPID.clear();
|
---|
273 | muonPID.clear();
|
---|
274 | NFCentralQ.Clear();
|
---|
275 |
|
---|
276 | itGen.Reset();
|
---|
277 | TrackCentral.clear();
|
---|
278 | towers.clear();
|
---|
279 | input_particles.clear();
|
---|
280 | inclusive_jets.clear();
|
---|
281 | sorted_jets.clear();
|
---|
282 |
|
---|
283 | // Loop over all particles in event
|
---|
284 | while( (particle = (TRootGenParticle*) itGen.Next()) )
|
---|
285 | {
|
---|
286 | genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
|
---|
287 |
|
---|
288 | int pid = abs(particle->PID);
|
---|
289 | float eta = fabs(particle->Eta);
|
---|
290 |
|
---|
291 | //subarray of the quarks (i.e. not final particles, i.e status not equal to 1)
|
---|
292 | // in the tracker (i.e. for those we know the tracks)
|
---|
293 | // with enough p_T
|
---|
294 | //// This subarray is needed for the B-jet algorithm
|
---|
295 | // optimization for speed : put first PID condition, then ETA condition, then either pt or status
|
---|
296 | 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 ?
|
---|
297 | eta < DET->MAX_TRACKER &&
|
---|
298 | particle->Status != 1 &&
|
---|
299 | particle->PT > DET->PT_QUARKS_MIN ) {
|
---|
300 | NFCentralQ.Add(particle);
|
---|
301 | }
|
---|
302 |
|
---|
303 |
|
---|
304 | // keeps only final particles, visible by the central detector, including the fiducial volume
|
---|
305 | // the ordering of conditions have been optimised for speed : put first the STATUS condition
|
---|
306 | if( (particle->Status == 1) &&
|
---|
307 | (
|
---|
308 | (pid == pMU && eta < DET->MAX_MU) ||
|
---|
309 | (pid != pMU && (pid != pNU1) && (pid != pNU2) && (pid != pNU3) && eta < DET->MAX_CALO_FWD)
|
---|
310 | )
|
---|
311 | ) {
|
---|
312 | switch(pid) {
|
---|
313 |
|
---|
314 | case pE: // all electrons with eta < DET->MAX_CALO_FWD
|
---|
315 | DET->SmearElectron(genMomentum);
|
---|
316 | electron.push_back(genMomentum);
|
---|
317 | elecPID.push_back(particle->PID);
|
---|
318 | break; // case pE
|
---|
319 | case pGAMMA: // all photons with eta < DET->MAX_CALO_FWD
|
---|
320 | DET->SmearElectron(genMomentum);
|
---|
321 | if(genMomentum.E()!=0 && eta < DET->MAX_TRACKER) {
|
---|
322 | elementPhoton = (TRootPhoton*) branchPhoton->NewEntry();
|
---|
323 | elementPhoton->Set(genMomentum);
|
---|
324 | }
|
---|
325 | break; // case pGAMMA
|
---|
326 | case pMU: // all muons with eta < DET->MAX_MU
|
---|
327 | DET->SmearMu(genMomentum);
|
---|
328 | muonPID.push_back(particle->PID);
|
---|
329 | muon.push_back(genMomentum);
|
---|
330 | break; // case pMU
|
---|
331 | case pLAMBDA: // all lambdas with eta < DET->MAX_CALO_FWD
|
---|
332 | case pK0S: // all K0s with eta < DET->MAX_CALO_FWD
|
---|
333 | DET->SmearHadron(genMomentum, 0.7);
|
---|
334 | break; // case hadron
|
---|
335 | default: // all other final particles with eta < DET->MAX_CALO_FWD
|
---|
336 | DET->SmearHadron(genMomentum, 1.0);
|
---|
337 | break;
|
---|
338 | } // switch (pid)
|
---|
339 |
|
---|
340 | // all final particles but muons and neutrinos
|
---|
341 | // for calorimetric towers and mission PT
|
---|
342 |
|
---|
343 | if(genMomentum.E() !=0) {
|
---|
344 | if(pid !=pMU) {
|
---|
345 | PhysicsTower CaloTower = PhysicsTower(LorentzVector(genMomentum.Px(),genMomentum.Py(),genMomentum.Pz(), genMomentum.E()));
|
---|
346 | towers.push_back(CaloTower);
|
---|
347 | // create a fastjet::PseudoJet with these components and put it onto
|
---|
348 | // back of the input_particles vector
|
---|
349 | input_particles.push_back(fastjet::PseudoJet(genMomentum.Px(),genMomentum.Py(),genMomentum.Pz(), genMomentum.E()));
|
---|
350 | //genMomentumCalo.SetPtEtaPhiE(CaloTower.Et(),CaloTower.iEta(),CaloTower.iPhi(),CaloTower.fourVector.E);
|
---|
351 | genMomentumCalo.SetPxPyPzE(CaloTower.fourVector.px,CaloTower.fourVector.py,CaloTower.fourVector.pz,CaloTower.fourVector.E);
|
---|
352 | elementCalo = (TRootCalo*) branchCalo->NewEntry();
|
---|
353 | elementCalo->Set(genMomentumCalo);
|
---|
354 | }
|
---|
355 | }
|
---|
356 |
|
---|
357 |
|
---|
358 | // all final charged particles
|
---|
359 | if(
|
---|
360 | ((rand()%100) < DET->TRACKING_EFF) &&
|
---|
361 | (genMomentum.E()!=0) &&
|
---|
362 | (fabs(particle->Eta) < DET->MAX_TRACKER) &&
|
---|
363 | (genMomentum.Pt() > DET->PT_TRACKS_MIN ) && // pt too small to be taken into account
|
---|
364 | (pid != pGAMMA) &&
|
---|
365 | (pid != pPI0) &&
|
---|
366 | (pid != pK0L) &&
|
---|
367 | (pid != pN) &&
|
---|
368 | (pid != pSIGMA0) &&
|
---|
369 | (pid != pDELTA0) &&
|
---|
370 | (pid != pK0S) // not charged particles : invisible by tracker
|
---|
371 | )
|
---|
372 | {
|
---|
373 | elementTracks = (TRootTracks*) branchTracks->NewEntry();
|
---|
374 | elementTracks->Set(genMomentum);
|
---|
375 | TrackCentral.push_back(genMomentum);
|
---|
376 | }
|
---|
377 |
|
---|
378 | } // switch
|
---|
379 |
|
---|
380 | // Forward particles in CASTOR ?
|
---|
381 | /* if (particle->Status == 1 && (fabs(particle->Eta) > DET->MIN_CALO_VFWD)
|
---|
382 | && (fabs(particle->Eta) < DET->MAX_CALO_VFWD)) {
|
---|
383 |
|
---|
384 |
|
---|
385 | } // CASTOR
|
---|
386 | */
|
---|
387 | // Zero degree calorimeter, for forward neutrons and photons
|
---|
388 | if (particle->Status ==1 && (pid == pN || pid == pGAMMA ) && eta > DET->MIN_ZDC ) {
|
---|
389 | // !!!!!!!!! vérifier que particle->Z est bien en micromÚtres!!!
|
---|
390 | // !!!!!!!!! vérifier que particle->T est bien en secondes!!!
|
---|
391 | // !!!!!!!!! pas de smearing ! on garde trop d'info !
|
---|
392 | elementZdc = (TRootZdcHits*) branchZDC->NewEntry();
|
---|
393 | elementZdc->Set(genMomentum);
|
---|
394 |
|
---|
395 | // time of flight t is t = T + d/[ cos(theta) v ]
|
---|
396 | //double tx = acos(particle->Px/particle->Pz);
|
---|
397 | //double ty = acos(particle->Py/particle->Pz);
|
---|
398 | //double theta = (1E-6)*sqrt( pow(tx,2) + pow(ty,2) );
|
---|
399 | //double flight_distance = (DET->ZDC_S - particle->Z*(1E-6))/cos(theta) ; // assumes that Z is in micrometers
|
---|
400 | double flight_distance = (DET->ZDC_S - particle->Z*(1E-6));
|
---|
401 | // assumes also that the emission angle is so small that 1/(cos theta) = 1
|
---|
402 | elementZdc->T = 0*particle->T + flight_distance/speed_of_light; // assumes highly relativistic particles
|
---|
403 | elementZdc->side = sign(particle->Eta);
|
---|
404 |
|
---|
405 | }
|
---|
406 |
|
---|
407 | // if forward proton
|
---|
408 | if( (pid == pP) && (particle->Status == 1) && (fabs(particle->Eta) > DET->MAX_CALO_FWD) )
|
---|
409 | {
|
---|
410 | // !!!!!!!! put here particle->CHARGE and particle->MASS
|
---|
411 | H_BeamParticle p1; /// put here particle->CHARGE and particle->MASS
|
---|
412 | p1.smearAng();
|
---|
413 | p1.smearPos();
|
---|
414 | p1.setPosition(p1.getX()-500.,p1.getY(),p1.getTX()-1*kickers_on*CRANG,p1.getTY(),0);
|
---|
415 | p1.set4Momentum(particle->Px,particle->Py,particle->Pz,particle->E);
|
---|
416 |
|
---|
417 | H_BeamLine *beamline;
|
---|
418 | if(particle->Eta >0) beamline = beamline1;
|
---|
419 | else beamline = beamline2;
|
---|
420 |
|
---|
421 | p1.computePath(beamline,1);
|
---|
422 |
|
---|
423 | if(p1.stopped(beamline)) {
|
---|
424 | if (p1.getStoppingElement()->getName()=="rp220_1" || p1.getStoppingElement()->getName()=="rp220_2") {
|
---|
425 | p1.propagate(DET->RP220_S);
|
---|
426 | elementRP220 = (TRootRomanPotHits*) branchRP220->NewEntry();
|
---|
427 | elementRP220->X = (1E-6)*p1.getX(); // [m]
|
---|
428 | elementRP220->Y = (1E-6)*p1.getY(); // [m]
|
---|
429 | elementRP220->Tx = (1E-6)*p1.getTX(); // [rad]
|
---|
430 | elementRP220->Ty = (1E-6)*p1.getTY(); // [rad]
|
---|
431 | elementRP220->S = p1.getS(); // [m]
|
---|
432 | elementRP220->T = -1; // not yet implemented
|
---|
433 | elementRP220->E = p1.getE(); // not yet implemented
|
---|
434 | elementRP220->q2 = -1; // not yet implemented
|
---|
435 | elementRP220->side = sign(particle->Eta);
|
---|
436 |
|
---|
437 | } else if (p1.getStoppingElement()->getName()=="rp420_1" || p1.getStoppingElement()->getName()=="rp420_2") {
|
---|
438 | p1.propagate(DET->FP420_S);
|
---|
439 | elementFP420 = (TRootRomanPotHits*) branchFP420->NewEntry();
|
---|
440 | elementFP420->X = (1E-6)*p1.getX(); // [m]
|
---|
441 | elementFP420->Y = (1E-6)*p1.getY(); // [m]
|
---|
442 | elementFP420->Tx = (1E-6)*p1.getTX(); // [rad]
|
---|
443 | elementFP420->Ty = (1E-6)*p1.getTY(); // [rad]
|
---|
444 | elementFP420->S = p1.getS(); // [m]
|
---|
445 | elementFP420->T = -1; // not yet implemented
|
---|
446 | elementFP420->E = p1.getE(); // not yet implemented
|
---|
447 | elementFP420->q2 = -1; // not yet implemented
|
---|
448 | elementFP420->side = sign(particle->Eta);
|
---|
449 | }
|
---|
450 | }
|
---|
451 |
|
---|
452 | // if(p1.stopped(beamline) && (p1.getStoppingElement()->getS() > 100))
|
---|
453 | // cout << "Eloss =" << 7000.-p1.getE() << " ; " << p1.getStoppingElement()->getName() << endl;
|
---|
454 | } // if forward proton
|
---|
455 |
|
---|
456 | } // while
|
---|
457 |
|
---|
458 | for(unsigned int i=0; i < electron.size(); i++) {
|
---|
459 | if(electron[i].E()!=0 && fabs(electron[i].Eta()) < DET->MAX_TRACKER && electron[i].Pt() > DET->ELEC_pt)
|
---|
460 | {
|
---|
461 | elementElec = (TRootElectron*) branchElectron->NewEntry();
|
---|
462 | elementElec->Set(electron[i]);
|
---|
463 | elementElec->Charge = sign(elecPID[i]);
|
---|
464 | elementElec->IsolFlag = DET->Isolation(electron[i].Phi(),electron[i].Eta(),TrackCentral,2.0);
|
---|
465 | }
|
---|
466 | }
|
---|
467 | for(unsigned int i=0; i < muon.size(); i++) {
|
---|
468 | if(muon[i].E()!=0 && fabs(muon[i].Eta()) < DET->MAX_MU && muon[i].Pt() > DET->MUON_pt)
|
---|
469 | {
|
---|
470 | elementMu = (TRootMuon*) branchMuon->NewEntry();
|
---|
471 | elementMu->Charge = sign(muonPID[i]);
|
---|
472 | elementMu->Set(muon[i]);
|
---|
473 | elementMu->IsolFlag = DET->Isolation(muon[i].Phi(),muon[i].Eta(),TrackCentral,2.0);
|
---|
474 | }
|
---|
475 | }
|
---|
476 |
|
---|
477 | // computes the Missing Transverse Momentum
|
---|
478 | TLorentzVector Att(0.,0.,0.,0.);
|
---|
479 | for(unsigned int i=0; i < towers.size(); i++)
|
---|
480 | {
|
---|
481 | Att.SetPxPyPzE(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E);
|
---|
482 | PTmis = PTmis + Att;
|
---|
483 | }
|
---|
484 | elementEtmis = (TRootETmis*) branchETmis->NewEntry();
|
---|
485 | elementEtmis->ET = (PTmis).Pt();
|
---|
486 | elementEtmis->Phi = (-PTmis).Phi();
|
---|
487 | elementEtmis->Px = (-PTmis).Px();
|
---|
488 | elementEtmis->Py = (-PTmis).Py();
|
---|
489 | //*****************************
|
---|
490 |
|
---|
491 | // run the jet clustering with the above jet definition
|
---|
492 | if(input_particles.size()!=0)
|
---|
493 | {
|
---|
494 | fastjet::ClusterSequence clust_seq(input_particles, jet_def);
|
---|
495 | // extract the inclusive jets with pt > 5 GeV
|
---|
496 | double ptmin = 5.0;
|
---|
497 | inclusive_jets = clust_seq.inclusive_jets(ptmin);
|
---|
498 | // sort jets into increasing pt
|
---|
499 | sorted_jets = sorted_by_pt(inclusive_jets);
|
---|
500 | }
|
---|
501 | for (unsigned int i = 0; i < sorted_jets.size(); i++) {
|
---|
502 | TLorentzVector JET;
|
---|
503 | JET.SetPxPyPzE(sorted_jets[i].px(),sorted_jets[i].py(),sorted_jets[i].pz(),sorted_jets[i].E());
|
---|
504 | // Tau jet identification : 1! track and electromagnetic collimation
|
---|
505 | if(fabs(JET.Eta()) < (DET->MAX_TRACKER - DET->TAU_CONE_TRACKS)) {
|
---|
506 | double Energie_tau_central = DET->EnergySmallCone(towers,JET.Eta(),JET.Phi());
|
---|
507 | if(
|
---|
508 | ( Energie_tau_central/JET.E() > DET->TAU_EM_COLLIMATION ) &&
|
---|
509 | ( DET->NumTracks(TrackCentral,DET->PT_TRACK_TAU,JET.Eta(),JET.Phi()) == 1 ) &&
|
---|
510 | ( JET.Pt() > DET->TAUJET_pt)
|
---|
511 | ) {
|
---|
512 | elementTauJet = (TRootTauJet*) branchTauJet->NewEntry();
|
---|
513 | elementTauJet->Set(JET);
|
---|
514 | } // if tau jet
|
---|
515 | } // if JET.eta < tracker - tau_cone : Tau jet identification
|
---|
516 |
|
---|
517 | if(JET.Pt() > DET->JET_pt)
|
---|
518 | {
|
---|
519 | elementJet = (TRootJet*) branchJet->NewEntry();
|
---|
520 | elementJet->Set(JET);
|
---|
521 | // b-jets
|
---|
522 | bool btag=false;
|
---|
523 | if((fabs(JET.Eta()) < DET->MAX_TRACKER && DET->Btaggedjet(JET, NFCentralQ)))btag=true;
|
---|
524 | elementJet->Btag = btag;
|
---|
525 | }
|
---|
526 | } // for itJet : loop on all jets
|
---|
527 |
|
---|
528 | treeWriter->Fill();
|
---|
529 | // Add here the trigger
|
---|
530 | // Should test all the trigger table on the event, based on reconstructed objects
|
---|
531 | } // Loop over all events
|
---|
532 | treeWriter->Write();
|
---|
533 |
|
---|
534 | cout << "** Exiting..." << endl;
|
---|
535 |
|
---|
536 | delete treeWriter;
|
---|
537 | delete treeReader;
|
---|
538 | delete DET;
|
---|
539 | if(converter) delete converter;
|
---|
540 |
|
---|
541 | todo("TODO");
|
---|
542 | }
|
---|
543 |
|
---|