156 const std::vector<std::string> flagnamesEB =
157 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
159 const std::vector<std::string> flagnamesEE =
160 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
162 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
164 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
166 const std::vector<std::string> severitynamesEB =
167 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
169 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
171 const std::vector<std::string> severitynamesEE =
172 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
174 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
178 if (cfgCone.hOverEConeSize > 0) {
179 cfgCone.onlyBehindCluster =
false;
180 cfgCone.checkHcalStatus =
false;
185 cfgCone.maxSeverityHB =
config.getParameter<
int>(
"maxHcalRecHitSeverity");
187 cfgCone.maxSeverityHE = cfgCone.maxSeverityHB;
190 cfgBc.hOverEConeSize = 0.;
191 cfgBc.onlyBehindCluster =
true;
192 cfgBc.checkHcalStatus =
false;
197 cfgBc.maxSeverityHB =
config.getParameter<
int>(
"maxHcalRecHitSeverity");
199 cfgBc.maxSeverityHE = cfgBc.maxSeverityHB;
201 hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
202 hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
265 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
268 bool validPhotonCoreHandle =
true;
271 if (!photonCoreHandle.
isValid()) {
272 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the photonCoreProducer";
273 validPhotonCoreHandle =
false;
277 bool validEcalRecHits =
true;
281 if (!barrelHitHandle.
isValid()) {
282 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the barrelEcalHits";
283 validEcalRecHits =
false;
285 if (validEcalRecHits)
291 if (!endcapHitHandle.
isValid()) {
292 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the endcapEcalHits";
293 validEcalRecHits =
false;
295 if (validEcalRecHits)
307 bool validVertex =
true;
311 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection " 321 if (validPhotonCoreHandle)
336 edm::LogInfo(
"PhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
341 for (
auto& pho : *outputPhotonCollection_p)
342 pho.hcalToRun2EffDepth();
365 std::vector<double> preselCutValues;
370 std::vector<int> flags_, severitiesexcl_;
372 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
377 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
383 hits = ecalBarrelHits;
389 hits = ecalEndcapHits;
393 edm::LogWarning(
"") <<
"PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
399 if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
410 float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology));
411 float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*
hits), &(*topology));
413 const auto& cov = EcalClusterTools::covariances(*(scRef->seed()), &(*
hits), &(*topology),
geometry);
414 const auto& locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*
hits), &(*topology));
418 float r9 = e3x3 / (scRef->rawEnergy());
430 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
436 caloPosition = unconvPos;
438 caloPosition = scRef->position();
458 newCandidate.setFiducialVolumeFlags(fiducialFlags);
459 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
465 showerShape.
e3x3 = e3x3;
476 newCandidate.setShowerShapeVariables(showerShape);
480 full5x5_showerShape.
e1x5 = full5x5_e1x5;
481 full5x5_showerShape.
e2x5 = full5x5_e2x5;
482 full5x5_showerShape.
e3x3 = full5x5_e3x3;
483 full5x5_showerShape.
e5x5 = full5x5_e5x5;
485 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
493 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
511 newCandidate.setMIPVariables(mipVar);
515 bool isLooseEM =
true;
516 if (newCandidate.pt() <
highEt_) {
517 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
519 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
521 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
523 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
525 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
527 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
529 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
531 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
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 HcalPFCuts *hcalCuts) const
std::vector< double > preselCutValuesEndcap_
std::vector< CaloTowerDetId > hcalTowersBehindClusters
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
isolationSumsCalculatorSet
void MIPcalculate(const reco::Photon *, const edm::Event &, const edm::EventSetup &es, reco::Photon::MIPVariables &mipId)
T const * product() const
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PositionCalc posCalculator_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
std::array< float, 7 > hcalOverEcalBc
PhotonEnergyCorrector photonEnergyCorrector_
Log< level::Error, false > LogError
bool runMVABasedHaloTagger_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
PhotonMIPHaloTagger photonMIPHaloTagger_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
PhotonIsolationCalculator photonIsolationCalculator_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
std::vector< int > flagsexclEB_
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)
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=nullptr)
#define DEFINE_FWK_MODULE(type)
void init(const edm::EventSetup &theEventSetup)
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const HcalPFCuts *hcalCuts, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, ElectronHcalHelper const &hcalHelperCone, ElectronHcalHelper const &hcalHelperBc, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
std::vector< int > severitiesexclEB_
std::string PhotonCollection_
Log< level::Info, false > LogInfo
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::array< float, 7 > hcalOverEcal
std::vector< Photon > PhotonCollection
collectin of Photon objects
std::vector< double > preselCutValuesBarrel_
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
auto hcalTowersBehindClusters(const reco::SuperCluster &sc) const
PhotonProducer(const edm::ParameterSet &ps)
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
std::unique_ptr< PhotonMVABasedHaloTagger > photonMVABasedHaloTagger_
Log< level::Warning, false > LogWarning
double hcalESum(const reco::SuperCluster &, int depth, const HcalPFCuts *hcalCuts) const
std::array< double, 4 > arrayHB
void produce(edm::Event &evt, const edm::EventSetup &es) override
std::array< double, 7 > arrayHE