CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonProducer Class Reference

#include <PhotonProducer.h>

Inheritance diagram for PhotonProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &r, edm::EventSetup const &es) overridefinal
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) overridefinal
 
 PhotonProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 
 ~PhotonProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::InputTag barrelEcalHits_
 
std::string candidateP4type_
 
edm::ParameterSet conf_
 
std::string conversionCollection_
 
std::string conversionProducer_
 
edm::InputTag endcapEcalHits_
 
EcalClusterFunctionBaseClassenergyCorrectionF
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::InputTag hcalTowers_
 
double highEt_
 
double hOverEConeSize_
 
double maxHOverE_
 
double minR9Barrel_
 
double minR9Endcap_
 
double minSCEt_
 
std::string PhotonCollection_
 
edm::InputTag photonCoreProducer_
 
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_
 
std::string vertexProducer_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Id:
PhotonProducer.h,v 1.46 2013/02/27 20:33:00 eulisse Exp
Date:
2013/02/27 20:33:00
Revision:
1.46
Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 41 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_, minR9Barrel_, minR9Endcap_, PhotonCollection_, photonCoreProducer_, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, usePrimaryVertex_, and vertexProducer_.

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

Definition at line 135 of file PhotonProducer.cc.

136 {
137 
138  //delete energyCorrectionF;
139 }

Member Function Documentation

void PhotonProducer::beginRun ( edm::Run const &  r,
edm::EventSetup const &  es 
)
finaloverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 143 of file PhotonProducer.cc.

References conf_, flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), init, PhotonMIPHaloTagger::setup(), PhotonIsolationCalculator::setup(), severitiesexclEB_, severitiesexclEE_, thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.

143  {
144 
146  edm::ParameterSet isolationSumsCalculatorSet = conf_.getParameter<edm::ParameterSet>("isolationSumsCalculatorSet");
148 
150  edm::ParameterSet mipVariableSet = conf_.getParameter<edm::ParameterSet>("mipVariableSet");
151  thePhotonMIPHaloTagger_->setup(mipVariableSet);
153  thePhotonEnergyCorrector_ -> init(theEventSetup);
154 }
T getParameter(std::string const &) const
edm::ParameterSet conf_
int init
Definition: HydjetWrapper.h:63
std::vector< int > flagsexclEB_
std::vector< int > flagsexclEE_
std::vector< int > severitiesexclEE_
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEB_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
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_)
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
void setup(const edm::ParameterSet &conf)
void PhotonProducer::endRun ( edm::Run const &  r,
edm::EventSetup const &  theEventSetup 
)
finaloverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 156 of file PhotonProducer.cc.

References thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.

156  {
157 
161 }
PhotonIsolationCalculator * thePhotonIsolationCalculator_
PhotonEnergyCorrector * thePhotonEnergyCorrector_
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
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

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

Pre-selection loose isolation cuts

Definition at line 266 of file PhotonProducer.cc.

References PhotonEnergyCorrector::calculate(), PositionCalc::Calculate_Location(), candidateP4type_, EcalClusterTools::covariances(), EcalClusterTools::e1x5(), reco::Photon::ShowerShape::e1x5, reco::Photon::ShowerShape::e2x5, EcalClusterTools::e2x5Max(), EcalClusterTools::e3x3(), reco::Photon::ShowerShape::e3x3, EcalClusterTools::e5x5(), reco::Photon::ShowerShape::e5x5, DetId::Ecal, reco::Photon::ecal_photons, EcalBarrel, EcalEndcap, EcalPreshower, EcalClusterTools::eMax(), flagsexclEB_, flagsexclEE_, geometry, EgammaHadTower::getDepth1HcalESum(), EgammaHadTower::getDepth2HcalESum(), EgammaTowerIsolation::getTowerESum(), reco::Photon::ShowerShape::hcalDepth1OverEcal, reco::Photon::ShowerShape::hcalDepth1OverEcalBc, reco::Photon::ShowerShape::hcalDepth2OverEcal, reco::Photon::ShowerShape::hcalDepth2OverEcalBc, reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, hOverEConeSize_, EcalClusterTools::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, minR9Barrel_, minR9Endcap_, p4, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, edm::Handle< T >::product(), edm::ESHandle< class >::product(), reco::Photon::regression1, runMIPTagger_, EgammaHadTower::setTowerCollection(), severitiesexclEB_, severitiesexclEE_, reco::Photon::ShowerShape::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), theCaloGeom_, thePhotonEnergyCorrector_, thePhotonIsolationCalculator_, thePhotonMIPHaloTagger_, and EgammaHadTower::towersOf().

Referenced by produce().

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

Implements edm::EDProducer.

Definition at line 164 of file PhotonProducer.cc.

References barrelEcalHits_, endcapEcalHits_, fillPhotonCollection(), edm::EventSetup::get(), edm::Event::getByLabel(), hcalTowers_, edm::InputTag::label(), PhotonCollection_, photonCoreProducer_, edm::ESHandle< class >::product(), edm::Event::put(), theCaloGeom_, theCaloTopo_, usePrimaryVertex_, GoodVertex_cfg::vertexCollection, and vertexProducer_.

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

Member Data Documentation

edm::InputTag PhotonProducer::barrelEcalHits_
private

Definition at line 70 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::string PhotonProducer::candidateP4type_
private

Definition at line 117 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::ParameterSet PhotonProducer::conf_
private

Definition at line 99 of file PhotonProducer.h.

Referenced by beginRun(), and PhotonProducer().

std::string PhotonProducer::conversionCollection_
private

Definition at line 76 of file PhotonProducer.h.

std::string PhotonProducer::conversionProducer_
private

Definition at line 75 of file PhotonProducer.h.

edm::InputTag PhotonProducer::endcapEcalHits_
private

Definition at line 71 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

EcalClusterFunctionBaseClass* PhotonProducer::energyCorrectionF
private

Definition at line 115 of file PhotonProducer.h.

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

Definition at line 81 of file PhotonProducer.h.

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

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

Definition at line 82 of file PhotonProducer.h.

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

edm::InputTag PhotonProducer::hcalTowers_
private

Definition at line 73 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

double PhotonProducer::highEt_
private

Definition at line 90 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::hOverEConeSize_
private

Definition at line 87 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::maxHOverE_
private

Definition at line 88 of file PhotonProducer.h.

double PhotonProducer::minR9Barrel_
private

Definition at line 91 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minR9Endcap_
private

Definition at line 92 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minSCEt_
private

Definition at line 89 of file PhotonProducer.h.

std::string PhotonProducer::PhotonCollection_
private

Definition at line 68 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

edm::InputTag PhotonProducer::photonCoreProducer_
private

Definition at line 69 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::string PhotonProducer::pixelSeedProducer_
private

Definition at line 96 of file PhotonProducer.h.

PositionCalc PhotonProducer::posCalculator_
private

Definition at line 101 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 112 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 113 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

bool PhotonProducer::runMIPTagger_
private

Definition at line 93 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 83 of file PhotonProducer.h.

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

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

Definition at line 84 of file PhotonProducer.h.

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

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

Definition at line 103 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and produce().

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

Definition at line 104 of file PhotonProducer.h.

Referenced by produce().

PhotonEnergyCorrector* PhotonProducer::thePhotonEnergyCorrector_
private

Definition at line 116 of file PhotonProducer.h.

Referenced by beginRun(), endRun(), and fillPhotonCollection().

PhotonIsolationCalculator* PhotonProducer::thePhotonIsolationCalculator_
private

Definition at line 107 of file PhotonProducer.h.

Referenced by beginRun(), endRun(), and fillPhotonCollection().

PhotonMIPHaloTagger* PhotonProducer::thePhotonMIPHaloTagger_
private

Definition at line 110 of file PhotonProducer.h.

Referenced by beginRun(), endRun(), and fillPhotonCollection().

bool PhotonProducer::usePrimaryVertex_
private

Definition at line 98 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

bool PhotonProducer::validConversions_
private

Definition at line 95 of file PhotonProducer.h.

bool PhotonProducer::validPixelSeeds_
private

Definition at line 106 of file PhotonProducer.h.

std::string PhotonProducer::vertexProducer_
private

Definition at line 97 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().