50 const auto v = position - origin;
65 if ( reconstructionStep_ ==
"final" ) {
119 const std::vector<std::string> flagnamesEB =
120 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEB");
122 const std::vector<std::string> flagnamesEE =
123 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEE");
126 StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
129 StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
131 const std::vector<std::string> severitynamesEB =
132 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEB");
135 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
137 const std::vector<std::string> severitynamesEE =
138 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEE");
141 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
147 thePhotonEnergyCorrector_->gedRegression()->setConsumes(sumes);
190 if ( reconstructionStep_ !=
"final"){
237 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
242 bool validPhotonCoreHandle=
false;
244 bool validPhotonHandle=
false;
257 if ( photonHandle.isValid()) {
258 validPhotonHandle=
true;
265 if (photonCoreHandle.isValid()) {
266 validPhotonCoreHandle=
true;
274 bool validEcalRecHits=
true;
278 if (!barrelHitHandle.isValid()) {
280 <<
"Error! Can't get the barrelEcalHits";
282 const EcalRecHitCollection& barrelRecHits(validEcalRecHits ? *(barrelHitHandle.product()) : dummyEB);
287 if (!endcapHitHandle.isValid()) {
289 <<
"Error! Can't get the endcapEcalHits";
291 const EcalRecHitCollection& endcapRecHits(validEcalRecHits ? *(endcapHitHandle.product()) : dummyEE);
293 bool validPreshowerRecHits=
true;
297 if (!preshowerHitHandle.isValid()) {
299 <<
"Error! Can't get the preshowerEcalHits";
301 if( validPreshowerRecHits ) preshowerRecHits = *(preshowerHitHandle.product());
308 if (!pfEGCandidateHandle.isValid()) {
310 <<
"Error! Can't get the pfEgammaCandidates";
318 if (!pfCandidateHandle.isValid()) {
320 <<
"Error! Can't get the pfCandidates";
350 bool validVertex=
true;
353 if (!vertexHandle.isValid()) {
355 <<
"Error! Can't get the product primary Vertex Collection";
373 if ( validPhotonCoreHandle)
384 outputPhotonCollection,
396 outputPhotonCollection,
398 phoChargedIsolationMap_CITK,
399 phoNeutralHadronIsolationMap_CITK,
400 phoPhotonIsolationMap_CITK);
405 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
406 outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
412 auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
414 unsigned nObj = pfEGCandidateHandle->size();
415 std::vector<reco::PhotonRef>
values(nObj);
417 for(
unsigned int lCand=0; lCand < nObj; lCand++) {
421 for(
unsigned int lSC=0; lSC < photonOrphHandle->size(); lSC++) {
424 if ( pfScRef != scRef )
continue;
425 values[lCand] = photonRef;
430 filler.insert(pfEGCandidateHandle,values.begin(),values.end());
458 std::vector<double> preselCutValues;
459 std::vector<int> flags_, severitiesexcl_;
461 for(
unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
472 int thedet = scRef->seed()->hitsAndFractions()[0].first.det();
473 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
476 hits = ecalBarrelHits;
481 hits = ecalEndcapHits;
490 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' ' << subdet;
498 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
504 double HoE1=towerIso1.
getTowerESum(&(*scRef))/scRef->energy();
505 double HoE2=towerIso2.
getTowerESum(&(*scRef))/scRef->energy();
509 std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
510 float hcalDepth1OverEcalBc = towerIsoBehindClus.
getDepth1HcalESum(TowersBehindClus)/scRef->energy();
511 float hcalDepth2OverEcalBc = towerIsoBehindClus.
getDepth2HcalESum(TowersBehindClus)/scRef->energy();
515 float maxXtal = ( hits !=
nullptr ? EcalClusterTools::eMax( *(scRef->seed()), &(*hits) ) : 0.
f );
518 float e1x5 = ( hits !=
nullptr ? EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
519 float e2x5 = ( hits !=
nullptr ? EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
520 float e3x3 = ( hits !=
nullptr ? EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
521 float e5x5 = ( hits !=
nullptr ? EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
522 std::vector<float> cov = ( hits !=
nullptr ? EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology),
geometry) : std::vector<float>( {0.f,0.f,0.f} ) );
523 std::vector<float> locCov = ( hits !=
nullptr ? EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology)) : std::vector<float>( {0.f,0.f,0.f} ) );
525 float sigmaEtaEta =
sqrt(cov[0]);
526 float sigmaIetaIeta =
sqrt(locCov[0]);
538 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
539 float full5x5_sigmaIetaIeta =
sqrt(full5x5_locCov[0]);
546 double photonEnergy=1.;
548 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
567 newCandidate.setFiducialVolumeFlags( fiducialFlags );
568 newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
573 showerShape.
e1x5= e1x5;
574 showerShape.
e2x5= e2x5;
575 showerShape.
e3x3= e3x3;
576 showerShape.
e5x5= e5x5;
587 const float sep = locCov[1];
590 showerShape.
e2nd = ( hits !=
nullptr ? EcalClusterTools::e2nd(*(scRef->seed()),&(*hits)) : 0.
f );
591 showerShape.
eTop = ( hits !=
nullptr ? EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
592 showerShape.
eLeft = ( hits !=
nullptr ? EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
593 showerShape.
eRight = ( hits !=
nullptr ? EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
594 showerShape.
eBottom = ( hits !=
nullptr ? EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
595 showerShape.
e1x3 = ( hits !=
nullptr ? EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
596 showerShape.
e2x2 = ( hits !=
nullptr ? EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
597 showerShape.
e2x5Max = ( hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
598 showerShape.
e2x5Left = ( hits !=
nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
599 showerShape.
e2x5Right = ( hits !=
nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
600 showerShape.
e2x5Top = ( hits !=
nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
601 showerShape.
e2x5Bottom = ( hits !=
nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.
f );
604 const float sigmaRR = toolsforES.eseffsirir( *scRef );
606 newCandidate.setShowerShapeVariables ( showerShape );
610 full5x5_showerShape.
e1x5= full5x5_e1x5;
611 full5x5_showerShape.
e2x5= full5x5_e2x5;
612 full5x5_showerShape.
e3x3= full5x5_e3x3;
613 full5x5_showerShape.
e5x5= full5x5_e5x5;
615 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
618 const float full5x5_spp = (!
edm::isFinite(full5x5_locCov[2]) ? 0. :
sqrt(full5x5_locCov[2]));
619 const float full5x5_sep = full5x5_locCov[1];
636 newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
674 newCandidate.setMIPVariables(mipVar);
681 if ( newCandidate.pt() <
highEt_) {
682 if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
683 if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=
false;
684 if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=
false;
685 if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
686 if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=
false;
687 if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=
false;
688 if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=
false;
689 if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
695 outputPhotonCollection.push_back(newCandidate);
715 std::vector<double> preselCutValues;
718 for(
unsigned int lSC=0; lSC < photonHandle->size(); lSC++) {
722 int thedet = scRef->seed()->hitsAndFractions()[0].first.det();
723 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
731 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' ' << subdet;
738 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
752 pfIso.
photonIso = (*photons_)[photonPtr];
780 outputPhotonCollection.push_back(newCandidate);
edm::InputTag photonProducer_
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
T getParameter(std::string const &) const
PhotonEnergyCorrector * thePhotonEnergyCorrector_
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
virtual void endRun(edm::Run const &, edm::EventSetup const &) overridefinal
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void calculate(const reco::Photon *, const edm::Event &, const edm::EventSetup &es, reco::Photon::FiducialFlags &phofid, reco::Photon::IsolationVariables &phoisolR03, reco::Photon::IsolationVariables &phoisolR04) const
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
edm::ESHandle< CaloGeometry > theCaloGeom_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::vector< CaloTowerDetId > hcalTowersBehindClusters
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setCandidateP4type(const P4type type)
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void produce(edm::Event &evt, const edm::EventSetup &es) override
float hcalDepth2OverEcalBc
edm::EDGetTokenT< edm::ValueMap< float > > phoPhotonIsolationToken_CITK
std::vector< int > flagsexclEB_
std::vector< Vertex > VertexCollection
collection of Vertex objects
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::string reconstructionStep_
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEE_
std::unique_ptr< ModifyObjectValueBase > & gedRegression()
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
std::string photonCollection_
edm::ESHandle< CaloTopology > theCaloTopo_
void setTowerCollection(const CaloTowerCollection *towercollection)
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
PositionCalc posCalculator_
double getDepth1HcalESum(const reco::SuperCluster &sc) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void setup(const edm::ParameterSet &conf, std::vector< int > const &flagsEB_, std::vector< int > const &flagsEE_, std::vector< int > const &severitiesEB_, std::vector< int > const &severitiesEE_, edm::ConsumesCollector &&iC)
void setPflowIDVariables(const PflowIDVariables &pfid)
std::vector< int > flagsexclEE_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedIsolationToken_CITK
void init(const edm::EventSetup &theEventSetup)
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
double getTowerESum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
std::vector< int > severitiesexclEB_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
GEDPhotonProducer(const edm::ParameterSet &ps)
float hcalDepth1OverEcalBc
T const * product() const
std::vector< double > preselCutValuesBarrel_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< Photon > PhotonCollection
collectin of Photon objects
std::vector< double > preselCutValuesEndcap_
T const * product() const
const LorentzVector & p4(P4type type) const
std::string candidateP4type_
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, const EcalRecHitCollection *preshowerHits, const edm::Handle< CaloTowerCollection > &hcalTowersHandle, const reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
edm::EDGetTokenT< edm::ValueMap< float > > phoNeutralHadronIsolationToken_CITK
double getDepth2HcalESum(const reco::SuperCluster &sc) const
ESHandle< TrackerGeometry > geometry
static int position[264][3]
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< EcalRecHitCollection > preshowerHits_
void setP4(P4type type, const LorentzVector &p4, float p4Error, bool setToRecoCandidate)
std::string valueMapPFCandPhoton_