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);
141 (
"ebReducedRecHitCollection"));
143 (
"ebReducedRecHitCollectionMiniAOD"));
146 (
"eeReducedRecHitCollection"));
148 (
"eeReducedRecHitCollectionMiniAOD"));
154 (
"esReducedRecHitCollection"));
156 (
"esReducedRecHitCollectionMiniAOD"));
207 const float coneSizeDR = 0.3;
208 const float dxyMax = 0.1;
209 const float dzMax = 0.2;
221 <<
"DataFormat does not contain a photon source!";
251 if( !vertices.isValid() )
253 if (vertices->empty())
return;
265 if( !pfCandidatesHandle.
isValid() )
268 if( !isAOD && src->size() ) {
270 if(
test.isNull() || !
test.isAvailable() ) {
272 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
278 std::vector<float> phoFull5x5SigmaIEtaIEta;
279 std::vector<float> phoFull5x5SigmaIEtaIPhi;
280 std::vector<float> phoFull5x5E1x3;
281 std::vector<float> phoFull5x5E2x2;
282 std::vector<float> phoFull5x5E2x5Max;
283 std::vector<float> phoFull5x5E5x5;
284 std::vector<float> phoESEffSigmaRR;
292 for (
unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
293 const auto& iPho = src->ptrAt(idxpho);
298 const auto& theseed = *(iPho->superCluster()->seed());
305 std::vector<float> vCov =
lazyToolnoZS->localCovariances( theseed );
306 see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
308 phoFull5x5SigmaIEtaIEta.push_back(see);
309 phoFull5x5SigmaIEtaIPhi.push_back(sep);
311 phoFull5x5E1x3 .push_back(
lazyToolnoZS-> e1x3 (theseed) );
312 phoFull5x5E2x2 .push_back(
lazyToolnoZS-> e2x2 (theseed) );
313 phoFull5x5E2x5Max.push_back(
lazyToolnoZS-> e2x5Max(theseed) );
316 phoESEffSigmaRR .push_back(
lazyToolnoZS->eseffsirir( *(iPho->superCluster()) ) );
324 iPho->superCluster()->y() - pv.
y(),
325 iPho->superCluster()->z() - pv.
z());
328 float chargedIsoSum = 0;
329 float neutralHadronIsoSum = 0;
330 float photonIsoSum = 0;
333 for (
unsigned idxcand = 0; idxcand < pfCandidatesHandle->size(); ++idxcand ){
337 const auto& iCand = pfCandidatesHandle->ptrAt(idxcand);
354 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(),photon_directionWrtVtx.Phi(),
355 iCand->eta(), iCand->phi());
356 if( dR2 > coneSizeDR*coneSizeDR )
continue;
359 bool inFootprint =
false;
361 inFootprint =
isInFootprint( (*particleBasedIsolationMap)[iPho], iCand );
367 if( inFootprint )
continue;
379 if(fabs(dxy) > dxyMax)
continue;
382 if (fabs(dz) >
dzMax)
continue;
385 chargedIsoSum += iCand->pt();
389 neutralHadronIsoSum += iCand->pt();
392 photonIsoSum += iCand->pt();
395 phoChargedIsolation .push_back( chargedIsoSum );
396 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
397 phoPhotonIsolation .push_back( photonIsoSum );
399 float worstChargedIso =
401 isAOD, coneSizeDR, dxyMax, dzMax);
402 phoWorstChargedIsolation .push_back( worstChargedIso );
424 const std::vector<float> &
values,
429 auto valMap = std::make_unique<ValueMap<float>>();
431 filler.insert(
handle, values.begin(), values.end());
446 template <
class T,
class U>
451 float dRmax,
float dxyMax,
float dzMax){
453 float worstIsolation = 999;
454 std::vector<float> allIsolations;
458 const float dRvetoBarrel = 0.0;
459 const float dRvetoEndcap = 0.0;
460 const float ptMin = 0.0;
464 dRveto = dRvetoBarrel;
466 dRveto = dRvetoEndcap;
469 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
473 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
474 photon->superCluster()->y() - vtx->y(),
475 photon->superCluster()->z() - vtx->z());
479 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
481 const auto& iCand = pfCandidates->ptrAt(
i);
488 if (iCand->pt() <
ptMin)
492 float dxy = theTrack->
dxy(vtx->position());
493 if( fabs(dxy) > dxyMax)
continue;
495 float dz = theTrack->
dz(vtx->position());
496 if ( fabs(dz) >
dzMax)
continue;
498 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
499 iCand->eta(), iCand->phi());
500 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
505 allIsolations.push_back(sum);
508 if( allIsolations.size()>0 )
509 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
511 return worstIsolation;
520 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
527 else if(
abs(pdgId) == 130)
529 else if(
abs(pdgId) == 211)
532 return thisCandidateType;
540 theTrack = &*( ((
const recoCandPtr) candidate)->trackRef());
542 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_
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
float computeWorstPFChargedIsolation(const T &photon, const U &pfCandidates, const edm::Handle< reco::VertexCollection > vertices, bool isAOD, float dRmax, float dxyMax, float dzMax)
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