CMS 3D CMS Logo

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  const edm::ESHandle<HGCalTriggerGeometryBase>& triggerGeometry = es.getHandle(token);
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;
76  break;
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:
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) {
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 &&
123  } else if (id.det() == DetId::HGCalHSc) {
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) {
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 &&
215  } else if (id.det() == DetId::HGCalHSc) {
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) {
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) {
233  } else if (id.det() == DetId::HGCalTrigger &&
237  } else if (id.det() == DetId::HGCalTrigger &&
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;
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 }
double waferZ(int layer, bool reco) const
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const =0
int layer() const
get the layer #
Definition: HFNoseDetId.h:57
bool isScintillator(const DetId &id) const
void eventSetup(const edm::EventSetup &, const edm::ESGetToken< HGCalTriggerGeometryBase, CaloGeometryRecord > &)
bool isSilicon(const DetId &) const
const HGCalTopology & eeTopology() const
const HGCalTriggerGeometryBase * geom_
T eta() const
Definition: PV3DBase.h:73
float getTCEta(const DetId &id, const float &vertex_z=0.) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
int thicknessIndex(const DetId &) const
bool isHad(const DetId &id) const
int zside() const
get the z-side of the cell (1/-1)
int zside() const
get the z-side of the cell (1/-1)
ForwardSubdetector
constexpr std::array< uint8_t, layerIndexSize > layer
void setGeometry(const HGCalTriggerGeometryBase *const)
int layer() const
get the layer #
int layer() const
get the layer #
bool isEE() const
consistency check : no bits left => no overhead
int type() const
get the type
int zside(const DetId &) const
int layer() const
get the layer #
T const * product() const
Definition: ESHandle.h:86
GlobalPoint getTCPosition(const DetId &id) const
SubDetectorType getSubDetectorType(const DetId &id) const
HGCalTriggerSubdetector subdet() const
get the subdetector
int layer() const
get the layer #
DetId simToReco(const DetId &, const HGCalTopology &) const
unsigned int layers(bool reco) const
int zside() const
get the z-side of the cell (1/-1)
bool isNose(const DetId &) const
float getTCPhi(const DetId &id) const
bool isEm(const DetId &) const
float getEta(const GlobalPoint &position, const float &vertex_z=0.) const
int type() const
get the type
Definition: HFNoseDetId.h:51
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
float getTCPt(const DetId &id, const float &hitEnergy, const float &vertex_z=0.) const
unsigned layerWithOffset(const DetId &) const
unsigned lastLayerFH() const
Definition: DetId.h:17
int type() const
get the type
unsigned layers(ForwardSubdetector type) const
Detector
Definition: DetId.h:24
int zside() const
get the z-side of the cell (1/-1)
int type() const
get the type
const HGCalTopology & noseTopology() const
unsigned layer(const DetId &) const
bool isEE() const
consistency check : no bits left => no overhead
Definition: HFNoseDetId.h:105
const HGCalTopology & fhTopology() const
float getLayerZ(const unsigned &layerWithOffset) const
float getPhi(const GlobalPoint &position) const
unsigned lastLayerEE(bool nose=false) const
const HGCalTopology & hscTopology() const
static int position[264][3]
Definition: ReadPGInfo.cc:289
int zside() const
get the z-side of the module (1/-1)
static constexpr unsigned kScintillatorPseudoThicknessIndex_
int type() const
get the type
int triggerSubdetId() const
get the trigger sub-detector
int layer() const
get the layer #
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
int zside() const
get the z-side of the cell (1/-1)
Definition: HFNoseDetId.h:54
float getPt(const GlobalPoint &position, const float &hitEnergy, const float &vertex_z=0.) const