[264] | 1 | /***********************************************************************
|
---|
| 2 | ** **
|
---|
| 3 | ** /----------------------------------------------\ **
|
---|
| 4 | ** | Delphes, a framework for the fast simulation | **
|
---|
| 5 | ** | of a generic collider experiment | **
|
---|
[443] | 6 | ** \------------- arXiv:0903.2225v1 ------------/ **
|
---|
[264] | 7 | ** **
|
---|
| 8 | ** **
|
---|
| 9 | ** This package uses: **
|
---|
| 10 | ** ------------------ **
|
---|
[443] | 11 | ** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
|
---|
| 12 | ** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
|
---|
| 13 | ** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
|
---|
[264] | 14 | ** FROG: [hep-ex/0901.2718v1] **
|
---|
[443] | 15 | ** HepMC: Comput. Phys. Commun.134 (2001) 41 **
|
---|
[264] | 16 | ** **
|
---|
| 17 | ** ------------------------------------------------------------------ **
|
---|
| 18 | ** **
|
---|
| 19 | ** Main authors: **
|
---|
| 20 | ** ------------- **
|
---|
| 21 | ** **
|
---|
[443] | 22 | ** Severine Ovyn Xavier Rouby **
|
---|
| 23 | ** severine.ovyn@uclouvain.be xavier.rouby@cern **
|
---|
[264] | 24 | ** **
|
---|
[443] | 25 | ** Center for Particle Physics and Phenomenology (CP3) **
|
---|
| 26 | ** Universite catholique de Louvain (UCL) **
|
---|
| 27 | ** Louvain-la-Neuve, Belgium **
|
---|
| 28 | ** **
|
---|
[264] | 29 | ** Copyright (C) 2008-2009, **
|
---|
[443] | 30 | ** All rights reserved. **
|
---|
[264] | 31 | ** **
|
---|
| 32 | ***********************************************************************/
|
---|
| 33 |
|
---|
[2] | 34 | #include <iostream>
|
---|
| 35 | #include <fstream>
|
---|
| 36 |
|
---|
| 37 | #include "TLorentzVector.h"
|
---|
| 38 |
|
---|
[219] | 39 | #include "ExRootTreeWriter.h"
|
---|
| 40 | #include "BlockClasses.h"
|
---|
| 41 | #include "LHEFConverter.h"
|
---|
[380] | 42 | #include "SmearUtil.h"
|
---|
| 43 | #include "PdgParticle.h"
|
---|
[2] | 44 |
|
---|
| 45 | using namespace std;
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | //------------------------------------------------------------------------------
|
---|
| 49 |
|
---|
| 50 | void LHEFConverter::AnalyseEvent(LHEF::Reader *reader, ExRootTreeBranch *branch, const Long64_t eventNumber)
|
---|
| 51 | {
|
---|
| 52 | const LHEF::HEPEUP &hepeup = reader->hepeup;
|
---|
| 53 |
|
---|
| 54 | TRootLHEFEvent *element;
|
---|
| 55 |
|
---|
| 56 | element = (TRootLHEFEvent*) branch->NewEntry();
|
---|
| 57 |
|
---|
| 58 | element->Number = eventNumber;
|
---|
| 59 | element->Nparticles = hepeup.NUP;
|
---|
| 60 | element->ProcessID = hepeup.IDPRUP;
|
---|
| 61 | element->Weight = hepeup.XWGTUP;
|
---|
| 62 | element->ScalePDF = hepeup.SCALUP;
|
---|
| 63 | element->CouplingQED = hepeup.AQEDUP;
|
---|
| 64 | element->CouplingQCD = hepeup.AQCDUP;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | //---------------------------------------------------------------------------
|
---|
| 68 |
|
---|
| 69 | void LHEFConverter::AnalyseParticles(LHEF::Reader *reader, ExRootTreeBranch *branch)
|
---|
| 70 | {
|
---|
| 71 | const LHEF::HEPEUP &hepeup = reader->hepeup;
|
---|
| 72 | Double_t signPz;
|
---|
| 73 | TLorentzVector momentum;
|
---|
| 74 | TRootLHEFParticle *element;
|
---|
| 75 |
|
---|
| 76 | for(Int_t particle = 0; particle < hepeup.NUP; ++particle)
|
---|
| 77 | {
|
---|
| 78 | element = (TRootLHEFParticle*) branch->NewEntry();
|
---|
| 79 |
|
---|
| 80 | element->PID = hepeup.IDUP[particle];
|
---|
| 81 | element->Status = hepeup.ISTUP[particle];
|
---|
| 82 | element->Mother1 = hepeup.MOTHUP[particle].first;
|
---|
| 83 | element->Mother2 = hepeup.MOTHUP[particle].second;
|
---|
| 84 | element->ColorLine1 = hepeup.ICOLUP[particle].first;
|
---|
| 85 | element->ColorLine2 = hepeup.ICOLUP[particle].second;
|
---|
| 86 | element->Px = hepeup.PUP[particle][0];
|
---|
| 87 | element->Py = hepeup.PUP[particle][1];
|
---|
| 88 | element->Pz = hepeup.PUP[particle][2];
|
---|
| 89 | element->E = hepeup.PUP[particle][3];
|
---|
[380] | 90 | //element->M = hepeup.PUP[particle][4];
|
---|
| 91 | //element->Charge = ChargeVal(element->PID);
|
---|
| 92 |
|
---|
| 93 | PdgParticle pdg_part = pdg_table[element->PID];
|
---|
| 94 | element->Charge = pdg_part.charge();
|
---|
| 95 | element->M = pdg_part.mass();
|
---|
| 96 |
|
---|
[2] | 97 | momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E);
|
---|
| 98 | element->PT = momentum.Perp();
|
---|
| 99 | signPz = (element->Pz >= 0.0) ? 1.0 : -1.0;
|
---|
[369] | 100 | //element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta(); to avoid a warning from ROOT, replace the "==0" by "< 1e-6"
|
---|
[413] | 101 | element->Eta = element->PT < 1E-6 ? signPz*999.9 : momentum.Eta();
|
---|
[2] | 102 | element->Phi = momentum.Phi();
|
---|
[413] | 103 | element->Rapidity = element->PT < 1E-6 ? signPz*999.9 : momentum.Rapidity();
|
---|
[2] | 104 | element->LifeTime = hepeup.VTIMUP[particle];
|
---|
| 105 | element->Spin = hepeup.SPINUP[particle];
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | LHEFConverter::~LHEFConverter()
|
---|
| 110 | {
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | //------------------------------------------------------------------------------
|
---|
[380] | 114 | LHEFConverter::LHEFConverter(const string& inputFileList, const string& outputFileName, const PdgTable& pdg, const int& Nevents) :
|
---|
| 115 | DataConverter(pdg,Nevents) {
|
---|
[2] | 116 |
|
---|
| 117 | ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN");
|
---|
| 118 |
|
---|
| 119 | // generated event from LHEF
|
---|
| 120 | ExRootTreeBranch *branchEvent = treeWriter->NewBranch("Event", TRootLHEFEvent::Class());
|
---|
| 121 |
|
---|
| 122 | // generated partons from LHEF
|
---|
| 123 | ExRootTreeBranch *branchParticle = treeWriter->NewBranch("Particle", TRootLHEFParticle::Class());
|
---|
| 124 |
|
---|
| 125 | // Open a stream connected to an event file:
|
---|
| 126 | ifstream infile(inputFileList.c_str());
|
---|
| 127 | string filename;
|
---|
| 128 | if(!infile.is_open()) {
|
---|
[245] | 129 | cerr << left << setw(30) <<"** ERROR: Can't open "<<""
|
---|
| 130 | << left << setw(20) << inputFileList <<""
|
---|
| 131 | << right << setw(19) <<"for input **"<<""<<endl;
|
---|
[2] | 132 | exit(1);
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | while(1) { // parsing the list of files
|
---|
| 136 |
|
---|
| 137 | infile >> filename;
|
---|
| 138 | if(!infile.good()) break;
|
---|
[18] | 139 | ifstream checking_the_file(filename.c_str());
|
---|
[245] | 140 | if(!checking_the_file.good())
|
---|
| 141 | {
|
---|
| 142 | cerr << left << setw(30) <<"** ERROR: Can't find file "<<""
|
---|
| 143 | << left << setw(20) << filename <<""
|
---|
| 144 | << right << setw(19) <<"for input **"<<""<<endl;
|
---|
| 145 | continue;
|
---|
[246] | 146 | }
|
---|
[18] | 147 | else checking_the_file.close();
|
---|
[2] | 148 |
|
---|
| 149 | // Create the Reader object:
|
---|
| 150 | LHEF::Reader *inputReader = new LHEF::Reader(filename);
|
---|
| 151 |
|
---|
| 152 | Long64_t allEntries = inputReader->getNumberOfEvents();
|
---|
[419] | 153 | allEntries = (Nevt<0)?allEntries:min((int)allEntries,Nevt); // do not miss the "+1"
|
---|
| 154 |
|
---|
[2] | 155 | if(allEntries > 0) {
|
---|
| 156 | // Loop over all events
|
---|
| 157 | Long64_t entry = 0;
|
---|
| 158 | while(inputReader->readEvent()) {
|
---|
| 159 | treeWriter->Clear();
|
---|
| 160 | AnalyseEvent(inputReader, branchEvent, entry + 1);
|
---|
| 161 | AnalyseParticles(inputReader, branchParticle);
|
---|
| 162 | treeWriter->Fill();
|
---|
| 163 | ++entry;
|
---|
[419] | 164 | if(allEntries<entry+1) break;
|
---|
[2] | 165 | }
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 | treeWriter->Write();
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | delete treeWriter;
|
---|
| 172 | //delete inputReader;
|
---|
| 173 | }
|
---|
| 174 |
|
---|