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 );
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_[]
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
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_
double y() const
y coordinate
reco::PFCandidate::ParticleType candidatePdgId(const edm::Ptr< reco::Candidate > candidate, bool isAOD)
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
edm::EDGetToken srcMiniAOD_
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
static char phoChargedIsolation_[]
static char phoFull5x5E2x5byE5x5_[]
static char phoFull5x5E2x2_[]
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
static char phoFull5x5E1x3_[]
static char phoFull5x5E2x5Max_[]
static char phoWorstChargedIsolation_[]
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesTokenMiniAOD_
static char phoFull5x5E5x5_[]
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
static char phoEcalPFClIsolation_[]
static char phoNeutralHadronIsolation_[]
bool isInFootprint(const T &thefootprint, const U &theCandidate)
double z() const
z coordinate
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesToken_
static char phoFull5x5E1x3byE5x5_[]
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_[]
void getImpactParameters(const edm::Ptr< reco::Candidate > &candidate, bool isAOD, const reco::Vertex &pv, float &dxy, float &dz)
phoNeutralHadronIsolation
static char phoWorstChargedIsolationWithConeVeto_[]