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);
144 (
"ebReducedRecHitCollection"));
146 (
"ebReducedRecHitCollectionMiniAOD"));
149 (
"eeReducedRecHitCollection"));
151 (
"eeReducedRecHitCollectionMiniAOD"));
157 (
"esReducedRecHitCollection"));
159 (
"esReducedRecHitCollectionMiniAOD"));
211 const float coneSizeDR = 0.3;
212 const float dxyMax = 0.1;
213 const float dzMax = 0.2;
225 <<
"DataFormat does not contain a photon source!";
255 if( !vertices.isValid() )
257 if (vertices->empty())
return;
269 if( !pfCandidatesHandle.
isValid() )
272 if( !isAOD && !src->empty() ) {
274 if(
test.isNull() || !
test.isAvailable() ) {
276 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
282 std::vector<float> phoFull5x5SigmaIEtaIEta;
283 std::vector<float> phoFull5x5SigmaIEtaIPhi;
284 std::vector<float> phoFull5x5E1x3;
285 std::vector<float> phoFull5x5E2x2;
286 std::vector<float> phoFull5x5E2x5Max;
287 std::vector<float> phoFull5x5E5x5;
288 std::vector<float> phoESEffSigmaRR;
294 std::vector<float> phoWorstChargedIsolationWithConeVeto;
297 for (
unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
298 const auto& iPho = src->ptrAt(idxpho);
303 const auto& theseed = *(iPho->superCluster()->seed());
310 std::vector<float> vCov =
lazyToolnoZS->localCovariances( theseed );
311 see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
313 phoFull5x5SigmaIEtaIEta.push_back(see);
314 phoFull5x5SigmaIEtaIPhi.push_back(sep);
316 phoFull5x5E1x3 .push_back(
lazyToolnoZS-> e1x3 (theseed) );
317 phoFull5x5E2x2 .push_back(
lazyToolnoZS-> e2x2 (theseed) );
318 phoFull5x5E2x5Max.push_back(
lazyToolnoZS-> e2x5Max(theseed) );
321 phoESEffSigmaRR .push_back(
lazyToolnoZS->eseffsirir( *(iPho->superCluster()) ) );
329 iPho->superCluster()->y() - pv.
y(),
330 iPho->superCluster()->z() - pv.
z());
333 float chargedIsoSum = 0;
334 float neutralHadronIsoSum = 0;
335 float photonIsoSum = 0;
338 for (
unsigned idxcand = 0; idxcand < pfCandidatesHandle->size(); ++idxcand ){
342 const auto& iCand = pfCandidatesHandle->ptrAt(idxcand);
359 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(),photon_directionWrtVtx.Phi(),
360 iCand->eta(), iCand->phi());
361 if( dR2 > coneSizeDR*coneSizeDR )
continue;
364 bool inFootprint =
false;
366 inFootprint =
isInFootprint( (*particleBasedIsolationMap)[iPho], iCand );
372 if( inFootprint )
continue;
383 if ( fabs(dxydz.first) > dxyMax)
continue;
384 if ( fabs(dxydz.second) >
dzMax)
continue;
387 chargedIsoSum += iCand->pt();
391 neutralHadronIsoSum += iCand->pt();
394 photonIsoSum += iCand->pt();
397 phoChargedIsolation .push_back( chargedIsoSum );
398 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
399 phoPhotonIsolation .push_back( photonIsoSum );
403 float dRvetoBarrel = 0.0;
404 float dRvetoEndcap = 0.0;
406 float worstChargedIso =
408 isAOD, coneSizeDR, dxyMax, dzMax,
409 dRvetoBarrel, dRvetoEndcap, ptMin);
410 phoWorstChargedIsolation .push_back( worstChargedIso );
417 float worstChargedIsoWithConeVeto =
419 isAOD, coneSizeDR, dxyMax, dzMax,
420 dRvetoBarrel, dRvetoEndcap, ptMin);
421 phoWorstChargedIsolationWithConeVeto .push_back( worstChargedIsoWithConeVeto );
445 const std::vector<float> &
values,
450 auto valMap = std::make_unique<ValueMap<float>>();
452 filler.insert(
handle, values.begin(), values.end());
467 template <
class T,
class U>
472 float dRmax,
float dxyMax,
float dzMax,
473 float dRvetoBarrel,
float dRvetoEndcap,
float ptMin){
476 float worstIsolation = 999;
477 std::vector<float> allIsolations;
481 dRveto = dRvetoBarrel;
483 dRveto = dRvetoEndcap;
486 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
490 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
491 photon->superCluster()->y() - vtx->y(),
492 photon->superCluster()->z() - vtx->z());
496 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
498 const auto& iCand = pfCandidates->ptrAt(
i);
505 if (iCand->pt() <
ptMin)
509 if ( fabs(dxydz.first) > dxyMax)
continue;
510 if ( fabs(dxydz.second) >
dzMax)
continue;
512 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
513 iCand->eta(), iCand->phi());
514 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
519 allIsolations.push_back(sum);
522 if( !allIsolations.empty() )
523 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
525 return worstIsolation;
534 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
541 else if(
abs(pdgId) == 130)
543 else if(
abs(pdgId) == 211)
546 return thisCandidateType;
549 std::pair<float,float>
554 return std::make_pair(theTrack.
dxy(vtxpos),theTrack.
dz(vtxpos));
557 return std::make_pair(theCand.
dxy(vtxpos),theCand.
dz(vtxpos));
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_
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_
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_
float computeWorstPFChargedIsolation(const T &photon, const U &pfCandidates, const edm::Handle< reco::VertexCollection > vertices, bool isAOD, float dRmax, float dxyMax, float dzMax, float dRvetoBarrel, float dRvetoEndcap, float ptMin)
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 phoNeutralHadronIsolation_[]
bool isInFootprint(const T &thefootprint, const U &theCandidate)
edm::Ptr< pat::PackedCandidate > patCandPtr
math::XYZPoint Point
point in the space
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 phoFull5x5SigmaIEtaIPhi_[]
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
edm::Ptr< pat::Photon > patPhotonPtr
static char phoESEffSigmaRR_[]
std::pair< float, float > getTrackDxyDz(const edm::Ptr< reco::Candidate > &candidate, const reco::Particle::Point &vtxpos, bool isAOD)
static char phoFull5x5SigmaIEtaIEta_[]
virtual float dxy() const
dxy with respect to the PV ref
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_[]