test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HoECalculator.cc
Go to the documentation of this file.
2 
6 
8  theCaloGeom_(0)
9 {
10 }
12  theCaloGeom_(caloGeom)
13 {
14 }
15 
17 {
18  return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), e,c);
19 }
20 
22 {
23  return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), e,c);
24 }
25 
26 /*
27 double HoECalculator::operator() ( const reco::SuperCluster* clus,
28  HBHERecHitMetaCollection *mhbhe, int ialgo) {
29  double HoE=0.;
30  switch (ialgo) {
31  case 1:
32  for (reco::CaloCluster_iterator bc=clus->clustersBegin(); bc!=clus->clustersEnd(); bc++) {
33  double HoEi = getHoE(GlobalPoint((*bc)->x(),(*bc)->y(),(*bc)->z()),clus->energy(), mhbhe);
34  if (HoEi > HoE) HoE = HoEi;
35  }
36  break;
37  case 2:
38  HoE = getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
39  break;
40  default:
41  std::cout << "!!! algo for HoE should be 1 or 2 " << std::endl;
42  }
43  return HoE;
44 }
45 
46 double HoECalculator::operator() ( const reco::BasicCluster* clus,
47  HBHERecHitMetaCollection *mhbhe) {
48  return getHoE(GlobalPoint(clus->x(),clus->y(),clus->z()), clus->energy(), mhbhe);
49 }
50 
51 */
52 
53 double HoECalculator::getHoE(GlobalPoint pclu, float ecalEnergy, const edm::Event& e , const edm::EventSetup& c )
54 {
55  if ( !theCaloGeom_.isValid() )
57 
58  //product the geometry
60 
61  //Create a HBHERecHitCollection
63  e.getByLabel("hbhereco","",hbhe);
64  const HBHERecHitCollection* hithbhe_ = hbhe.product();
65 
66  double HoE=0.;
68  const CaloSubdetectorGeometry *geometry_p ;
69  geometry_p = geometry.getSubdetectorGeometry (DetId::Hcal,4) ;
70  DetId hcalDetId ;
71  hcalDetId = geometry_p->getClosestCell(pclu) ;
72  double hcalEnergy = 0 ;
73 
75  iterRecHit = hithbhe_->find(hcalDetId) ;
76  if (iterRecHit!=hithbhe_->end()) {
77  hcalEnergy = iterRecHit->energy() ;
78  HoE = hcalEnergy/ecalEnergy ;
79  }
80 
81  return HoE ;
82 }
83 
84 /*
85 double HoECalculator::getHoE(GlobalPoint pos, float energy,
86  HBHERecHitMetaCollection *mhbhe) {
87 
88  double HoE=0.;
89 
90  if (mhbhe) {
91  const CaloSubdetectorGeometry *geometry_p ;
92  geometry_p = theCaloGeom_->getSubdetectorGeometry (DetId::Hcal,4) ;
93  HcalDetId dB= geometry_p->getClosestCell(pos);
94  CaloRecHitMetaCollectionV::const_iterator i=mhbhe->find(dB);
95  if (i!=mhbhe->end()) {
96  HoE = i->energy()/energy;
97  }
98  }
99  return HoE ;
100 }
101 */
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
const HBHERecHitCollection * hithbhe_
Definition: HoECalculator.h:49
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< HBHERecHit >::const_iterator const_iterator
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:160
double operator()(const reco::BasicCluster *, const edm::Event &e, const edm::EventSetup &c)
edm::ESHandle< CaloGeometry > theCaloGeom_
Definition: HoECalculator.h:48
void get(HolderT &iHolder) const
double getHoE(GlobalPoint pos, float energy, const edm::Event &e, const edm::EventSetup &c)
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:154
double energy() const
cluster energy
Definition: CaloCluster.h:121
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
const_iterator end() const
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:157
bool isValid() const
Definition: ESHandle.h:47