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);
162 (
"ebReducedRecHitCollection"));
164 (
"ebReducedRecHitCollectionMiniAOD"));
167 (
"eeReducedRecHitCollection"));
169 (
"eeReducedRecHitCollectionMiniAOD"));
175 (
"esReducedRecHitCollection"));
177 (
"esReducedRecHitCollectionMiniAOD"));
237 const float coneSizeDR = 0.3;
238 const float dxyMax = 0.1;
239 const float dzMax = 0.2;
251 <<
"DataFormat does not contain a photon source!";
281 if( !vertices.isValid() )
283 if (vertices->empty())
return;
295 if( !pfCandidatesHandle.
isValid() )
298 if( !isAOD && !src->empty() ) {
300 if(
test.isNull() || !
test.isAvailable() ) {
302 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
308 std::vector<float> phoFull5x5SigmaIEtaIEta;
309 std::vector<float> phoFull5x5SigmaIEtaIPhi;
310 std::vector<float> phoFull5x5E1x3;
311 std::vector<float> phoFull5x5E2x2;
312 std::vector<float> phoFull5x5E2x5Max;
313 std::vector<float> phoFull5x5E5x5;
314 std::vector<float> phoESEffSigmaRR;
320 std::vector<float> phoWorstChargedIsolationWithConeVeto;
321 std::vector<float> phoWorstChargedIsolationWithPVConstraint;
322 std::vector<float> phoWorstChargedIsolationWithConeVetoWithPVConstraint;
325 std::vector<float> phoTrkIsolation;
326 std::vector<float> phoHcalPFClIsolation;
327 std::vector<float> phoEcalPFClIsolation;
330 for (
unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
331 const auto& iPho = src->ptrAt(idxpho);
336 const auto& theseed = *(iPho->superCluster()->seed());
343 std::vector<float> vCov =
lazyToolnoZS->localCovariances( theseed );
344 see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
346 phoFull5x5SigmaIEtaIEta.push_back(see);
347 phoFull5x5SigmaIEtaIPhi.push_back(sep);
349 phoFull5x5E1x3 .push_back(
lazyToolnoZS-> e1x3 (theseed) );
350 phoFull5x5E2x2 .push_back(
lazyToolnoZS-> e2x2 (theseed) );
351 phoFull5x5E2x5Max.push_back(
lazyToolnoZS-> e2x5Max(theseed) );
354 phoESEffSigmaRR .push_back(
lazyToolnoZS->eseffsirir( *(iPho->superCluster()) ) );
362 iPho->superCluster()->y() - pv.
y(),
363 iPho->superCluster()->z() - pv.
z());
366 phoTrkIsolation .push_back( iPho->trkSumPtSolidConeDR04());
369 phoHcalPFClIsolation .push_back(0.
f);
370 phoEcalPFClIsolation .push_back(0.
f);
375 phoHcalPFClIsolation .push_back(
patPhotonPtr->hcalPFClusterIso());
376 phoEcalPFClIsolation .push_back(
patPhotonPtr->ecalPFClusterIso());
381 float chargedIsoSum = 0;
382 float neutralHadronIsoSum = 0;
383 float photonIsoSum = 0;
386 for (
unsigned idxcand = 0; idxcand < pfCandidatesHandle->size(); ++idxcand ){
390 const auto& iCand = pfCandidatesHandle->ptrAt(idxcand);
407 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(),photon_directionWrtVtx.Phi(),
408 iCand->eta(), iCand->phi());
409 if( dR2 > coneSizeDR*coneSizeDR )
continue;
412 bool inFootprint =
false;
414 inFootprint =
isInFootprint( (*particleBasedIsolationMap)[iPho], iCand );
420 if( inFootprint )
continue;
429 float dxy = -999,
dz=-999;
433 if(fabs(dxy) > dxyMax)
continue;
434 if (fabs(
dz) > dzMax)
continue;
437 chargedIsoSum += iCand->pt();
441 neutralHadronIsoSum += iCand->pt();
444 photonIsoSum += iCand->pt();
447 phoChargedIsolation .push_back( chargedIsoSum );
448 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
449 phoPhotonIsolation .push_back( photonIsoSum );
453 float dRvetoBarrel = 0.0;
454 float dRvetoEndcap = 0.0;
456 bool isPVConstraint=
false;
457 float worstChargedIso =
459 isAOD, isPVConstraint,pv,coneSizeDR, dxyMax, dzMax,
460 dRvetoBarrel, dRvetoEndcap, ptMin);
461 phoWorstChargedIsolation .push_back( worstChargedIso );
468 float worstChargedIsoWithConeVeto =
470 isAOD, isPVConstraint,pv, coneSizeDR, dxyMax, dzMax,
471 dRvetoBarrel, dRvetoEndcap, ptMin);
472 phoWorstChargedIsolationWithConeVeto .push_back( worstChargedIsoWithConeVeto );
475 float worstChargedIsoWithPVConstraint =
477 isAOD, isPVConstraint,pv,coneSizeDR, dxyMax, dzMax,
478 dRvetoBarrel, dRvetoEndcap, ptMin);
479 phoWorstChargedIsolationWithPVConstraint .push_back( worstChargedIsoWithPVConstraint );
486 float worstChargedIsoWithConeVetoWithPVConstraint =
488 isAOD,isPVConstraint, pv, coneSizeDR, dxyMax, dzMax,
489 dRvetoBarrel, dRvetoEndcap, ptMin);
490 phoWorstChargedIsolationWithConeVetoWithPVConstraint .push_back( worstChargedIsoWithConeVetoWithPVConstraint );
521 const std::vector<float> &
values,
526 auto valMap = std::make_unique<ValueMap<float>>();
528 filler.insert(
handle, values.begin(), values.end());
543 template <
class T,
class U>
548 float dRmax,
float dxyMax,
float dzMax,
549 float dRvetoBarrel,
float dRvetoEndcap,
float ptMin){
552 float worstIsolation = 999;
553 std::vector<float> allIsolations;
557 dRveto = dRvetoBarrel;
559 dRveto = dRvetoEndcap;
562 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
566 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
567 photon->superCluster()->y() - vtx->y(),
568 photon->superCluster()->z() - vtx->z());
572 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
574 const auto& iCand = pfCandidates->ptrAt(
i);
581 if (iCand->pt() <
ptMin)
584 float dxy=-999,
dz=-999;
590 if( fabs(dxy) > dxyMax)
continue;
591 if ( fabs(
dz) > dzMax)
continue;
593 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
594 iCand->eta(), iCand->phi());
595 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
600 allIsolations.push_back(sum);
603 if( !allIsolations.empty() )
604 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
606 return worstIsolation;
616 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
623 else if(
abs(pdgId) == 130)
625 else if(
abs(pdgId) == 211)
628 return thisCandidateType;
636 theTrack = &*( ((
const recoCandPtr) candidate)->trackRef());
638 theTrack = &( ((
const patCandPtr) candidate)->pseudoTrack());
645 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
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_[]
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
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
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)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
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_[]