14 inline double deltaR2(
double eta0,
double phi0,
double eta,
double phi){
18 return dphi*dphi+(eta-eta0)*(eta-eta0);
21 double deltaPhi(
double phi0,
double phi){
28 class ParticlePtGreater{
32 return p1->momentum().perp() > p2->momentum().perp();
39 token_(consumes<edm::
HepMCProduct>(edm::
InputTag(iConfig.getUntrackedParameter(
"moduleLabel",std::
string(
"generator")),
"unsmeared"))),
40 etaMin(iConfig.getUntrackedParameter<double>(
"MinEMEta", 0)),
41 eTSumMin(iConfig.getUntrackedParameter<double>(
"ETSumMin", 50.)),
42 pTMin(iConfig.getUntrackedParameter<double>(
"MinEMpT", 5.)),
43 etaMax(iConfig.getUntrackedParameter<double>(
"MaxEMEta", 2.7)),
44 eTSumMax(iConfig.getUntrackedParameter<double>(
"ETSumMax", 100.)),
45 pTMax(iConfig.getUntrackedParameter<double>(
"MaxEMpT", 999999.)),
47 maxnumberofeventsinrun(iConfig.getUntrackedParameter<int>(
"MaxEvents",3000000)){
55 cout <<
" Cut Definition: " << endl;
62 cout <<
" 5x5 crystal cone around EM axis in ECAL Barrel = " <<
deltaEB << endl;
63 cout <<
" 5x5 crystal cone around EM axis in ECAL Endcap = " <<
deltaEE << endl;
78 throw cms::Exception(
"endJob") <<
"we have reached the maximum number of events ";
84 bool accepted =
false;
88 list<const HepMC::GenParticle *> EM_seeds;
89 const HepMC::GenEvent * myGenEvent = evt->GetEvent();
94 for ( HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
95 p != myGenEvent->particles_end();
99 if ( (
abs((*p)->pdg_id())==11 || (*p)->pdg_id()==22)
101 && (*p)->momentum().perp() >
pTMin
102 && (*p)->momentum().perp() <
pTMax
103 && fabs((*p)->momentum().eta()) <
etaMax
104 && fabs((*p)->momentum().eta()) >
etaMin ) {
105 EM_seeds.push_back(*
p);
110 EM_seeds.sort(ParticlePtGreater());
115 for(std::list<const HepMC::GenParticle *>::const_iterator is=EM_seeds.begin();
118 double etaEM=(*is)->momentum().eta();
119 double phiEM=(*is)->momentum().phi();
120 double ptEM=(*is)->momentum().perp();
132 tgx=(*is)->momentum().px()/(*is)->momentum().pz();
133 tgy=(*is)->momentum().py()/(*is)->momentum().pz();
139 for ( HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
140 p != myGenEvent->particles_end();
143 if (((*p)->status()==1 && (*p)->pdg_id() == 22) ||
144 ((*p)->status()==1 &&
abs((*p)->pdg_id()) == 11) )
170 double pt=(*p)->momentum().perp();
171 if (pt == ptEM) continue ;
172 double eta=(*p)->momentum().eta();
173 double phi=(*p)->momentum().phi();
179 else if(
std::abs((*p)->momentum().px()/(*p)->momentum().pz() - tgx)
181 std::abs((*p)->momentum().py()/(*p)->momentum().pz() - tgy)
186 etaEMClus += (eta-etaEMClus)*pt/ptEMClus ;
187 phiEMClus +=
deltaPhi(phi,phiEM)*pt/ptEMClus;
191 etaEMClus += ((*p)->momentum().px()/(*p)->momentum().pz() - tgx)*pt/ptEMClus ;
192 phiEMClus += ((*p)->momentum().py()/(*p)->momentum().pz() - tgy)*pt/ptEMClus;
203 <<
" Proccess ID " << myGenEvent->signal_process_id() << endl;
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< edm::HepMCProduct > token_
PythiaFilterEMJet(const edm::ParameterSet &)
Abs< T >::type abs(const T &t)
double deltaR2(const T1 &t1, const T2 &t2)
virtual bool filter(edm::Event &, const edm::EventSetup &)
int maxnumberofeventsinrun