51 void endJob()
override ;
93 ClusterConeSize_ = (double) iConfig.
getParameter<
double>(
"ClusterConeSize");
94 EMSeedThreshold_ = (double) iConfig.
getParameter<
double>(
"EMSeedThreshold");
95 PionSeedThreshold_ = (double) iConfig.
getParameter<
double>(
"PionSeedThreshold");
96 GenParticleThreshold_ = (double) iConfig.
getParameter<
double>(
"GenParticleThreshold");
97 SecondarySeedThreshold_ = (double) iConfig.
getParameter<
double>(
"SecondarySeedThreshold");
98 IsoConeSize_ = (double) iConfig.
getParameter<
double>(
"IsoConeSize");
99 IsolationCutOff_ = (double) iConfig.
getParameter<
double>(
"IsolationCutOff");
101 ClusterEtThreshold_ = (double) iConfig.
getParameter<
double>(
"ClusterEtThreshold");
102 ClusterEtRatio_ = (double) iConfig.
getParameter<
double>(
"ClusterEtRatio");
103 CaloIsoEtRatio_ = (double) iConfig.
getParameter<
double>(
"CaloIsoEtRatio");
104 TrackIsoEtRatio_ = (double) iConfig.
getParameter<
double>(
"TrackIsoEtRatio");
105 ClusterTrackEtRatio_ = (double) iConfig.
getParameter<
double>(
"ClusterTrackEtRatio");
107 MaxClusterCharge_ = (
int) iConfig.
getParameter<
int>(
"MaxClusterCharge");
108 ChargedParticleThreshold_ = (
int) iConfig.
getParameter<
int>(
"ChargedParticleThreshold");
109 ClusterNonSeedThreshold_ = (
int) iConfig.
getParameter<
int>(
"ClusterNonSeedThreshold");
110 ClusterSeedThreshold_ = (
int) iConfig.
getParameter<
int>(
"ClusterSeedThreshold");
132 using namespace reco;
135 iEvent.
getByLabel(
"genParticles", GenParticles);
137 bool FilterResult =
false;
138 double etalimit = 2.4;
141 vector <pair <GenParticle, GenParticle> > ClusterSeeds;
142 int NumPassClusters = 0;
144 for (GenParticleCollection::const_iterator itGenParticles = GenParticles->begin(); itGenParticles != GenParticles->end(); ++itGenParticles) {
145 double CandidateEt = itGenParticles->et();
146 double CandidateEta = itGenParticles->eta();
147 double CandidatePDGID =
abs(itGenParticles->pdgId());
148 double CandidatePhi = itGenParticles->phi();
152 if ((CandidatePDGID==22 || CandidatePDGID==11
153 || CandidatePDGID==211 || CandidatePDGID==310 || CandidatePDGID==130
154 || CandidatePDGID==321 || CandidatePDGID==2112 || CandidatePDGID==2212 || CandidatePDGID==3122)
155 &&
abs(CandidateEta)<etalimit && CandidateEt>EMSeedThreshold_) {
158 if ((CandidatePDGID==211 || CandidatePDGID==321
159 || CandidatePDGID==2112 || CandidatePDGID==2212 || CandidatePDGID==3122)
160 && CandidateEt<PionSeedThreshold_) newseed=
false;
163 for (GenParticleCollection::const_iterator checkGenParticles = GenParticles->begin(); checkGenParticles != GenParticles->end(); ++checkGenParticles) {
164 double GenEt = checkGenParticles->et();
165 double GenEta = checkGenParticles->eta();
166 double GenPDGID =
abs(checkGenParticles->pdgId());
167 double GenPhi = checkGenParticles->phi();
168 double dR =
deltaR2(CandidateEta,CandidatePhi,GenEta,GenPhi);
170 if ((((GenPDGID==22 || GenPDGID==11 || GenPDGID==310 || GenPDGID==130) && GenEt>CandidateEt)
171 || ((GenPDGID==211 || GenPDGID==321 || GenPDGID==2112 || GenPDGID==2212 || GenPDGID==3122) && GenEt>CandidateEt && GenEt>PionSeedThreshold_))
172 && dR<ClusterConeSize_) newseed=
false;
174 if ((GenPDGID==211 || GenPDGID==321 || GenPDGID==2112 || GenPDGID==2212 || GenPDGID==3122)
175 && (GenEt>SecondarySeed.
et() || SecondarySeed.
et()==CandidateEt)
176 && GenEt>SecondarySeedThreshold_ && GenEt<CandidateEt && dR<ClusterConeSize_) SecondarySeed=*checkGenParticles;
180 if (newseed) ClusterSeeds.push_back(make_pair(*itGenParticles,SecondarySeed));
184 for (vector<pair <GenParticle, GenParticle> >::const_iterator itClusterSeeds = ClusterSeeds.begin(); itClusterSeeds != ClusterSeeds.end(); ++itClusterSeeds) {
185 double CaloIsoEnergy = 0;
186 double ClusterEnergy = 0;
187 double ClusterTrackEnergy = 0;
188 double ClusterEta = itClusterSeeds->first.
eta();
189 double ClusterPhi = itClusterSeeds->first.phi();
190 double TrackIsoEnergy = 0;
191 double ClusterTotalCharge = 0;
192 double ClusterTotalEnergy = 0;
194 double SecondaryEta = itClusterSeeds->second.eta();
195 double SecondaryPhi = itClusterSeeds->second.phi();
197 int NumChargesInConeCounter = 0;
198 int NumSeedsInConeCounter = 0;
199 int NumNonSeedsInConeCounter = 0;
201 for(GenParticleCollection::const_iterator itGenParticles = GenParticles->begin(); itGenParticles != GenParticles->end(); ++itGenParticles) {
202 bool TheSecondarySeed =
false;
203 bool TheSeedParticle =
false;
204 double GenCharge = itGenParticles->charge();
205 double GenEt = itGenParticles->et();
206 double GenEta = itGenParticles->eta();
207 double GenPDGID =
abs(itGenParticles->pdgId());
208 double GenPhi = itGenParticles->phi();
209 double GenStatus = itGenParticles->status();
210 double dR =
deltaR2(GenEta,GenPhi,ClusterEta,ClusterPhi);
212 if (ClusterEta==GenEta && ClusterPhi==GenPhi) TheSeedParticle=
true;
213 if (SecondaryEta==GenEta && SecondaryPhi==GenPhi && !(SecondaryEta==ClusterEta && SecondaryPhi==ClusterPhi)) TheSecondarySeed=
true;
214 if (GenStatus==1 && GenEt>GenParticleThreshold_) {
216 if (dR<ClusterConeSize_) {
217 if (GenCharge!=0 && !TheSeedParticle && !TheSecondarySeed) {
218 NumChargesInConeCounter++;
219 ClusterTotalCharge += GenCharge;
220 ClusterTrackEnergy += GenEt;
222 if (GenPDGID!=12 && GenPDGID!=14 && GenPDGID!=16) ClusterTotalEnergy+=GenEt;
223 if (GenPDGID!=12 && GenPDGID!=14 && GenPDGID!=16 && GenPDGID!=22 && GenPDGID!=11 && GenPDGID!=310 && GenPDGID!=130 && !TheSeedParticle && !TheSecondarySeed) NumNonSeedsInConeCounter++;
224 if (GenPDGID==22 || GenPDGID==11 || GenPDGID==310 || GenPDGID==130 || TheSeedParticle || TheSecondarySeed) {
225 NumSeedsInConeCounter++;
226 ClusterEnergy += GenEt;
229 if (dR<IsoConeSize_ && dR>ClusterConeSize_) {
230 if (GenCharge!=0) TrackIsoEnergy += GenEt;
231 if (GenPDGID>100 || GenPDGID==22 || GenPDGID==11) CaloIsoEnergy += GenEt;
238 if (Debug_)
cout <<
"ClusterEnergy: " << ClusterEnergy <<
" | CaloIsoEtRatio: " << CaloIsoEnergy/ClusterEnergy <<
" | TrackIsoEtRatio: " << TrackIsoEnergy/ClusterEnergy <<
" | ClusterTrackEtRatio: " << ClusterTrackEnergy/ClusterEnergy <<
" | ClusterEtRatio: " << ClusterEnergy/ClusterTotalEnergy <<
" | ChargedParticles: " << NumChargesInConeCounter <<
" | ClusterNonSeeds: " << NumNonSeedsInConeCounter <<
" | ClusterSeeds: " << NumSeedsInConeCounter << endl;
239 if ((ClusterEnergy<IsolationCutOff_
240 && ClusterEnergy>ClusterEtThreshold_
241 && ClusterEnergy/ClusterTotalEnergy>ClusterEtRatio_
242 && CaloIsoEnergy/ClusterEnergy<CaloIsoEtRatio_
243 && TrackIsoEnergy/ClusterEnergy<TrackIsoEtRatio_
244 && ClusterTrackEnergy/ClusterEnergy<ClusterTrackEtRatio_
245 &&
abs(ClusterTotalCharge)<MaxClusterCharge_
246 && NumChargesInConeCounter<ChargedParticleThreshold_
247 && NumNonSeedsInConeCounter<ClusterNonSeedThreshold_
248 && NumSeedsInConeCounter<ClusterSeedThreshold_) ||
249 (ClusterEnergy>=IsolationCutOff_
250 && ClusterEnergy>ClusterEtThreshold_
251 && ClusterEnergy/ClusterTotalEnergy>ClusterEtRatio_
254 && ClusterTrackEnergy/ClusterEnergy<ClusterTrackEtRatio_
255 &&
abs(ClusterTotalCharge)<MaxClusterCharge_
256 && NumChargesInConeCounter<ChargedParticleThreshold_
257 && NumNonSeedsInConeCounter<ClusterNonSeedThreshold_
323 if (NumPassClusters>=NumPhotons_) FilterResult=
true;
T getParameter(std::string const &) const
double eta() const final
momentum pseudorapidity
int ChargedParticleThreshold_
bool filter(edm::Event &, const edm::EventSetup &) override
double ClusterTrackEtRatio_
double GenParticleThreshold_
PhotonEnrichmentFilter(const edm::ParameterSet &)
double PionSeedThreshold_
#define DEFINE_FWK_MODULE(type)
double et() const final
transverse energy
Abs< T >::type abs(const T &t)
double ClusterEtThreshold_
double SecondarySeedThreshold_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
int ClusterNonSeedThreshold_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
int ClusterSeedThreshold_
~PhotonEnrichmentFilter() override