CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonProducer Class Reference

#include <PhotonProducer.h>

Inheritance diagram for PhotonProducer:
edm::stream::EDProducer<>

Public Member Functions

 PhotonProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 ~PhotonProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

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)
 

Private Attributes

edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHits_
 
std::string candidateP4type_
 
edm::ParameterSet conf_
 
std::string conversionCollection_
 
std::string conversionProducer_
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHits_
 
EcalClusterFunctionBaseClassenergyCorrectionF
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::EDGetTokenT< CaloTowerCollectionhcalTowers_
 
double highEt_
 
double hOverEConeSize_
 
double maxHOverE_
 
double minR9Barrel_
 
double minR9Endcap_
 
double minSCEt_
 
std::string PhotonCollection_
 
edm::EDGetTokenT< reco::PhotonCoreCollectionphotonCoreProducer_
 
std::string pixelSeedProducer_
 
PositionCalc posCalculator_
 
std::vector< double > preselCutValuesBarrel_
 
std::vector< double > preselCutValuesEndcap_
 
bool runMIPTagger_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
edm::ESHandle< CaloGeometrytheCaloGeom_
 
edm::ESHandle< CaloTopologytheCaloTopo_
 
PhotonEnergyCorrectorthePhotonEnergyCorrector_
 
PhotonIsolationCalculatorthePhotonIsolationCalculator_
 
PhotonMIPHaloTaggerthePhotonMIPHaloTagger_
 
bool usePrimaryVertex_
 
bool validConversions_
 
bool validPixelSeeds_
 
edm::EDGetTokenT< reco::VertexCollectionvertexProducer_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 37 of file PhotonProducer.h.

Constructor & Destructor Documentation

PhotonProducer::PhotonProducer ( const edm::ParameterSet ps)

Definition at line 38 of file PhotonProducer.cc.

References barrelEcalHits_, candidateP4type_, conf_, endcapEcalHits_, flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), hcalTowers_, highEt_, hOverEConeSize_, gedPhotons_cfi::isolationSumsCalculatorSet, minR9Barrel_, minR9Endcap_, gedPhotons_cfi::mipVariableSet, PhotonCollection_, photonCoreProducer_, cleanAndMergeSuperClusters_cfi::posCalcParameters, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, PhotonIsolationCalculator::setup(), PhotonMIPHaloTagger::setup(), severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, thePhotonMIPHaloTagger_, usePrimaryVertex_, and vertexProducer_.

38  :
39 
40  conf_(config)
41 {
42 
43  // use onfiguration file to setup input/output collection names
44 
46  consumes<reco::PhotonCoreCollection>(conf_.getParameter<edm::InputTag>("photonCoreProducer"));
48  consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("barrelEcalHits"));
50  consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("endcapEcalHits"));
52  consumes<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("primaryVertexProducer"));
53  hcalTowers_ =
54  consumes<CaloTowerCollection>(conf_.getParameter<edm::InputTag>("hcalTowers"));
55  hOverEConeSize_ = conf_.getParameter<double>("hOverEConeSize");
56  highEt_ = conf_.getParameter<double>("highEt");
57  // R9 value to decide converted/unconverted
58  minR9Barrel_ = conf_.getParameter<double>("minR9Barrel");
59  minR9Endcap_ = conf_.getParameter<double>("minR9Endcap");
60  usePrimaryVertex_ = conf_.getParameter<bool>("usePrimaryVertex");
61  runMIPTagger_ = conf_.getParameter<bool>("runMIPTagger");
62 
63  candidateP4type_ = config.getParameter<std::string>("candidateP4type") ;
64 
66  config.getParameter<edm::ParameterSet>("posCalcParameters");
68 
69 
70  //AA
71  //Flags and Severities to be excluded from photon calculations
72  const std::vector<std::string> flagnamesEB =
73  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
74 
75  const std::vector<std::string> flagnamesEE =
76  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
77 
79  StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
80 
82  StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
83 
84  const std::vector<std::string> severitynamesEB =
85  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
86 
88  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
89 
90  const std::vector<std::string> severitynamesEE =
91  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
92 
94  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
95 
96  //AA
97 
98  //
99 
100  // Parameters for the position calculation:
101  // std::map<std::string,double> providedParameters;
102  // providedParameters.insert(std::make_pair("LogWeighted",conf_.getParameter<bool>("posCalc_logweight")));
103  //providedParameters.insert(std::make_pair("T0_barl",conf_.getParameter<double>("posCalc_t0_barl")));
104  //providedParameters.insert(std::make_pair("T0_endc",conf_.getParameter<double>("posCalc_t0_endc")));
105  //providedParameters.insert(std::make_pair("T0_endcPresh",conf_.getParameter<double>("posCalc_t0_endcPresh")));
106  //providedParameters.insert(std::make_pair("W0",conf_.getParameter<double>("posCalc_w0")));
107  //providedParameters.insert(std::make_pair("X0",conf_.getParameter<double>("posCalc_x0")));
108  //posCalculator_ = PositionCalc(providedParameters);
109  // cut values for pre-selection
110  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("minSCEtBarrel"));
111  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("maxHoverEBarrel"));
112  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetBarrel"));
113  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeBarrel"));
114  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetBarrel"));
115  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeBarrel"));
116  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackSolidConeBarrel"));
117  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackHollowConeBarrel"));
118  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumSolidConeBarrel"));
119  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumHollowConeBarrel"));
120  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutBarrel"));
121  //
122  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("minSCEtEndcap"));
123  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("maxHoverEEndcap"));
124  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetEndcap"));
125  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeEndcap"));
126  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetEndcap"));
127  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeEndcap"));
128  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackSolidConeEndcap"));
129  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackHollowConeEndcap"));
130  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumSolidConeEndcap"));
131  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumHollowConeEndcap"));
132  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutEndcap"));
133  //
134 
135  thePhotonEnergyCorrector_ = new PhotonEnergyCorrector(conf_, consumesCollector());
138  thePhotonIsolationCalculator_->setup(isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_,consumesCollector());
139 
140 
143  thePhotonMIPHaloTagger_->setup(mipVariableSet,consumesCollector());
144 
145  // Register the product
146  produces< reco::PhotonCollection >(PhotonCollection_);
147 
148 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
std::vector< double > preselCutValuesEndcap_
edm::ParameterSet conf_
PositionCalc posCalculator_
Definition: config.py:1
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
double hOverEConeSize_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
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_
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEB_
std::string PhotonCollection_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
std::vector< double > preselCutValuesBarrel_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
PhotonProducer::~PhotonProducer ( )
override

Definition at line 150 of file PhotonProducer.cc.

References thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.

151 {
155  //delete energyCorrectionF;
156 }
PhotonIsolationCalculator * thePhotonIsolationCalculator_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_

Member Function Documentation

void PhotonProducer::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 
)
private

fill shower shape block

fill full5x5 shower shape block

get ecal photon specific corrected energy plus values from regressions and store them in the Photon

Pre-selection loose isolation cuts

Definition at line 263 of file PhotonProducer.cc.

References PhotonEnergyCorrector::calculate(), PositionCalc::Calculate_Location(), candidateP4type_, EcalClusterToolsT< noZS >::covariances(), EcalClusterToolsT< noZS >::e1x5(), reco::Photon::ShowerShape::e1x5, reco::Photon::ShowerShape::e2x5, EcalClusterToolsT< noZS >::e2x5Max(), EcalClusterToolsT< noZS >::e3x3(), reco::Photon::ShowerShape::e3x3, EcalClusterToolsT< noZS >::e5x5(), reco::Photon::ShowerShape::e5x5, DetId::Ecal, reco::Photon::ecal_photons, EcalBarrel, EcalEndcap, EcalPreshower, photonPostprocessing_cfi::eMax, EcalClusterToolsT< noZS >::eMax(), flagsexclEB_, flagsexclEE_, particleFlow_cfi::full5x5_sigmaIetaIeta, geometry, EgammaHadTower::getDepth1HcalESum(), EgammaHadTower::getDepth2HcalESum(), CaloGeometry::getSubdetectorGeometry(), EgammaTowerIsolation::getTowerESum(), reco::Photon::ShowerShape::hcalDepth1OverEcal, reco::Photon::ShowerShape::hcalDepth1OverEcalBc, reco::Photon::ShowerShape::hcalDepth2OverEcal, reco::Photon::ShowerShape::hcalDepth2OverEcalBc, reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, hfClusterShapes_cfi::hits, hOverEConeSize_, init, createfilelist::int, EcalClusterToolsT< noZS >::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, minR9Barrel_, minR9Endcap_, nullptr, p4, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), electrons_cff::r9, reco::Photon::regression1, runMIPTagger_, EgammaHadTower::setTowerCollection(), severitiesexclEB_, severitiesexclEE_, electronIdCutBased_cfi::sigmaEtaEta, reco::Photon::ShowerShape::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), theCaloGeom_, thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, thePhotonMIPHaloTagger_, EgammaHadTower::towersOf(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by produce().

273  {
274 
276  const CaloSubdetectorGeometry* subDetGeometry =nullptr ;
279  std::vector<double> preselCutValues;
280  float minR9=0;
281 
283 
284  std::vector<int> flags_, severitiesexcl_;
285 
286  for(unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
287 
288  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
289  reco::SuperClusterRef scRef=coreRef->superCluster();
290  // const reco::SuperCluster* pClus=&(*scRef);
291  iSC++;
292 
293  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
294  subDetGeometry = theCaloGeom_->getSubdetectorGeometry(DetId::Ecal, subdet);
295 
296  if (subdet==EcalBarrel) {
297  preselCutValues = preselCutValuesBarrel_;
298  minR9 = minR9Barrel_;
299  hits = ecalBarrelHits;
300  flags_ = flagsexclEB_;
301  severitiesexcl_ = severitiesexclEB_;
302  } else if (subdet==EcalEndcap) {
303  preselCutValues = preselCutValuesEndcap_;
304  minR9 = minR9Endcap_;
305  hits = ecalEndcapHits;
306  flags_ = flagsexclEE_;
307  severitiesexcl_ = severitiesexclEE_;
308  } else {
309  edm::LogWarning("")<<"PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
310  }
311  if(hits == nullptr) continue;
312 
313  // SC energy preselection
314  if (scRef->energy()/cosh(scRef->eta()) <= preselCutValues[0] ) continue;
315  // calculate HoE
316 
317  const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
318  EgammaTowerIsolation towerIso1(hOverEConeSize_,0.,0.,1,hcalTowersColl) ;
319  EgammaTowerIsolation towerIso2(hOverEConeSize_,0.,0.,2,hcalTowersColl) ;
320  double HoE1=towerIso1.getTowerESum(&(*scRef))/scRef->energy();
321  double HoE2=towerIso2.getTowerESum(&(*scRef))/scRef->energy();
322 
323  EgammaHadTower towerIsoBehindClus(es);
324  towerIsoBehindClus.setTowerCollection(hcalTowersHandle.product());
325  std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.towersOf(*scRef);
326  float hcalDepth1OverEcalBc = towerIsoBehindClus.getDepth1HcalESum(TowersBehindClus)/scRef->energy();
327  float hcalDepth2OverEcalBc = towerIsoBehindClus.getDepth2HcalESum(TowersBehindClus)/scRef->energy();
328  // std::cout << " PhotonProducer calculation of HoE with towers in a cone " << HoE1 << " " << HoE2 << std::endl;
329  //std::cout << " PhotonProducer calcualtion of HoE with towers behind the BCs " << hcalDepth1OverEcalBc << " " << hcalDepth2OverEcalBc << std::endl;
330 
331 
332  // recalculate position of seed BasicCluster taking shower depth for unconverted photon
333  math::XYZPoint unconvPos = posCalculator_.Calculate_Location(scRef->seed()->hitsAndFractions(),hits,subDetGeometry,geometryES);
334 
335 
336  float maxXtal = EcalClusterTools::eMax( *(scRef->seed()), &(*hits) );
337  //AA
338  //Change these to consider severity level of hits
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));
345 
346  float sigmaEtaEta = sqrt(cov[0]);
347  float sigmaIetaIeta = sqrt(locCov[0]);
348  float r9 =e3x3/(scRef->rawEnergy());
349 
350  float full5x5_maxXtal = noZS::EcalClusterTools::eMax( *(scRef->seed()), &(*hits) );
351  //AA
352  //Change these to consider severity level of hits
353  float full5x5_e1x5 = noZS::EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology));
354  float full5x5_e2x5 = noZS::EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology));
355  float full5x5_e3x3 = noZS::EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology));
356  float full5x5_e5x5 = noZS::EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology));
357  std::vector<float> full5x5_cov = noZS::EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology), geometry);
358  std::vector<float> full5x5_locCov = noZS::EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology));
359 
360  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
361  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
362 
363  // compute position of ECAL shower
364  math::XYZPoint caloPosition;
365  if (r9>minR9) {
366  caloPosition = unconvPos;
367  } else {
368  caloPosition = scRef->position();
369  }
370 
372  double photonEnergy=1.;
373  math::XYZPoint vtx(0.,0.,0.);
374  if (!vertexCollection.empty()) vtx = vertexCollection.begin()->position();
375  // compute momentum vector of photon from primary vertex and cluster position
376  math::XYZVector direction = caloPosition - vtx;
377  //math::XYZVector momentum = direction.unit() * photonEnergy ;
378  math::XYZVector momentum = direction.unit() ;
379 
380  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
381  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy );
382  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
383  //std::cout << " standard p4 before " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
384  //std::cout << " type " <<newCandidate.getCandidateP4type() << " standard p4 after " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
385 
386  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
387  reco::Photon::FiducialFlags fiducialFlags;
388  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
389  thePhotonIsolationCalculator_-> calculate ( &newCandidate,evt,es,fiducialFlags,isolVarR04, isolVarR03);
390  newCandidate.setFiducialVolumeFlags( fiducialFlags );
391  newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
392 
393 
395  reco::Photon::ShowerShape showerShape;
396  showerShape.e1x5= e1x5;
397  showerShape.e2x5= e2x5;
398  showerShape.e3x3= e3x3;
399  showerShape.e5x5= e5x5;
400  showerShape.maxEnergyXtal = maxXtal;
401  showerShape.sigmaEtaEta = sigmaEtaEta;
402  showerShape.sigmaIetaIeta = sigmaIetaIeta;
403  showerShape.hcalDepth1OverEcal = HoE1;
404  showerShape.hcalDepth2OverEcal = HoE2;
405  showerShape.hcalDepth1OverEcalBc = hcalDepth1OverEcalBc;
406  showerShape.hcalDepth2OverEcalBc = hcalDepth2OverEcalBc;
407  showerShape.hcalTowersBehindClusters = TowersBehindClus;
408  newCandidate.setShowerShapeVariables ( showerShape );
409 
411  reco::Photon::ShowerShape full5x5_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;
416  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
417  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
418  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
419  newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
420 
423  // Photon candidate takes by default (set in photons_cfi.py) a 4-momentum derived from the ecal photon-specific corrections.
424  thePhotonEnergyCorrector_->calculate(evt, newCandidate, subdet, vertexCollection,es);
425  if ( candidateP4type_ == "fromEcalEnergy") {
426  newCandidate.setP4( newCandidate.p4(reco::Photon::ecal_photons) );
427  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
428  } else if ( candidateP4type_ == "fromRegression") {
429  newCandidate.setP4( newCandidate.p4(reco::Photon::regression1) );
430  newCandidate.setCandidateP4type(reco::Photon::regression1);
431  }
432 
433  // std::cout << " final p4 " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
434 
435 
436  // std::cout << " PhotonProducer from candidate HoE with towers in a cone " << newCandidate.hadronicOverEm() << " " << newCandidate.hadronicDepth1OverEm() << " " << newCandidate.hadronicDepth2OverEm() << std::endl;
437  // std::cout << " PhotonProducer from candidate of HoE with towers behind the BCs " << newCandidate.hadTowOverEm() << " " << newCandidate.hadTowDepth1OverEm() << " " << newCandidate.hadTowDepth2OverEm() << std::endl;
438 
439 
440  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
442  if(subdet==EcalBarrel && runMIPTagger_ )
443  {
444 
445  thePhotonMIPHaloTagger_-> MIPcalculate( &newCandidate,evt,es,mipVar);
446  newCandidate.setMIPVariables(mipVar);
447  }
448 
449 
450 
452  bool isLooseEM=true;
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;
462  }
463 
464 
465 
466  if ( isLooseEM)
467  outputPhotonCollection.push_back(newCandidate);
468 
469 
470  }
471 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
std::vector< double > preselCutValuesEndcap_
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: Photon.h:152
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
#define nullptr
int init
Definition: HydjetWrapper.h:67
PositionCalc posCalculator_
double hOverEConeSize_
std::vector< int > flagsexclEB_
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEB_
edm::ESHandle< CaloGeometry > theCaloGeom_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
T const * product() const
Definition: Handle.h:74
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< double > preselCutValuesBarrel_
ESHandle< TrackerGeometry > geometry
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:68
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
T const * product() const
Definition: ESHandle.h:86
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void PhotonProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 158 of file PhotonProducer.cc.

References barrelEcalHits_, particleFlowSuperClusterOOTECAL_cff::barrelRecHits, endcapEcalHits_, particleFlowSuperClusterOOTECAL_cff::endcapRecHits, fillPhotonCollection(), edm::EventSetup::get(), edm::Event::getByToken(), hcalTowers_, edm::HandleBase::isValid(), eostools::move(), gedPhotons_cfi::outputPhotonCollection, PhotonCollection_, photonCoreProducer_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), theCaloGeom_, theCaloTopo_, ecaldqm::topology(), usePrimaryVertex_, particleFlowSuperClusterECAL_cfi::vertexCollection, and vertexProducer_.

158  {
159 
160  using namespace edm;
161  // nEvt_++;
162 
164  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
165 
166 
167  // Get the PhotonCore collection
168  bool validPhotonCoreHandle=true;
169  Handle<reco::PhotonCoreCollection> photonCoreHandle;
170  theEvent.getByToken(photonCoreProducer_,photonCoreHandle);
171  if (!photonCoreHandle.isValid()) {
172  edm::LogError("PhotonProducer")
173  << "Error! Can't get the photonCoreProducer";
174  validPhotonCoreHandle=false;
175  }
176 
177  // Get EcalRecHits
178  bool validEcalRecHits=true;
179  Handle<EcalRecHitCollection> barrelHitHandle;
181  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
182  if (!barrelHitHandle.isValid()) {
183  edm::LogError("PhotonProducer")
184  << "Error! Can't get the barrelEcalHits";
185  validEcalRecHits=false;
186  }
187  if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.product());
188 
189 
190  Handle<EcalRecHitCollection> endcapHitHandle;
191  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
193  if (!endcapHitHandle.isValid()) {
194  edm::LogError("PhotonProducer")
195  << "Error! Can't get the endcapEcalHits";
196  validEcalRecHits=false;
197  }
198  if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.product());
199 
200  //AA
201  //Get the severity level object
203  theEventSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
204  //
205 
206 
207 // get Hcal towers collection
208  Handle<CaloTowerCollection> hcalTowersHandle;
209  theEvent.getByToken(hcalTowers_, hcalTowersHandle);
210 
211 
212  // get the geometry from the event setup:
213  theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);
214 
215  //
216  // update energy correction function
217  // energyCorrectionF->init(theEventSetup);
218 
219  edm::ESHandle<CaloTopology> pTopology;
220  theEventSetup.get<CaloTopologyRecord>().get(theCaloTopo_);
222 
223  // Get the primary event vertex
224  Handle<reco::VertexCollection> vertexHandle;
226  bool validVertex=true;
227  if ( usePrimaryVertex_ ) {
228  theEvent.getByToken(vertexProducer_, vertexHandle);
229  if (!vertexHandle.isValid()) {
230  edm::LogWarning("PhotonProducer") << "Error! Can't get the product primary Vertex Collection "<< "\n";
231  validVertex=false;
232  }
233  if (validVertex) vertexCollection = *(vertexHandle.product());
234  }
235  // math::XYZPoint vtx(0.,0.,0.);
236  //if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
237 
238 
239  int iSC=0; // index in photon collection
240  // Loop over barrel and endcap SC collections and fill the photon collection
241  if ( validPhotonCoreHandle)
242  fillPhotonCollection(theEvent,
243  theEventSetup,
244  photonCoreHandle,
245  topology,
246  &barrelRecHits,
247  &endcapRecHits,
248  hcalTowersHandle,
249  //vtx,
250  vertexCollection,
251  outputPhotonCollection,
252  iSC,
253  sevLv.product());
254 
255 
256  // put the product in the event
257  edm::LogInfo("PhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
258  outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
259  theEvent.put(std::move(outputPhotonCollection_p), PhotonCollection_);
260 
261 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
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)
CaloTopology const * topology(0)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
edm::ESHandle< CaloTopology > theCaloTopo_
bool isValid() const
Definition: HandleBase.h:74
std::string PhotonCollection_
edm::ESHandle< CaloGeometry > theCaloGeom_
T const * product() const
Definition: Handle.h:74
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
HLT enums.
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<EcalRecHitCollection> PhotonProducer::barrelEcalHits_
private

Definition at line 64 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::string PhotonProducer::candidateP4type_
private

Definition at line 111 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::ParameterSet PhotonProducer::conf_
private

Definition at line 93 of file PhotonProducer.h.

Referenced by PhotonProducer().

std::string PhotonProducer::conversionCollection_
private

Definition at line 70 of file PhotonProducer.h.

std::string PhotonProducer::conversionProducer_
private

Definition at line 69 of file PhotonProducer.h.

edm::EDGetTokenT<EcalRecHitCollection> PhotonProducer::endcapEcalHits_
private

Definition at line 65 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

EcalClusterFunctionBaseClass* PhotonProducer::energyCorrectionF
private

Definition at line 109 of file PhotonProducer.h.

std::vector<int> PhotonProducer::flagsexclEB_
private

Definition at line 75 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::flagsexclEE_
private

Definition at line 76 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::EDGetTokenT<CaloTowerCollection> PhotonProducer::hcalTowers_
private

Definition at line 66 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

double PhotonProducer::highEt_
private

Definition at line 84 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::hOverEConeSize_
private

Definition at line 81 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::maxHOverE_
private

Definition at line 82 of file PhotonProducer.h.

double PhotonProducer::minR9Barrel_
private

Definition at line 85 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minR9Endcap_
private

Definition at line 86 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minSCEt_
private

Definition at line 83 of file PhotonProducer.h.

std::string PhotonProducer::PhotonCollection_
private

Definition at line 62 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

edm::EDGetTokenT<reco::PhotonCoreCollection> PhotonProducer::photonCoreProducer_
private

Definition at line 63 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::string PhotonProducer::pixelSeedProducer_
private

Definition at line 90 of file PhotonProducer.h.

PositionCalc PhotonProducer::posCalculator_
private

Definition at line 95 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<double> PhotonProducer::preselCutValuesBarrel_
private

Definition at line 106 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<double> PhotonProducer::preselCutValuesEndcap_
private

Definition at line 107 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

bool PhotonProducer::runMIPTagger_
private

Definition at line 87 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::severitiesexclEB_
private

Definition at line 77 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::severitiesexclEE_
private

Definition at line 78 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::ESHandle<CaloGeometry> PhotonProducer::theCaloGeom_
private

Definition at line 97 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and produce().

edm::ESHandle<CaloTopology> PhotonProducer::theCaloTopo_
private

Definition at line 98 of file PhotonProducer.h.

Referenced by produce().

PhotonEnergyCorrector* PhotonProducer::thePhotonEnergyCorrector_
private

Definition at line 110 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), PhotonProducer(), and ~PhotonProducer().

PhotonIsolationCalculator* PhotonProducer::thePhotonIsolationCalculator_
private

Definition at line 101 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), PhotonProducer(), and ~PhotonProducer().

PhotonMIPHaloTagger* PhotonProducer::thePhotonMIPHaloTagger_
private

Definition at line 104 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), PhotonProducer(), and ~PhotonProducer().

bool PhotonProducer::usePrimaryVertex_
private

Definition at line 92 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

bool PhotonProducer::validConversions_
private

Definition at line 89 of file PhotonProducer.h.

bool PhotonProducer::validPixelSeeds_
private

Definition at line 100 of file PhotonProducer.h.

edm::EDGetTokenT<reco::VertexCollection> PhotonProducer::vertexProducer_
private

Definition at line 67 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().