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);
138 (
"ebReducedRecHitCollection"));
140 (
"ebReducedRecHitCollectionMiniAOD"));
143 (
"eeReducedRecHitCollection"));
145 (
"eeReducedRecHitCollectionMiniAOD"));
148 (
"esReducedRecHitCollection"));
150 (
"esReducedRecHitCollectionMiniAOD"));
197 const float coneSizeDR = 0.3;
198 const float dxyMax = 0.1;
199 const float dzMax = 0.2;
205 if( !
src.isValid() ){
209 if( !
src.isValid() ) {
211 <<
"DataFormat does not contain a photon source!";
243 if( !pfCandidatesHandle.isValid() )
246 if( !isAOD &&
src->size() ) {
248 if(
test.isNull() || !
test.isAvailable() ) {
250 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
256 std::vector<float> phoFull5x5SigmaIEtaIEta;
257 std::vector<float> phoFull5x5SigmaIEtaIPhi;
258 std::vector<float> phoFull5x5E1x3;
259 std::vector<float> phoFull5x5E2x2;
260 std::vector<float> phoFull5x5E2x5Max;
261 std::vector<float> phoFull5x5E5x5;
262 std::vector<float> phoESEffSigmaRR;
264 std::vector<float> phoChargedIsolation;
265 std::vector<float> phoNeutralHadronIsolation;
266 std::vector<float> phoPhotonIsolation;
267 std::vector<float> phoWorstChargedIsolation;
270 for (
unsigned idxpho = 0; idxpho <
src->size(); ++idxpho) {
271 const auto& iPho =
src->ptrAt(idxpho);
276 const auto& theseed = *(iPho->superCluster()->seed());
283 std::vector<float> vCov =
lazyToolnoZS->localCovariances( theseed );
284 see = (
isnan(vCov[0]) ? 0. :
sqrt(vCov[0]));
286 phoFull5x5SigmaIEtaIEta.push_back(see);
287 phoFull5x5SigmaIEtaIPhi.push_back(sep);
289 phoFull5x5E1x3 .push_back(
lazyToolnoZS-> e1x3 (theseed) );
290 phoFull5x5E2x2 .push_back(
lazyToolnoZS-> e2x2 (theseed) );
291 phoFull5x5E2x5Max.push_back(
lazyToolnoZS-> e2x5Max(theseed) );
292 phoFull5x5E5x5 .push_back(
lazyToolnoZS-> e5x5 (theseed) );
294 phoESEffSigmaRR .push_back(
lazyToolnoZS->eseffsirir( *(iPho->superCluster()) ) );
302 iPho->superCluster()->y() -
pv.y(),
303 iPho->superCluster()->z() -
pv.z());
306 float chargedIsoSum = 0;
307 float neutralHadronIsoSum = 0;
308 float photonIsoSum = 0;
311 for (
unsigned idxcand = 0; idxcand < pfCandidatesHandle->size(); ++idxcand ){
315 const auto& iCand = pfCandidatesHandle->ptrAt(idxcand);
332 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(),photon_directionWrtVtx.Phi(),
333 iCand->eta(), iCand->phi());
334 if( dR2 > coneSizeDR*coneSizeDR )
continue;
337 bool inFootprint =
false;
339 inFootprint =
isInFootprint( (*particleBasedIsolationMap)[iPho], iCand );
342 inFootprint =
isInFootprint(patPhotonPtr->associatedPackedPFCandidates(), iCand);
345 if( inFootprint )
continue;
356 float dxy = theTrack->
dxy(
pv.position());
357 if(fabs(dxy) > dxyMax)
continue;
359 float dz = theTrack->
dz(
pv.position());
360 if (fabs(dz) >
dzMax)
continue;
363 chargedIsoSum += iCand->pt();
367 neutralHadronIsoSum += iCand->pt();
370 photonIsoSum += iCand->pt();
373 phoChargedIsolation .push_back( chargedIsoSum );
374 phoNeutralHadronIsolation.push_back( neutralHadronIsoSum );
375 phoPhotonIsolation .push_back( photonIsoSum );
377 float worstChargedIso =
379 isAOD, coneSizeDR, dxyMax,
dzMax);
380 phoWorstChargedIsolation .push_back( worstChargedIso );
402 const std::vector<float> &
values,
411 iEvent.
put(valMap, label);
424 template <
class T,
class U>
429 float dRmax,
float dxyMax,
float dzMax){
431 float worstIsolation = 999;
432 std::vector<float> allIsolations;
436 const float dRvetoBarrel = 0.0;
437 const float dRvetoEndcap = 0.0;
438 const float ptMin = 0.0;
442 dRveto = dRvetoBarrel;
444 dRveto = dRvetoEndcap;
447 for(
unsigned int ivtx=0; ivtx<vertices->size(); ++ivtx) {
451 math::XYZVector photon_directionWrtVtx(photon->superCluster()->x() - vtx->x(),
452 photon->superCluster()->y() - vtx->y(),
453 photon->superCluster()->z() - vtx->z());
457 for(
unsigned i=0;
i<pfCandidates->size();
i++) {
459 const auto& iCand = pfCandidates->ptrAt(
i);
466 if (iCand->pt() <
ptMin)
470 float dxy = theTrack->
dxy(vtx->position());
471 if( fabs(dxy) > dxyMax)
continue;
473 float dz = theTrack->
dz(vtx->position());
474 if ( fabs(dz) >
dzMax)
continue;
476 float dR2 =
deltaR2(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(),
477 iCand->eta(), iCand->phi());
478 if(dR2 > dRmax*dRmax || dR2 < dRveto*dRveto)
continue;
483 allIsolations.push_back(sum);
486 if( allIsolations.size()>0 )
487 worstIsolation = * std::max_element( allIsolations.begin(), allIsolations.end() );
489 return worstIsolation;
498 thisCandidateType = ( (
const recoCandPtr)candidate)->particleId();
505 else if(
abs(pdgId) == 130)
507 else if(
abs(pdgId) == 211)
510 return thisCandidateType;
518 theTrack = &*( ((
const recoCandPtr) candidate)->trackRef());
520 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_
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)
reco::PFCandidate::ParticleType candidatePdgId(const edm::Ptr< reco::Candidate > candidate, bool isAOD)
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
edm::EDGetToken srcMiniAOD_
void insert(const H &h, I begin, I end)
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_[]
EcalClusterLazyToolsT< noZS::EcalClusterTools > EcalClusterLazyTools
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
static char phoFull5x5E1x3_[]
static char phoFull5x5E2x5Max_[]
static char phoWorstChargedIsolation_[]
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
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_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
static char phoNeutralHadronIsolation_[]
bool isInFootprint(const T &thefootprint, const U &theCandidate)
edm::Ptr< pat::PackedCandidate > patCandPtr
Abs< T >::type abs(const T &t)
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...
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)
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