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->size() ) {
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;
384 if(fabs(dxy) > dxyMax)
continue;
387 if (fabs(dz) >
dzMax)
continue;
390 chargedIsoSum += iCand->pt();
394 neutralHadronIsoSum += iCand->pt();
397 photonIsoSum += iCand->pt();
400 phoChargedIsolation .push_back( chargedIsoSum );
401 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
402 phoPhotonIsolation .push_back( photonIsoSum );
406 float dRvetoBarrel = 0.0;
407 float dRvetoEndcap = 0.0;
409 float worstChargedIso =
411 isAOD, coneSizeDR, dxyMax, dzMax,
412 dRvetoBarrel, dRvetoEndcap, ptMin);
413 phoWorstChargedIsolation .push_back( worstChargedIso );
420 float worstChargedIsoWithConeVeto =
422 isAOD, coneSizeDR, dxyMax, dzMax,
423 dRvetoBarrel, dRvetoEndcap, ptMin);
424 phoWorstChargedIsolationWithConeVeto .push_back( worstChargedIsoWithConeVeto );
448 const std::vector<float> &
values,
453 auto valMap = std::make_unique<ValueMap<float>>();
455 filler.insert(
handle, values.begin(), values.end());
470 template <
class T,
class U>
475 float dRmax,
float dxyMax,
float dzMax,
476 float dRvetoBarrel,
float dRvetoEndcap,
float ptMin){
479 float worstIsolation = 999;
480 std::vector<float> allIsolations;
484 dRveto = dRvetoBarrel;
486 dRveto = dRvetoEndcap;
489 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
493 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
494 photon->superCluster()->y() - vtx->y(),
495 photon->superCluster()->z() - vtx->z());
499 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
501 const auto& iCand = pfCandidates->ptrAt(
i);
508 if (iCand->pt() <
ptMin)
512 float dxy = theTrack->
dxy(vtx->position());
513 if( fabs(dxy) > dxyMax)
continue;
515 float dz = theTrack->
dz(vtx->position());
516 if ( fabs(dz) >
dzMax)
continue;
518 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
519 iCand->eta(), iCand->phi());
520 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
525 allIsolations.push_back(sum);
528 if( allIsolations.size()>0 )
529 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
531 return worstIsolation;
540 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
547 else if(
abs(pdgId) == 130)
549 else if(
abs(pdgId) == 211)
552 return thisCandidateType;
560 theTrack = &*( ((
const recoCandPtr) candidate)->trackRef());
562 theTrack = &( ((
const patCandPtr) candidate)->pseudoTrack());
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_
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
Abs< T >::type abs(const T &t)
double z() const
z coordinate
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCandidatesToken_
virtual 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_
~PhotonIDValueMapProducer()
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
edm::Ptr< pat::Photon > patPhotonPtr
static char phoESEffSigmaRR_[]
static char phoFull5x5SigmaIEtaIEta_[]
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_[]