3 #include "Math/GenVector/VectorUtil.h"
8 #include "TLorentzVector.h"
14 using namespace HepMC;
18 label(iConfig.getUntrackedParameter<std::string>(
"moduleLabel",std::string(
"generator"))),
20 maxEvents(iConfig.getUntrackedParameter<int>(
"maxEvents", 100000)),
21 ptSeedThr(iConfig.getUntrackedParameter<double>(
"PtSeedThr")),
22 etaSeedThr(iConfig.getUntrackedParameter<double>(
"EtaSeedThr")),
23 ptGammaThr(iConfig.getUntrackedParameter<double>(
"PtGammaThr")),
24 etaGammaThr(iConfig.getUntrackedParameter<double>(
"EtaGammaThr")),
25 ptTkThr(iConfig.getUntrackedParameter<double>(
"PtTkThr")),
26 etaTkThr(iConfig.getUntrackedParameter<double>(
"EtaTkThr")),
27 ptElThr(iConfig.getUntrackedParameter<double>(
"PtElThr")),
28 etaElThr(iConfig.getUntrackedParameter<double>(
"EtaElThr")),
29 dRTkMax(iConfig.getUntrackedParameter<double>(
"dRTkMax")),
30 dRSeedMax(iConfig.getUntrackedParameter<double>(
"dRSeedMax")),
31 dPhiSeedMax(iConfig.getUntrackedParameter<double>(
"dPhiSeedMax")),
32 dEtaSeedMax(iConfig.getUntrackedParameter<double>(
"dEtaSeedMax")),
33 dRNarrowCone(iConfig.getUntrackedParameter<double>(
"dRNarrowCone")),
34 pTMinCandidate1(iConfig.getUntrackedParameter<double>(
"PtMinCandidate1")),
35 pTMinCandidate2(iConfig.getUntrackedParameter<double>(
"PtMinCandidate2")),
36 etaMaxCandidate(iConfig.getUntrackedParameter<double>(
"EtaMaxCandidate")),
37 invMassWide(iConfig.getUntrackedParameter<double>(
"InvMassWide")),
38 invMassNarrow(iConfig.getUntrackedParameter<double>(
"InvMassNarrow")),
39 nTkConeMax(iConfig.getUntrackedParameter<int>(
"NTkConeMax")),
40 nTkConeSum(iConfig.getUntrackedParameter<int>(
"NTkConeSum")),
41 acceptPrompts(iConfig.getUntrackedParameter<bool>(
"AcceptPrompts")),
42 promptPtThreshold(iConfig.getUntrackedParameter<double>(
"PromptPtThreshold")) {
125 throw cms::Exception(
"endJob")<<
"We have reached the maximum number of events...";
130 bool accepted =
false;
136 std::vector<const GenParticle*> seeds, egamma,
stable;
137 std::vector<const GenParticle*>::const_iterator itPart, itStable, itEn;
139 for(HepMC::GenEvent::particle_const_iterator
p =
myGenEvent->particles_begin();
p !=
myGenEvent->particles_end(); ++
p) {
142 ((*p)->status()==1&&(*p)->pdg_id() == 22) ||
143 ((*p)->status()==1&&
abs((*p)->pdg_id()) == 11) ||
144 (*p)->pdg_id() == 111 ||
145 abs((*p)->pdg_id()) == 221 ||
146 abs((*p)->pdg_id()) == 331 ||
147 abs((*p)->pdg_id()) == 113 ||
148 abs((*p)->pdg_id()) == 223)
151 if ((*p)->momentum().perp() >
ptSeedThr &&
157 const GenParticle* mother = (*p)->production_vertex() ?
158 *((*p)->production_vertex()->particles_in_const_begin()) : 0;
159 const GenParticle* motherMother = (mother != 0 && mother->production_vertex()) ?
160 *(mother->production_vertex()->particles_in_const_begin()) : 0;
161 const GenParticle* motherMotherMother = (motherMother != 0 && motherMother->production_vertex()) ?
162 *(motherMother->production_vertex()->particles_in_const_begin()) : 0;
164 for(itPart = seeds.begin(); itPart != seeds.end(); itPart++) {
166 if ((*itPart) == mother ||
167 (*itPart) == motherMother ||
168 (*itPart) == motherMotherMother) {
174 if (!isUsed) seeds.push_back(*
p);
179 if (seeds.size() < 2)
return accepted;
181 for(HepMC::GenEvent::particle_const_iterator
p =
myGenEvent->particles_begin();
p !=
myGenEvent->particles_end(); ++
p) {
183 if ((*p)->status() == 1) {
186 if (
abs((*p)->pdg_id()) == 211 ||
187 abs((*p)->pdg_id()) == 321 ||
188 abs((*p)->pdg_id()) == 11 ||
189 abs((*p)->pdg_id()) == 13 ||
190 abs((*p)->pdg_id()) == 15) {
192 if ((*p)->momentum().perp() >
ptTkThr &&
193 fabs((*p)->momentum().eta()) <
etaTkThr) {
194 stable.push_back(*
p);
199 if ((*p)->pdg_id() == 22 &&
202 egamma.push_back(*
p);
204 if (
abs((*p)->pdg_id()) == 11 &&
205 (*p)->momentum().perp() >
ptElThr &&
206 fabs((*p)->momentum().eta()) <
etaElThr) {
207 egamma.push_back(*
p);
212 std::vector<int> nTracks;
213 std::vector<TLorentzVector> candidate, candidateNarrow, candidateSeed;
214 std::vector<const GenParticle*>::iterator itSeed;
216 for(itSeed = seeds.begin(); itSeed != seeds.end(); ++itSeed) {
218 TLorentzVector
energy, narrowCone, temp1, temp2, tempseed;
220 tempseed.SetXYZM((*itSeed)->momentum().px(), (*itSeed)->momentum().py(), (*itSeed)->momentum().pz(), 0);
221 for(itEn = egamma.begin(); itEn != egamma.end(); ++itEn) {
222 temp1.SetXYZM((*itEn)->momentum().px(), (*itEn)->momentum().py(), (*itEn)->momentum().pz(), 0);
224 double DR = temp1.DeltaR(tempseed);
225 double DPhi = temp1.DeltaPhi(tempseed);
226 double DEta = (*itEn)->momentum().eta()-(*itSeed)->momentum().eta();
227 if(DPhi<0) DPhi=-DPhi;
228 if(DEta<0) DEta=-DEta;
241 if ( energy.Et() != 0. ) {
244 temp2.SetXYZM(energy.Px(), energy.Py(), energy.Pz(), 0);
246 for(itStable = stable.begin(); itStable != stable.end(); ++itStable) {
247 temp1.SetXYZM((*itStable)->momentum().px(), (*itStable)->momentum().py(), (*itStable)->momentum().pz(), 0);
248 double DR = temp1.DeltaR(temp2);
254 if((*itSeed)->status() == 1&&(*itSeed)->pdg_id() == 22) {
255 const GenParticle* mother = (*itSeed)->production_vertex() ?
256 *((*itSeed)->production_vertex()->particles_in_const_begin()) : 0;
258 if(mother->pdg_id()>=-22&&mother->pdg_id()<=22) {
259 const GenParticle* motherMother = (mother != 0 && mother->production_vertex()) ?
260 *(mother->production_vertex()->particles_in_const_begin()) : 0;
262 if(motherMother->pdg_id()>=-22&&motherMother->pdg_id()<=22) {
271 if(isPrompt) counter=0;
280 candidate.push_back(energy);
281 candidateSeed.push_back(tempseed);
282 candidateNarrow.push_back(narrowCone);
283 nTracks.push_back(counter);
288 if (candidate.size() <2)
return accepted;
290 TLorentzVector minv, minvNarrow;
296 for(
unsigned int i=0;
i<candidate.size()-1; ++
i) {
298 if (candidate[
i].Energy() <1.)
continue;
302 for(
unsigned int j=
i+1;
j<candidate.size(); ++
j) {
303 if (candidate[
j].Energy() <1.)
continue;
309 if (candidate[
i].
Pt() > candidate[
j].Pt()) {
320 minv = candidate[
i] + candidate[
j];
323 minvNarrow = candidateNarrow[
i] + candidateNarrow[
j];
virtual bool filter(edm::Event &, const edm::EventSetup &)
~PythiaFilterGammaGamma()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const HepMC::GenEvent * myGenEvent
PythiaFilterGammaGamma(const edm::ParameterSet &)