/** \class Merger * * Merges multiple input arrays into one output array * and sums transverse momenta of all input objects. * * $Date: 2012-11-18 15:57:08 +0100 (Sun, 18 Nov 2012) $ * $Revision: 814 $ * * * \author P. Demin - UCL, Louvain-la-Neuve * */ #include "modules/Merger.h" #include "classes/DelphesClasses.h" #include "classes/DelphesFactory.h" #include "classes/DelphesFormula.h" #include "ExRootAnalysis/ExRootResult.h" #include "ExRootAnalysis/ExRootFilter.h" #include "ExRootAnalysis/ExRootClassifier.h" #include "TMath.h" #include "TString.h" #include "TFormula.h" #include "TRandom3.h" #include "TObjArray.h" #include "TDatabasePDG.h" #include "TLorentzVector.h" #include #include #include #include using namespace std; //------------------------------------------------------------------------------ Merger::Merger() { } //------------------------------------------------------------------------------ Merger::~Merger() { } //------------------------------------------------------------------------------ void Merger::Init() { // import arrays with output from other modules ExRootConfParam param = GetParam("InputArray"); Long_t i, size; const TObjArray *array; TIterator *iterator; DelphesFormula *formula; size = param.GetSize(); for(i = 0; i < size/2; ++i) { array = ImportArray(param[i*2].GetString()); iterator = array->MakeIterator(); formula = new DelphesFormula; formula->Compile(param[i*2 + 1].GetString()); fInputMap[iterator] = formula; } // create output arrays fOutputArray = ExportArray(GetString("OutputArray", "candidates")); fMomentumOutputArray = ExportArray(GetString("MomentumOutputArray", "momentum")); } //------------------------------------------------------------------------------ void Merger::Finish() { map< TIterator *, DelphesFormula * >::iterator itInputMap; TIterator *iterator; DelphesFormula *formula; for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap) { iterator = itInputMap->first; formula = itInputMap->second; if(iterator) delete iterator; if(formula) delete formula; } } //------------------------------------------------------------------------------ void Merger::Process() { Candidate *candidate; TLorentzVector momentum; Double_t eta, pt; map< TIterator *, DelphesFormula * >::iterator itInputMap; TIterator *iterator; DelphesFormula *formula; DelphesFactory *factory = GetFactory(); momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0); // loop over all input arrays for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap) { iterator = itInputMap->first; formula = itInputMap->second; // loop over all candidates iterator->Reset(); while((candidate = static_cast(iterator->Next()))) { const TLorentzVector &candidatePosition = candidate->Position; const TLorentzVector &candidateMomentum = candidate->Momentum; eta = candidatePosition.Eta(); pt = candidateMomentum.Pt(); if(formula->Eval(pt, eta)) { momentum += candidateMomentum; fOutputArray->Add(candidate); } } } candidate = factory->NewCandidate(); candidate->Position.SetXYZT(0.0, 0.0, 0.0, 0.0); candidate->Momentum = momentum; fMomentumOutputArray->Add(candidate); } //------------------------------------------------------------------------------