48 const auto v = position - origin;
63 if ( reconstructionStep_ ==
"final" ) {
108 const std::vector<std::string> flagnamesEB =
109 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEB");
111 const std::vector<std::string> flagnamesEE =
112 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEE");
115 StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
118 StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
120 const std::vector<std::string> severitynamesEB =
121 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEB");
124 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
126 const std::vector<std::string> severitynamesEE =
127 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEE");
130 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
137 thePhotonEnergyCorrector_->gedRegression()->varCalc()->setTokens(regr_conf,
consumesCollector());
180 if ( reconstructionStep_ !=
"final"){
240 bool validPhotonCoreHandle=
false;
242 bool validPhotonHandle=
false;
247 if ( photonHandle.isValid()) {
248 validPhotonHandle=
true;
256 if (photonCoreHandle.isValid()) {
257 validPhotonCoreHandle=
true;
269 bool validEcalRecHits=
true;
273 if (!barrelHitHandle.isValid()) {
275 <<
"Error! Can't get the barrelEcalHits";
276 validEcalRecHits=
false;
278 if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.product());
284 if (!endcapHitHandle.isValid()) {
286 <<
"Error! Can't get the endcapEcalHits";
287 validEcalRecHits=
false;
289 if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.product());
296 if (!pfEGCandidateHandle.isValid()) {
298 <<
"Error! Can't get the pfEgammaCandidates";
306 if (!pfCandidateHandle.isValid()) {
308 <<
"Error! Can't get the pfCandidates";
342 bool validVertex=
true;
345 if (!vertexHandle.isValid()) {
347 <<
"Error! Can't get the product primary Vertex Collection";
358 if ( validPhotonCoreHandle)
368 outputPhotonCollection,
380 outputPhotonCollection,
386 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
387 outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
395 unsigned nObj = pfEGCandidateHandle->size();
396 std::vector<reco::PhotonRef>
values(nObj);
398 for(
unsigned int lCand=0; lCand < nObj; lCand++) {
402 for(
unsigned int lSC=0; lSC < photonOrphHandle->size(); lSC++) {
405 if ( pfScRef != scRef )
continue;
406 values[lCand] = photonRef;
411 filler.
insert(pfEGCandidateHandle,values.begin(),values.end());
438 std::vector<double> preselCutValues;
439 std::vector<int> flags_, severitiesexcl_;
441 for(
unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
452 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
455 hits = ecalBarrelHits;
460 hits = ecalEndcapHits;
464 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
472 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
478 double HoE1=towerIso1.
getTowerESum(&(*scRef))/scRef->energy();
479 double HoE2=towerIso2.
getTowerESum(&(*scRef))/scRef->energy();
483 std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
484 float hcalDepth1OverEcalBc = towerIsoBehindClus.
getDepth1HcalESum(TowersBehindClus)/scRef->energy();
485 float hcalDepth2OverEcalBc = towerIsoBehindClus.
getDepth2HcalESum(TowersBehindClus)/scRef->energy();
489 float maxXtal = EcalClusterTools::eMax( *(scRef->seed()), &(*hits) );
492 float e1x5 = EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology));
493 float e2x5 = EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology));
494 float e3x3 = EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology));
495 float e5x5 = EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology));
496 std::vector<float> cov = EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology),
geometry);
497 std::vector<float> locCov = EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology));
499 float sigmaEtaEta =
sqrt(cov[0]);
500 float sigmaIetaIeta =
sqrt(locCov[0]);
512 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
513 float full5x5_sigmaIetaIeta =
sqrt(full5x5_locCov[0]);
520 double photonEnergy=1.;
522 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
539 newCandidate.setFiducialVolumeFlags( fiducialFlags );
540 newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
545 showerShape.
e1x5= e1x5;
546 showerShape.
e2x5= e2x5;
547 showerShape.
e3x3= e3x3;
548 showerShape.
e5x5= e5x5;
557 newCandidate.setShowerShapeVariables ( showerShape );
561 full5x5_showerShape.
e1x5= full5x5_e1x5;
562 full5x5_showerShape.
e2x5= full5x5_e2x5;
563 full5x5_showerShape.
e3x3= full5x5_e3x3;
564 full5x5_showerShape.
e5x5= full5x5_e5x5;
566 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
568 newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
602 newCandidate.setMIPVariables(mipVar);
609 if ( newCandidate.pt() <
highEt_) {
610 if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
611 if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=
false;
612 if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=
false;
613 if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
614 if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=
false;
615 if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=
false;
616 if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=
false;
617 if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
623 outputPhotonCollection.push_back(newCandidate);
643 std::vector<double> preselCutValues;
646 for(
unsigned int lSC=0; lSC < photonHandle->size(); lSC++) {
650 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
656 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
663 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
687 if ( newCandidate.
hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
688 if ( newCandidate.
ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.
pt() ) isLooseEM=
false;
689 if ( newCandidate.
hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.
pt() ) isLooseEM=
false;
690 if ( newCandidate.
nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
694 if ( newCandidate.
sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
700 outputPhotonCollection.push_back(newCandidate);
edm::InputTag photonProducer_
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
T getParameter(std::string const &) const
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
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_
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 edm::Handle< CaloTowerCollection > &hcalTowersHandle, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
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.
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float hcalDepth2OverEcalBc
float trkSumPtSolidConeDR04() const
void insert(const H &h, I begin, I end)
std::vector< int > flagsexclEB_
std::vector< Vertex > VertexCollection
collection of Vertex objects
float ecalRecHitSumEtConeDR04() const
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::string reconstructionStep_
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEE_
virtual double pt() const
transverse momentum
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)
float sigmaIetaIeta() const
PFPhotonIsolationCalculator * thePFBasedIsolationCalculator_
std::vector< int > flagsexclEE_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
int nTrkHollowConeDR04() const
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
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_
ParameterSet const & getParameterSet(std::string const &) const
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
int nTrkSolidConeDR04() const
std::string candidateP4type_
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
float trkSumPtHollowConeDR04() const
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_
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
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_