Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:06:58

0001 #include <iostream>
0002 #include "GeneratorInterface/HiGenCommon/interface/EcalGenEvtSelector.h"
0003 #include "FWCore/Utilities/interface/EDMException.h"
0004 using namespace std;
0005 
0006 EcalGenEvtSelector::EcalGenEvtSelector(const edm::ParameterSet& pset) : BaseHiGenEvtSelector(pset) {
0007   partonId_ = pset.getParameter<vector<int> >("partons");
0008   partonStatus_ = pset.getParameter<vector<int> >("partonStatus");
0009   partonPt_ = pset.getParameter<vector<double> >("partonPt");
0010 
0011   particleId_ = pset.getParameter<vector<int> >("particles");
0012   particleStatus_ = pset.getParameter<vector<int> >("particleStatus");
0013   particlePt_ = pset.getParameter<vector<double> >("particlePt");
0014 
0015   etaMax_ = pset.getParameter<double>("etaMax");
0016 
0017   int id = partonId_.size();
0018   int st = partonStatus_.size();
0019   int pt = partonPt_.size();
0020 
0021   if (partonId_.size() != partonStatus_.size() || partonId_.size() != partonPt_.size()) {
0022     throw edm::Exception(edm::errors::LogicError) << id << st << pt << endl;
0023   }
0024 
0025   id = particleId_.size();
0026   st = particleStatus_.size();
0027   pt = particlePt_.size();
0028 
0029   if (particleId_.size() != particleStatus_.size() || particleId_.size() != particlePt_.size()) {
0030     throw edm::Exception(edm::errors::LogicError) << id << st << pt << endl;
0031   }
0032 }
0033 
0034 bool EcalGenEvtSelector::filter(HepMC::GenEvent* evt) {
0035   HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
0036   HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
0037 
0038   bool foundParticle = false;
0039   bool foundParton = false;
0040 
0041   HepMC::GenEvent::particle_const_iterator it = begin;
0042   while ((!foundParton || !foundParticle) && it != end) {
0043     for (unsigned i = 0; i < partonId_.size(); ++i) {
0044       if (selectParticle(*it, partonStatus_[i], partonId_[i], partonPt_[i], etaMax_))
0045         foundParton = true;
0046     }
0047     for (unsigned i = 0; i < particleId_.size(); ++i) {
0048       if (selectParticle(*it, particleStatus_[i], particleId_[i], particlePt_[i], etaMax_))
0049         foundParticle = true;
0050     }
0051     ++it;
0052   }
0053 
0054   return (foundParton && foundParticle);
0055 }