ATLAS Offline Software
CaloCell.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOEVENT_CALOCELL_H
6 #define CALOEVENT_CALOCELL_H
7 
26 // Update:
27 // Jan 10 2001 HMA
28 // ordor of static/virtual/const
29 // Nov 12 2001 EDF
30 // Inherit from Navigible. Now CaloCell has a pure virtual method
31 // and can not be instantiated directly.
32 // June 13 2003 DR delegate to CaloDetDescrElement
33 // Feb 25 2004 DR CaloGain data member
34 // Apr 01 2004 PL new navigation and clean-up
35 //
36 
38 
40 
41 #include "Identifier/Identifier.h"
43 #include "FourMom/P4EEtaPhiMBase.h"
44 #include <math.h>
45 #include <iostream>
46 #include <functional>
47 #include <memory>
48 
49 //class CaloDetDescrElement;
50 #include "CaloDetDescr/CaloDetDescrElement.h"
52 
53 
54 class CaloCell: virtual public P4EEtaPhiMBase,
55  virtual public INavigable4Momentum,
57 {
58 public:
59 
61  CaloCell();
62 
65  float energy,
66  float time,
67  double quality,
69 
72  float energy,
73  float time,
77 
78 
81  const Identifier & ID,
82  float energy,
83  float time,
84  double quality,
86 
89  const Identifier & ID,
90  float energy,
91  float time,
95 
96 
98  virtual ~CaloCell ();
99 
101  void assign (const CaloDetDescrElement* caloDDE,
102  const Identifier & ID,
103  float energy,
104  float time,
108 
110  double energy () const;
112  virtual double phi () const override final;
114  virtual double eta () const override final;
116  virtual double sinTh () const override final;
118  virtual double cosTh () const override final;
120  virtual double sinPhi () const override final;
122  virtual double cosPhi () const override final;
124  virtual double cotTh () const override final;
126  virtual double m () const override final;
128  virtual double e () const override final;
130  virtual double et () const override final;
132  float x () const;
134  float y () const;
136  float z () const;
137 
140  Identifier ID () const ;
141 
143  float time () const;
145  uint16_t quality() const;
147  uint16_t provenance() const;
149  CaloGain::CaloGain gain() const;
150 
152  virtual bool badcell() const;
153 
155  const CaloDetDescrElement* caloDDE() const;
156 
158  virtual void setCaloDDE (const CaloDetDescrElement* caloDDE);
160  virtual void setEnergy (float energy);
162  virtual void addEnergy (float energy);
164  virtual void scaleEnergy (float scale);
166  virtual void setTime (float time);
168  virtual void setQuality (uint16_t quality);
169 
171  virtual void setQuality (double quality);
172 
174  void setProvenance (uint16_t prov);
175 
178 
180  virtual void set4Mom (const I4Momentum * const theI4Mom ) override final;
181 
183  virtual void set4Mom (const I4Momentum & theI4Mom) override final;
184 
186  virtual void set4Mom (const CLHEP::HepLorentzVector & theHlv ) override final;
187 
188 
190  virtual std::unique_ptr<CaloCell> clone() const;
191 
193  void set (const CaloDetDescrElement* caloDDE,
194  const Identifier& ID);
195 
197  void set (float energy,
198  float time,
202 
203 
205  void set (float energy,
206  float time,
207  double quality,
209 
210 
211 protected:
212 
214  float m_energy ;
216  float m_time ;
217 
218  // Reflex doesn't handle unions completely correctly.
219  // If you have a union as a data member, it will print a warning
220  // at runtime. So, hide the union from reflex. (Only m_quality is used
221  // in inlined code.)
223 #ifdef __REFLEX__
224  int m_quality ;
225 # define m_qualProv ((uint16_t*)&m_quality)
226 # define m_tileQual ((uint8_t*)&m_quality)
227 #else
228  union {
229  int m_quality = 0 ;
232  };
233 #endif
234 
241 
242 };
243 
244 
245 // inlines
246 
248  :
249  m_energy(0),
250  m_time(0),
251  m_quality(0),
252  m_gain(CaloGain::UNKNOWNGAIN),
253  m_caloDDE(0)
254 {}
255 
256 
257 #ifndef __REFLEX__
258 inline
260  const Identifier & ID,
261  float energy,
262  float time,
263  uint16_t quality,
264  uint16_t provenance,
266 {
267  m_energy = energy;
268  m_time = time;
269  m_ID = ID;
270  m_gain = gain;
271  m_caloDDE = caloDDE;
272  m_qualProv[0]=quality;
274 }
275 #endif
276 
277 
278 
279 inline Identifier CaloCell::ID() const {
280  return m_ID;
281 }
282 
283 
290  std::size_t operator() (const CaloCell* p) const
291  {
292  return p->ID().get_identifier32().get_compact();
293  }
294 };
295 
296 
297 // Make this the default hash function for NavigationToken.
298 inline
299 std::size_t navigationHash (const CaloCell* p)
300 {
301  return p->ID().get_identifier32().get_compact();
302 }
303 
304 inline
306  return m_caloDDE;
307 }
308 
309 
310 inline
311 double CaloCell::energy() const
312 {
313  return m_energy;
314 }
315 
316 inline
317 double CaloCell::e() const
318 {
319  return m_energy;
320 }
321 
322 
323 inline
324 double CaloCell::m() const
325 {
326  // zero mass by convention
327  return 0.;
328 }
329 
330 
331 inline
333 {
334  return m_qualProv[0];
335 }
336 
337 inline
339 {
340  // cppcheck-suppress objectIndex
341  return m_qualProv[1];
342 }
343 
344 inline
346 {
347  return m_gain;
348 }
349 
350 
351 inline
352 float CaloCell::time() const
353 {
354  return m_time;
355 }
356 
357 
358 inline
359 double CaloCell::phi() const
360 {
361  return m_caloDDE->phi();
362 }
363 
364 
365 inline
366 double CaloCell::eta() const
367 {
368  return m_caloDDE->eta();
369 }
370 
371 
372 inline
373 double CaloCell::sinTh() const
374 {
375  return m_caloDDE->sinTh();
376 }
377 
378 
379 inline
380 double CaloCell::cosTh() const
381 {
382  return m_caloDDE->cosTh();
383 }
384 
385 
386 inline
387 double CaloCell::cotTh() const
388 {
389  return m_caloDDE->cotTh();
390 }
391 
392 
393 inline
394 double CaloCell::sinPhi() const
395 {
396  return m_caloDDE->sinPhi();
397 }
398 
399 
400 inline
401 double CaloCell::cosPhi() const
402 {
403  return m_caloDDE->cosPhi();
404 }
405 
406 inline double
408 {
409  return this->e() * this->sinTh();
410 }
411 
412 inline
413 float CaloCell::x() const
414 {
415  return m_caloDDE->x();
416 }
417 
418 
419 inline
420 float CaloCell::y() const
421 {
422  return m_caloDDE->y();
423 }
424 
425 
426 inline
427 float CaloCell::z() const
428 {
429  return m_caloDDE->z();
430 }
431 
432 
433 #endif
434 
CaloDetDescrElement::cosPhi
float cosPhi() const
for fast px py pz computation
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:391
navigationHash
std::size_t navigationHash(const CaloCell *p)
Definition: CaloCell.h:299
CaloCell::assign
void assign(const CaloDetDescrElement *caloDDE, const Identifier &ID, float energy, float time, uint16_t quality, uint16_t provenance, CaloGain::CaloGain gain)
For initializing a cell we get from a DataPool.
Definition: CaloCell.h:259
I4Momentum
Definition: I4Momentum.h:31
CaloCell::setCaloDDE
virtual void setCaloDDE(const CaloDetDescrElement *caloDDE)
set pointer to CaloDetDescrElement
Definition: CaloCell.cxx:127
CaloCell::m_tileQual
uint8_t m_tileQual[4]
Definition: CaloCell.h:231
P4EEtaPhiMBase.h
CaloCell::cotTh
virtual double cotTh() const override final
get cottan(theta)
Definition: CaloCell.h:387
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:359
CaloDetDescrElement::cotTh
float cotTh() const
for fast px py pz computation
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:387
CaloCell::set
void set(const CaloDetDescrElement *caloDDE, const Identifier &ID)
Fast method to change the identity of a cell.
Definition: CaloCell.cxx:90
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
CaloDetDescrElement::y
float y() const
cell y
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:365
INavigable4Momentum.h
CaloCell::y
float y() const
get y (through CaloDetDescrElement)
Definition: CaloCell.h:420
CaloCell::set4Mom
virtual void set4Mom(const I4Momentum *const theI4Mom) override final
set 4Momentum (will throw exception since cannot be implemented)
Definition: CaloCell.cxx:179
CaloCell::setTime
virtual void setTime(float time)
set time
Definition: CaloCell.cxx:151
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition: CaloGain.h:20
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
NavigableTerminalNode
Dummy type needed fro specialized implementation.
Definition: NavigableTerminalNode.h:19
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
CaloCellIDFcn
A functional to get the ID from a CaloCell pointer.
Definition: CaloCell.h:289
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:338
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition: CaloCell.cxx:136
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
CaloCell::clone
virtual std::unique_ptr< CaloCell > clone() const
clone a CaloCell
Definition: CaloCell.cxx:200
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
CaloGain
Definition: CaloGain.h:10
CaloCell::energy
double energy() const
get energy (data member)
Definition: CaloCell.h:311
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition: CaloGain.h:18
GeoPrimitives.h
CaloCell::cosPhi
virtual double cosPhi() const override final
get cos(phi)
Definition: CaloCell.h:401
CaloCell::m_quality
int m_quality
Definition: CaloCell.h:229
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CaloCell::CaloCell
CaloCell()
default constructor (should not be used, only there for persistency reason)
Definition: CaloCell.h:247
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
CaloCell::setQuality
virtual void setQuality(uint16_t quality)
set quality
Definition: CaloCell.cxx:156
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CaloCell::m_qualProv
uint16_t m_qualProv[2]
Definition: CaloCell.h:230
CaloCell::m_gain
CaloGain::CaloGain m_gain
gain
Definition: CaloCell.h:237
CaloCell::m_energy
float m_energy
energy (in MeV)
Definition: CaloCell.h:214
CaloCell::badcell
virtual bool badcell() const
check is cell is dead
Definition: CaloCell.cxx:210
CaloCell::et
virtual double et() const override final
get et
Definition: CaloCell.h:407
CaloCell::setGain
void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN)
set gain
Definition: CaloCell.cxx:173
CaloCell::setProvenance
void setProvenance(uint16_t prov)
set Provenance
Definition: CaloCell.cxx:167
CaloCell::quality
uint16_t quality() const
get quality (data member)
Definition: CaloCell.h:332
CaloCell::~CaloCell
virtual ~CaloCell()
default destructor
Definition: CaloCell.cxx:13
CaloCell::scaleEnergy
virtual void scaleEnergy(float scale)
scale energy
Definition: CaloCell.cxx:146
NavigableTerminalNode.h
CaloCell::gain
CaloGain::CaloGain gain() const
get gain (data member )
Definition: CaloCell.h:345
CaloCell::ID
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition: CaloCell.h:279
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
CaloDetDescrElement::x
float x() const
cell x
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:363
CaloCellIDFcn::operator()
std::size_t operator()(const CaloCell *p) const
Definition: CaloCell.h:290
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCell::m_time
float m_time
time
Definition: CaloCell.h:216
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
P4EEtaPhiMBase
Definition: P4EEtaPhiMBase.h:26
CaloDetDescrElement::z
float z() const
cell z
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
INavigable4Momentum
Definition: INavigable4Momentum.h:21
CaloDetDescrElement::cosTh
float cosTh() const
for fast px py pz computation
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:385
CaloCell::m
virtual double m() const override final
get mass (hardcoded to be null)
Definition: CaloCell.h:324
CaloCell::z
float z() const
get z (through CaloDetDescrElement)
Definition: CaloCell.h:427
CaloCell::x
float x() const
get x (through CaloDetDescrElement)
Definition: CaloCell.h:413
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloCell::cosTh
virtual double cosTh() const override final
get cos(theta) (derived from sinTh)
Definition: CaloCell.h:380
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloCell::m_caloDDE
const CaloDetDescrElement * m_caloDDE
pointer to static CaloDetDescrElement to access information that does not change from event to event
Definition: CaloCell.h:240
CaloDetDescrElement::sinTh
float sinTh() const
for algorithm working in transverse Energy
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:383
CaloCell::addEnergy
virtual void addEnergy(float energy)
add energy
Definition: CaloCell.cxx:141
CaloDetDescrElement::sinPhi
float sinPhi() const
for fast px py pz computation
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:389
CaloGain.h
CaloCell::sinPhi
virtual double sinPhi() const override final
get sin(phi)
Definition: CaloCell.h:394
CaloCell::m_ID
Identifier m_ID
offline identifier
Definition: CaloCell.h:235
CaloCell::sinTh
virtual double sinTh() const override final
get sin(theta) (through CaloDetDescrElement)
Definition: CaloCell.h:373
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366
Identifier
Definition: IdentifierFieldParser.cxx:14