45 inline double ptFast(
const double energy,
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());
246 bool validPhotonCoreHandle=
false;
248 bool validPhotonHandle=
false;
253 if ( photonHandle.isValid()) {
254 validPhotonHandle=
true;
262 if (photonCoreHandle.isValid()) {
263 validPhotonCoreHandle=
true;
275 bool validEcalRecHits=
true;
279 if (!barrelHitHandle.isValid()) {
281 <<
"Error! Can't get the barrelEcalHits";
282 validEcalRecHits=
false;
284 if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.product());
290 if (!endcapHitHandle.isValid()) {
292 <<
"Error! Can't get the endcapEcalHits";
293 validEcalRecHits=
false;
295 if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.product());
302 if (!pfEGCandidateHandle.isValid()) {
304 <<
"Error! Can't get the pfEgammaCandidates";
312 if (!pfCandidateHandle.isValid()) {
314 <<
"Error! Can't get the pfCandidates";
348 bool validVertex=
true;
351 if (!vertexHandle.isValid()) {
353 <<
"Error! Can't get the product primary Vertex Collection";
364 if ( validPhotonCoreHandle)
374 outputPhotonCollection,
386 outputPhotonCollection,
392 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
393 outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
401 unsigned nObj = pfEGCandidateHandle->size();
402 std::vector<reco::PhotonRef>
values(nObj);
404 for(
unsigned int lCand=0; lCand < nObj; lCand++) {
408 for(
unsigned int lSC=0; lSC < photonOrphHandle->size(); lSC++) {
411 if ( pfScRef != scRef )
continue;
412 values[lCand] = photonRef;
417 filler.
insert(pfEGCandidateHandle,values.begin(),values.end());
444 std::vector<double> preselCutValues;
445 std::vector<int> flags_, severitiesexcl_;
447 for(
unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
458 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
461 hits = ecalBarrelHits;
466 hits = ecalEndcapHits;
470 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
478 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
484 double HoE1=towerIso1.
getTowerESum(&(*scRef))/scRef->energy();
485 double HoE2=towerIso2.
getTowerESum(&(*scRef))/scRef->energy();
489 std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
490 float hcalDepth1OverEcalBc = towerIsoBehindClus.
getDepth1HcalESum(TowersBehindClus)/scRef->energy();
491 float hcalDepth2OverEcalBc = towerIsoBehindClus.
getDepth2HcalESum(TowersBehindClus)/scRef->energy();
505 float sigmaEtaEta =
sqrt(cov[0]);
506 float sigmaIetaIeta =
sqrt(locCov[0]);
512 double photonEnergy=1.;
514 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
531 newCandidate.setFiducialVolumeFlags( fiducialFlags );
532 newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
537 showerShape.
e1x5= e1x5;
538 showerShape.
e2x5= e2x5;
539 showerShape.
e3x3= e3x3;
540 showerShape.
e5x5= e5x5;
549 newCandidate.setShowerShapeVariables ( showerShape );
583 newCandidate.setMIPVariables(mipVar);
590 if ( newCandidate.pt() <
highEt_) {
591 if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
592 if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=
false;
593 if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=
false;
594 if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
595 if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=
false;
596 if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=
false;
597 if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=
false;
598 if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
604 outputPhotonCollection.push_back(newCandidate);
624 std::vector<double> preselCutValues;
627 for(
unsigned int lSC=0; lSC < photonHandle->size(); lSC++) {
631 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
637 edm::LogWarning(
"")<<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster";
644 ptFast(parentSCRef->energy(),parentSCRef->position(),
math::XYZPoint(0,0,0)) <= preselCutValues[0] )
continue;
668 if ( newCandidate.
hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
669 if ( newCandidate.
ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.
pt() ) isLooseEM=
false;
670 if ( newCandidate.
hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.
pt() ) isLooseEM=
false;
671 if ( newCandidate.
nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=
false;
675 if ( newCandidate.
sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
681 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
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_
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_
static int position[TOTALCHAMBERS][3]
void setup(const edm::ParameterSet &conf)
std::string photonCollection_
edm::ESHandle< CaloTopology > theCaloTopo_
bool isNonnull() const
Checks for non-null.
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 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
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
std::vector< double > preselCutValuesBarrel_
ParameterSet const & getParameterSet(std::string const &) const
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
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_)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< double > preselCutValuesEndcap_
T const * product() const
int nTrkSolidConeDR04() const
std::vector< Photon > PhotonCollection
collectin of Photon objects
T const * product() 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
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
void setup(const edm::ParameterSet &conf)
virtual float pt() const GCC11_FINAL
transverse momentum
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_