32 template <
class T,
class U>
34 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr ) {
35 if( itr->key() == theCandidate.key() )
return true;
55 const std::vector<float> &
values,
66 template <
class T,
class U>
71 float dRmax,
float dxyMax,
float dzMax,
72 float dRvetoBarrel,
float dRvetoEndcap,
float ptMin);
170 (
"ebReducedRecHitCollection"));
172 (
"ebReducedRecHitCollectionMiniAOD"));
175 (
"eeReducedRecHitCollection"));
177 (
"eeReducedRecHitCollectionMiniAOD"));
183 (
"esReducedRecHitCollection"));
185 (
"esReducedRecHitCollectionMiniAOD"));
249 const float coneSizeDR = 0.3;
250 const float dxyMax = 0.1;
251 const float dzMax = 0.2;
263 <<
"DataFormat does not contain a photon source!";
293 if( !vertices.isValid() )
295 if (vertices->empty())
return;
307 if( !pfCandidatesHandle.
isValid() )
310 if( !isAOD && !src->empty() ) {
312 if(
test.isNull() || !
test.isAvailable() ) {
314 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
320 std::vector<float> phoFull5x5SigmaIEtaIEta;
321 std::vector<float> phoFull5x5SigmaIEtaIPhi;
322 std::vector<float> phoFull5x5E1x3;
323 std::vector<float> phoFull5x5E2x2;
324 std::vector<float> phoFull5x5E2x5Max;
325 std::vector<float> phoFull5x5E5x5;
326 std::vector<float> phoESEffSigmaRR;
328 std::vector<float> phoFull5x5E1x3byE5x5;
329 std::vector<float> phoFull5x5E2x2byE5x5;
330 std::vector<float> phoFull5x5E2x5byE5x5;
336 std::vector<float> phoWorstChargedIsolationWithConeVeto;
337 std::vector<float> phoWorstChargedIsolationWithPVConstraint;
338 std::vector<float> phoWorstChargedIsolationWithConeVetoWithPVConstraint;
341 std::vector<float> phoTrkIsolation;
342 std::vector<float> phoHcalPFClIsolation;
343 std::vector<float> phoEcalPFClIsolation;
346 for (
unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
347 const auto& iPho = src->ptrAt(idxpho);
352 const auto& theseed = *(iPho->superCluster()->seed());
359 std::vector<float> vCov =
lazyToolnoZS->localCovariances( theseed );
360 see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
362 phoFull5x5SigmaIEtaIEta.push_back(see);
363 phoFull5x5SigmaIEtaIPhi.push_back(sep);
365 phoFull5x5E1x3 .push_back(
lazyToolnoZS-> e1x3 (theseed) );
366 phoFull5x5E2x2 .push_back(
lazyToolnoZS-> e2x2 (theseed) );
367 phoFull5x5E2x5Max.push_back(
lazyToolnoZS-> e2x5Max(theseed) );
370 phoFull5x5E1x3byE5x5.push_back(phoFull5x5E1x3[idxpho]/phoFull5x5E5x5[idxpho]);
371 phoFull5x5E2x2byE5x5.push_back(phoFull5x5E2x2[idxpho]/phoFull5x5E5x5[idxpho]);
372 phoFull5x5E2x5byE5x5.push_back(phoFull5x5E2x5Max[idxpho]/phoFull5x5E5x5[idxpho]);
374 phoESEffSigmaRR .push_back(
lazyToolnoZS->eseffsirir( *(iPho->superCluster()) ) );
382 iPho->superCluster()->y() - pv.
y(),
383 iPho->superCluster()->z() - pv.
z());
386 phoTrkIsolation .push_back( iPho->trkSumPtSolidConeDR04());
389 phoHcalPFClIsolation .push_back(0.
f);
390 phoEcalPFClIsolation .push_back(0.
f);
395 phoHcalPFClIsolation .push_back(
patPhotonPtr->hcalPFClusterIso());
396 phoEcalPFClIsolation .push_back(
patPhotonPtr->ecalPFClusterIso());
401 float chargedIsoSum = 0;
402 float neutralHadronIsoSum = 0;
403 float photonIsoSum = 0;
406 for (
unsigned idxcand = 0; idxcand < pfCandidatesHandle->size(); ++idxcand ){
410 const auto& iCand = pfCandidatesHandle->ptrAt(idxcand);
427 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(),photon_directionWrtVtx.Phi(),
428 iCand->eta(), iCand->phi());
429 if( dR2 > coneSizeDR*coneSizeDR )
continue;
432 bool inFootprint =
false;
434 inFootprint =
isInFootprint( (*particleBasedIsolationMap)[iPho], iCand );
440 if( inFootprint )
continue;
449 float dxy = -999,
dz=-999;
453 if(fabs(dxy) > dxyMax)
continue;
454 if (fabs(
dz) > dzMax)
continue;
457 chargedIsoSum += iCand->pt();
461 neutralHadronIsoSum += iCand->pt();
464 photonIsoSum += iCand->pt();
467 phoChargedIsolation .push_back( chargedIsoSum );
468 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
469 phoPhotonIsolation .push_back( photonIsoSum );
473 float dRvetoBarrel = 0.0;
474 float dRvetoEndcap = 0.0;
476 bool isPVConstraint=
false;
477 float worstChargedIso =
479 isAOD, isPVConstraint,pv,coneSizeDR, dxyMax, dzMax,
480 dRvetoBarrel, dRvetoEndcap, ptMin);
481 phoWorstChargedIsolation .push_back( worstChargedIso );
488 float worstChargedIsoWithConeVeto =
490 isAOD, isPVConstraint,pv, coneSizeDR, dxyMax, dzMax,
491 dRvetoBarrel, dRvetoEndcap, ptMin);
492 phoWorstChargedIsolationWithConeVeto .push_back( worstChargedIsoWithConeVeto );
495 float worstChargedIsoWithPVConstraint =
497 isAOD, isPVConstraint,pv,coneSizeDR, dxyMax, dzMax,
498 dRvetoBarrel, dRvetoEndcap, ptMin);
499 phoWorstChargedIsolationWithPVConstraint .push_back( worstChargedIsoWithPVConstraint );
506 float worstChargedIsoWithConeVetoWithPVConstraint =
508 isAOD,isPVConstraint, pv, coneSizeDR, dxyMax, dzMax,
509 dRvetoBarrel, dRvetoEndcap, ptMin);
510 phoWorstChargedIsolationWithConeVetoWithPVConstraint .push_back( worstChargedIsoWithConeVetoWithPVConstraint );
545 const std::vector<float> &
values,
550 auto valMap = std::make_unique<ValueMap<float>>();
552 filler.insert(
handle, values.begin(), values.end());
567 template <
class T,
class U>
572 float dRmax,
float dxyMax,
float dzMax,
573 float dRvetoBarrel,
float dRvetoEndcap,
float ptMin){
576 float worstIsolation = 999;
577 std::vector<float> allIsolations;
581 dRveto = dRvetoBarrel;
583 dRveto = dRvetoEndcap;
586 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
590 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
591 photon->superCluster()->y() - vtx->y(),
592 photon->superCluster()->z() - vtx->z());
596 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
598 const auto& iCand = pfCandidates->ptrAt(
i);
605 if (iCand->pt() <
ptMin)
608 float dxy=-999,
dz=-999;
614 if( fabs(dxy) > dxyMax)
continue;
615 if ( fabs(
dz) > dzMax)
continue;
617 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
618 iCand->eta(), iCand->phi());
619 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
624 allIsolations.push_back(sum);
627 if( !allIsolations.empty() )
628 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
630 return worstIsolation;
640 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
647 else if(
abs(pdgId) == 130)
649 else if(
abs(pdgId) == 211)
652 return thisCandidateType;
660 theTrack = &*( ((
const recoCandPtr) candidate)->trackRef());
662 theTrack = &( ((
const patCandPtr) candidate)->pseudoTrack());
669 float &
dxy,
float &
dz){
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
~PhotonIDValueMapProducer() override
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Photon > > &handle, const std::vector< float > &values, const std::string &label) const
static char phoFull5x5E2x2byE5x5_[]
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
const reco::Track * getTrackPointer(const edm::Ptr< reco::Candidate > candidate, bool isAOD)
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParticleType
particle types
edm::EDGetTokenT< reco::VertexCollection > vtxTokenMiniAOD_
static char phoHcalPFClIsolation_[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< noZS::EcalClusterLazyTools > lazyToolnoZS
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionMiniAOD_
#define DEFINE_FWK_MODULE(type)
double y() const
y coordinate
reco::PFCandidate::ParticleType candidatePdgId(const edm::Ptr< reco::Candidate > candidate, bool isAOD)
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
edm::EDGetToken srcMiniAOD_
PhotonIDValueMapProducer(const edm::ParameterSet &)
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
static char phoChargedIsolation_[]
static char phoFull5x5E2x5byE5x5_[]
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationTokenMiniAOD_
static char phoFull5x5E2x2_[]
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
const Point & position() const
position
static char phoFull5x5E1x3_[]
static char phoFull5x5E2x5Max_[]
static char phoWorstChargedIsolation_[]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesTokenMiniAOD_
void addDefault(ParameterSetDescription const &psetDescription)
static char phoFull5x5E5x5_[]
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
static char phoEcalPFClIsolation_[]
static char phoNeutralHadronIsolation_[]
bool isInFootprint(const T &thefootprint, const U &theCandidate)
edm::Ptr< pat::PackedCandidate > patCandPtr
Abs< T >::type abs(const T &t)
double z() const
z coordinate
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesToken_
void produce(edm::Event &, const edm::EventSetup &) override
static char phoFull5x5E1x3byE5x5_[]
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double x() const
x coordinate
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static char phoPhotonIsolation_[]
static char phoTrkIsolation_[]
static char phoFull5x5SigmaIEtaIPhi_[]
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
static char phoWorstChargedIsolationWithConeVetoWithPVConstraint_[]
float computeWorstPFChargedIsolation(const T &photon, const U &pfCandidates, const edm::Handle< reco::VertexCollection > vertices, bool isAOD, bool isPVConstraint, const reco::Vertex &pv, float dRmax, float dxyMax, float dzMax, float dRvetoBarrel, float dRvetoEndcap, float ptMin)
edm::Ptr< pat::Photon > patPhotonPtr
static char phoESEffSigmaRR_[]
static char phoWorstChargedIsolationWithPVConstraint_[]
static char phoFull5x5SigmaIEtaIEta_[]
virtual float dxy() const
dxy with respect to the PV ref
void getImpactParameters(const edm::Ptr< reco::Candidate > &candidate, bool isAOD, const reco::Vertex &pv, float &dxy, float &dz)
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
edm::Ptr< reco::PFCandidate > recoCandPtr
phoNeutralHadronIsolation
static char phoWorstChargedIsolationWithConeVeto_[]