ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCell.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef CALOEVENT_CALOCELL_H
6#define CALOEVENT_CALOCELL_H
7
25
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"
44#include <math.h>
45#include <iostream>
46#include <functional>
47#include <memory>
48
49//class CaloDetDescrElement;
50#include "CaloDetDescr/CaloDetDescrElement.h"
52
53
54class CaloCell: virtual public P4EEtaPhiMBase,
55 virtual public INavigable4Momentum,
57{
58public:
59
61 CaloCell();
62
65 float energy,
66 float time,
67 double quality,
69
72 float energy,
73 float time,
74 uint16_t quality,
75 uint16_t provenance,
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,
92 uint16_t quality,
93 uint16_t provenance,
95
96 CaloCell(const CaloCell&) = default;
97 CaloCell(CaloCell&&) = default;
98
99 CaloCell& operator= (const CaloCell&) = default;
101
102
104 virtual ~CaloCell ();
105
108 const Identifier & ID,
109 float energy,
110 float time,
111 uint16_t quality,
112 uint16_t provenance,
114
116 double energy () const;
117
121
123 virtual double phi () const override final;
125 virtual double eta () const override final;
127 virtual double sinTh () const override final;
129 virtual double cosTh () const override final;
131 virtual double sinPhi () const override final;
133 virtual double cosPhi () const override final;
135 virtual double cotTh () const override final;
137 virtual double m () const override final;
139 virtual double e () const override final;
141 virtual double et () const override final;
142
144
146 float x () const;
148 float y () const;
150 float z () const;
151
154 Identifier ID () const ;
155
157 float time () const;
159 uint16_t quality() const;
161 uint16_t provenance() const;
164
170 void addEnergy (float energy);
172 void addTime (float delta);
174 void setProvenance (uint16_t prov);
176 void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN);
178 void setQuality (uint16_t quality);
180 void setQuality (double quality);
181
185
186 virtual bool badcell() const;
188 virtual void setEnergy (float energy);
190 virtual void scaleEnergy (float scale);
192 virtual void setTime (float time);
194
196 virtual void set4Mom (const I4Momentum * const theI4Mom ) override final;
197
199 virtual void set4Mom (const I4Momentum & theI4Mom) override final;
200
202 virtual void set4Mom (const CLHEP::HepLorentzVector & theHlv ) override final;
203
204
206 virtual std::unique_ptr<CaloCell> clone() const;
207
211
213 void set (float energy,
214 float time,
215 uint16_t quality,
216 uint16_t provenance,
218
219
221 void set (float energy,
222 float time,
223 double quality,
225
226
228
230 float m_energy ;
232 float m_time ;
233
234 // Reflex doesn't handle unions completely correctly.
235 // If you have a union as a data member, it will print a warning
236 // at runtime. So, hide the union from reflex. (Only m_quality is used
237 // in inlined code.)
239#ifdef __REFLEX__
240 int m_quality ;
241# define m_qualProv ((uint16_t*)&m_quality)
242# define m_tileQual ((uint8_t*)&m_quality)
243#else
244 union {
245 int m_quality = 0 ;
246 uint16_t m_qualProv[2];
247 uint8_t m_tileQual[4];
248 };
249#endif
257
258};
259
260
261// inlines
262
264 :
265 m_energy(0),
266 m_time(0),
267 m_quality(0),
268 m_gain(CaloGain::UNKNOWNGAIN),
269 m_caloDDE(0)
270{}
271
272
273#ifndef __REFLEX__
274inline
276 const Identifier & ID,
277 float energy,
278 float time,
279 uint16_t quality,
280 uint16_t provenance,
282{
284 m_time = time;
285 m_ID = ID;
286 m_gain = gain;
290}
291#endif
292
293
294
295inline Identifier CaloCell::ID() const {
296 return m_ID;
297}
298
299
306 std::size_t operator() (const CaloCell* p) const
307 {
308 return p->ID().get_identifier32().get_compact();
309 }
310};
311
312
313// Make this the default hash function for NavigationToken.
314inline
315std::size_t navigationHash (const CaloCell* p)
316{
317 return p->ID().get_identifier32().get_compact();
318}
319
320inline
322 return m_caloDDE;
323}
324
325
326inline
327double CaloCell::energy() const
328{
329 return m_energy;
330}
331
332inline
333double CaloCell::e() const
334{
335 return m_energy;
336}
337
338
339inline
340double CaloCell::m() const
341{
342 // zero mass by convention
343 return 0.;
344}
345
346
347inline
348uint16_t CaloCell::quality() const
349{
350 return m_qualProv[0];
351}
352
353inline
354uint16_t CaloCell::provenance() const
355{
356 // cppcheck-suppress objectIndex
357 return m_qualProv[1];
358}
359
360inline
362{
363 return m_gain;
364}
365
366
367inline
368float CaloCell::time() const
369{
370 return m_time;
371}
372
373
374inline
375double CaloCell::phi() const
376{
377 return m_caloDDE->phi();
378}
379
380
381inline
382double CaloCell::eta() const
383{
384 return m_caloDDE->eta();
385}
386
387
388inline
389double CaloCell::sinTh() const
390{
391 return m_caloDDE->sinTh();
392}
393
394
395inline
396double CaloCell::cosTh() const
397{
398 return m_caloDDE->cosTh();
399}
400
401
402inline
403double CaloCell::cotTh() const
404{
405 return m_caloDDE->cotTh();
406}
407
408
409inline
410double CaloCell::sinPhi() const
411{
412 return m_caloDDE->sinPhi();
413}
414
415
416inline
417double CaloCell::cosPhi() const
418{
419 return m_caloDDE->cosPhi();
420}
421
422inline double
424{
425 return this->e() * this->sinTh();
426}
427
428inline
429float CaloCell::x() const
430{
431 return m_caloDDE->x();
432}
433
434
435inline
436float CaloCell::y() const
437{
438 return m_caloDDE->y();
439}
440
441
442inline
443float CaloCell::z() const
444{
445 return m_caloDDE->z();
446}
447
448inline
450 m_energy += energy;
451}
452
453inline
454void CaloCell::addTime (float delta)
455{
456 m_time += delta;
457}
458
459inline
461{
462 m_qualProv[0] = quality;
463}
464
465inline
467{
468 m_quality = (int)(quality);
469}
470
471inline
473{
474 m_energy = energy ;
475}
476
477inline
478void CaloCell::scaleEnergy (float scale)
479{
480 m_energy *= scale ;
481}
482
483inline
485{
486 m_time = time;
487}
488
489inline
490void CaloCell::setProvenance (uint16_t prov)
491{
492 // cppcheck-suppress objectIndex
493 m_qualProv[1] = prov;
494}
495
496inline
501
502inline
505 if (m_caloDDE) {
506 m_ID = m_caloDDE->identify();
507 }
508}
509
510inline
512 const Identifier& ID) {
513 m_ID = ID;
515}
516
517#endif
518
519
std::size_t navigationHash(const CaloCell *p)
Definition CaloCell.h:315
#define protected
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
void addEnergy(float energy)
add energy
Definition CaloCell.h:449
float time() const
get time (data member)
Definition CaloCell.h:368
const CaloDetDescrElement * m_caloDDE
pointer to static CaloDetDescrElement to access information that does not change from event to event
Definition CaloCell.h:256
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
int m_quality
Definition CaloCell.h:245
uint8_t m_tileQual[4]
Definition CaloCell.h:247
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
CaloCell()
default constructor (should not be used, only there for persistency reason)
Definition CaloCell.h:263
float m_energy
energy (in MeV)
Definition CaloCell.h:230
void addTime(float delta)
add time
Definition CaloCell.h:454
virtual void setTime(float time)
set time
Definition CaloCell.h:484
double energy() const
get energy (data member)
Definition CaloCell.h:327
void setCaloDDE(const CaloDetDescrElement *caloDDE)
set pointer to CaloDetDescrElement
Definition CaloCell.h:503
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
uint16_t provenance() const
get provenance (data member)
Definition CaloCell.h:354
float y() const
get y (through CaloDetDescrElement)
Definition CaloCell.h:436
virtual void set4Mom(const I4Momentum *const theI4Mom) override final
set 4Momentum (will throw exception since cannot be implemented)
Definition CaloCell.cxx:115
virtual double cosPhi() const override final
get cos(phi)
Definition CaloCell.h:417
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN)
set gain
Definition CaloCell.h:497
virtual double sinTh() const override final
get sin(theta) (through CaloDetDescrElement)
Definition CaloCell.h:389
virtual ~CaloCell()
default destructor
Definition CaloCell.cxx:13
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:275
uint16_t quality() const
get quality (data member)
Definition CaloCell.h:348
void set(const CaloDetDescrElement *caloDDE, const Identifier &ID)
Fast method to change the identity of a cell.
Definition CaloCell.h:511
CaloCell(CaloCell &&)=default
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
virtual double m() const override final
get mass (hardcoded to be null)
Definition CaloCell.h:340
float m_time
time
Definition CaloCell.h:232
virtual double cosTh() const override final
get cos(theta) (derived from sinTh)
Definition CaloCell.h:396
void setQuality(uint16_t quality)
set quality
Definition CaloCell.h:460
CaloGain::CaloGain gain() const
get gain (data member )
Definition CaloCell.h:361
virtual double cotTh() const override final
get cottan(theta)
Definition CaloCell.h:403
CaloCell & operator=(const CaloCell &)=default
float z() const
get z (through CaloDetDescrElement)
Definition CaloCell.h:443
float x() const
get x (through CaloDetDescrElement)
Definition CaloCell.h:429
virtual void scaleEnergy(float scale)
scale energy
Definition CaloCell.h:478
Identifier m_ID
offline identifier
Definition CaloCell.h:251
virtual double et() const override final
get et
Definition CaloCell.h:423
virtual double sinPhi() const override final
get sin(phi)
Definition CaloCell.h:410
void setProvenance(uint16_t prov)
set Provenance
Definition CaloCell.h:490
CaloCell(const CaloCell &)=default
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Definition CaloCell.h:295
CaloGain::CaloGain m_gain
gain
Definition CaloCell.h:253
uint16_t m_qualProv[2]
Definition CaloCell.h:246
This class groups all DetDescr information related to a CaloCell.
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition I4Momentum.h:31
P4EEtaPhiMBase is a base class for classes with 4-momentum behavior, for which E, eta,...
virtual void scaleEnergy(float scale) override final
scale energy and eneDiff (final override of CaloCell method)
Definition TileCell.cxx:140
void addEnergy(float e, int pmt, int gain)
set energy and gain for one PMT
Definition TileCell.cxx:145
virtual std::unique_ptr< CaloCell > clone() const override final
clone
Definition TileCell.cxx:106
virtual bool badcell(void) const override final
check if whole cell is bad (i.e.
Definition TileCell.h:214
virtual void setEnergy(float ene) override final
set total energy, reset eneDiff to zero (final override of CaloCell method)
Definition TileCell.cxx:123
void setQuality(unsigned char qual, unsigned char qbit, int pmt)
set quality value and quality bits for one PMT (TileCell specific overloads)
Definition TileCell.h:280
virtual void setTime(float t) override final
set cell time, reset timeDiff
Definition TileCell.h:251
STL class.
STL namespace.
A functional to get the ID from a CaloCell pointer.
Definition CaloCell.h:305
std::size_t operator()(const CaloCell *p) const
Definition CaloCell.h:306