/*********************************************************************** ** ** ** /----------------------------------------------\ ** ** | Delphes, a framework for the fast simulation | ** ** | of a generic collider experiment | ** ** \----------------------------------------------/ ** ** ** ** ** ** This package uses: ** ** ------------------ ** ** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] ** ** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] ** ** FROG: [hep-ex/0901.2718v1] ** ** ** ** ------------------------------------------------------------------ ** ** ** ** Main authors: ** ** ------------- ** ** ** ** Severine Ovyn Xavier Rouby ** ** severine.ovyn@uclouvain.be xavier.rouby@cern ** ** ** ** Center for Particle Physics and Phenomenology (CP3) ** ** Universite catholique de Louvain (UCL) ** ** Louvain-la-Neuve, Belgium ** ** ** ** Copyright (C) 2008-2009, ** ** All rights reserved. ** ** ** ***********************************************************************/ #include #include #include "TLorentzVector.h" #include "ExRootTreeWriter.h" #include "BlockClasses.h" #include "LHEFConverter.h" #include "SmearUtil.h" #include "PdgParticle.h" using namespace std; //------------------------------------------------------------------------------ void LHEFConverter::AnalyseEvent(LHEF::Reader *reader, ExRootTreeBranch *branch, const Long64_t eventNumber) { const LHEF::HEPEUP &hepeup = reader->hepeup; TRootLHEFEvent *element; element = (TRootLHEFEvent*) branch->NewEntry(); element->Number = eventNumber; element->Nparticles = hepeup.NUP; element->ProcessID = hepeup.IDPRUP; element->Weight = hepeup.XWGTUP; element->ScalePDF = hepeup.SCALUP; element->CouplingQED = hepeup.AQEDUP; element->CouplingQCD = hepeup.AQCDUP; } //--------------------------------------------------------------------------- void LHEFConverter::AnalyseParticles(LHEF::Reader *reader, ExRootTreeBranch *branch) { const LHEF::HEPEUP &hepeup = reader->hepeup; Double_t signPz; TLorentzVector momentum; TRootLHEFParticle *element; for(Int_t particle = 0; particle < hepeup.NUP; ++particle) { element = (TRootLHEFParticle*) branch->NewEntry(); element->PID = hepeup.IDUP[particle]; element->Status = hepeup.ISTUP[particle]; element->Mother1 = hepeup.MOTHUP[particle].first; element->Mother2 = hepeup.MOTHUP[particle].second; element->ColorLine1 = hepeup.ICOLUP[particle].first; element->ColorLine2 = hepeup.ICOLUP[particle].second; element->Px = hepeup.PUP[particle][0]; element->Py = hepeup.PUP[particle][1]; element->Pz = hepeup.PUP[particle][2]; element->E = hepeup.PUP[particle][3]; //element->M = hepeup.PUP[particle][4]; //element->Charge = ChargeVal(element->PID); PdgParticle pdg_part = pdg_table[element->PID]; element->Charge = pdg_part.charge(); element->M = pdg_part.mass(); momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E); element->PT = momentum.Perp(); signPz = (element->Pz >= 0.0) ? 1.0 : -1.0; //element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta(); to avoid a warning from ROOT, replace the "==0" by "< 1e-6" element->Eta = element->PT < 1E-6 ? signPz*999.9 : momentum.Eta(); element->Phi = momentum.Phi(); element->Rapidity = element->PT < 1E-6 ? signPz*999.9 : momentum.Rapidity(); element->LifeTime = hepeup.VTIMUP[particle]; element->Spin = hepeup.SPINUP[particle]; } } LHEFConverter::~LHEFConverter() { } //------------------------------------------------------------------------------ //Nevents not yet implemented! 08.03.2009 LHEFConverter::LHEFConverter(const string& inputFileList, const string& outputFileName, const PdgTable& pdg, const int& Nevents) : DataConverter(pdg,Nevents) { ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN"); // generated event from LHEF ExRootTreeBranch *branchEvent = treeWriter->NewBranch("Event", TRootLHEFEvent::Class()); // generated partons from LHEF ExRootTreeBranch *branchParticle = treeWriter->NewBranch("Particle", TRootLHEFParticle::Class()); // Open a stream connected to an event file: ifstream infile(inputFileList.c_str()); string filename; if(!infile.is_open()) { cerr << left << setw(30) <<"** ERROR: Can't open "<<"" << left << setw(20) << inputFileList <<"" << right << setw(19) <<"for input **"<<""<> filename; if(!infile.good()) break; ifstream checking_the_file(filename.c_str()); if(!checking_the_file.good()) { cerr << left << setw(30) <<"** ERROR: Can't find file "<<"" << left << setw(20) << filename <<"" << right << setw(19) <<"for input **"<<""<getNumberOfEvents(); if(allEntries > 0) { // Loop over all events Long64_t entry = 0; while(inputReader->readEvent()) { treeWriter->Clear(); AnalyseEvent(inputReader, branchEvent, entry + 1); AnalyseParticles(inputReader, branchParticle); treeWriter->Fill(); ++entry; } } } treeWriter->Write(); delete treeWriter; //delete inputReader; }