72 const std::vector<std::string> flagnamesEB =
73 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEB");
75 const std::vector<std::string> flagnamesEE =
76 config.
getParameter<std::vector<std::string> >(
"RecHitFlagToBeExcludedEE");
79 StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
82 StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
84 const std::vector<std::string> severitynamesEB =
85 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEB");
88 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
90 const std::vector<std::string> severitynamesEE =
91 config.
getParameter<std::vector<std::string> >(
"RecHitSeverityToBeExcludedEE");
94 StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
164 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
168 bool validPhotonCoreHandle=
true;
171 if (!photonCoreHandle.
isValid()) {
173 <<
"Error! Can't get the photonCoreProducer";
174 validPhotonCoreHandle=
false;
178 bool validEcalRecHits=
true;
182 if (!barrelHitHandle.
isValid()) {
184 <<
"Error! Can't get the barrelEcalHits";
185 validEcalRecHits=
false;
187 if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.
product());
193 if (!endcapHitHandle.
isValid()) {
195 <<
"Error! Can't get the endcapEcalHits";
196 validEcalRecHits=
false;
198 if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.
product());
226 bool validVertex=
true;
230 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
233 if (validVertex) vertexCollection = *(vertexHandle.
product());
241 if ( validPhotonCoreHandle)
251 outputPhotonCollection,
257 edm::LogInfo(
"PhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
258 outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
279 std::vector<double> preselCutValues;
284 std::vector<int> flags_, severitiesexcl_;
286 for(
unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
293 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
299 hits = ecalBarrelHits;
305 hits = ecalEndcapHits;
309 edm::LogWarning(
"")<<
"PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
311 if(hits ==
nullptr)
continue;
314 if (scRef->energy()/cosh(scRef->eta()) <= preselCutValues[0] )
continue;
320 double HoE1=towerIso1.
getTowerESum(&(*scRef))/scRef->energy();
321 double HoE2=towerIso2.
getTowerESum(&(*scRef))/scRef->energy();
325 std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
326 float hcalDepth1OverEcalBc = towerIsoBehindClus.
getDepth1HcalESum(TowersBehindClus)/scRef->energy();
327 float hcalDepth2OverEcalBc = towerIsoBehindClus.
getDepth2HcalESum(TowersBehindClus)/scRef->energy();
339 float e1x5 = EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology));
340 float e2x5 = EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology));
341 float e3x3 = EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology));
342 float e5x5 = EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology));
343 std::vector<float> cov = EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology),
geometry);
344 std::vector<float> locCov = EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology));
347 float sigmaIetaIeta =
sqrt(locCov[0]);
348 float r9 =e3x3/(scRef->rawEnergy());
360 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
366 caloPosition = unconvPos;
368 caloPosition = scRef->position();
372 double photonEnergy=1.;
374 if (!vertexCollection.empty()) vtx = vertexCollection.begin()->position();
390 newCandidate.setFiducialVolumeFlags( fiducialFlags );
391 newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
396 showerShape.
e1x5= e1x5;
397 showerShape.
e2x5= e2x5;
398 showerShape.
e3x3= e3x3;
399 showerShape.
e5x5= e5x5;
408 newCandidate.setShowerShapeVariables ( showerShape );
412 full5x5_showerShape.
e1x5= full5x5_e1x5;
413 full5x5_showerShape.
e2x5= full5x5_e2x5;
414 full5x5_showerShape.
e3x3= full5x5_e3x3;
415 full5x5_showerShape.
e5x5= full5x5_e5x5;
417 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
419 newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
446 newCandidate.setMIPVariables(mipVar);
453 if ( newCandidate.pt() <
highEt_) {
454 if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=
false;
455 if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=
false;
456 if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=
false;
457 if ( newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]) ) isLooseEM=
false;
458 if ( newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]) ) isLooseEM=
false;
459 if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=
false;
460 if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=
false;
461 if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=
false;
467 outputPhotonCollection.push_back(newCandidate);
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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, const EcalSeverityLevelAlgo *sevLv)
std::vector< double > preselCutValuesEndcap_
std::vector< CaloTowerDetId > hcalTowersBehindClusters
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
isolationSumsCalculatorSet
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float hcalDepth2OverEcalBc
std::vector< Vertex > VertexCollection
collection of Vertex objects
PositionCalc posCalculator_
~PhotonProducer() override
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
void setTowerCollection(const CaloTowerCollection *towercollection)
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::vector< int > flagsexclEB_
double getDepth1HcalESum(const reco::SuperCluster &sc) const
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)
edm::ESHandle< CaloTopology > theCaloTopo_
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
double getTowerESum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEB_
std::string PhotonCollection_
edm::ESHandle< CaloGeometry > theCaloGeom_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
float hcalDepth1OverEcalBc
T const * product() const
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 > preselCutValuesBarrel_
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
double getDepth2HcalESum(const reco::SuperCluster &sc) const
ESHandle< TrackerGeometry > geometry
PhotonProducer(const edm::ParameterSet &ps)
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
void produce(edm::Event &evt, const edm::EventSetup &es) override
T const * product() const