== Library Interface == Here is an explanation of how Delphes' library can be called from a program. == Installation == Commands to download and build the library: {{{ setup ROOT environment variables wget http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.12.tar.gz tar -zxf Delphes-3.0.10.tar.gz cd Delphes-3.0.10 make -j 4 # library ls libDelphes.so # headers ls modules/Delphes.h ls classes/DelphesClasses.h ls classes/DelphesFactory.h # config file ls examples/delphes_card_CMS.tcl }}} == Complete example == A fully functional application using the Delphes library can be found in {{{ readers/DelphesSTDHEP.cpp }}} == Simplified example == {{{ReadEvent}}}, {{{ReadParticle}}}, {{{ConvertInput}}} and {{{ConvertOutput}}} functions should be implemented by the library's user. {{{ #include #include #include "TROOT.h" #include "TApplication.h" #include "TObjArray.h" #include "TDatabasePDG.h" #include "TParticlePDG.h" #include "TLorentzVector.h" #include "modules/Delphes.h" #include "classes/DelphesClasses.h" #include "classes/DelphesFactory.h" using namespace std; void ConvertInput(DelphesFactory *factory, TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray); void ConvertOutput(Delphes *modularDelphes); bool ReadEvent() { return true; } bool ReadParticle() { return true; } int main() { // Declaration of variables ExRootConfReader *confReader; Delphes *modularDelphes; DelphesFactory *factory; TObjArray *allParticleOutputArray; TObjArray *stableParticleOutputArray; TObjArray *partonOutputArray; gROOT->SetBatch(); int appargc = 1; char appName[] = "DelphesExample"; char *appargv[] = {appName}; TApplication app(appName, &appargc, appargv); try { // Initialization confReader = new ExRootConfReader; confReader->ReadFile("examples/delphes_card_CMS.tcl"); modularDelphes = new Delphes("Delphes"); modularDelphes->SetConfReader(confReader); factory = modularDelphes->GetFactory(); allParticleOutputArray = modularDelphes->ExportArray("allParticles"); stableParticleOutputArray = modularDelphes->ExportArray("stableParticles"); partonOutputArray = modularDelphes->ExportArray("partons"); modularDelphes->InitTask(); // Event loop while(ReadEvent()) { modularDelphes->Clear(); ConvertInput(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray); modularDelphes->ProcessTask(); ConvertOutput(modularDelphes); } // Finalization modularDelphes->FinishTask(); delete modularDelphes; delete confReader; return 0; } catch(runtime_error &e) { cerr << "** ERROR: " << e.what() << endl; return 1; } } void ConvertInput(DelphesFactory *factory, TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray) { Candidate *candidate; TDatabasePDG *pdg; TParticlePDG *pdgParticle; Int_t pdgCode; Int_t pid, status; Double_t px, py, pz, e; Double_t x, y, z, t; pdg = TDatabasePDG::Instance(); while(ReadParticle()) { candidate = factory->NewCandidate(); candidate->PID = pid; pdgCode = TMath::Abs(candidate->PID); candidate->Status = status; pdgParticle = pdg->GetParticle(pid); candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999; candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9; candidate->Momentum.SetPxPyPzE(px, py, pz, e); candidate->Position.SetXYZT(x, y, z, t); allParticleOutputArray->Add(candidate); if(!pdgParticle) return; if(status == 1) { stableParticleOutputArray->Add(candidate); } else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) { partonOutputArray->Add(candidate); } } } void ConvertOutput(Delphes *modularDelphes) { const TObjArray *arrayJets = modularDelphes->ImportArray("FastJetFinder/jets"); TIter iteratorJets(arrayJets); Candidate *candidate; iteratorJets.Reset(); while((candidate = static_cast(iteratorJets.Next()))) { const TLorentzVector &momentum = candidate->Momentum; } } }}}