CMS 3D CMS Logo

HGCalTriggerTools.cc
Go to the documentation of this file.
2 
3 
5 
12 
14 
16 
17 
18 namespace {
19  constexpr char hgcalee_sens[] = "HGCalEESensitive";
20  constexpr char hgcalfh_sens[] = "HGCalHESiliconSensitive";
21 
22 
23  template<typename DDD>
24  inline void check_ddd(const DDD* ddd) {
25  if( nullptr == ddd ) {
26  throw cms::Exception("hgcal::HGCalTriggerTools")
27  << "DDDConstants not accessible to hgcal::HGCalTriggerTools!";
28  }
29  }
30 
31  template<typename GEOM>
32  inline void check_geom(const GEOM* geom) {
33  if( nullptr == geom ) {
34  throw cms::Exception("hgcal::HGCalTriggerTools")
35  << "Geometry not provided yet to hgcal::HGCalTriggerTools!";
36  }
37  }
38 
39  inline const HcalDDDRecConstants* get_ddd(const CaloSubdetectorGeometry* geom,
40  const HcalDetId& detid) {
41  const HcalGeometry* hc = static_cast<const HcalGeometry*>(geom);
42  const HcalDDDRecConstants* ddd = hc->topology().dddConstants();
43  check_ddd(ddd);
44  return ddd;
45  }
46 
47  inline const HGCalDDDConstants* get_ddd(const CaloSubdetectorGeometry* geom,
48  const HGCalDetId& detid) {
49  const HGCalGeometry* hg = static_cast<const HGCalGeometry*>(geom);
50  const HGCalDDDConstants* ddd = &(hg->topology().dddConstants());
51  check_ddd(ddd);
52  return ddd;
53  }
54 
55 }
56 
57 void
60 {
62  es.get<CaloGeometryRecord>().get(triggerGeometry_);
63  geom_ = triggerGeometry_.product();
64 
69 }
70 
72  if(id.det() == DetId::Hcal) {
73  throw cms::Exception("hgcal::HGCalTriggerTools")
74  << "method getTCPosition called for DetId not belonging to a TC";
75  // FIXME: this would actually need a better test...but at the moment I can not think to anything better
76  // to distinguish a TC detId
77  }
78 
80  return position;
81 }
82 
83 
84 unsigned
87 {
88  unsigned layers = 0;
89  switch(type)
90  {
92  layers = eeLayers_;
93  break;
95  layers = fhLayers_;
96  break;
98  layers = bhLayers_;
99  break;
101  layers = totalLayers_;
102  break;
103  default:
104  break;
105  };
106  return layers;
107 }
108 
109 unsigned
111 layer(const DetId& id) const {
113  if( id.det() == DetId::Forward) {
114  const HGCalDetId hid(id);
115  layer = hid.layer();
116  } else if( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) {
117  const HcalDetId hcid(id);
118  layer = hcid.depth();
119  }
120  return layer;
121 }
122 
123 unsigned
125 layerWithOffset(const DetId& id) const {
126  unsigned int l = layer(id);
127  if( id.det() == DetId::Forward && id.subdetId() == HGCHEF ) {
128  l += eeLayers_;
129  } else if( (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) ||
130  (id.det() == DetId::Forward && id.subdetId() == HGCHEB) ) {
131  l += eeLayers_ + fhLayers_;
132  }
133  return l;
134 }
135 
136 float HGCalTriggerTools::getEta(const GlobalPoint& position, const float& vertex_z) const {
137  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z()-vertex_z);
138  return corrected_position.eta();
139 }
140 
141 float HGCalTriggerTools::getTCEta(const DetId& id, const float& vertex_z) const {
143  return getEta(position, vertex_z);
144 }
145 
147  float phi = atan2(position.y(),position.x());
148  return phi;
149 }
150 
151 float HGCalTriggerTools::getTCPhi(const DetId& id) const {
153  return getPhi(position);
154 }
155 
156 float HGCalTriggerTools::getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
157  float eta = getEta(position, vertex_z);
158  float pt = hitEnergy / cosh(eta);
159  return pt;
160 }
161 
162 float HGCalTriggerTools::getTCPt(const DetId& id, const float& hitEnergy, const float& vertex_z) const {
164  return getPt(position, hitEnergy, vertex_z);
165 }
166 
167 float HGCalTriggerTools::getLayerZ(const unsigned& layerWithOffset) const {
168  int subdet = ForwardSubdetector::HGCEE;
169  unsigned offset = 0;
170  if(layerWithOffset > lastLayerEE() && layerWithOffset <= lastLayerFH()) {
172  offset = lastLayerEE();
173  } else if(layerWithOffset > lastLayerFH()) {
175  offset = lastLayerFH();
176  }
177  return getLayerZ(subdet, layerWithOffset - offset);
178 }
179 
180 float HGCalTriggerTools::getLayerZ(const int& subdet, const unsigned& layer) const {
181  float layerGlobalZ = 0.;
182  if(subdet == ForwardSubdetector::HGCEE) {
183  layerGlobalZ = geom_->eeTopology().dddConstants().waferZ(layer, true);
184  } else if(subdet == ForwardSubdetector::HGCHEF) {
185  layerGlobalZ = geom_->fhTopology().dddConstants().waferZ(layer, true);
186  } else if(subdet == HcalSubdetector::HcalEndcap || subdet == ForwardSubdetector::HGCHEB) {
187  std::pair<int,int> eta_range = geom_->bhTopology().dddConstants()->getEtaRange(1);
188  layerGlobalZ = geom_->bhTopology().dddConstants()->getRZ(HcalSubdetector::HcalEndcap,eta_range.second,layer);
189  }
190  return layerGlobalZ;
191 }
type
Definition: HCALResponse.h:21
float getTCEta(const DetId &id, const float &vertex_z=0.) const
unsigned layer(const DetId &) const
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:167
void eventSetup(const edm::EventSetup &)
unsigned lastLayerEE() const
const HGCalTopology & eeTopology() const
const HGCalTriggerGeometryBase * geom_
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
float getLayerZ(const unsigned &layerWithOffset) const
unsigned layerWithOffset(const DetId &) const
ForwardSubdetector
#define constexpr
std::pair< int, int > getEtaRange(const int &i) const
const HcalTopology & topology() const
Definition: HcalGeometry.h:116
int depth() const
get the tower depth
Definition: HcalDetId.cc:108
unsigned int layers(bool reco) const
float getEta(const GlobalPoint &position, const float &vertex_z=0.) const
const HcalTopology & bhTopology() const
T z() const
Definition: PV3DBase.h:64
const HGCalTopology & topology() const
Definition: HGCalGeometry.h:99
double getRZ(const int &subdet, const int &ieta, const int &depth) const
float getTCPhi(const DetId &id) const
float getTCPt(const DetId &id, const float &hitEnergy, const float &vertex_z=0.) const
double waferZ(int layer, bool reco) const
float getPhi(const GlobalPoint &position) const
Definition: DetId.h:18
unsigned layers(ForwardSubdetector type) const
const HGCalDDDConstants & dddConstants() const
int getMaxDepth(const int &type) const
const T & get() const
Definition: EventSetup.h:59
T eta() const
Definition: PV3DBase.h:76
float getPt(const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const
static int position[264][3]
Definition: ReadPGInfo.cc:509
susybsm::HSCParticleCollection hc
Definition: classes.h:25
GlobalPoint getTCPosition(const DetId &id) const
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
const HGCalTopology & fhTopology() const
int layer() const
get the layer #
Definition: HGCalDetId.h:48
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const =0
unsigned lastLayerFH() const