CMS 3D CMS Logo

HoECalculator.cc
Go to the documentation of this file.
2 
6 
7 HoECalculator::HoECalculator() : theCaloGeom_(nullptr) {}
8 HoECalculator::HoECalculator(const edm::ESHandle<CaloGeometry>& caloGeom) : theCaloGeom_(caloGeom) {}
9 
11  return getHoE(GlobalPoint(clus->x(), clus->y(), clus->z()), clus->energy(), e, c);
12 }
13 
15  return getHoE(GlobalPoint(clus->x(), clus->y(), clus->z()), clus->energy(), e, c);
16 }
17 
18 /*
19 double HoECalculator::operator() ( const reco::SuperCluster* clus,
20  HBHERecHitMetaCollection *mhbhe, int ialgo) {
21  double HoE=0.;
22  switch (ialgo) {
23  case 1:
24  for (reco::CaloCluster_iterator bc=clus->clustersBegin(); bc!=clus->clustersEnd(); bc++) {
25  double HoEi = getHoE(GlobalPoint((*bc)->x(),(*bc)->y(),(*bc)->z()),clus->energy(), mhbhe);
26  if (HoEi > HoE) HoE = HoEi;
27  }
28  break;
29  case 2:
30  HoE = getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
31  break;
32  default:
33  std::cout << "!!! algo for HoE should be 1 or 2 " << std::endl;
34  }
35  return HoE;
36 }
37 
38 double HoECalculator::operator() ( const reco::BasicCluster* clus,
39  HBHERecHitMetaCollection *mhbhe) {
40  return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
41 }
42 
43 */
44 
45 double HoECalculator::getHoE(GlobalPoint pclu, float ecalEnergy, const edm::Event& e, const edm::EventSetup& c) {
46  if (!theCaloGeom_.isValid())
48 
49  //product the geometry
51 
52  //Create a HBHERecHitCollection
54  e.getByLabel("hbhereco", "", hbhe);
55  const HBHERecHitCollection* hithbhe_ = hbhe.product();
56 
57  double HoE = 0.;
59  const CaloSubdetectorGeometry* geometry_p;
60  geometry_p = geometry.getSubdetectorGeometry(DetId::Hcal, 4);
61  DetId hcalDetId;
62  hcalDetId = geometry_p->getClosestCell(pclu);
63  double hcalEnergy = 0;
64 
66  iterRecHit = hithbhe_->find(hcalDetId);
67  if (iterRecHit != hithbhe_->end()) {
68  hcalEnergy = iterRecHit->energy();
69  HoE = hcalEnergy / ecalEnergy;
70  }
71 
72  return HoE;
73 }
74 
75 /*
76 double HoECalculator::getHoE(GlobalPoint pos, float energy,
77  HBHERecHitMetaCollection *mhbhe) {
78 
79  double HoE=0.;
80 
81  if (mhbhe) {
82  const CaloSubdetectorGeometry *geometry_p ;
83  geometry_p = theCaloGeom_->getSubdetectorGeometry (DetId::Hcal,4) ;
84  HcalDetId dB= geometry_p->getClosestCell(pos);
85  CaloRecHitMetaCollectionV::const_iterator i=mhbhe->find(dB);
86  if (i!=mhbhe->end()) {
87  HoE = i->energy()/energy;
88  }
89  }
90  return HoE ;
91 }
92 */
const HBHERecHitCollection * hithbhe_
Definition: HoECalculator.h:40
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< T >::const_iterator const_iterator
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:172
double operator()(const reco::BasicCluster *, const edm::Event &e, const edm::EventSetup &c)
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< CaloGeometry > theCaloGeom_
Definition: HoECalculator.h:39
double getHoE(GlobalPoint pos, float energy, const edm::Event &e, const edm::EventSetup &c)
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:178
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:175
virtual DetId getClosestCell(const GlobalPoint &r) const
bool isValid() const
Definition: ESHandle.h:44
const_iterator end() const
double energy() const
cluster energy
Definition: CaloCluster.h:149
Definition: DetId.h:17
iterator find(key_type k)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const