138 const std::vector<std::string> flagnamesEB =
139 config.
getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
141 const std::vector<std::string> flagnamesEE =
142 config.
getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
144 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
146 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
148 const std::vector<std::string> severitynamesEB =
149 config.
getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
151 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
153 const std::vector<std::string> severitynamesEE =
154 config.
getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
156 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
160 if (cfgCone.hOverEConeSize > 0) {
161 cfgCone.onlyBehindCluster =
false;
162 cfgCone.checkHcalStatus =
false;
167 cfgCone.maxSeverityHB = config.
getParameter<
int>(
"maxHcalRecHitSeverity");
169 cfgCone.maxSeverityHE = cfgCone.maxSeverityHB;
172 cfgBc.hOverEConeSize = 0.;
173 cfgBc.onlyBehindCluster =
true;
174 cfgBc.checkHcalStatus =
false;
179 cfgBc.maxSeverityHB = config.
getParameter<
int>(
"maxHcalRecHitSeverity");
181 cfgBc.maxSeverityHE = cfgBc.maxSeverityHB;
183 hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
184 hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
229 isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_, consumesCollector());
243 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
246 bool validPhotonCoreHandle =
true;
249 if (!photonCoreHandle.isValid()) {
250 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the photonCoreProducer";
251 validPhotonCoreHandle =
false;
255 bool validEcalRecHits =
true;
259 if (!barrelHitHandle.isValid()) {
260 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the barrelEcalHits";
261 validEcalRecHits =
false;
263 if (validEcalRecHits)
269 if (!endcapHitHandle.isValid()) {
270 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the endcapEcalHits";
271 validEcalRecHits =
false;
273 if (validEcalRecHits)
285 bool validVertex =
true;
288 if (!vertexHandle.isValid()) {
289 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "
299 if (validPhotonCoreHandle)
309 outputPhotonCollection,
313 edm::LogInfo(
"PhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
314 outputPhotonCollection_p->assign(outputPhotonCollection.begin(), outputPhotonCollection.end());
318 for (
auto& pho : *outputPhotonCollection_p)
319 pho.hcalToRun2EffDepth();
341 std::vector<double> preselCutValues;
346 std::vector<int> flags_, severitiesexcl_;
348 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
353 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
359 hits = ecalBarrelHits;
365 hits = ecalEndcapHits;
369 edm::LogWarning(
"") <<
"PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
375 if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
382 float maxXtal = EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
385 float e1x5 = EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
386 float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
387 float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
388 float e5x5 = EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
389 const auto& cov = EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology),
geometry);
390 const auto& locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
392 float sigmaEtaEta =
sqrt(cov[0]);
393 float sigmaIetaIeta =
sqrt(locCov[0]);
394 float r9 = e3x3 / (scRef->rawEnergy());
406 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
407 float full5x5_sigmaIetaIeta =
sqrt(full5x5_locCov[0]);
412 caloPosition = unconvPos;
414 caloPosition = scRef->position();
418 double photonEnergy = 1.;
420 if (!vertexCollection.empty())
421 vtx = vertexCollection.begin()->position();
428 reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
434 newCandidate.setFiducialVolumeFlags(fiducialFlags);
435 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
439 showerShape.
e1x5 = e1x5;
440 showerShape.
e2x5 = e2x5;
441 showerShape.
e3x3 = e3x3;
442 showerShape.
e5x5 = e5x5;
452 newCandidate.setShowerShapeVariables(showerShape);
456 full5x5_showerShape.
e1x5 = full5x5_e1x5;
457 full5x5_showerShape.
e2x5 = full5x5_e2x5;
458 full5x5_showerShape.
e3x3 = full5x5_e3x3;
459 full5x5_showerShape.
e5x5 = full5x5_e5x5;
461 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
469 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
487 newCandidate.setMIPVariables(mipVar);
491 bool isLooseEM =
true;
492 if (newCandidate.pt() <
highEt_) {
493 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
495 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
497 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
499 if (newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]))
501 if (newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]))
503 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
505 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
507 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
512 outputPhotonCollection.push_back(newCandidate);
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
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
double hcalESum(const reco::SuperCluster &, int depth) const
std::vector< double > preselCutValuesEndcap_
std::vector< CaloTowerDetId > hcalTowersBehindClusters
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void MIPcalculate(const reco::Photon *, const edm::Event &, const edm::EventSetup &es, reco::Photon::MIPVariables &mipId)
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
std::vector< Vertex > VertexCollection
collection of Vertex objects
PositionCalc posCalculator_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
std::array< float, 7 > hcalOverEcalBc
PhotonEnergyCorrector photonEnergyCorrector_
Log< level::Error, false > LogError
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
bool getData(T &iHolder) const
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_
auto hcalTowersBehindClusters(const reco::SuperCluster &sc) const
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=nullptr)
void init(const edm::EventSetup &theEventSetup)
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
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_
T getParameter(std::string const &) const
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, ElectronHcalHelper const &hcalHelperCone, ElectronHcalHelper const &hcalHelperBc, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
tuple config
parse the configuration file
PhotonProducer(const edm::ParameterSet &ps)
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
Log< level::Warning, false > LogWarning
std::array< double, 4 > arrayHB
void produce(edm::Event &evt, const edm::EventSetup &es) override
std::array< double, 7 > arrayHE