Go to the documentation of this file.00001 #include <iostream>
00002 #include "GeneratorInterface/HiGenCommon/interface/EcalGenEvtSelectorFrag.h"
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 #include "HepMC/GenVertex.h"
00005 using namespace std;
00006
00007 EcalGenEvtSelectorFrag::EcalGenEvtSelectorFrag(const edm::ParameterSet& pset) : BaseHiGenEvtSelector(pset){
00008
00009 partonId_ = pset.getParameter<vector<int> >("partons");
00010 partonStatus_ = pset.getParameter<vector<int> >("partonStatus");
00011 partonPt_ = pset.getParameter<vector<double> >("partonPt");
00012
00013 particleId_ = pset.getParameter<vector<int> >("particles");
00014 particleStatus_ = pset.getParameter<vector<int> >("particleStatus");
00015 particlePt_ = pset.getParameter<vector<double> >("particlePt");
00016
00017 etaMax_ = pset.getParameter<double>("etaMax");
00018
00019 int id = partonId_.size();
00020 int st = partonStatus_.size();
00021 int pt = partonPt_.size();
00022
00023 if(partonId_.size() != partonStatus_.size() || partonId_.size() != partonPt_.size()){
00024 throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
00025 }
00026
00027 id = particleId_.size();
00028 st = particleStatus_.size();
00029 pt = particlePt_.size();
00030
00031 if(particleId_.size() != particleStatus_.size() || particleId_.size() != particlePt_.size()){
00032 throw edm::Exception(edm::errors::LogicError)<<id<<st<<pt<<endl;
00033
00034 }
00035
00036 }
00037
00038 bool EcalGenEvtSelectorFrag::filter(HepMC::GenEvent *evt){
00039
00040 HepMC::GenEvent::particle_const_iterator begin = evt->particles_begin();
00041 HepMC::GenEvent::particle_const_iterator end = evt->particles_end();
00042
00043 bool foundParticle = false;
00044 bool foundParton = false;
00045
00046 HepMC::GenEvent::particle_const_iterator it = begin;
00047 while((!foundParton || !foundParticle) && it != end){
00048 bool isFrag = false;
00049 bool isThisPhoton = false;
00050
00051 foundParton = true;
00052
00053
00054
00055
00056 for(unsigned i = 0; i < particleId_.size(); ++i){
00057 if(selectParticle(*it, particleStatus_[i], particleId_[i], particlePt_[i], etaMax_)) isThisPhoton =true;
00058 }
00059
00060
00061
00062 if ( !((*it)->production_vertex()) ) {
00063 isFrag = false;
00064 }
00065 else {
00066 const HepMC::GenVertex* productionVertex = (*it)->production_vertex();
00067
00068 size_t numberOfMothers = productionVertex->particles_in_size();
00069 if ( numberOfMothers <= 0 ) {
00070 isFrag = false ;
00071
00072 }
00073 else {
00074
00075 HepMC::GenVertex::particles_in_const_iterator motherIt = productionVertex->particles_in_const_begin();
00076 for( ; motherIt != productionVertex->particles_in_const_end(); motherIt++) {
00077 if ( fabs( (*motherIt)->pdg_id() ) <= 22 ) {
00078 isFrag = true;
00079 }
00080 }
00081 }
00082 }
00083
00084 if ( (isFrag == true) && ( isThisPhoton == true) ) {
00085
00086 foundParticle = true;
00087 }
00088
00089 ++it;
00090
00091
00092
00093
00094 }
00095
00096 foundParton = true ;
00097 return (foundParton && foundParticle);
00098 }