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 
67  if(geom_->isV9Geometry())
68  {
71  }
72  else
73  {
76  }
77 }
78 
80  if(id.det() == DetId::Hcal) {
81  throw cms::Exception("hgcal::HGCalTriggerTools")
82  << "method getTCPosition called for DetId not belonging to a TC";
83  // FIXME: this would actually need a better test...but at the moment I can not think to anything better
84  // to distinguish a TC detId
85  }
86 
88  return position;
89 }
90 
91 
92 unsigned
95 {
96  unsigned layers = 0;
97  switch(type)
98  {
100  layers = eeLayers_;
101  break;
103  layers = fhLayers_;
104  break;
106  layers = bhLayers_;
107  break;
109  layers = totalLayers_;
110  break;
111  default:
112  break;
113  };
114  return layers;
115 }
116 
117 unsigned
119 layer(const DetId& id) const {
121  if( id.det() == DetId::Forward) {
122  const HGCalDetId hid(id);
123  layer = hid.layer();
124  } else if( id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) {
125  const HcalDetId hcid(id);
126  layer = hcid.depth();
127  }
128  return layer;
129 }
130 
131 unsigned
133 layerWithOffset(const DetId& id) const {
134  unsigned int l = layer(id);
135  if( id.det() == DetId::Forward && id.subdetId() == HGCHEF ) {
136  l += eeLayers_;
137  } else if( (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) ||
138  (id.det() == DetId::Forward && id.subdetId() == HGCHEB) ) {
139  if(geom_->isV9Geometry()) l += eeLayers_;
140  else l += eeLayers_ + fhLayers_;
141  }
142  return l;
143 }
144 
145 float HGCalTriggerTools::getEta(const GlobalPoint& position, const float& vertex_z) const {
146  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z()-vertex_z);
147  return corrected_position.eta();
148 }
149 
150 float HGCalTriggerTools::getTCEta(const DetId& id, const float& vertex_z) const {
152  return getEta(position, vertex_z);
153 }
154 
156  float phi = atan2(position.y(),position.x());
157  return phi;
158 }
159 
160 float HGCalTriggerTools::getTCPhi(const DetId& id) const {
162  return getPhi(position);
163 }
164 
165 float HGCalTriggerTools::getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
166  float eta = getEta(position, vertex_z);
167  float pt = hitEnergy / cosh(eta);
168  return pt;
169 }
170 
171 float HGCalTriggerTools::getTCPt(const DetId& id, const float& hitEnergy, const float& vertex_z) const {
173  return getPt(position, hitEnergy, vertex_z);
174 }
175 
176 float HGCalTriggerTools::getLayerZ(const unsigned& layerWithOffset) const {
177  int subdet = ForwardSubdetector::HGCEE;
178  unsigned offset = 0;
179  if(layerWithOffset > lastLayerEE() && layerWithOffset <= lastLayerFH()) {
181  offset = lastLayerEE();
182  } else if(layerWithOffset > lastLayerFH()) {
184  offset = lastLayerFH();
185  }
186  return getLayerZ(subdet, layerWithOffset - offset);
187 }
188 
189 float HGCalTriggerTools::getLayerZ(const int& subdet, const unsigned& layer) const {
190  float layerGlobalZ = 0.;
191  if(subdet == ForwardSubdetector::HGCEE) {
192  layerGlobalZ = geom_->eeTopology().dddConstants().waferZ(layer, true);
193  } else if(subdet == ForwardSubdetector::HGCHEF) {
194  layerGlobalZ = geom_->fhTopology().dddConstants().waferZ(layer, true);
195  } else if(subdet == HcalSubdetector::HcalEndcap || subdet == ForwardSubdetector::HGCHEB) {
196  if(geom_->isV9Geometry())
197  {
198  layerGlobalZ = geom_->hscTopology().dddConstants().waferZ(layer, true);
199  }
200  else
201  {
202  layerGlobalZ = geom_->bhTopology().dddConstants()->getRZ(
204  geom_->bhTopology().dddConstants()->getEtaRange(1).second,
205  layer);
206  }
207  }
208  return layerGlobalZ;
209 }
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:117
int depth() const
get the tower depth
Definition: HcalDetId.h:162
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
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
const HGCalTopology & hscTopology() const
int getMaxDepth(const int &type) const
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
T get() const
Definition: EventSetup.h:62
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