33 for (
auto& it : footprint) {
34 if (it.key() == candidate.
key())
40 struct CachingPtrCandidate {
43 track(isAOD ? &*static_cast<
const reco::PFCandidate*>(cPtr)->trackRef() : nullptr),
44 packed(isAOD ? nullptr : static_cast<
const pat::PackedCandidate*>(cPtr)) {}
51 void getImpactParameters(
const CachingPtrCandidate& candidate,
const reco::Vertex&
pv,
float&
dxy,
float&
dz) {
52 if (candidate.track !=
nullptr) {
53 dxy = candidate.track->dxy(pv.
position());
54 dz = candidate.track->dz(pv.
position());
56 dxy = candidate.packed->dxy(pv.
position());
57 dz = candidate.packed->dz(pv.
position());
72 else if (
abs(pdgId) == 130)
74 else if (
abs(pdgId) == 211)
126 "phoFull5x5SigmaIEtaIEta",
127 "phoFull5x5SigmaIEtaIPhi",
134 "phoFull5x5E1x3byE5x5",
135 "phoFull5x5E2x2byE5x5",
136 "phoFull5x5E2x5byE5x5",
138 "phoChargedIsolation",
139 "phoNeutralHadronIsolation",
140 "phoPhotonIsolation",
141 "phoWorstChargedIsolation",
142 "phoWorstChargedIsolationConeVeto",
143 "phoWorstChargedIsolationConeVetoPVConstr",
146 "phoHcalPFClIsolation",
147 "phoEcalPFClIsolation"};
162 : usesES_(!cfg.getParameter<edm::
InputTag>(
"esReducedRecHitCollection").
label().
empty()),
163 src_(consumes(cfg.getParameter<edm::
InputTag>(
"src"))),
164 ebRecHits_(consumes(cfg.getParameter<edm::
InputTag>(
"ebReducedRecHitCollection"))),
165 eeRecHits_(consumes(cfg.getParameter<edm::
InputTag>(
"eeReducedRecHitCollection"))),
166 esRecHits_(consumes(cfg.getParameter<edm::
InputTag>(
"esReducedRecHitCollection"))),
167 vtxToken_(consumes(cfg.getParameter<edm::
InputTag>(
"vertices"))),
168 pfCandsToken_(consumes(cfg.getParameter<edm::
InputTag>(
"pfCandidates"))),
170 cfg.getParameter<edm::
InputTag>(
"particleBasedIsolation")) ),
172 isAOD_(
cfg.getParameter<
bool>(
"isAOD")) {
187 }
else if (!
src->empty()) {
189 if (
test.isNull() || !
test.isAvailable()) {
191 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
209 for (
auto const& iPho :
src->ptrs()) {
213 const auto&
seed = *(iPho->superCluster()->seed());
219 const auto& vCov = lazyToolnoZS.localCovariances(
seed);
221 vars[1].push_back(vCov[1]);
222 vars[2].push_back(lazyToolnoZS.e1x3(
seed));
223 vars[3].push_back(lazyToolnoZS.e2x2(
seed));
224 vars[4].push_back(lazyToolnoZS.e2x5Max(
seed));
225 vars[5].push_back(lazyToolnoZS.e5x5(
seed));
226 vars[6].push_back(lazyToolnoZS.eseffsirir(*(iPho->superCluster())));
227 vars[7].push_back(vars[2].back() / vars[5].back());
228 vars[8].push_back(vars[3].back() / vars[5].back());
229 vars[9].push_back(vars[4].back() / vars[5].back());
237 iPho->superCluster()->x() - pv.
x(), iPho->superCluster()->y() - pv.
y(), iPho->superCluster()->z() - pv.
z());
240 float chargedIsoSum = 0.;
241 float neutralHadronIsoSum = 0.;
242 float photonIsoSum = 0.;
245 for (
auto const& iCand : pfCandsHandle->ptrs()) {
266 float dR2 =
deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi());
267 if (dR2 > coneSizeDR2)
272 if (isInFootprint((*particleBasedIsolationMap)[iPho], iCand))
276 if (isInFootprint(patPhotonPtr->associatedPackedPFCandidates(), iCand))
290 getImpactParameters(CachingPtrCandidate(&*iCand,
isAOD_), pv, dxy, dz);
292 if (fabs(dxy) > dxyMax || fabs(dz) > dzMax)
296 chargedIsoSum += iCand->pt();
300 neutralHadronIsoSum += iCand->pt();
303 photonIsoSum += iCand->pt();
306 vars[10].push_back(chargedIsoSum);
307 vars[11].push_back(neutralHadronIsoSum);
308 vars[12].push_back(photonIsoSum);
315 options |= PT_MIN_THRESH |
DR_VETO;
323 vars[16].push_back(iPho->trkSumPtSolidConeDR04());
325 vars[17].push_back(0.
f);
326 vars[18].push_back(0.
f);
336 auto valMap = std::make_unique<edm::ValueMap<float>>();
354 desc.
add<
bool>(
"isAOD",
false);
355 descriptions.
add(
"photonIDValueMapProducer", desc);
366 float worstIsolation = 0.0;
370 std::vector<CachingPtrCandidate> chargedCands;
371 chargedCands.reserve(pfCands.
size());
372 for (
auto const& aCand : pfCands) {
378 if ((options & PT_MIN_THRESH) && aCand.pt() <
ptMin)
381 chargedCands.emplace_back(&aCand, isAOD);
385 for (
unsigned int ivtx = 0; ivtx < vertices.size(); ++ivtx) {
392 const float phoWrtVtxPhi = phoWrtVtx.phi();
393 const float phoWrtVtxEta = phoWrtVtx.eta();
397 for (
auto const& aCCand : chargedCands) {
398 auto iCand = aCCand.candidate;
399 float dR2 =
deltaR2(phoWrtVtxEta, phoWrtVtxPhi, iCand->eta(), iCand->phi());
400 if (dR2 > coneSizeDR2 || (options & DR_VETO && dR2 < dRveto2))
405 if (options & PV_CONSTRAINT)
406 getImpactParameters(aCCand, pv, dxy, dz);
408 getImpactParameters(aCCand, *vtx, dxy, dz);
410 if (fabs(dxy) > dxyMax || fabs(dz) > dzMax)
416 worstIsolation =
std::max(sum, worstIsolation);
419 return worstIsolation;
~PhotonIDValueMapProducer() override
const unsigned char DR_VETO
float computeWorstPFChargedIsolation(const reco::Photon &photon, const edm::View< reco::Candidate > &pfCands, const reco::VertexCollection &vertices, const reco::Vertex &pv, unsigned char options, bool isAOD) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParticleType
particle types
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const unsigned char PV_CONSTRAINT
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr bool isNotFinite(T x)
#define DEFINE_FWK_MODULE(type)
double y() const
y coordinate
PhotonIDValueMapProducer(const edm::ParameterSet &)
std::vector< Vertex > VertexCollection
collection of Vertex objects
constexpr float dRveto2Endcap
constexpr float coneSizeDR2
EcalClusterLazyToolsT< noZS::EcalClusterTools > EcalClusterLazyTools
const Point & position() const
position
const std::string names[nVars_]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const unsigned char PT_MIN_THRESH
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
Abs< T >::type abs(const T &t)
double z() const
z coordinate
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr float dRveto2Barrel
double x() const
x coordinate
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const edm::EDGetTokenT< reco::VertexCollection > vtxToken_
const edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandsToken_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< EcalRecHitCollection > esRecHits_
edm::Ptr< pat::Photon > patPhotonPtr
Particle reconstructed by the particle flow algorithm.
const edm::EDGetToken particleBasedIsolationToken_
edm::Ref< l1t::PFCandidateCollection > PFCandidateRef
const edm::EDGetTokenT< edm::View< reco::Photon > > src_