[260] | 1 | /***********************************************************************
|
---|
| 2 | ** **
|
---|
| 3 | ** /----------------------------------------------\ **
|
---|
| 4 | ** | Delphes, a framework for the fast simulation | **
|
---|
| 5 | ** | of a generic collider experiment | **
|
---|
[401] | 6 | ** \------------- arXiv:0903.2225v1 ------------/ **
|
---|
[260] | 7 | ** **
|
---|
| 8 | ** **
|
---|
| 9 | ** This package uses: **
|
---|
| 10 | ** ------------------ **
|
---|
[429] | 11 | ** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
|
---|
[260] | 12 | ** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
|
---|
[429] | 13 | ** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
|
---|
[260] | 14 | ** FROG: [hep-ex/0901.2718v1] **
|
---|
[429] | 15 | ** HepMC: Comput. Phys. Commun.134 (2001) 41 **
|
---|
[260] | 16 | ** **
|
---|
| 17 | ** ------------------------------------------------------------------ **
|
---|
| 18 | ** **
|
---|
| 19 | ** Main authors: **
|
---|
| 20 | ** ------------- **
|
---|
| 21 | ** **
|
---|
| 22 | ** Severine Ovyn Xavier Rouby **
|
---|
| 23 | ** severine.ovyn@uclouvain.be xavier.rouby@cern **
|
---|
| 24 | ** **
|
---|
| 25 | ** Center for Particle Physics and Phenomenology (CP3) **
|
---|
[429] | 26 | ** Universite catholique de Louvain (UCL) **
|
---|
| 27 | ** Louvain-la-Neuve, Belgium **
|
---|
[260] | 28 | ** **
|
---|
| 29 | ** Copyright (C) 2008-2009, **
|
---|
[429] | 30 | ** All rights reserved. **
|
---|
[260] | 31 | ** **
|
---|
| 32 | ***********************************************************************/
|
---|
[2] | 33 |
|
---|
| 34 | /// \file Delphes.cpp
|
---|
[264] | 35 | /// \brief Executable for Delphes
|
---|
[2] | 36 |
|
---|
| 37 | #include "TChain.h"
|
---|
| 38 | #include "TApplication.h"
|
---|
[191] | 39 | #include "TStopwatch.h"
|
---|
[228] | 40 | #include "TFile.h"
|
---|
[2] | 41 |
|
---|
[228] | 42 | #include "ExRootTreeReader.h"
|
---|
| 43 | #include "ExRootTreeWriter.h"
|
---|
| 44 | #include "ExRootTreeBranch.h"
|
---|
[264] | 45 | #include "ExRootProgressBar.h"
|
---|
[2] | 46 |
|
---|
[228] | 47 | #include "DataConverter.h"
|
---|
| 48 | #include "LHEFConverter.h"
|
---|
[350] | 49 | #include "HepMCConverter.h"
|
---|
[353] | 50 | #include "HEPEVTConverter.h"
|
---|
[228] | 51 | #include "STDHEPConverter.h"
|
---|
[307] | 52 | #include "LHCOConverter.h"
|
---|
[457] | 53 | #include "DelphesRootConverter.h"
|
---|
[2] | 54 |
|
---|
[228] | 55 | #include "SmearUtil.h"
|
---|
[264] | 56 | #include "CaloUtil.h"
|
---|
[228] | 57 | #include "BFieldProp.h"
|
---|
| 58 | #include "TriggerUtil.h"
|
---|
| 59 | #include "VeryForward.h"
|
---|
| 60 | #include "JetsUtil.h"
|
---|
| 61 | #include "FrogUtil.h"
|
---|
[2] | 62 |
|
---|
[55] | 63 | #include <vector>
|
---|
| 64 | #include <iostream>
|
---|
[547] | 65 | #include <cstdlib> // abs(int)
|
---|
[11] | 66 |
|
---|
[2] | 67 | using namespace std;
|
---|
| 68 |
|
---|
| 69 | //------------------------------------------------------------------------------
|
---|
| 70 |
|
---|
| 71 | int main(int argc, char *argv[])
|
---|
| 72 | {
|
---|
[463] | 73 |
|
---|
[2] | 74 | int appargc = 2;
|
---|
[228] | 75 | char *appName= new char[20];
|
---|
| 76 | char *appOpt= new char[20];
|
---|
| 77 | sprintf(appName,"Delphes");
|
---|
| 78 | sprintf(appOpt,"-b");
|
---|
| 79 | char *appargv[] = {appName,appOpt};
|
---|
[2] | 80 | TApplication app(appName, &appargc, appargv);
|
---|
[228] | 81 | delete [] appName;
|
---|
| 82 | delete [] appOpt;
|
---|
[307] | 83 |
|
---|
[249] | 84 | if(argc != 3 && argc != 4 && argc != 5) {
|
---|
[94] | 85 | cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
|
---|
[429] | 86 | cout << " input_list - list of files in Ntpl, StdHep, HepMC or LHEF format," << endl;
|
---|
[94] | 87 | cout << " output_file - output file." << endl;
|
---|
| 88 | cout << " detector_card - Datacard containing resolution variables for the detector simulation (optional) "<<endl;
|
---|
| 89 | cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
|
---|
| 90 | exit(1);
|
---|
[2] | 91 | }
|
---|
[401] | 92 |
|
---|
| 93 | print_header();
|
---|
[228] | 94 |
|
---|
[307] | 95 | // 1. ********** initialisation ***********
|
---|
| 96 |
|
---|
[2] | 97 | srand (time (NULL)); /* Initialisation du générateur */
|
---|
[530] | 98 | TRandom3 * grandom = new TRandom3();
|
---|
[313] | 99 | TStopwatch globalwatch, loopwatch, triggerwatch, frogwatch, lhcowatch;
|
---|
[191] | 100 | globalwatch.Start();
|
---|
[2] | 101 |
|
---|
[307] | 102 |
|
---|
[249] | 103 | //read the output TROOT file
|
---|
[2] | 104 | string inputFileList(argv[1]), outputfilename(argv[2]);
|
---|
[249] | 105 | if(outputfilename.find(".root") > outputfilename.length()) {
|
---|
| 106 | cout <<"** ERROR: 'output_file' should be a .root file. Exiting... **"<< endl;
|
---|
[94] | 107 | exit(1);
|
---|
[2] | 108 | }
|
---|
[44] | 109 | //create output log-file name
|
---|
[45] | 110 | string forLog = outputfilename;
|
---|
| 111 | string LogName = forLog.erase(forLog.find(".root"));
|
---|
[44] | 112 | LogName = LogName+"_run.log";
|
---|
[94] | 113 |
|
---|
[2] | 114 | TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
|
---|
| 115 | outputFile->Close();
|
---|
[94] | 116 |
|
---|
[2] | 117 | string line;
|
---|
| 118 | ifstream infile(inputFileList.c_str());
|
---|
[384] | 119 | if(!infile.good()) {
|
---|
| 120 | cout << "** ERROR: Input list (" << left << setw(13) << inputFileList << ") not found. Exiting... **"<< endl;
|
---|
| 121 | cout <<"*********************************************************************"<< endl;
|
---|
| 122 | exit(1);
|
---|
| 123 | }
|
---|
[2] | 124 | infile >> line; // the first line determines the type of input files
|
---|
[94] | 125 |
|
---|
[44] | 126 | //read the datacard input file
|
---|
[304] | 127 | string DetDatacard("data/DetectorCard.dat"); //for detector smearing parameters
|
---|
| 128 | string TrigDatacard("data/TriggerCard.dat"); //for trigger selection
|
---|
[307] | 129 |
|
---|
[249] | 130 | string lineCard1,lineCard2;
|
---|
| 131 | bool detecCard=false,trigCard=false;
|
---|
| 132 | if(argv[3])
|
---|
| 133 | {
|
---|
| 134 | ifstream infile1(argv[3]);
|
---|
| 135 | infile1 >> lineCard1; // the first line determines the type of input files
|
---|
| 136 | if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==true)
|
---|
[307] | 137 | cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
|
---|
[249] | 138 | else if(strstr(lineCard1.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[3]; detecCard=true;}
|
---|
| 139 | else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==true)
|
---|
[307] | 140 | cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
|
---|
[249] | 141 | else if(strstr(lineCard1.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[3]; trigCard=true;}
|
---|
| 142 | }
|
---|
| 143 | if(argv[4])
|
---|
| 144 | {
|
---|
| 145 | ifstream infile2(argv[4]);
|
---|
| 146 | infile2 >> lineCard2; // the first line determines the type of input files
|
---|
| 147 | if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==true)
|
---|
[307] | 148 | cerr <<"** ERROR: A DETECTOR card has already been loaded **"<< endl;
|
---|
[249] | 149 | else if(strstr(lineCard2.c_str(),"DETECTOR") && detecCard==false){DetDatacard =argv[4]; detecCard=true;}
|
---|
| 150 | else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==true)
|
---|
[307] | 151 | cerr <<"** ERROR: A TRIGGER card has already been loaded **"<< endl;
|
---|
[249] | 152 | else if(strstr(lineCard2.c_str(),"TRIGGER") && trigCard==false){TrigDatacard =argv[4]; trigCard=true;}
|
---|
| 153 | }
|
---|
[94] | 154 |
|
---|
[55] | 155 | //Smearing information
|
---|
[44] | 156 | RESOLution *DET = new RESOLution();
|
---|
[380] | 157 |
|
---|
[212] | 158 | cout <<"** **"<< endl;
|
---|
| 159 | cout <<"** ####### Start reading DETECTOR parameters ####### **"<< endl;
|
---|
| 160 | cout << left << setw(40) <<"** Opening configuration card: "<<""
|
---|
[258] | 161 | << left << setw(27) << DetDatacard <<""
|
---|
| 162 | << right << setw(2) <<"**"<<""<<endl;
|
---|
[44] | 163 | DET->ReadDataCard(DetDatacard);
|
---|
[304] | 164 | cout << left << setw(40) <<"** Parameters summarised in: "<<""
|
---|
[258] | 165 | << left << setw(27) << LogName <<""
|
---|
| 166 | << right << setw(2) <<"**"<<""<<endl;
|
---|
[212] | 167 | cout <<"** **"<< endl;
|
---|
[380] | 168 | DET->ReadParticleDataGroupTable();
|
---|
[474] | 169 | //DET->PDGtable.print();
|
---|
[494] | 170 |
|
---|
[55] | 171 | //Trigger information
|
---|
[249] | 172 | cout <<"** ########### Start reading TRIGGER card ########## **"<< endl;
|
---|
| 173 | if(trigCard==false)
|
---|
[307] | 174 | {
|
---|
| 175 | cout <<"** WARNING: Datacard not found, use default card **" << endl;
|
---|
| 176 | TrigDatacard="data/TriggerCard.dat";
|
---|
| 177 | }
|
---|
[72] | 178 | TriggerTable *TRIGT = new TriggerTable();
|
---|
[80] | 179 | TRIGT->TriggerCardReader(TrigDatacard.c_str());
|
---|
[72] | 180 | TRIGT->PrintTriggerTable(LogName);
|
---|
[212] | 181 | if(DET->FLAG_trigger == 1)
|
---|
| 182 | {
|
---|
| 183 | cout << left << setw(40) <<"** Opening configuration card: "<<""
|
---|
[258] | 184 | << left << setw(27) << TrigDatacard <<""
|
---|
| 185 | << right << setw(2) <<"**"<<""<<endl;
|
---|
[212] | 186 | cout <<"** **"<< endl;
|
---|
| 187 | }
|
---|
[453] | 188 |
|
---|
| 189 | // Logfile
|
---|
| 190 | DET->setNames(inputFileList,DetDatacard,TrigDatacard);
|
---|
| 191 | DET->Logfile(LogName);
|
---|
| 192 |
|
---|
[55] | 193 | //Propagation of tracks in the B field
|
---|
[228] | 194 | TrackPropagation *TRACP = new TrackPropagation(DET);
|
---|
[94] | 195 |
|
---|
[55] | 196 | //Jet information
|
---|
[228] | 197 | JetsUtil *JETRUN = new JetsUtil(DET);
|
---|
[94] | 198 |
|
---|
[55] | 199 | //VFD information
|
---|
[228] | 200 | VeryForward * VFD = new VeryForward(DET);
|
---|
[307] | 201 |
|
---|
[178] | 202 | // data converters
|
---|
[212] | 203 | cout <<"** **"<<endl;
|
---|
[415] | 204 | cout <<"** ####### Start conversion to TRoot format ######## **"<< endl;
|
---|
[418] | 205 |
|
---|
| 206 | if(line.rfind(".hepmc") < line.length())
|
---|
| 207 | {
|
---|
| 208 | cout <<"** HepMC ASCII file format detected **"<<endl;
|
---|
| 209 | cout <<"** This can take several minutes **"<< endl;
|
---|
| 210 | HepMCConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
|
---|
| 211 | }
|
---|
| 212 | else if(line.rfind(".hep") < line.length())
|
---|
[2] | 213 | {
|
---|
[212] | 214 | cout <<"** StdHEP file format detected **"<<endl;
|
---|
| 215 | cout <<"** This can take several minutes **"<< endl;
|
---|
[418] | 216 | STDHEPConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
|
---|
[2] | 217 | }
|
---|
[418] | 218 | else if(line.rfind(".lhe") < line.length())
|
---|
[2] | 219 | {
|
---|
[212] | 220 | cout <<"** LHEF file format detected **"<<endl;
|
---|
| 221 | cout <<"** This can take several minutes **"<< endl;
|
---|
[418] | 222 | LHEFConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
|
---|
[2] | 223 | }
|
---|
[418] | 224 | else if(line.rfind(".root") < line.length())
|
---|
[457] | 225 | // can be either a root file from h2root (i.e. with "h101" tree)
|
---|
| 226 | // or a root file from Delphes (i.e. with "GEN" tree)
|
---|
[2] | 227 | {
|
---|
[457] | 228 | TFile f(line.c_str());
|
---|
| 229 | if (f.FindKey("GEN")) {
|
---|
| 230 | cout <<"** Delphes ROOT file format detected **"<<endl;
|
---|
| 231 | cout <<"** This can take several minutes **"<< endl;
|
---|
| 232 | DelphesRootConverter converter(inputFileList,outputfilename,DET->NEvents);
|
---|
| 233 | }
|
---|
| 234 | else
|
---|
| 235 | if (f.FindKey("h101")) {
|
---|
| 236 | cout <<"** h2root file format detected **"<<endl;
|
---|
| 237 | cout <<"** This can take several minutes **"<< endl;
|
---|
| 238 | HEPEVTConverter converter(inputFileList,outputfilename,DET->PDGtable,DET->NEvents);
|
---|
| 239 | }
|
---|
| 240 | else {
|
---|
| 241 | cerr << left << setw(4) <<"** "<<""
|
---|
| 242 | << left << setw(63) << line.c_str() <<""
|
---|
| 243 | << right << setw(2) <<"**"<<endl;
|
---|
| 244 | cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
|
---|
| 245 | cout <<"** **"<< endl;
|
---|
| 246 | cout <<"*********************************************************************"<< endl;
|
---|
| 247 | return -1;
|
---|
| 248 | } // not found any interesting input tree
|
---|
| 249 | f.Close();
|
---|
| 250 | } // .root file
|
---|
[212] | 251 | else {
|
---|
[307] | 252 | cerr << left << setw(4) <<"** "<<""
|
---|
| 253 | << left << setw(63) << line.c_str() <<""
|
---|
| 254 | << right << setw(2) <<"**"<<endl;
|
---|
| 255 | cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
|
---|
| 256 | cout <<"** **"<< endl;
|
---|
| 257 | cout <<"*********************************************************************"<< endl;
|
---|
| 258 | return -1;};
|
---|
[212] | 259 | cout <<"** Exiting conversion... **"<< endl;
|
---|
[307] | 260 |
|
---|
[2] | 261 | TChain chain("GEN");
|
---|
| 262 | chain.Add(outputfilename.c_str());
|
---|
| 263 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
|
---|
| 264 | const TClonesArray *branchGen = treeReader->UseBranch("Particle");
|
---|
[307] | 265 |
|
---|
[2] | 266 | TIter itGen((TCollection*)branchGen);
|
---|
| 267 |
|
---|
[178] | 268 | //Output file : contents of the analysis object data
|
---|
[2] | 269 | ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
|
---|
[267] | 270 | ExRootTreeBranch *branchTauJet = treeWriter->NewBranch("TauJet", TRootTauJet::Class());
|
---|
[2] | 271 | ExRootTreeBranch *branchJet = treeWriter->NewBranch("Jet", TRootJet::Class());
|
---|
| 272 | ExRootTreeBranch *branchElectron = treeWriter->NewBranch("Electron", TRootElectron::Class());
|
---|
| 273 | ExRootTreeBranch *branchMuon = treeWriter->NewBranch("Muon", TRootMuon::Class());
|
---|
| 274 | ExRootTreeBranch *branchPhoton = treeWriter->NewBranch("Photon", TRootPhoton::Class());
|
---|
[268] | 275 | ExRootTreeBranch *branchTrack = treeWriter->NewBranch("Tracks", TRootTracks::Class());
|
---|
[2] | 276 | ExRootTreeBranch *branchETmis = treeWriter->NewBranch("ETmis", TRootETmis::Class());
|
---|
| 277 | ExRootTreeBranch *branchCalo = treeWriter->NewBranch("CaloTower", TRootCalo::Class());
|
---|
| 278 | ExRootTreeBranch *branchZDC = treeWriter->NewBranch("ZDChits", TRootZdcHits::Class());
|
---|
| 279 | ExRootTreeBranch *branchRP220 = treeWriter->NewBranch("RP220hits", TRootRomanPotHits::Class());
|
---|
[380] | 280 | //ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootForwardTaggerHits::Class());
|
---|
| 281 | ExRootTreeBranch *branchFP420 = treeWriter->NewBranch("FP420hits", TRootRomanPotHits::Class());
|
---|
[30] | 282 |
|
---|
[2] | 283 | TRootETmis *elementEtmis;
|
---|
| 284 | TRootElectron *elementElec;
|
---|
| 285 | TRootMuon *elementMu;
|
---|
| 286 | TRootPhoton *elementPhoton;
|
---|
[268] | 287 | TRootTracks * elementTrack;
|
---|
[2] | 288 | TRootCalo *elementCalo;
|
---|
| 289 |
|
---|
[184] | 290 | TLorentzVector genMomentum(0,0,0,0); // four-momentum at the vertex
|
---|
| 291 | TLorentzVector genMomentumBfield(0,0,0,0); // four-momentum at the exit of the tracks
|
---|
| 292 | TLorentzVector momentumCaloSegmentation(0,0,0,0); // four-momentum in the calo, after applying the calo segmentation
|
---|
[2] | 293 | LorentzVector jetMomentum;
|
---|
[94] | 294 |
|
---|
[55] | 295 | vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
|
---|
| 296 | vector<fastjet::PseudoJet> sorted_jets;
|
---|
[290] | 297 | vector<TRootTracks> TrackCentral;
|
---|
[2] | 298 | vector<PhysicsTower> towers;
|
---|
[264] | 299 | vector<D_Particle> electron;
|
---|
| 300 | vector<D_Particle> muon;
|
---|
| 301 | vector<D_Particle> gamma;
|
---|
[307] | 302 |
|
---|
| 303 | vector<int> NTrackJet;
|
---|
[98] | 304 |
|
---|
[350] | 305 | TSimpleArray<TRootC::GenParticle> NFCentralQ;
|
---|
[307] | 306 |
|
---|
| 307 | D_CaloList list_of_calorimeters;
|
---|
| 308 | D_CaloElement CentralCalo("centralcalo",
|
---|
| 309 | -DET->CEN_max_calo_cen, DET->CEN_max_calo_cen,
|
---|
| 310 | DET->ELG_Ccen, DET->ELG_Ncen, DET->ELG_Scen,
|
---|
[494] | 311 | DET->HAD_Ccen, DET->HAD_Ncen, DET->HAD_Scen);
|
---|
| 312 | D_CaloElement ForwardECCalo("forwardendcapcalo",
|
---|
| 313 | DET->CEN_max_calo_cen, DET->CEN_max_calo_ec,
|
---|
| 314 | DET->ELG_Cec, DET->ELG_Nec, DET->ELG_Sec,
|
---|
| 315 | DET->HAD_Cec, DET->HAD_Nec, DET->HAD_Sec );
|
---|
| 316 | D_CaloElement BackwardECCalo("backwardendcapcalo",
|
---|
| 317 | -DET->CEN_max_calo_ec, -DET->CEN_max_calo_cen,
|
---|
| 318 | DET->ELG_Cec, DET->ELG_Nec, DET->ELG_Sec,
|
---|
| 319 | DET->HAD_Cec, DET->HAD_Nec, DET->HAD_Sec );
|
---|
[307] | 320 | D_CaloElement ForwardCalo("forwardcalo",
|
---|
[494] | 321 | DET->CEN_max_calo_ec, DET->CEN_max_calo_fwd,
|
---|
[307] | 322 | DET->ELG_Cfwd, DET->ELG_Nfwd, DET->ELG_Sfwd,
|
---|
[494] | 323 | DET->HAD_Cfwd, DET->HAD_Nfwd, DET->HAD_Sfwd );
|
---|
[307] | 324 | D_CaloElement BackwardCalo("backwardcalo",
|
---|
[494] | 325 | -DET->CEN_max_calo_fwd, -DET->CEN_max_calo_ec,
|
---|
[307] | 326 | DET->ELG_Cfwd, DET->ELG_Nfwd, DET->ELG_Sfwd,
|
---|
[494] | 327 | DET->HAD_Cfwd, DET->HAD_Nfwd, DET->HAD_Sfwd );
|
---|
[307] | 328 | //D_CaloElement CastorCalo("castor",5.5,6.6,1,0,0,1,0,0);
|
---|
| 329 | list_of_calorimeters.addElement(CentralCalo);
|
---|
[494] | 330 | list_of_calorimeters.addElement(ForwardECCalo);
|
---|
[307] | 331 | list_of_calorimeters.addElement(ForwardCalo);
|
---|
[494] | 332 | list_of_calorimeters.addElement(BackwardECCalo);
|
---|
[307] | 333 | list_of_calorimeters.addElement(BackwardCalo);
|
---|
| 334 | //list_of_calorimeters.addElement(CastorCalo);
|
---|
| 335 | list_of_calorimeters.sortElements();
|
---|
| 336 |
|
---|
| 337 |
|
---|
| 338 | // 2. ********** Loop over all events ***********
|
---|
[2] | 339 | Long64_t entry, allEntries = treeReader->GetEntries();
|
---|
[212] | 340 | cout <<"** **"<<endl;
|
---|
| 341 | cout <<"** ####### Start fast detector simulation ######## **"<< endl;
|
---|
| 342 | cout << left << setw(52) <<"** Total number of events to run: "<<""
|
---|
| 343 | << left << setw(15) << allEntries <<""
|
---|
| 344 | << right << setw(2) <<"**"<<endl;
|
---|
[307] | 345 |
|
---|
[251] | 346 | ExRootProgressBar *Progress = new ExRootProgressBar(allEntries);
|
---|
[307] | 347 |
|
---|
[191] | 348 | loopwatch.Start();
|
---|
[307] | 349 |
|
---|
[178] | 350 | // loop on all events
|
---|
| 351 | for(entry = 0; entry < allEntries; ++entry)
|
---|
[2] | 352 | {
|
---|
[251] | 353 | Progress->Update(entry);
|
---|
[2] | 354 | TLorentzVector PTmis(0,0,0,0);
|
---|
| 355 | treeReader->ReadEntry(entry);
|
---|
| 356 | treeWriter->Clear();
|
---|
| 357 |
|
---|
[30] | 358 | electron.clear();
|
---|
| 359 | muon.clear();
|
---|
[74] | 360 | gamma.clear();
|
---|
[30] | 361 | NFCentralQ.Clear();
|
---|
| 362 |
|
---|
[2] | 363 | TrackCentral.clear();
|
---|
| 364 | towers.clear();
|
---|
[11] | 365 | input_particles.clear();
|
---|
[307] | 366 | NTrackJet.clear();
|
---|
[310] | 367 |
|
---|
[384] | 368 | // 'list_of_active_towers' contains the exact list of calorimetric towers which have some deposits inside (E>0).
|
---|
| 369 | // The towers of this list will be smeared according to the calo resolution, afterwards
|
---|
[310] | 370 | D_CaloTowerList list_of_active_towers;
|
---|
[384] | 371 |
|
---|
| 372 | // 'list_of_towers_with_photon' and 'list_of_centowers_with_neutrals' are list of towers, whose energy is **not** computed.
|
---|
| 373 | // They are only used to store the eta/phi of some towers, in order to search later inside 'list_of_active_towers'.
|
---|
| 374 | // 'list_of_towers_with_photon' contains the towers hit by photons only
|
---|
| 375 | // 'list_of_centowers_with_neutrals' is used to the jet-E-flow calculation: contains the towers with eta < CEN_max_tracker,
|
---|
| 376 | // i.e. towers behind the tracker.
|
---|
[310] | 377 | D_CaloTowerList list_of_towers_with_photon; // to speed up the code: will only look in interesting towers for gamma candidates
|
---|
[384] | 378 |
|
---|
| 379 | D_CaloTowerList list_of_centowers_with_neutrals; // list of towers with neutral particles : for jet E-flow
|
---|
| 380 | float etamax_calocoverage_behindtracker = DET->CEN_max_tracker; // finds the extension in eta of the furthest
|
---|
| 381 | for (unsigned int i=1; i< DET->TOWER_number+1; i++) { // cell (at least) partially behind the tracker
|
---|
| 382 | if(DET->TOWER_eta_edges[i] > DET->CEN_max_tracker) break;
|
---|
| 383 | etamax_calocoverage_behindtracker = DET->TOWER_eta_edges[i];
|
---|
| 384 | }
|
---|
[310] | 385 | // 2.1a Loop over all particles in event, to fill the towers
|
---|
| 386 | itGen.Reset();
|
---|
[350] | 387 | TRootC::GenParticle *particleG;
|
---|
| 388 | while( (particleG = (TRootC::GenParticle*) itGen.Next()) )
|
---|
[310] | 389 | {
|
---|
[307] | 390 | TRootGenParticle *particle = new TRootGenParticle(particleG);
|
---|
[380] | 391 | PdgParticle pdg_part = DET->PDGtable[particle->PID];
|
---|
| 392 | particle->Charge = pdg_part.charge();
|
---|
| 393 | particle->M = pdg_part.mass();
|
---|
| 394 | //particle->Charge=ChargeVal(particle->PID);
|
---|
| 395 | particle->setFractions(); // init
|
---|
[307] | 396 | int pid = abs(particle->PID);
|
---|
| 397 |
|
---|
[264] | 398 | // 2.1a.1********************* preparation for the b-tagging
|
---|
| 399 | //// This subarray is needed for the B-jet algorithm
|
---|
| 400 | // optimization for speed : put first PID condition, then ETA condition, then either pt or status
|
---|
| 401 | 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 ?
|
---|
| 402 | fabs(particle->Eta) < DET->CEN_max_tracker &&
|
---|
| 403 | particle->Status != 1 &&
|
---|
[310] | 404 | particle->PT > DET->PT_QUARKS_MIN )
|
---|
| 405 | {
|
---|
[319] | 406 | NFCentralQ.Add(particleG);
|
---|
[310] | 407 | }
|
---|
[307] | 408 |
|
---|
[264] | 409 | // 2.1a.2********************* visible particles only
|
---|
[469] | 410 | if( (particle->Status == 1) && (! pdg_part.invisible() ) )
|
---|
[310] | 411 | {
|
---|
| 412 | // 2.1a.2.1 Central solenoidal magnetic field
|
---|
| 413 | TRACP->bfield(particle); // fills in particle->EtaCalo et particle->PhiCalo
|
---|
| 414 | // 2.1a.2.2 Filling the calorimetric towers -- includes also forward detectors ?
|
---|
| 415 | // first checks if the charged particles reach the calo!
|
---|
| 416 | if( DET->FLAG_bfield ||
|
---|
| 417 | particle->Charge==0 ||
|
---|
| 418 | (!DET->FLAG_bfield && particle->Charge!=0 && particle->PT > DET->TRACK_ptmin))
|
---|
| 419 | if(
|
---|
| 420 | (particle->EtaCalo > list_of_calorimeters.getEtamin() ) &&
|
---|
| 421 | (particle->EtaCalo < list_of_calorimeters.getEtamax() )
|
---|
| 422 | )
|
---|
[307] | 423 | {
|
---|
[310] | 424 | float iEta=UNDEFINED, iPhi=UNDEFINED;
|
---|
| 425 | DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
|
---|
| 426 | if (iEta != UNDEFINED && iPhi != UNDEFINED)
|
---|
| 427 | {
|
---|
| 428 | D_CaloTower tower(iEta,iPhi); // new tower
|
---|
| 429 | tower.Set_Eem_Ehad_E_ET(particle->E*particle->getFem() , particle->E*particle->getFhad() );
|
---|
| 430 | list_of_active_towers.addTower(tower);
|
---|
| 431 | // this list may contain several times the same calotower, as several particles
|
---|
| 432 | // may leave some energy in the same calotower
|
---|
| 433 | // After the loop on particles, identical cells in the list should be merged
|
---|
| 434 | } // iEta and iPhi must be defined
|
---|
| 435 | }
|
---|
[307] | 436 |
|
---|
[310] | 437 | // 2.1a.2.3 charged particles in tracker: energy flow
|
---|
| 438 | // if bfield not simulated, pt should be high enough to be taken into account
|
---|
| 439 | // it is supposed here that DET->MAX_calo > DET->CEN_max_tracker > DET->CEN_max_mu > 0
|
---|
| 440 | if( particle->Charge !=0 &&
|
---|
| 441 | fabs(particle->EtaCalo)< DET->CEN_max_tracker && // stays in the tracker -> track available
|
---|
| 442 | ( DET->FLAG_bfield ||
|
---|
| 443 | (!DET->FLAG_bfield && particle->PT > DET->TRACK_ptmin)
|
---|
| 444 | )
|
---|
| 445 | )
|
---|
| 446 | {
|
---|
| 447 | // 2.1a.2.3.1 Filling the particle properties + smearing
|
---|
| 448 | // Hypothesis: the final eta/phi are the ones from the generator, thanks to the track reconstruction
|
---|
| 449 | // This is the EnergyFlow hypothesis
|
---|
| 450 | particle->SetEtaPhi(particle->Eta,particle->Phi);
|
---|
| 451 | float sET=UNDEFINED; // smeared ET, computed from the smeared E -> needed for the tracks
|
---|
| 452 |
|
---|
| 453 | // 2.1a.2.3.2 Muons
|
---|
| 454 | if (pid == pMU && fabs(particle->EtaCalo)< DET->CEN_max_mu)
|
---|
| 455 | {
|
---|
| 456 | TLorentzVector p;
|
---|
| 457 | float sPT = gRandom->Gaus(particle->PT, DET->MU_SmearPt*particle->PT );
|
---|
| 458 | if (sPT > 0 && sPT > DET->PTCUT_muon)
|
---|
| 459 | {
|
---|
| 460 | p.SetPtEtaPhiE(sPT,particle->Eta,particle->Phi,sPT*cosh(particle->Eta));
|
---|
[390] | 461 | muon.push_back(D_Particle(p,particle->PID,particle->EtaCalo,particle->PhiCalo));
|
---|
[310] | 462 | }
|
---|
| 463 | sET = (sPT >0)? sPT : 0;
|
---|
| 464 | }
|
---|
| 465 | // 2.1a.2.3.3 Electrons
|
---|
| 466 | else if (pid == pE)
|
---|
| 467 | {
|
---|
| 468 | // Finds in which calorimeter the particle has gone, to know its resolution
|
---|
| 469 |
|
---|
| 470 | D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
|
---|
| 471 | if(currentCalo.getName() == dummyCalo.getName())
|
---|
| 472 | {
|
---|
| 473 | cout << "** Warning: the calo coverage behind the tracker is not complete! **" << endl;
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | // final smeared EM energy // electromagnetic fraction F_em =1 for electrons;
|
---|
| 477 | float sE = currentCalo.getElectromagneticResolution().Smear(particle->E);
|
---|
| 478 | if (sE>0)
|
---|
| 479 | {
|
---|
| 480 | sET = sE/cosh(particle->Eta);
|
---|
| 481 | // NB: ET is found via the calorimetry and not via the track curvature
|
---|
| 482 |
|
---|
| 483 | TLorentzVector p;
|
---|
| 484 | p.SetPtEtaPhiE(sET,particle->Eta,particle->Phi,sE);
|
---|
| 485 | if (sET > DET->PTCUT_elec)
|
---|
| 486 | electron.push_back(D_Particle(p,particle->PID,particle->EtaCalo,particle->PhiCalo));
|
---|
[384] | 487 | //if(DET->JET_Eflow) input_particles.push_back(fastjet::PseudoJet(p.Px(),p.Py(),p.Pz(),p.E()));
|
---|
[310] | 488 | }
|
---|
| 489 | else { sET=0;} // if negative smeared energy -- needed for the tracks
|
---|
| 490 | }
|
---|
| 491 | // 2.1a.2.3.4 Other charged particles : smear them for the tracks!
|
---|
| 492 | else
|
---|
| 493 | { //other particles
|
---|
| 494 | D_CaloElement currentCalo = list_of_calorimeters.getElement(particle->EtaCalo);
|
---|
| 495 | float sEem = currentCalo.getElectromagneticResolution().Smear(particle->E * particle->getFem());
|
---|
| 496 | float sEhad = currentCalo.getHadronicResolution().Smear(particle->E * particle->getFhad());
|
---|
| 497 | float sE = ( (sEem>0)? sEem : 0 ) + ( (sEhad>0)? sEhad : 0 );
|
---|
| 498 | sET = sE/cosh(particle->EtaCalo);
|
---|
| 499 | }
|
---|
[307] | 500 |
|
---|
[310] | 501 | // 2.1a.2.3.5 Tracks
|
---|
[530] | 502 | //if( (rand()%100) < DET->TRACK_eff && sET!=0)
|
---|
| 503 | if( (grandom->Uniform()*100.) < DET->TRACK_eff && sET!=0)
|
---|
[310] | 504 | {
|
---|
| 505 | elementTrack = (TRootTracks*) branchTrack->NewEntry();
|
---|
| 506 | elementTrack->Set(particle->Eta, particle->Phi, particle->EtaCalo, particle->PhiCalo, sET, particle->Charge);
|
---|
[547] | 507 | elementTrack->Vx=particle->X;
|
---|
| 508 | elementTrack->Vy=particle->Y;
|
---|
| 509 | elementTrack->Vz=particle->Z;
|
---|
[310] | 510 | TrackCentral.push_back(*elementTrack); // tracks at vertex!
|
---|
[384] | 511 | if(DET->JET_Eflow)
|
---|
| 512 | input_particles.push_back(fastjet::PseudoJet(particle->Px,particle->Py,particle->Pz,particle->E));
|
---|
[310] | 513 | // TODO!!! apply a smearing on the position of the origin of the track
|
---|
| 514 | // TODO!!! elementTracks->SetPositionOut(Xout,Yout,Zout);
|
---|
| 515 | }
|
---|
| 516 | } // 2.1a.2.3 : if tracker/energy-flow
|
---|
| 517 | // 2.1a.2.4 Photons
|
---|
| 518 | // stays in the tracker -> track available -> gamma ID
|
---|
| 519 | else if( (pid == pGAMMA) && fabs(particle->EtaCalo)< DET->CEN_max_tracker )
|
---|
| 520 | {
|
---|
| 521 | float iEta=UNDEFINED, iPhi=UNDEFINED;
|
---|
| 522 | DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
|
---|
| 523 | D_CaloTower tower(iEta,iPhi);
|
---|
| 524 | // stores the list of towers where to apply the photon ID algorithm. Just a trick for a faster search
|
---|
| 525 | list_of_towers_with_photon.addTower(tower);
|
---|
[307] | 526 | }
|
---|
[384] | 527 | // 2.1a.2.5 Neutrals within tracker -- for jet energy flow
|
---|
| 528 | else if( particle->Charge ==0 && fabs(particle->EtaCalo)< etamax_calocoverage_behindtracker)
|
---|
| 529 | {
|
---|
| 530 | float iEta=UNDEFINED, iPhi=UNDEFINED;
|
---|
| 531 | DET->BinEtaPhi(particle->PhiCalo,particle->EtaCalo,iPhi,iEta); // fills in iPhi and iEta
|
---|
| 532 | D_CaloTower tower(iEta,iPhi);
|
---|
| 533 | list_of_centowers_with_neutrals.addTower(tower);
|
---|
| 534 | }
|
---|
| 535 | // 2.1a.2.6 : very forward detectors
|
---|
[310] | 536 | else
|
---|
| 537 | {
|
---|
| 538 | if (DET->FLAG_RP==1)
|
---|
| 539 | {
|
---|
| 540 | // for the moment, only protons are transported
|
---|
| 541 | // BUT !!! could be a beam of other particles! (heavy ions?)
|
---|
| 542 | // BUT ALSO !!! if very forward muons, or others!
|
---|
| 543 | VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
|
---|
| 544 | }
|
---|
| 545 | // 2.1a.2.6: Zero degree calorimeter
|
---|
| 546 | if(DET->FLAG_vfd==1)
|
---|
| 547 | {
|
---|
| 548 | VFD->ZDC(treeWriter,branchZDC,particle);
|
---|
| 549 | }
|
---|
| 550 | }
|
---|
[307] | 551 |
|
---|
[310] | 552 | } // 2.1a.2 : if visible particle
|
---|
[307] | 553 | delete particle;
|
---|
[310] | 554 | }// loop on all particles 2.1a
|
---|
[384] | 555 |
|
---|
[310] | 556 | // 2.1b loop on all (activated) towers
|
---|
| 557 | // at this stage, list_of_active_towers may contain several times the same tower
|
---|
| 558 | // first step is to merge identical towers, by matching their (iEta,iPhi)
|
---|
| 559 |
|
---|
| 560 | list_of_active_towers.sortElements();
|
---|
| 561 | list_of_active_towers.mergeDuplicates();
|
---|
| 562 |
|
---|
| 563 | // Calotower smearing
|
---|
| 564 | list_of_active_towers.smearTowers(list_of_calorimeters);
|
---|
| 565 |
|
---|
| 566 | for(unsigned int i=0; i<list_of_active_towers.size(); i++)
|
---|
| 567 | {
|
---|
[307] | 568 | float iEta = list_of_active_towers[i].getEta();
|
---|
| 569 | float iPhi = list_of_active_towers[i].getPhi();
|
---|
| 570 | float e = list_of_active_towers[i].getE();
|
---|
[310] | 571 | if(iEta != UNDEFINED && iPhi != UNDEFINED && e!=0)
|
---|
| 572 | {
|
---|
| 573 | elementCalo = (TRootCalo*) branchCalo->NewEntry();
|
---|
| 574 | elementCalo->set(list_of_active_towers[i]);
|
---|
| 575 | // not beautiful : should be improved!
|
---|
| 576 | TLorentzVector p;
|
---|
| 577 | p.SetPtEtaPhiE(list_of_active_towers[i].getET(), iEta, iPhi, e );
|
---|
| 578 | PhysicsTower Tower(LorentzVector(p.Px(),p.Py(),p.Pz(),p.E()));
|
---|
| 579 | towers.push_back(Tower);
|
---|
| 580 | }
|
---|
[307] | 581 | } // loop on towers
|
---|
[310] | 582 |
|
---|
[384] | 583 | // 2.1c photon ID
|
---|
| 584 | // list_of_towers_with_photon is the list of towers with photon candidates
|
---|
| 585 | // already smeared !
|
---|
| 586 | // sorts the vector and smears duplicates
|
---|
[310] | 587 | list_of_towers_with_photon.mergeDuplicates();
|
---|
[321] | 588 | for(unsigned int i=0; i<list_of_towers_with_photon.size(); i++) {
|
---|
[264] | 589 | float eta = list_of_towers_with_photon[i].getEta();
|
---|
| 590 | float phi = list_of_towers_with_photon[i].getPhi();
|
---|
[384] | 591 | D_CaloTower cal(list_of_active_towers.getElement(eta,phi)); //// <---------- buh???????
|
---|
[310] | 592 | if(cal.getEta() != UNDEFINED && cal.getPhi() != UNDEFINED && cal.getE() > 0)
|
---|
| 593 | {
|
---|
| 594 | TLorentzVector p;
|
---|
| 595 | p.SetPtEtaPhiE(cal.getET(), eta,phi,cal.getE() );
|
---|
| 596 | if (cal.getET() > DET->PTCUT_gamma) { gamma.push_back(D_Particle(p,pGAMMA,p.Eta(),p.Phi())); }
|
---|
| 597 | }
|
---|
[307] | 598 | } // for -- list of photons
|
---|
[384] | 599 |
|
---|
| 600 | // 2.1d jet-E-flow -- taking into account the neutrals within tracker
|
---|
| 601 | if(DET->JET_Eflow) {
|
---|
| 602 | list_of_centowers_with_neutrals.mergeDuplicates();
|
---|
| 603 | for(unsigned int i=0; i<list_of_centowers_with_neutrals.size(); i++) {
|
---|
| 604 | float eta = list_of_centowers_with_neutrals[i].getEta();
|
---|
| 605 | float phi = list_of_centowers_with_neutrals[i].getPhi();
|
---|
| 606 | D_CaloTower cal(list_of_active_towers.getElement(eta,phi));
|
---|
| 607 | if(cal.getEta() != UNDEFINED && cal.getPhi() != UNDEFINED && cal.getE() > 0)
|
---|
| 608 | {
|
---|
| 609 | TLorentzVector p;
|
---|
| 610 | p.SetPtEtaPhiE(cal.getET(), eta,phi,cal.getE() );
|
---|
| 611 | //cout << "**************list: " << p.Px() << " " << p.Py() << " " << p.Pz() << " " << p.E() << endl;
|
---|
| 612 | input_particles.push_back(fastjet::PseudoJet(p.Px(),p.Py(),p.Pz(),p.E()));
|
---|
| 613 | }
|
---|
| 614 | } // for - list_of_centowers
|
---|
| 615 | } // JET_Eflow
|
---|
| 616 |
|
---|
[178] | 617 | // 2.2 ********** Output preparation & complex objects ***********
|
---|
| 618 | // 2.2.1 ********************* sorting collections by decreasing pt
|
---|
[74] | 619 | DET->SortedVector(electron);
|
---|
[321] | 620 | float iPhiEl=0,iEtaEl=0,ptisoEl=0;
|
---|
[310] | 621 | for(unsigned int i=0; i < electron.size(); i++)
|
---|
| 622 | {
|
---|
| 623 | elementElec = (TRootElectron*) branchElectron->NewEntry();
|
---|
| 624 | elementElec->Set(electron[i].Px(),electron[i].Py(),electron[i].Pz(),electron[i].E());
|
---|
| 625 | elementElec->EtaCalo = electron[i].EtaCalo();
|
---|
| 626 | elementElec->PhiCalo = electron[i].PhiCalo();
|
---|
[536] | 627 | elementElec->Charge = - sign(electron[i].PID());
|
---|
[321] | 628 | elementElec->IsolFlag = DET->Isolation(electron[i],TrackCentral,DET->ISOL_PT,DET->ISOL_Cone,ptisoEl);
|
---|
| 629 | elementElec->IsolPt = ptisoEl;
|
---|
[312] | 630 | DET->BinEtaPhi(elementElec->PhiCalo,elementElec->EtaCalo,iPhiEl,iEtaEl);
|
---|
| 631 | D_CaloTower calElec(list_of_active_towers.getElement(iEtaEl,iPhiEl));
|
---|
[310] | 632 | elementElec->EHoverEE = calElec.getEhad()/calElec.getEem();
|
---|
[312] | 633 | }
|
---|
[310] | 634 |
|
---|
[74] | 635 | DET->SortedVector(muon);
|
---|
[321] | 636 | float iPhiMu=0,iEtaMu=0,ptisoMu=0;
|
---|
[310] | 637 | for(unsigned int i=0; i < muon.size(); i++)
|
---|
| 638 | {
|
---|
| 639 | elementMu = (TRootMuon*) branchMuon->NewEntry();
|
---|
[536] | 640 | elementMu->Charge = - sign(muon[i].PID());
|
---|
[310] | 641 | elementMu->Set(muon[i].Px(),muon[i].Py(),muon[i].Pz(),muon[i].E());
|
---|
| 642 | elementMu->EtaCalo = muon[i].EtaCalo();
|
---|
| 643 | elementMu->PhiCalo = muon[i].PhiCalo();
|
---|
[321] | 644 | elementMu->IsolFlag = DET->Isolation(muon[i],TrackCentral,DET->ISOL_PT,DET->ISOL_Cone,ptisoMu);
|
---|
| 645 | elementMu->IsolPt = ptisoMu;
|
---|
| 646 | DET->BinEtaPhi(elementMu->PhiCalo,elementMu->EtaCalo,iPhiMu,iEtaMu);
|
---|
[312] | 647 | D_CaloTower calMuon(list_of_active_towers.getElement(iEtaMu,iPhiMu));
|
---|
[321] | 648 | if( calMuon.getEem() !=0 ) elementMu->EHoverEE = calMuon.getEhad()/calMuon.getEem();
|
---|
| 649 | else elementMu->EHoverEE = UNDEFINED;
|
---|
[395] | 650 | elementMu->EtRatio = DET->CaloIsolation(muon[i], list_of_active_towers,iPhiMu,iEtaMu);
|
---|
[310] | 651 | }
|
---|
| 652 |
|
---|
[74] | 653 | DET->SortedVector(gamma);
|
---|
[310] | 654 | for(unsigned int i=0; i < gamma.size(); i++)
|
---|
| 655 | {
|
---|
| 656 | elementPhoton = (TRootPhoton*) branchPhoton->NewEntry();
|
---|
| 657 | elementPhoton->Set(gamma[i].Px(),gamma[i].Py(),gamma[i].Pz(),gamma[i].E());
|
---|
| 658 | D_CaloTower calGamma(list_of_active_towers.getElement(gamma[i].EtaCalo(),gamma[i].PhiCalo()));
|
---|
| 659 | elementPhoton->EHoverEE = calGamma.getEhad()/calGamma.getEem();
|
---|
| 660 | }
|
---|
[30] | 661 |
|
---|
[178] | 662 | // 2.2.2 ************* computes the Missing Transverse Momentum
|
---|
[71] | 663 | TLorentzVector Att(0.,0.,0.,0.);
|
---|
| 664 | for(unsigned int i=0; i < towers.size(); i++)
|
---|
| 665 | {
|
---|
[107] | 666 | Att.SetPxPyPzE(towers[i].fourVector.px, towers[i].fourVector.py, towers[i].fourVector.pz, towers[i].fourVector.E);
|
---|
| 667 | if(fabs(Att.Eta()) < DET->CEN_max_calo_fwd)
|
---|
[307] | 668 | {
|
---|
| 669 | PTmis = PTmis + Att;
|
---|
| 670 | // create a fastjet::PseudoJet with these components and put it onto
|
---|
| 671 | // back of the input_particles vector
|
---|
[384] | 672 | if(!DET->JET_Eflow)
|
---|
| 673 | input_particles.push_back(fastjet::PseudoJet(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E));
|
---|
| 674 | else { if(fabs(Att.Eta()) > DET->CEN_max_tracker)
|
---|
| 675 | input_particles.push_back(fastjet::PseudoJet(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E));
|
---|
| 676 | }
|
---|
[307] | 677 | }
|
---|
[71] | 678 | }
|
---|
| 679 | elementEtmis = (TRootETmis*) branchETmis->NewEntry();
|
---|
| 680 | elementEtmis->ET = (PTmis).Pt();
|
---|
| 681 | elementEtmis->Phi = (-PTmis).Phi();
|
---|
| 682 | elementEtmis->Px = (-PTmis).Px();
|
---|
| 683 | elementEtmis->Py = (-PTmis).Py();
|
---|
[74] | 684 |
|
---|
[264] | 685 | // 2.2.3 ************* jets, B-tag, tau jets
|
---|
[310] | 686 | vector<int> NTrackJet; //for number of tracks
|
---|
| 687 | vector<float> EHADEEM; //for energyHad over energyEm
|
---|
| 688 | sorted_jets=JETRUN->RunJets(input_particles, TrackCentral,NTrackJet,EHADEEM,list_of_active_towers);
|
---|
| 689 | JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ,NTrackJet,EHADEEM);
|
---|
| 690 | JETRUN->RunTauJets(treeWriter,branchTauJet,sorted_jets,towers, TrackCentral,NTrackJet,EHADEEM);
|
---|
[74] | 691 |
|
---|
[72] | 692 | treeWriter->Fill();
|
---|
[178] | 693 | } // 2. Loop over all events ('for' loop)
|
---|
[307] | 694 |
|
---|
[212] | 695 | cout <<"** Exiting detector simulation... **"<< endl;
|
---|
[307] | 696 |
|
---|
| 697 |
|
---|
[2] | 698 | treeWriter->Write();
|
---|
[77] | 699 | delete treeWriter;
|
---|
[191] | 700 | loopwatch.Stop();
|
---|
[307] | 701 |
|
---|
| 702 |
|
---|
| 703 |
|
---|
[212] | 704 | // 3. ********** Trigger & Frog ***********
|
---|
[178] | 705 | // 3.1 ************ running the trigger in case the FLAG trigger is put to 1 in the datacard
|
---|
[191] | 706 | triggerwatch.Start();
|
---|
[94] | 707 | if(DET->FLAG_trigger == 1)
|
---|
[72] | 708 | {
|
---|
[307] | 709 | cout <<"** **"<<endl;
|
---|
| 710 | cout <<"** ########### Start Trigger selection ########### **"<< endl;
|
---|
| 711 |
|
---|
[178] | 712 | // input
|
---|
[72] | 713 | TChain chainT("Analysis");
|
---|
| 714 | chainT.Add(outputfilename.c_str());
|
---|
| 715 | ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chainT);
|
---|
[74] | 716 |
|
---|
[178] | 717 | // output
|
---|
[72] | 718 | TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
|
---|
| 719 | TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
|
---|
| 720 | TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
|
---|
| 721 | TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
|
---|
| 722 | TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
|
---|
| 723 | TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
|
---|
[74] | 724 |
|
---|
[72] | 725 | ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(outputfilename, "Trigger");
|
---|
| 726 | ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
|
---|
[307] | 727 |
|
---|
| 728 |
|
---|
[72] | 729 | Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
|
---|
[178] | 730 | // loop on all entries
|
---|
| 731 | for(entryT = 0; entryT < allEntriesT; ++entryT) {
|
---|
[307] | 732 | treeWriterT->Clear();
|
---|
| 733 | treeReaderT->ReadEntry(entryT);
|
---|
| 734 | TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
|
---|
| 735 | treeWriterT->Fill();
|
---|
[178] | 736 | } // loop on all entries
|
---|
[212] | 737 | cout <<"** Exiting trigger simulation... **"<< endl;
|
---|
[94] | 738 |
|
---|
[72] | 739 | treeWriterT->Write();
|
---|
| 740 | delete treeWriterT;
|
---|
[228] | 741 | delete treeReaderT;
|
---|
[178] | 742 | } // trigger
|
---|
[307] | 743 | triggerwatch.Stop();
|
---|
| 744 |
|
---|
| 745 |
|
---|
[178] | 746 | // 3.2 ************** FROG display
|
---|
[191] | 747 | frogwatch.Start();
|
---|
[228] | 748 | if(DET->FLAG_frog == 1) {
|
---|
[307] | 749 | cout <<"** **"<<endl;
|
---|
| 750 | cout <<"** ################## Start FROG ################# **"<< endl;
|
---|
| 751 |
|
---|
| 752 | FrogDisplay *FROG = new FrogDisplay(DET);
|
---|
| 753 | FROG->BuildEvents(outputfilename);
|
---|
| 754 | FROG->BuildGeom();
|
---|
| 755 | delete FROG;
|
---|
[313] | 756 | cout <<"** Exiting FROG preparation... **"<< endl;
|
---|
[228] | 757 | }
|
---|
| 758 | frogwatch.Stop();
|
---|
[94] | 759 |
|
---|
[307] | 760 | // 3.3 *************** LHCO output
|
---|
[313] | 761 | lhcowatch.Start();
|
---|
[307] | 762 | if(DET->FLAG_lhco == 1){
|
---|
| 763 | cout <<"** **"<<endl;
|
---|
[415] | 764 | cout <<"** ############ Start LHCO conversion ############ **"<< endl;
|
---|
[307] | 765 |
|
---|
| 766 | //LHCOConverter *LHCO = new LHCOConverter(outputfilename,LogNameLHCO);
|
---|
| 767 | LHCOConverter *LHCO = new LHCOConverter(outputfilename,"");
|
---|
| 768 | LHCO->CopyRunLogFile();
|
---|
| 769 | LHCO->ConvertExRootAnalysisToLHCO();
|
---|
| 770 | delete LHCO;
|
---|
[416] | 771 | cout <<"** Exiting LHCO conversion... **"<< endl;
|
---|
[307] | 772 | }
|
---|
[313] | 773 | lhcowatch.Stop();
|
---|
[307] | 774 |
|
---|
| 775 |
|
---|
| 776 |
|
---|
| 777 | // 4. ********** End & Exit ***********
|
---|
| 778 |
|
---|
[191] | 779 | globalwatch.Stop();
|
---|
[397] | 780 | time_report(globalwatch,loopwatch,triggerwatch,frogwatch,lhcowatch,DET->FLAG_frog,DET->FLAG_trigger,DET->FLAG_lhco,LogName,allEntries);
|
---|
[474] | 781 |
|
---|
| 782 | cout << left << setw(16) << "** " << ""
|
---|
| 783 | << left << setw(51) << get_time_date() << "**" << endl;
|
---|
| 784 |
|
---|
[307] | 785 | cout <<"** **"<< endl;
|
---|
| 786 | cout <<"** Exiting Delphes ... **"<< endl;
|
---|
| 787 | cout <<"** **"<< endl;
|
---|
| 788 | cout <<"*********************************************************************"<< endl;
|
---|
| 789 | cout <<"*********************************************************************"<< endl;
|
---|
| 790 |
|
---|
[2] | 791 | delete treeReader;
|
---|
| 792 | delete DET;
|
---|
[264] | 793 | delete TRIGT;
|
---|
[74] | 794 | delete TRACP;
|
---|
| 795 | delete JETRUN;
|
---|
| 796 | delete VFD;
|
---|
[530] | 797 | delete grandom; // TRandom3
|
---|
[94] | 798 |
|
---|
[2] | 799 | }
|
---|