Go to the documentation of this file.00001 #include <iostream>
00002 #include "GeneratorInterface/HiGenCommon/interface/HadronDecayGenEvtSelector.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 using namespace std;
00005
00006 HadronDecayGenEvtSelector::HadronDecayGenEvtSelector(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
00027 int id = hadronId_.size();
00028 int st = hadronStatus_.size();
00029 int etamax = hadronEtaMax_.size();
00030 int etamin = hadronEtaMin_.size();
00031 int pmin = hadronPMin_.size();
00032 int ptmax = hadronPtMax_.size();
00033 int ptmin = hadronPtMin_.size();
00034
00035 if( id!=st || id!=etamax || id!=etamin || id!=ptmax || id!=ptmin || id!=pmin)
00036 {
00037 throw edm::Exception(edm::errors::LogicError)<<"Hadron selection parameters: "<<id<<st<<etamax<<etamin<<pmin<<ptmax<<ptmin<<endl;
00038 }
00039
00040
00041 }
00042
00043
00044
00045 bool HadronDecayGenEvtSelector::filter(HepMC::GenEvent *evt)
00046 {
00047
00048
00049 HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
00050 HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
00051
00052 bool foundHadron = false;
00053 bool foundDecay = false;
00054
00055 int foundtrig = 0;
00056 HepMC::GenEvent::particle_const_iterator it = begin;
00057 while( (!foundHadron || !foundDecay) && it != end )
00058 {
00059 for(unsigned i = 0; i < hadronId_.size(); ++i)
00060 {
00061 if( selectParticle(*it,
00062 hadronStatus_[i], hadronId_[i],
00063 hadronEtaMax_[i],hadronEtaMin_[i],
00064 hadronPMin_[i],
00065 hadronPtMax_[i],hadronPtMin_[i]) ) foundHadron = true;
00066 }
00067
00068 if( selectParticle(*it,
00069 decayStatus_, decayId_,
00070 decayEtaMax_,decayEtaMin_,
00071 decayPMin_,
00072 decayPtMax_,decayPtMin_) ) foundtrig++;
00073 if(decayNtrig_ == foundtrig) foundDecay = true;
00074
00075 ++it;
00076 }
00077
00078 return (foundHadron && foundDecay);
00079 }
00080
00081
00082