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