CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include <iostream>
00002 #include "GeneratorInterface/HiGenCommon/interface/EcalGenEvtSelector.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 using namespace std;
00005 
00006 EcalGenEvtSelector::EcalGenEvtSelector(const edm::ParameterSet& pset) : BaseHiGenEvtSelector(pset){
00007 
00008    partonId_ = pset.getParameter<vector<int> >("partons");
00009    partonStatus_ = pset.getParameter<vector<int> >("partonStatus");
00010    partonPt_ = pset.getParameter<vector<double> >("partonPt");
00011 
00012    particleId_ = pset.getParameter<vector<int> >("particles");
00013    particleStatus_ = pset.getParameter<vector<int> >("particleStatus");
00014    particlePt_ = pset.getParameter<vector<double> >("particlePt");
00015    
00016    etaMax_ = pset.getParameter<double>("etaMax");
00017    
00018    int id = partonId_.size();
00019    int st = partonStatus_.size();
00020    int pt = partonPt_.size();
00021 
00022    if(partonId_.size() != partonStatus_.size() || partonId_.size() != partonPt_.size()){
00023       throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
00024    }
00025 
00026    id = particleId_.size();
00027    st = particleStatus_.size();
00028    pt = particlePt_.size();
00029 
00030    if(particleId_.size() != particleStatus_.size() || particleId_.size() != particlePt_.size()){
00031       throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
00032 
00033    }
00034 
00035 }
00036 
00037 bool EcalGenEvtSelector::filter(HepMC::GenEvent *evt){
00038    HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
00039    HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
00040 
00041    bool foundParticle = false;
00042    bool foundParton = false;
00043    
00044    HepMC::GenEvent::particle_const_iterator it = begin;
00045    while((!foundParton || !foundParticle) && it != end){
00046       for(unsigned i = 0; i < partonId_.size(); ++i){
00047          if(selectParticle(*it, partonStatus_[i], partonId_[i], partonPt_[i], etaMax_)) foundParton = true;
00048       }
00049       for(unsigned i = 0; i < particleId_.size(); ++i){
00050          if(selectParticle(*it, particleStatus_[i], particleId_[i], particlePt_[i], etaMax_)) foundParticle = true;
00051       }
00052       ++it;
00053    }
00054 
00055    return (foundParton && foundParticle);
00056 }