22 template <
class T,
class U>
25 for (
auto& it : footprint) {
26 if (it.key() == candidate.key())
49 template <
class T,
class U>
84 "phoFull5x5SigmaIEtaIEta",
85 "phoFull5x5SigmaIEtaIPhi",
92 "phoFull5x5E1x3byE5x5",
93 "phoFull5x5E2x2byE5x5",
94 "phoFull5x5E2x5byE5x5",
96 "phoChargedIsolation",
97 "phoNeutralHadronIsolation",
99 "phoWorstChargedIsolation",
100 "phoWorstChargedIsolationConeVeto",
101 "phoWorstChargedIsolationConeVetoPVConstr",
104 "phoHcalPFClIsolation",
105 "phoEcalPFClIsolation" 122 || !cfg.getParameter<
edm::InputTag>(
"esReducedRecHitCollectionMiniAOD").
label().
empty())
123 ,
src_( consumesCollector(), cfg,
"src",
"srcMiniAOD")
124 ,
ebRecHits_ (
src_, consumesCollector(), cfg,
"ebReducedRecHitCollection",
"ebReducedRecHitCollectionMiniAOD")
125 ,
eeRecHits_ (
src_, consumesCollector(), cfg,
"eeReducedRecHitCollection",
"eeReducedRecHitCollectionMiniAOD")
126 ,
esRecHits_ (
src_, consumesCollector(), cfg,
"esReducedRecHitCollection",
"esReducedRecHitCollectionMiniAOD")
127 ,
vtxToken_ (
src_, consumesCollector(), cfg,
"vertices",
"verticesMiniAOD")
128 ,
pfCandsToken_(
src_, consumesCollector(), cfg,
"pfCandidates",
"pfCandidatesMiniAOD")
130 cfg.getParameter<
edm::InputTag>(
"particleBasedIsolation")) )
154 if (
test.isNull() || !
test.isAvailable()) {
156 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
161 std::unique_ptr<noZS::EcalClusterLazyTools> lazyToolnoZS;
164 lazyToolnoZS = std::make_unique<noZS::EcalClusterLazyTools>(
167 lazyToolnoZS = std::make_unique<noZS::EcalClusterLazyTools>(
176 std::vector<float> vars[
nVars_];
179 for (
unsigned i = 0;
i <
src->size(); ++
i) {
180 const auto& iPho =
src->ptrAt(
i);
185 const auto& theseed = *(iPho->superCluster()->seed());
191 std::vector<float> vCov = lazyToolnoZS->localCovariances(theseed);
192 vars[0].push_back(
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
193 vars[1].push_back(vCov[1]);
194 vars[2].push_back(lazyToolnoZS->e1x3(theseed));
195 vars[3].push_back(lazyToolnoZS->e2x2(theseed));
196 vars[4].push_back(lazyToolnoZS->e2x5Max(theseed));
197 vars[5].push_back(lazyToolnoZS->e5x5(theseed));
198 vars[6].push_back(lazyToolnoZS->eseffsirir(*(iPho->superCluster())));
199 vars[7].push_back(vars[2][
i] / vars[5][
i]);
200 vars[8].push_back(vars[3][i] / vars[5][i]);
201 vars[9].push_back(vars[4][i] / vars[5][i]);
209 iPho->superCluster()->x() - pv.
x(), iPho->superCluster()->y() - pv.
y(), iPho->superCluster()->z() - pv.
z());
212 float chargedIsoSum = 0.;
213 float neutralHadronIsoSum = 0.;
214 float photonIsoSum = 0.;
217 for (
unsigned int idxcand = 0; idxcand < pfCandsHandle->size(); ++idxcand) {
221 const auto& iCand = pfCandsHandle->ptrAt(idxcand);
240 float dR2 =
deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi());
269 chargedIsoSum += iCand->pt();
273 neutralHadronIsoSum += iCand->pt();
276 photonIsoSum += iCand->pt();
279 vars[10].push_back(chargedIsoSum);
280 vars[11].push_back(neutralHadronIsoSum);
281 vars[12].push_back(photonIsoSum);
296 vars[16].push_back(iPho->trkSumPtSolidConeDR04());
298 vars[17].push_back(0.
f);
299 vars[18].push_back(0.
f);
329 descriptions.
add(
"photonIDValueMapProducer", desc);
335 template <
class T,
class U>
339 float worstIsolation = 0.0;
344 for (
unsigned int ivtx = 0; ivtx < vertices->size(); ++ivtx) {
349 photon->superCluster()->y() - vtx->y(), photon->superCluster()->z() - vtx->z());
353 for (
unsigned int i = 0;
i < pfCands->size();
i++) {
355 const auto& iCand = pfCands->ptrAt(
i);
375 float dR2 =
deltaR2(phoWrtVtx.Eta(), phoWrtVtx.Phi(), iCand->eta(), iCand->phi());
377 (options &
DR_VETO && dR2 < dRveto * dRveto))
383 worstIsolation =
std::max(sum, worstIsolation);
386 return worstIsolation;
400 else if (
abs(pdgId) == 130)
402 else if (
abs(pdgId) == 211)
~PhotonIDValueMapProducer() override
const unsigned char DR_VETO
ParticleType
particle types
const unsigned char PV_CONSTRAINT
float computeWorstPFChargedIsolation(const T &photon, const U &pfCands, const edm::Handle< reco::VertexCollection > vertices, const reco::Vertex &pv, unsigned char options)
MultiTokenT< edm::View< reco::Candidate > > pfCandsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
double y() const
y coordinate
MultiTokenT< EcalRecHitCollection > esRecHits_
PhotonIDValueMapProducer(const edm::ParameterSet &)
bool isInFootprint(const T &footprint, const U &candidate)
const Point & position() const
position
const std::string names[nVars_]
edm::EDGetToken particleBasedIsolationToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const unsigned char PT_MIN_THRESH
MultiTokenT< edm::View< reco::Photon > > src_
Abs< T >::type abs(const T &t)
double z() const
z coordinate
void produce(edm::Event &, const edm::EventSetup &) override
MultiTokenT< EcalRecHitCollection > eeRecHits_
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
ParameterDescriptionBase * add(U const &iLabel, T const &value)
MultiTokenT< reco::VertexCollection > vtxToken_
edm::Handle< T > getValidHandle(const edm::Event &iEvent)
double x() const
x coordinate
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MultiTokenT< EcalRecHitCollection > ebRecHits_
const reco::Track * getTrackPointer(const edm::Ptr< reco::Candidate > candidate)
edm::Ptr< pat::Photon > patPhotonPtr
int getGoodTokenIndex() const
reco::PFCandidate::ParticleType candidatePdgId(const edm::Ptr< reco::Candidate > candidate)
void getImpactParameters(const edm::Ptr< reco::Candidate > &candidate, const reco::Vertex &pv, float &dxy, float &dz)