[264] | 1 | /***********************************************************************
|
---|
| 2 | ** **
|
---|
| 3 | ** /----------------------------------------------\ **
|
---|
| 4 | ** | Delphes, a framework for the fast simulation | **
|
---|
| 5 | ** | of a generic collider experiment | **
|
---|
| 6 | ** \----------------------------------------------/ **
|
---|
| 7 | ** **
|
---|
| 8 | ** **
|
---|
| 9 | ** This package uses: **
|
---|
| 10 | ** ------------------ **
|
---|
| 11 | ** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
|
---|
| 12 | ** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
|
---|
| 13 | ** FROG: [hep-ex/0901.2718v1] **
|
---|
| 14 | ** **
|
---|
| 15 | ** ------------------------------------------------------------------ **
|
---|
| 16 | ** **
|
---|
| 17 | ** Main authors: **
|
---|
| 18 | ** ------------- **
|
---|
| 19 | ** **
|
---|
| 20 | ** Severine Ovyn Xavier Rouby **
|
---|
| 21 | ** severine.ovyn@uclouvain.be xavier.rouby@cern **
|
---|
| 22 | ** **
|
---|
| 23 | ** Center for Particle Physics and Phenomenology (CP3) **
|
---|
| 24 | ** Universite catholique de Louvain (UCL) **
|
---|
| 25 | ** Louvain-la-Neuve, Belgium **
|
---|
| 26 | ** **
|
---|
| 27 | ** Copyright (C) 2008-2009, **
|
---|
| 28 | ** All rights reserved. **
|
---|
| 29 | ** **
|
---|
| 30 | ***********************************************************************/
|
---|
[220] | 31 |
|
---|
| 32 |
|
---|
[2] | 33 | #include <iostream>
|
---|
| 34 | #include <fstream>
|
---|
| 35 | #include "TLorentzVector.h"
|
---|
[220] | 36 | #include "BlockClasses.h"
|
---|
| 37 | #include "ExRootTreeWriter.h"
|
---|
| 38 | #include "ExRootTreeBranch.h"
|
---|
| 39 | #include "stdhep_mcfio.h"
|
---|
| 40 | #include "stdhep_declarations.h"
|
---|
| 41 | #include "STDHEPConverter.h"
|
---|
[2] | 42 |
|
---|
| 43 | using namespace std;
|
---|
| 44 |
|
---|
| 45 | //---------------------------------------------------------------------------
|
---|
| 46 |
|
---|
| 47 | void STDHEPConverter::AnalyseEvent(ExRootTreeBranch *branch, const Long64_t eventNumber)
|
---|
| 48 | {
|
---|
| 49 | TRootGenEvent *element;
|
---|
| 50 |
|
---|
| 51 | element = static_cast<TRootGenEvent*>(branch->NewEntry());
|
---|
| 52 |
|
---|
| 53 | element->Number = eventNumber;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | //---------------------------------------------------------------------------
|
---|
| 57 |
|
---|
| 58 | void STDHEPConverter::AnalyseParticles(ExRootTreeBranch *branch)
|
---|
| 59 | {
|
---|
[295] | 60 | int Nmax = -1; // useless for the moment -- should be changed in order
|
---|
| 61 | if(Nmax>0) Nmax = min(Nmax,myhepevt.nhep); // to use Nevt in DataConverter
|
---|
| 62 | else Nmax = myhepevt.nhep;
|
---|
| 63 |
|
---|
[350] | 64 | TRootC::GenParticle *element;
|
---|
[2] | 65 |
|
---|
| 66 | Double_t signPz;
|
---|
| 67 | TLorentzVector momentum;
|
---|
| 68 | Int_t number;
|
---|
| 69 |
|
---|
[295] | 70 | for(number = 0; number < Nmax; ++number)
|
---|
[2] | 71 | {
|
---|
[350] | 72 | element = static_cast<TRootC::GenParticle*>(branch->NewEntry());
|
---|
[2] | 73 |
|
---|
| 74 | element->PID = myhepevt.idhep[number];
|
---|
| 75 | element->Status = myhepevt.isthep[number];
|
---|
| 76 | element->M1 = myhepevt.jmohep[number][0] - 1;
|
---|
| 77 | element->M2 = myhepevt.jmohep[number][1] - 1;
|
---|
| 78 | element->D1 = myhepevt.jdahep[number][0] - 1;
|
---|
| 79 | element->D2 = myhepevt.jdahep[number][1] - 1;
|
---|
| 80 | // element->Charge = myhepevt.hepchg(element->PID);
|
---|
| 81 |
|
---|
| 82 | element->E = myhepevt.phep[number][3];
|
---|
| 83 | element->Px = myhepevt.phep[number][0];
|
---|
| 84 | element->Py = myhepevt.phep[number][1];
|
---|
| 85 | element->Pz = myhepevt.phep[number][2];
|
---|
[56] | 86 | element->M = myhepevt.phep[number][4];
|
---|
[2] | 87 |
|
---|
| 88 | momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E);
|
---|
| 89 | element->PT = momentum.Perp();
|
---|
| 90 | signPz = (element->Pz >= 0.0) ? 1.0 : -1.0;
|
---|
| 91 | element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta();
|
---|
| 92 | element->Phi = momentum.Phi();
|
---|
| 93 |
|
---|
| 94 | element->T = myhepevt.vhep[number][3];
|
---|
| 95 | element->X = myhepevt.vhep[number][0];
|
---|
| 96 | element->Y = myhepevt.vhep[number][1];
|
---|
| 97 | element->Z = myhepevt.vhep[number][2];
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | //------------------------------------------------------------------------------
|
---|
| 103 |
|
---|
| 104 | STDHEPConverter::~STDHEPConverter()
|
---|
| 105 | {
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | //------------------------------------------------------------------------------
|
---|
| 109 |
|
---|
[295] | 110 | STDHEPConverter::STDHEPConverter(const string& inputFileList, const string& outputFileName, const int& Nevents) : DataConverter(Nevents)
|
---|
[2] | 111 | {
|
---|
| 112 | int ierr, entryType;
|
---|
| 113 | int istr = 0;
|
---|
| 114 | int nevt = 0;
|
---|
| 115 |
|
---|
| 116 | ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN");
|
---|
| 117 |
|
---|
| 118 | // information about generated event
|
---|
| 119 | ExRootTreeBranch *branchGenEvent = treeWriter->NewBranch("Event", TRootGenEvent::Class());
|
---|
| 120 | // generated particles from HEPEVT
|
---|
[350] | 121 | ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class());
|
---|
[2] | 122 |
|
---|
| 123 | // Open a stream connected to an event file:
|
---|
| 124 | ifstream infile(inputFileList.c_str());
|
---|
| 125 | string filename;
|
---|
| 126 | if(!infile.is_open())
|
---|
| 127 | {
|
---|
[245] | 128 | cerr << left << setw(30) <<"** ERROR: Can't open "<<""
|
---|
| 129 | << left << setw(20) << inputFileList <<""
|
---|
| 130 | << right << setw(19) <<"for input **"<<""<<endl;
|
---|
| 131 |
|
---|
[2] | 132 | exit(1);
|
---|
| 133 | }
|
---|
| 134 | while(1)
|
---|
| 135 | {
|
---|
| 136 | infile >> filename;
|
---|
| 137 | if(!infile.good()) break;
|
---|
[18] | 138 | ifstream checking_the_file(filename.c_str());
|
---|
[245] | 139 | if(!checking_the_file.good())
|
---|
| 140 | {
|
---|
| 141 | cerr << left << setw(30) <<"** ERROR: Can't find file "<<""
|
---|
| 142 | << left << setw(20) << filename <<""
|
---|
| 143 | << right << setw(19) <<"for input **"<<""<<endl;
|
---|
| 144 | continue;
|
---|
| 145 | }
|
---|
[18] | 146 | else checking_the_file.close();
|
---|
[2] | 147 |
|
---|
| 148 | ierr = StdHepXdrReadInit(const_cast<char*>(filename.c_str()), &nevt, istr);
|
---|
| 149 |
|
---|
| 150 | if(ierr != 0)
|
---|
| 151 | {
|
---|
[245] | 152 | cerr <<"** ERROR: Can't open file for input **"<<endl;
|
---|
[2] | 153 | break;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | Long64_t allEntries = nevt;
|
---|
| 157 |
|
---|
| 158 | if(allEntries > 0)
|
---|
| 159 | {
|
---|
| 160 | // Loop over all objects
|
---|
| 161 | Long64_t entry = 0;
|
---|
| 162 | Long64_t recordNumber = 1;
|
---|
| 163 | for(entry = 0; entry < allEntries; ++entry)
|
---|
| 164 | {
|
---|
| 165 | ierr = StdHepXdrRead(&entryType, istr);
|
---|
| 166 |
|
---|
| 167 | if(ierr != 0)
|
---|
| 168 | {
|
---|
[245] | 169 | cerr << left << setw(49) <<"** ERROR: Unexpected end of file after"<<""
|
---|
| 170 | << left << setw(10) << entry <<""
|
---|
| 171 | << right << setw(10) <<"entries **"<<""<<endl;
|
---|
[2] | 172 | break;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | // analyse only entries with standard HEPEVT common block
|
---|
| 176 | if(entryType == 1)
|
---|
| 177 | {
|
---|
| 178 | // add empty events for missing event numbers
|
---|
| 179 | while(recordNumber < myhepevt.nevhep)
|
---|
| 180 | {
|
---|
| 181 | treeWriter->Clear();
|
---|
| 182 | AnalyseEvent(branchGenEvent, recordNumber);
|
---|
| 183 | treeWriter->Fill();
|
---|
| 184 | ++recordNumber;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | treeWriter->Clear();
|
---|
| 188 |
|
---|
| 189 | AnalyseEvent(branchGenEvent, myhepevt.nevhep);
|
---|
| 190 | AnalyseParticles(branchGenParticle);
|
---|
| 191 |
|
---|
| 192 | treeWriter->Fill();
|
---|
| 193 |
|
---|
| 194 | ++recordNumber;
|
---|
| 195 |
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
| 198 | }
|
---|
[245] | 199 | StdHepXdrEnd(istr);
|
---|
[2] | 200 | }
|
---|
| 201 | treeWriter->Write();
|
---|
| 202 |
|
---|
| 203 | delete treeWriter;
|
---|
| 204 |
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 |
|
---|