3 #include "Math/GenVector/VectorUtil.h"
8 #include "TLorentzVector.h"
14 using namespace HepMC;
18 token_(consumes<edm::
HepMCProduct>(edm::
InputTag(iConfig.getUntrackedParameter(
"moduleLabel",std::
string(
"generator")),
"unsmeared"))),
19 maxEvents(iConfig.getUntrackedParameter<int>(
"maxEvents", 100000)),
20 ptSeedThr(iConfig.getUntrackedParameter<double>(
"PtSeedThr")),
21 etaSeedThr(iConfig.getUntrackedParameter<double>(
"EtaSeedThr")),
22 ptGammaThr(iConfig.getUntrackedParameter<double>(
"PtGammaThr")),
23 etaGammaThr(iConfig.getUntrackedParameter<double>(
"EtaGammaThr")),
24 ptTkThr(iConfig.getUntrackedParameter<double>(
"PtTkThr")),
25 etaTkThr(iConfig.getUntrackedParameter<double>(
"EtaTkThr")),
26 ptElThr(iConfig.getUntrackedParameter<double>(
"PtElThr")),
27 etaElThr(iConfig.getUntrackedParameter<double>(
"EtaElThr")),
28 dRTkMax(iConfig.getUntrackedParameter<double>(
"dRTkMax")),
29 dRSeedMax(iConfig.getUntrackedParameter<double>(
"dRSeedMax")),
30 dPhiSeedMax(iConfig.getUntrackedParameter<double>(
"dPhiSeedMax")),
31 dEtaSeedMax(iConfig.getUntrackedParameter<double>(
"dEtaSeedMax")),
32 dRNarrowCone(iConfig.getUntrackedParameter<double>(
"dRNarrowCone")),
33 pTMinCandidate1(iConfig.getUntrackedParameter<double>(
"PtMinCandidate1")),
34 pTMinCandidate2(iConfig.getUntrackedParameter<double>(
"PtMinCandidate2")),
35 etaMaxCandidate(iConfig.getUntrackedParameter<double>(
"EtaMaxCandidate")),
36 invMassMin(iConfig.getUntrackedParameter<double>(
"InvMassMin")),
37 invMassMax(iConfig.getUntrackedParameter<double>(
"InvMassMax")),
38 energyCut(iConfig.getUntrackedParameter<double>(
"EnergyCut")),
39 nTkConeMax(iConfig.getUntrackedParameter<int>(
"NTkConeMax")),
40 nTkConeSum(iConfig.getUntrackedParameter<int>(
"NTkConeSum")),
41 acceptPrompts(iConfig.getUntrackedParameter<bool>(
"AcceptPrompts")),
42 promptPtThreshold(iConfig.getUntrackedParameter<double>(
"PromptPtThreshold")) {
61 throw cms::Exception(
"endJob")<<
"We have reached the maximum number of events...";
66 bool accepted =
false;
72 std::vector<const GenParticle*> seeds, egamma,
stable;
73 std::vector<const GenParticle*>::const_iterator itPart, itStable, itEn;
76 for(HepMC::GenEvent::particle_const_iterator
p =
myGenEvent->particles_begin();
p !=
myGenEvent->particles_end(); ++
p) {
79 ((*p)->status()==1&&(*p)->pdg_id() == 22) ||
80 ((*p)->status()==1&&
abs((*p)->pdg_id()) == 11))
84 if ((*p)->momentum().perp() >
ptSeedThr &&
92 if ((*p)->status() == 1) {
95 if (
abs((*p)->pdg_id()) == 211 ||
96 abs((*p)->pdg_id()) == 321 ||
97 abs((*p)->pdg_id()) == 11 ||
98 abs((*p)->pdg_id()) == 13 ||
99 abs((*p)->pdg_id()) == 15) {
101 if ((*p)->momentum().perp() >
ptTkThr &&
102 fabs((*p)->momentum().eta()) <
etaTkThr) {
103 stable.push_back(*
p);
108 if ((*p)->pdg_id() == 22 &&
111 egamma.push_back(*
p);
113 if (
abs((*p)->pdg_id()) == 11 &&
114 (*p)->momentum().perp() >
ptElThr &&
115 fabs((*p)->momentum().eta()) <
etaElThr) {
116 egamma.push_back(*
p);
121 if (seeds.size() < 2)
return accepted;
123 std::vector<int> nTracks;
124 std::vector<TLorentzVector> candidate, candidateNarrow, candidateSeed;
125 std::vector<const GenParticle*>::iterator itSeed;
129 int first_different_id;
131 for(itSeed = seeds.begin(); itSeed != seeds.end(); ++itSeed) {
133 TLorentzVector
energy, narrowCone, temp1, temp2, tempseed;
135 tempseed.SetXYZM((*itSeed)->momentum().px(), (*itSeed)->momentum().py(), (*itSeed)->momentum().pz(), 0);
136 for(itEn = egamma.begin(); itEn != egamma.end(); ++itEn) {
137 temp1.SetXYZM((*itEn)->momentum().px(), (*itEn)->momentum().py(), (*itEn)->momentum().pz(), 0);
139 double DR = temp1.DeltaR(tempseed);
140 double DPhi = temp1.DeltaPhi(tempseed);
141 double DEta = (*itEn)->momentum().eta()-(*itSeed)->momentum().eta();
142 if(DPhi<0) DPhi=-DPhi;
143 if(DEta<0) DEta=-DEta;
155 if ( energy.Et() != 0. ) {
158 temp2.SetXYZM(energy.Px(), energy.Py(), energy.Pz(), 0);
160 for(itStable = stable.begin(); itStable != stable.end(); ++itStable) {
161 temp1.SetXYZM((*itStable)->momentum().px(), (*itStable)->momentum().py(), (*itStable)->momentum().pz(), 0);
162 double DR = temp1.DeltaR(temp2);
171 this_id = (*itSeed)->pdg_id();
173 while (mom->pdg_id() == this_id) {
175 const GenParticle* mother = mom->production_vertex() ?
176 *(mom->production_vertex()->particles_in_const_begin()) : 0;
184 first_different_id = mom->pdg_id();
186 if (mom->status() == 2 &&
std::abs(first_different_id)>100) isPrompt=
false;
189 if(isPrompt) counter=0;
196 candidate.push_back(energy);
197 candidateSeed.push_back(tempseed);
198 candidateNarrow.push_back(narrowCone);
199 nTracks.push_back(counter);
202 if (candidate.size() <2)
return accepted;
204 TLorentzVector minvMin, minvMax;
207 for(
unsigned int i=0;
i<candidate.size()-1; ++
i) {
209 if (candidate[
i].Energy() <
energyCut)
continue;
213 for(
unsigned int j=
i+1;
j<candidate.size(); ++
j) {
214 if (candidate[
j].Energy() <
energyCut)
continue;
220 if (candidate[
i].
Pt() > candidate[
j].Pt()) {
231 minvMin = candidate[
i] + candidate[
j];
234 minvMax = candidate[
i] + candidate[
j];
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual bool filter(edm::Event &, const edm::EventSetup &)
~PythiaFilterGammaGamma()
Abs< T >::type abs(const T &t)
static std::atomic< unsigned int > counter
const HepMC::GenEvent * myGenEvent
PythiaFilterGammaGamma(const edm::ParameterSet &)
edm::EDGetTokenT< edm::HepMCProduct > token_