CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalTriggerTools.cc
Go to the documentation of this file.
2 
4 
12 
14 
16 
17 namespace {
18  template <typename DDD>
19  inline void check_ddd(const DDD* ddd) {
20  if (nullptr == ddd) {
21  throw cms::Exception("hgcal::HGCalTriggerTools") << "DDDConstants not accessible to hgcal::HGCalTriggerTools!";
22  }
23  }
24 
25  template <typename GEOM>
26  inline void check_geom(const GEOM* geom) {
27  if (nullptr == geom) {
28  throw cms::Exception("hgcal::HGCalTriggerTools") << "Geometry not provided yet to hgcal::HGCalTriggerTools!";
29  }
30  }
31 } // namespace
32 
33 // Kept for backward compatibility: used in L1Trigger/L1CaloTrigger/test
36  es.get<CaloGeometryRecord>().get(triggerGeometry);
37  setGeometry(triggerGeometry.product());
38 }
39 
41  geom_ = geom;
46 
49 }
50 
52  if (id.det() == DetId::HGCalEE) {
53  throw cms::Exception("hgcal::HGCalTriggerTools") << "method getTCPosition called for DetId not belonging to a TC";
54  // FIXME: this would actually need a better test...but at the moment I can not think to anything better
55  // to distinguish a TC detId
56  }
57 
59  return position;
60 }
61 
63  unsigned layers = 0;
64  switch (type) {
66  layers = eeLayers_;
67  break;
69  layers = fhLayers_;
70  break;
72  layers = bhLayers_;
73  break;
75  layers = noseLayers_;
76  break;
78  layers = totalLayers_;
79  break;
80  default:
81  break;
82  };
83  return layers;
84 }
85 
87  unsigned layers = 0;
88  switch (type) {
89  case DetId::HGCalEE:
90  layers = eeLayers_;
91  break;
92  case DetId::HGCalHSi:
93  layers = fhLayers_;
94  break;
95  case DetId::HGCalHSc:
96  layers = bhLayers_;
97  break;
98  // FIXME: to do HFNose
99  case DetId::Forward:
100  layers = totalLayers_;
101  break;
102  default:
103  break;
104  }
105  return layers;
106 }
107 
108 unsigned HGCalTriggerTools::layer(const DetId& id) const {
110  if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
111  layer = HFNoseDetId(id).layer();
112  } else if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HGCTrigger) {
113  layer = HGCalTriggerModuleDetId(id).layer();
114  } else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
115  layer = HGCSiliconDetId(id).layer();
116  } else if (id.det() == DetId::HGCalTrigger &&
119  layer = HGCalTriggerDetId(id).layer();
120  } else if (id.det() == DetId::HGCalTrigger &&
122  layer = HFNoseTriggerDetId(id).layer();
123  } else if (id.det() == DetId::HGCalHSc) {
124  layer = HGCScintillatorDetId(id).layer();
125  }
126  return layer;
127 }
128 
129 unsigned HGCalTriggerTools::layerWithOffset(const DetId& id) const {
130  unsigned int l = layer(id);
131 
132  if (isNose(id)) {
133  l = layer(id); // no offset for HFnose
134  } else if (isHad(id)) {
135  l += eeLayers_;
136  }
137 
138  return l;
139 }
140 
141 bool HGCalTriggerTools::isEm(const DetId& id) const {
142  bool em = false;
143 
144  if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
145  em = HFNoseDetId(id).isEE();
146  } else if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HGCTrigger) {
147  em = HGCalTriggerModuleDetId(id).isEE();
148  } else if (id.det() == DetId::HGCalEE) {
149  em = true;
150  } else if (id.det() == DetId::HGCalTrigger &&
152  em = true;
153  } else if (id.det() == DetId::HGCalTrigger &&
155  em = HFNoseTriggerDetId(id).isEE();
156  }
157  return em;
158 }
159 
160 bool HGCalTriggerTools::isNose(const DetId& id) const {
161  bool nose = false;
162  if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
163  nose = true;
164  } else if (id.det() == DetId::HGCalTrigger &&
166  nose = true;
167  }
168  return nose;
169 }
170 
171 bool HGCalTriggerTools::isSilicon(const DetId& id) const {
172  bool silicon = false;
173  if (id.det() == DetId::Forward && id.subdetId() == HGCTrigger) {
175  } else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
176  silicon = true;
177  } else if (id.det() == DetId::HGCalTrigger &&
179  silicon = true;
180  } else if (id.det() == DetId::HGCalTrigger &&
183  silicon = true;
184  }
185  return silicon;
186 }
187 
189  SubDetectorType subdet;
190  if (!isScintillator(id)) {
191  if (isEm(id))
193  else
195  } else
197  return subdet;
198 }
199 
200 int HGCalTriggerTools::zside(const DetId& id) const {
201  int zside = 0;
202  if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
203  zside = HFNoseDetId(id).zside();
204  } else if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::HGCTrigger) {
205  zside = HGCalTriggerModuleDetId(id).zside();
206  } else if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
207  zside = HGCSiliconDetId(id).zside();
208  } else if (id.det() == DetId::HGCalTrigger &&
211  zside = HGCalTriggerDetId(id).zside();
212  } else if (id.det() == DetId::HGCalTrigger &&
214  zside = HFNoseTriggerDetId(id).zside();
215  } else if (id.det() == DetId::HGCalHSc) {
216  zside = HGCScintillatorDetId(id).zside();
217  }
218  return zside;
219 }
220 
222  if (isScintillator(id)) {
224  }
225  unsigned det = id.det();
226  int thickness = 0;
227  if (det == DetId::HGCalEE || det == DetId::HGCalHSi) {
228  thickness = HGCSiliconDetId(id).type();
229  } else if (det == DetId::Forward && id.subdetId() == ForwardSubdetector::HFNose) {
230  thickness = HFNoseDetId(id).type();
231  } else if (det == DetId::Forward && id.subdetId() == ForwardSubdetector::HGCTrigger) {
232  thickness = HGCalTriggerModuleDetId(id).type();
233  } else if (id.det() == DetId::HGCalTrigger &&
236  thickness = HGCalTriggerDetId(id).type();
237  } else if (id.det() == DetId::HGCalTrigger &&
239  thickness = HFNoseTriggerDetId(id).type();
240  }
241  return thickness;
242 }
243 
244 float HGCalTriggerTools::getEta(const GlobalPoint& position, const float& vertex_z) const {
245  GlobalPoint corrected_position = GlobalPoint(position.x(), position.y(), position.z() - vertex_z);
246  return corrected_position.eta();
247 }
248 
249 float HGCalTriggerTools::getTCEta(const DetId& id, const float& vertex_z) const {
251  return getEta(position, vertex_z);
252 }
253 
255  float phi = atan2(position.y(), position.x());
256  return phi;
257 }
258 
259 float HGCalTriggerTools::getTCPhi(const DetId& id) const {
261  return getPhi(position);
262 }
263 
264 float HGCalTriggerTools::getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z) const {
265  float eta = getEta(position, vertex_z);
266  float pt = hitEnergy / cosh(eta);
267  return pt;
268 }
269 
270 float HGCalTriggerTools::getTCPt(const DetId& id, const float& hitEnergy, const float& vertex_z) const {
272  return getPt(position, hitEnergy, vertex_z);
273 }
274 
275 float HGCalTriggerTools::getLayerZ(const unsigned& layerWithOffset) const {
276  int subdet = ForwardSubdetector::HGCEE;
277  unsigned offset = 0;
278  if (layerWithOffset > lastLayerEE() && layerWithOffset <= lastLayerFH()) {
280  offset = lastLayerEE();
281  } else if (layerWithOffset > lastLayerFH()) {
283  offset = lastLayerFH();
284  }
285  // note for HFnose offset is always zero since we have less layers than HGCEE
286  return getLayerZ(subdet, layerWithOffset - offset);
287 }
288 
289 float HGCalTriggerTools::getLayerZ(const int& subdet, const unsigned& layer) const {
290  float layerGlobalZ = 0.;
291  if ((subdet == ForwardSubdetector::HGCEE) || (subdet == DetId::HGCalEE)) {
292  layerGlobalZ = geom_->eeTopology().dddConstants().waferZ(layer, true);
293  } else if ((subdet == ForwardSubdetector::HGCHEF) || (subdet == DetId::HGCalHSi)) {
294  layerGlobalZ = geom_->fhTopology().dddConstants().waferZ(layer, true);
295  } else if (subdet == ForwardSubdetector::HFNose) {
296  layerGlobalZ = geom_->noseTopology().dddConstants().waferZ(layer, true);
297  } else if ((subdet == ForwardSubdetector::HGCHEB) || (subdet == DetId::HGCalHSc)) {
298  layerGlobalZ = geom_->hscTopology().dddConstants().waferZ(layer, true);
299  }
300  return layerGlobalZ;
301 }
302 
303 DetId HGCalTriggerTools::simToReco(const DetId& simid, const HGCalTopology& topo) const {
304  DetId recoid(0);
305  const auto& dddConst = topo.dddConstants();
306  if (dddConst.waferHexagon8() || dddConst.tileTrapezoid()) {
307  recoid = simid;
308  }
309  return recoid;
310 }
bool isScintillator(const DetId &id) const
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const =0
int zside() const
get the z-side of the module (1/-1)
int thicknessIndex(const DetId &) const
float getTCEta(const DetId &id, const float &vertex_z=0.) const
unsigned layer(const DetId &) const
int zside() const
get the z-side of the cell (1/-1)
Definition: HFNoseDetId.h:53
void eventSetup(const edm::EventSetup &)
HGCalTriggerSubdetector subdet() const
get the subdetector
int type() const
get the type
Definition: HFNoseDetId.h:50
bool isEE() const
consistency check : no bits left =&gt; no overhead
Definition: HFNoseDetId.h:104
const HGCalTopology & eeTopology() const
const HGCalTriggerGeometryBase * geom_
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:60
bool isEE() const
consistency check : no bits left =&gt; no overhead
int zside() const
get the z-side of the cell (1/-1)
int zside() const
get the z-side of the cell (1/-1)
float getLayerZ(const unsigned &layerWithOffset) const
unsigned layerWithOffset(const DetId &) const
ForwardSubdetector
int type() const
get the type
constexpr std::array< uint8_t, layerIndexSize > layer
void setGeometry(const HGCalTriggerGeometryBase *const)
int layer() const
get the layer #
int type() const
get the type
bool isHad(const DetId &id) const
unsigned int layers(bool reco) const
float getEta(const GlobalPoint &position, const float &vertex_z=0.) const
int layer() const
get the layer #
Definition: HFNoseDetId.h:56
int zside(const DetId &) const
int type() const
get the type
int layer() const
get the layer #
T z() const
Definition: PV3DBase.h:61
int zside() const
get the z-side of the cell (1/-1)
unsigned lastLayerEE(bool nose=false) const
bool isNose(const DetId &) const
int layer() const
get the layer #
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:17
unsigned layers(ForwardSubdetector type) const
bool isSilicon(const DetId &) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
const HGCalTopology & hscTopology() const
Detector
Definition: DetId.h:24
T const * product() const
Definition: ESHandle.h:86
int triggerSubdetId() const
get the trigger sub-detector
int layer() const
get the layer #
int layer() const
get the layer #
SubDetectorType getSubDetectorType(const DetId &id) const
T eta() const
Definition: PV3DBase.h:73
bool isEm(const DetId &) const
int zside() const
get the z-side of the cell (1/-1)
float getPt(const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const
static int position[264][3]
Definition: ReadPGInfo.cc:289
T get() const
Definition: EventSetup.h:82
const HGCalTopology & noseTopology() const
GlobalPoint getTCPosition(const DetId &id) const
DetId simToReco(const DetId &, const HGCalTopology &) const
static constexpr unsigned kScintillatorPseudoThicknessIndex_
int type() const
get the type
T x() const
Definition: PV3DBase.h:59
const HGCalTopology & fhTopology() const
unsigned lastLayerFH() const