128 flagsexclEB_{StringToEnumValue<EcalRecHit::Flags>(
129 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB"))},
130 flagsexclEE_{StringToEnumValue<EcalRecHit::Flags>(
131 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE"))},
132 severitiesexclEB_{StringToEnumValue<EcalSeverityLevel::SeverityLevel>(
133 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB"))},
134 severitiesexclEE_{StringToEnumValue<EcalSeverityLevel::SeverityLevel>(
135 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE"))},
141 consumesCollector()),
143 photonEnergyCorrector_(
config, consumesCollector()) {
146 photonCoreProducer_ = consumes<reco::PhotonCoreCollection>(
config.getParameter<
edm::InputTag>(
"photonCoreProducer"));
147 barrelEcalHits_ = consumes<EcalRecHitCollection>(
config.getParameter<
edm::InputTag>(
"barrelEcalHits"));
148 endcapEcalHits_ = consumes<EcalRecHitCollection>(
config.getParameter<
edm::InputTag>(
"endcapEcalHits"));
149 vertexProducer_ = consumes<reco::VertexCollection>(
config.getParameter<
edm::InputTag>(
"primaryVertexProducer"));
150 hbheRecHits_ = consumes<HBHERecHitCollection>(
config.getParameter<
edm::InputTag>(
"hbheRecHits"));
151 hOverEConeSize_ =
config.getParameter<
double>(
"hOverEConeSize");
152 highEt_ =
config.getParameter<
double>(
"highEt");
154 minR9Barrel_ =
config.getParameter<
double>(
"minR9Barrel");
155 minR9Endcap_ =
config.getParameter<
double>(
"minR9Endcap");
156 usePrimaryVertex_ =
config.getParameter<
bool>(
"usePrimaryVertex");
157 runMIPTagger_ =
config.getParameter<
bool>(
"runMIPTagger");
158 runMVABasedHaloTagger_ =
config.getParameter<
bool>(
"runMVABasedHaloTagger");
166 cutsFromDB_ =
config.getParameter<
bool>(
"usePFThresholdsFromDB");
168 hcalCutsToken_ = esConsumes<HcalPFCuts, HcalPFCutsRcd>(
edm::ESInputTag(
"",
"withTopo"));
196 hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
197 hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
199 hcalRun2EffDepth_ =
config.getParameter<
bool>(
"hcalRun2EffDepth");
215 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"minSCEtBarrel"));
216 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"maxHoverEBarrel"));
217 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"ecalRecHitSumEtOffsetBarrel"));
218 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"ecalRecHitSumEtSlopeBarrel"));
219 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"hcalRecHitSumEtOffsetBarrel"));
220 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"hcalRecHitSumEtSlopeBarrel"));
221 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"nTrackSolidConeBarrel"));
222 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"nTrackHollowConeBarrel"));
223 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"trackPtSumSolidConeBarrel"));
224 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"trackPtSumHollowConeBarrel"));
225 preselCutValuesBarrel_.push_back(
config.getParameter<
double>(
"sigmaIetaIetaCutBarrel"));
227 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"minSCEtEndcap"));
228 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"maxHoverEEndcap"));
229 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"ecalRecHitSumEtOffsetEndcap"));
230 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"ecalRecHitSumEtSlopeEndcap"));
231 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"hcalRecHitSumEtOffsetEndcap"));
232 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"hcalRecHitSumEtSlopeEndcap"));
233 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"nTrackSolidConeEndcap"));
234 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"nTrackHollowConeEndcap"));
235 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"trackPtSumSolidConeEndcap"));
236 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"trackPtSumHollowConeEndcap"));
237 preselCutValuesEndcap_.push_back(
config.getParameter<
double>(
"sigmaIetaIetaCutEndcap"));
241 produces<reco::PhotonCollection>(PhotonCollection_);
253 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
256 bool validPhotonCoreHandle =
true;
259 if (!photonCoreHandle.
isValid()) {
260 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the photonCoreProducer";
261 validPhotonCoreHandle =
false;
265 bool validEcalRecHits =
true;
269 if (!barrelHitHandle.
isValid()) {
270 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the barrelEcalHits";
271 validEcalRecHits =
false;
273 if (validEcalRecHits)
279 if (!endcapHitHandle.
isValid()) {
280 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the endcapEcalHits";
281 validEcalRecHits =
false;
283 if (validEcalRecHits)
295 bool validVertex =
true;
299 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection " 309 if (validPhotonCoreHandle)
324 edm::LogInfo(
"PhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
329 for (
auto& pho : *outputPhotonCollection_p)
330 pho.hcalToRun2EffDepth();
353 std::vector<double> preselCutValues;
358 std::vector<int> flags_, severitiesexcl_;
360 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
365 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
371 hits = ecalBarrelHits;
377 hits = ecalEndcapHits;
381 edm::LogWarning(
"") <<
"PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
387 if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
398 float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology));
399 float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*
hits), &(*topology));
401 const auto& cov = EcalClusterTools::covariances(*(scRef->seed()), &(*
hits), &(*topology),
geometry);
402 const auto& locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*
hits), &(*topology));
406 float r9 = e3x3 / (scRef->rawEnergy());
418 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
424 caloPosition = unconvPos;
426 caloPosition = scRef->position();
446 newCandidate.setFiducialVolumeFlags(fiducialFlags);
447 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
453 showerShape.
e3x3 = e3x3;
464 newCandidate.setShowerShapeVariables(showerShape);
468 full5x5_showerShape.
e1x5 = full5x5_e1x5;
469 full5x5_showerShape.
e2x5 = full5x5_e2x5;
470 full5x5_showerShape.
e3x3 = full5x5_e3x3;
471 full5x5_showerShape.
e5x5 = full5x5_e5x5;
473 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
481 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
498 newCandidate.setMIPVariables(mipVar);
502 bool isLooseEM =
true;
503 if (newCandidate.pt() <
highEt_) {
504 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
506 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
508 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
510 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
512 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
514 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
516 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
518 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.
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
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits
std::unique_ptr< const PhotonMVABasedHaloTagger > photonMVABasedHaloTagger_
bool runMVABasedHaloTagger_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
PhotonIsolationCalculator photonIsolationCalculator_
const PhotonMIPHaloTagger photonMIPHaloTagger_
reco::Photon::MIPVariables mipCalculate(const reco::Photon &, const edm::Event &, const edm::EventSetup &es) const
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
std::vector< int > flagsexclEB_
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 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_
EgammaHcalIsolation::arrayHB eThresHB
EgammaHcalIsolation::arrayHE eThresHE
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