CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/GeneratorInterface/HiGenCommon/src/PartonHadronDecayGenEvtSelector.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include "GeneratorInterface/HiGenCommon/interface/PartonHadronDecayGenEvtSelector.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 using namespace std;
00005 
00006 PartonHadronDecayGenEvtSelector::PartonHadronDecayGenEvtSelector(const edm::ParameterSet& pset) : BaseHiGenEvtSelector(pset)
00007 {
00008 
00009   hadronId_       = pset.getParameter<vector<int> >("hadrons");
00010   hadronStatus_   = pset.getParameter<vector<int> >("hadronStatus");
00011   hadronEtaMax_   = pset.getParameter<vector<double> >("hadronEtaMax");
00012   hadronEtaMin_   = pset.getParameter<vector<double> >("hadronEtaMin");
00013   hadronPMin_     = pset.getParameter<vector<double> >("hadronPMin");
00014   hadronPtMax_    = pset.getParameter<vector<double> >("hadronPtMax");
00015   hadronPtMin_    = pset.getParameter<vector<double> >("hadronPtMin");
00016   
00017   decayId_        = pset.getParameter<int>("decays");
00018   decayStatus_    = pset.getParameter<int>("decayStatus");
00019   decayEtaMax_    = pset.getParameter<double>("decayEtaMax");
00020   decayEtaMin_    = pset.getParameter<double>("decayEtaMin");
00021   decayPMin_      = pset.getParameter<double>("decayPMin");
00022   decayPtMax_     = pset.getParameter<double>("decayPtMax");
00023   decayPtMin_     = pset.getParameter<double>("decayPtMin");
00024   decayNtrig_     = pset.getParameter<int>("decayNtrig");
00025 
00026   partonId_       = pset.getParameter<vector<int> >("partons");
00027   partonStatus_   = pset.getParameter<vector<int> >("partonStatus");
00028   partonEtaMax_   = pset.getParameter<vector<double> >("partonEtaMax");
00029   partonPtMin_    = pset.getParameter<vector<double> >("partonPtMin");
00030      
00031   int id     = hadronId_.size();
00032   int st     = hadronStatus_.size();
00033   int etamax = hadronEtaMax_.size();
00034   int etamin = hadronEtaMin_.size();
00035   int pmin   = hadronPMin_.size();
00036   int ptmax  = hadronPtMax_.size();
00037   int ptmin  = hadronPtMin_.size();
00038   
00039   if( id!=st || id!=etamax || id!=etamin || id!=ptmax || id!=ptmin || id!=pmin)
00040     {
00041       throw edm::Exception(edm::errors::LogicError)<<"Hadron selection parameters: "<<id<<st<<etamax<<etamin<<pmin<<ptmax<<ptmin<<endl;
00042     }
00043   
00044 
00045   id     = partonId_.size();
00046   st     = partonStatus_.size();
00047   etamax = partonEtaMax_.size();
00048   ptmin  = partonPtMin_.size();
00049   
00050   if( id!=st || id!=etamax || id!=ptmin )
00051     {
00052       throw edm::Exception(edm::errors::LogicError)<<"Parton selection parameters: "<<id<<st<<etamax<<ptmin<<endl;
00053     }
00054   
00055 }
00056 
00057 
00058 //____________________________________________________________________________________________
00059 bool PartonHadronDecayGenEvtSelector::filter(HepMC::GenEvent *evt)
00060 {
00061   // loop over HepMC event, and search for  products of interest
00062 
00063   HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
00064   HepMC::GenEvent::particle_const_iterator end   = evt->particles_end();
00065   
00066   bool foundHadron   = false;
00067   bool foundDecay    = false;
00068   bool foundParton   = false;
00069   
00070   HepMC::GenEvent::particle_const_iterator it = begin;
00071   while( !foundParton && it != end )
00072     {
00073       for(unsigned i = 0; i < partonId_.size(); ++i)
00074         {
00075           if( selectParticle(*it,
00076                              partonStatus_[i], partonId_[i],  
00077                              partonPtMin_[i],partonEtaMax_[i]) ) foundParton = true;
00078         }
00079       ++it;
00080     }
00081 
00082   int foundtrig = 0;
00083   HepMC::GenEvent::particle_const_iterator it2 = begin;
00084  
00085   if(foundParton)
00086     {
00087       while( (!foundHadron || !foundDecay) && it2 != end )
00088         {
00089           
00090           for(unsigned i = 0; i < hadronId_.size(); ++i)
00091             {
00092               if( selectParticle(*it2, 
00093                                  hadronStatus_[i], hadronId_[i], 
00094                                  hadronEtaMax_[i],hadronEtaMin_[i], 
00095                                  hadronPMin_[i],
00096                                  hadronPtMax_[i],hadronPtMin_[i]) ) foundHadron = true;
00097             }
00098         
00099           if( selectParticle(*it2, 
00100                              decayStatus_, decayId_, 
00101                              decayEtaMax_,decayEtaMin_, 
00102                              decayPMin_,
00103                              decayPtMax_,decayPtMin_) ) foundtrig++;
00104           if(decayNtrig_ == foundtrig) foundDecay = true;
00105            
00106           ++it2;
00107         }
00108     }
00109   
00110   return (foundHadron && foundDecay && foundParton);
00111 }
00112 
00113 
00114 //____________________________________________________________________________________________