33 for (
auto& it : footprint) {
34 if (it.key() == candidate.
key())
40 struct CachingPtrCandidate {
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)
124 "phoFull5x5SigmaIEtaIEta",
125 "phoFull5x5SigmaIEtaIPhi",
132 "phoFull5x5E1x3byE5x5",
133 "phoFull5x5E2x2byE5x5",
134 "phoFull5x5E2x5byE5x5",
136 "phoChargedIsolation",
137 "phoNeutralHadronIsolation",
138 "phoPhotonIsolation",
139 "phoWorstChargedIsolation",
140 "phoWorstChargedIsolationConeVeto",
141 "phoWorstChargedIsolationConeVetoPVConstr",
144 "phoHcalPFClIsolation",
145 "phoEcalPFClIsolation"};
168 cfg.getParameter<
edm::
InputTag>(
"particleBasedIsolation")) ),
169 isAOD_(cfg.getParameter<
bool>(
"isAOD")) {
184 }
else if (!
src->empty()) {
186 if (
test.isNull() || !
test.isAvailable()) {
188 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
204 for (
auto const& iPho :
src->ptrs()) {
208 const auto&
seed = *(iPho->superCluster()->seed());
214 std::vector<float> vCov = lazyToolnoZS.localCovariances(
seed);
216 vars[1].push_back(vCov[1]);
217 vars[2].push_back(lazyToolnoZS.e1x3(
seed));
218 vars[3].push_back(lazyToolnoZS.e2x2(
seed));
219 vars[4].push_back(lazyToolnoZS.e2x5Max(
seed));
220 vars[5].push_back(lazyToolnoZS.e5x5(
seed));
221 vars[6].push_back(lazyToolnoZS.eseffsirir(*(iPho->superCluster())));
222 vars[7].push_back(vars[2].back() / vars[5].back());
223 vars[8].push_back(vars[3].back() / vars[5].back());
224 vars[9].push_back(vars[4].back() / vars[5].back());
232 iPho->superCluster()->x() - pv.
x(), iPho->superCluster()->y() - pv.
y(), iPho->superCluster()->z() - pv.
z());
235 float chargedIsoSum = 0.;
236 float neutralHadronIsoSum = 0.;
237 float photonIsoSum = 0.;
240 for (
auto const& iCand : pfCandsHandle->ptrs()) {
261 float dR2 =
deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi());
262 if (dR2 > coneSizeDR2)
267 if (isInFootprint((*particleBasedIsolationMap)[iPho], iCand))
285 getImpactParameters(CachingPtrCandidate(&*iCand,
isAOD_), pv, dxy, dz);
287 if (fabs(dxy) > dxyMax || fabs(dz) > dzMax)
291 chargedIsoSum += iCand->pt();
295 neutralHadronIsoSum += iCand->pt();
298 photonIsoSum += iCand->pt();
301 vars[10].push_back(chargedIsoSum);
302 vars[11].push_back(neutralHadronIsoSum);
303 vars[12].push_back(photonIsoSum);
310 options |= PT_MIN_THRESH |
DR_VETO;
318 vars[16].push_back(iPho->trkSumPtSolidConeDR04());
320 vars[17].push_back(0.
f);
321 vars[18].push_back(0.
f);
331 auto valMap = std::make_unique<edm::ValueMap<float>>();
349 desc.
add<
bool>(
"isAOD",
false);
350 descriptions.
add(
"photonIDValueMapProducer", desc);
361 float worstIsolation = 0.0;
365 std::vector<CachingPtrCandidate> chargedCands;
366 chargedCands.reserve(pfCands.
size());
367 for (
auto const& aCand : pfCands) {
373 if ((options & PT_MIN_THRESH) && aCand.pt() <
ptMin)
376 chargedCands.emplace_back(&aCand, isAOD);
380 for (
unsigned int ivtx = 0; ivtx < vertices.size(); ++ivtx) {
387 const float phoWrtVtxPhi = phoWrtVtx.phi();
388 const float phoWrtVtxEta = phoWrtVtx.eta();
392 for (
auto const& aCCand : chargedCands) {
393 auto iCand = aCCand.candidate;
394 float dR2 =
deltaR2(phoWrtVtxEta, phoWrtVtxPhi, iCand->eta(), iCand->phi());
395 if (dR2 > coneSizeDR2 || (options & DR_VETO && dR2 < dRveto2))
400 if (options & PV_CONSTRAINT)
401 getImpactParameters(aCCand, pv, dxy, dz);
403 getImpactParameters(aCCand, *vtx, dxy, dz);
405 if (fabs(dxy) > dxyMax || fabs(dz) > dzMax)
411 worstIsolation =
std::max(sum, worstIsolation);
414 return worstIsolation;
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
~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
const unsigned char PV_CONSTRAINT
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr bool isNotFinite(T x)
double y() const
y coordinate
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
PhotonIDValueMapProducer(const edm::ParameterSet &)
std::vector< Vertex > VertexCollection
collection of Vertex objects
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
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
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
Abs< T >::type abs(const T &t)
double z() const
z coordinate
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double x() const
x coordinate
const edm::EDGetTokenT< reco::VertexCollection > vtxToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< EcalRecHitCollection > esRecHits_
edm::Ptr< pat::Photon > patPhotonPtr
Particle reconstructed by the particle flow algorithm.
const edm::EDGetToken particleBasedIsolationToken_
const edm::EDGetTokenT< edm::View< reco::Photon > > src_