49 const auto v = position - origin;
64 if ( reconstructionStep_ ==
"final" ) {
111 const std::vector<std::string> flagnamesEB =
112 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEB");
114 const std::vector<std::string> flagnamesEE =
115 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEE");
118 StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
121 StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
123 const std::vector<std::string> severitynamesEB =
124 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEB");
127 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
129 const std::vector<std::string> severitynamesEE =
130 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEE");
133 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
139 thePhotonEnergyCorrector_->gedRegression()->setConsumes(sumes);
182 if ( reconstructionStep_ !=
"final"){
242 bool validPhotonCoreHandle=
false;
244 bool validPhotonHandle=
false;
249 if ( photonHandle.isValid()) {
250 validPhotonHandle=
true;
257 if (photonCoreHandle.isValid()) {
258 validPhotonCoreHandle=
true;
266 bool validEcalRecHits=
true;
270 if (!barrelHitHandle.isValid()) {
271 validEcalRecHits=
false;
273 <<
"Error! Can't get the barrelEcalHits";
275 const EcalRecHitCollection& barrelRecHits(validEcalRecHits ? *(barrelHitHandle.product()) : dummyEB);
280 if (!endcapHitHandle.isValid()) {
281 validEcalRecHits=
false;
283 <<
"Error! Can't get the endcapEcalHits";
285 const EcalRecHitCollection& endcapRecHits(validEcalRecHits ? *(endcapHitHandle.product()) : dummyEE);
287 bool validPreshowerRecHits=
true;
291 if (!preshowerHitHandle.isValid()) {
292 validPreshowerRecHits=
false;
294 <<
"Error! Can't get the preshowerEcalHits";
296 if( validPreshowerRecHits ) preshowerRecHits = *(preshowerHitHandle.product());
303 if (!pfEGCandidateHandle.isValid()) {
305 <<
"Error! Can't get the pfEgammaCandidates";
313 if (!pfCandidateHandle.isValid()) {
315 <<
"Error! Can't get the pfCandidates";
345 bool validVertex=
true;
348 if (!vertexHandle.isValid()) {
351 <<
"Error! Can't get the product primary Vertex Collection";
369 if ( validPhotonCoreHandle)
380 outputPhotonCollection,
392 outputPhotonCollection,
398 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
399 outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
407 unsigned nObj = pfEGCandidateHandle->size();
408 std::vector<reco::PhotonRef>
values(nObj);
410 for(
unsigned int lCand=0; lCand < nObj; lCand++) {
414 for(
unsigned int lSC=0; lSC < photonOrphHandle->size(); lSC++) {
417 if ( pfScRef != scRef )
continue;
418 values[lCand] = photonRef;
423 filler.
insert(pfEGCandidateHandle,values.begin(),values.end());
451 std::vector<double> preselCutValues;
452 std::vector<int> flags_, severitiesexcl_;
454 for(
unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
465 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
468 hits = ecalBarrelHits;
473 hits = ecalEndcapHits;
477 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
485 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
491 double HoE1=towerIso1.
getTowerESum(&(*scRef))/scRef->energy();
492 double HoE2=towerIso2.
getTowerESum(&(*scRef))/scRef->energy();
496 std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
497 float hcalDepth1OverEcalBc = towerIsoBehindClus.
getDepth1HcalESum(TowersBehindClus)/scRef->energy();
498 float hcalDepth2OverEcalBc = towerIsoBehindClus.
getDepth2HcalESum(TowersBehindClus)/scRef->energy();
502 float maxXtal = EcalClusterTools::eMax( *(scRef->seed()), &(*hits) );
505 float e1x5 = EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology));
506 float e2x5 = EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology));
507 float e3x3 = EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology));
508 float e5x5 = EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology));
509 std::vector<float> cov = EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology),
geometry);
510 std::vector<float> locCov = EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology));
512 float sigmaEtaEta =
sqrt(cov[0]);
513 float sigmaIetaIeta =
sqrt(locCov[0]);
525 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
526 float full5x5_sigmaIetaIeta =
sqrt(full5x5_locCov[0]);
533 double photonEnergy=1.;
535 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
552 newCandidate.setFiducialVolumeFlags( fiducialFlags );
553 newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
557 showerShape.
e1x5= e1x5;
558 showerShape.
e2x5= e2x5;
559 showerShape.
e3x3= e3x3;
560 showerShape.
e5x5= e5x5;
571 const float sep = locCov[1];
574 showerShape.
e2nd = EcalClusterTools::e2nd(*(scRef->seed()),&(*hits));
575 showerShape.
eTop = EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology));
576 showerShape.
eLeft = EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology));
577 showerShape.
eRight = EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology));
578 showerShape.
eBottom = EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology));
579 showerShape.
e1x3 = EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology));
580 showerShape.
e2x2 = EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology));
581 showerShape.
e2x5Max = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
582 showerShape.
e2x5Left = EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology));
583 showerShape.
e2x5Right = EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology));
584 showerShape.
e2x5Top = EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology));
585 showerShape.
e2x5Bottom = EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology));
588 const float sigmaRR = toolsforES.eseffsirir( *scRef );
590 newCandidate.setShowerShapeVariables ( showerShape );
594 full5x5_showerShape.
e1x5= full5x5_e1x5;
595 full5x5_showerShape.
e2x5= full5x5_e2x5;
596 full5x5_showerShape.
e3x3= full5x5_e3x3;
597 full5x5_showerShape.
e5x5= full5x5_e5x5;
599 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
602 const float full5x5_spp = (!
edm::isFinite(full5x5_locCov[2]) ? 0. :
sqrt(full5x5_locCov[2]));
603 const float full5x5_sep = full5x5_locCov[1];
620 newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
656 newCandidate.setMIPVariables(mipVar);
663 if ( newCandidate.pt() <
highEt_) {
664 if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
665 if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=
false;
666 if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=
false;
667 if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
668 if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=
false;
669 if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=
false;
670 if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=
false;
671 if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
677 outputPhotonCollection.push_back(newCandidate);
697 std::vector<double> preselCutValues;
700 for(
unsigned int lSC=0; lSC < photonHandle->size(); lSC++) {
704 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
710 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
717 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
752 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
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
float hcalDepth2OverEcalBc
void insert(const H &h, I begin, I end)
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)
void setup(const edm::ParameterSet &conf)
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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)
PFPhotonIsolationCalculator * thePFBasedIsolationCalculator_
std::vector< int > flagsexclEE_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
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
double getDepth2HcalESum(const reco::SuperCluster &sc) const
ESHandle< TrackerGeometry > geometry
static int position[264][3]
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< EcalRecHitCollection > preshowerHits_
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
void setP4(P4type type, const LorentzVector &p4, float p4Error, bool setToRecoCandidate)
void calculate(const reco::Photon *, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, edm::Handle< reco::VertexCollection > &vertices, const edm::Event &e, const edm::EventSetup &es, reco::Photon::PflowIsolationVariables &phoisol03)
std::string valueMapPFCandPhoton_