ATLAS Offline Software
TileCell.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileCell.cxx
7 // Author : Ed Frank, Ambreesh Gupta
8 // Created : Jan, 2001
9 //
10 // DESCRIPTION:
11 // Implementation comments only. Class level comments go in .h file.
12 //
13 // HISTORY:
14 //
15 // 12June02 Completely changed by Zhifang Wu
16 //
17 // BUGS:
18 //
19 //
20 //*****************************************************************************
21 
22 #include "TileEvent/TileCell.h"
24 
25 #include "CaloIdentifier/TileID.h"
26 #include "CaloDetDescr/CaloDetDescrElement.h"
27 
28 #include <iostream>
29 #include <sstream>
30 #include <iomanip>
31 
32 // get cabling
33 namespace {
34 const TileCablingService * const s_cabling = TileCablingService::getInstance();
35 }
36 
37 //=========================
38 // Constructors
39 //=========================
41  : CaloCell()
42  , m_eneDiff(0.0)
43  , m_timeDiff(0.0)
44 {
45 }
46 
47 TileCell::TileCell(const CaloDetDescrElement* const & caloDDE,
48  float energy, float time, uint16_t quality,
49  uint16_t provenance, CaloGain::CaloGain gain)
50  : CaloCell(caloDDE,energy,time,quality,provenance,gain)
51  , m_eneDiff(energy)
52  , m_timeDiff(0.0)
53 {
54 }
55 
56 TileCell::TileCell(const CaloDetDescrElement* const & caloDDE,
57  const Identifier & cell_ID,
58  float energy, float time, uint16_t quality,
59  uint16_t provenance, CaloGain::CaloGain gain)
60  : CaloCell(caloDDE,cell_ID,energy,time,quality,provenance,gain)
61  , m_eneDiff(energy)
62  , m_timeDiff(0.0)
63 {
64 }
65 
66 TileCell::TileCell(const CaloDetDescrElement* const & caloDDE,
67  float ene1, float ene2, float time1, float time2,
68  int qual1, int qual2, int qbit1, int qbit2,
69  int gain1, int gain2)
70  : CaloCell(caloDDE,ene1+ene2,(time1+time2)/2.0, 0, 0,
71  (CaloGain::CaloGain) ( 0xFFFFFFF0 | (static_cast<unsigned int>(gain2) << 2) | (gain1 & 3) ))
72  , m_eneDiff(ene1-ene2)
73  , m_timeDiff((time1-time2)/2.)
74 {
75  m_tileQual[0] = std::min(255,abs(qual1));
76  // cppcheck-suppress objectIndex
77  m_tileQual[1] = std::min(255,abs(qual2));
78  // cppcheck-suppress objectIndex
79  m_tileQual[2] = (qbit1 & 0xFF);
80  // cppcheck-suppress objectIndex
81  m_tileQual[3] = (qbit2 & 0xFF);
82 }
83 
85  : CaloCell(cell->caloDDE(),cell->ID(),cell->energy(),cell->time(),cell->quality(),cell->provenance(),cell->gain())
86  , m_eneDiff(cell->eneDiff())
87  , m_timeDiff(cell->timeDiff())
88 {
89 }
90 
91 TileCell::TileCell(const CaloDetDescrElement* const & caloDDE,
92  const Identifier & cell_ID,
93  float energy, float time, uint16_t quality,
94  uint16_t provenance, CaloGain::CaloGain gain,
95  float eneDiff, float timeDiff)
96  : CaloCell(caloDDE,cell_ID,energy,time,quality,provenance,gain)
97  , m_eneDiff(eneDiff)
98  , m_timeDiff(timeDiff)
99 {
100 }
101 
103 { }
104 
105 // clone this cell
106 std::unique_ptr<CaloCell> TileCell::clone() const
107 {
108  return std::make_unique<TileCell>(this->caloDDE(),
109  this->ID(),
110  this->energy(),
111  this->time(),
112  this->quality(),
113  this->provenance(),
114  this->gain(),
115  this->eneDiff(),
116  this->timeDiff());
117 }
118 
119 
120 //=========================
121 // Set attributes
122 //=========================
123 void TileCell::setEnergy(float ene)
124 {
125  m_energy = ene;
126 
127  // cells with single PMT should always have zero energy in second PMT
129  m_eneDiff = ene;
130  } else {
131  m_eneDiff = 0.0;
132  }
133 }
134 void TileCell::setEnergy(float e1, float e2)
135 {
136  m_eneDiff = e1-e2;
137  m_energy = e1+e2;
138 }
139 
140 void TileCell::addEnergy(float ene)
141 {
142  m_energy += ene;
143 }
145 {
146  m_energy *= scale;
147  m_eneDiff *= scale;
148 }
149 void TileCell::addEnergy(float e, int pmt, int gain)
150 {
151  if (pmt > 0) { // second pmt
152  m_eneDiff -= e;
153  m_gain = (CaloGain::CaloGain)( (m_gain & 0xFFFFFFF3) | ((gain & 3) << 2) );
154  } else { // first PMT
155  m_eneDiff += e;
156  m_gain = (CaloGain::CaloGain)( (m_gain & 0xFFFFFFFC) | ( gain & 3 ) );
157  }
158  m_energy += e;
159 }
160 
161 void TileCell::setTime(float t, int pmt) // works only for second PMT in a cell
162 {
163  if (pmt > 0) { // second pmt in a cell with index "1",
164  m_time = (m_time + t)/2.;
165  m_timeDiff = m_time - t;
166  } else { // second in a cell pmt with index "0"
167  m_time = (t + m_time)/2.;
168  m_timeDiff = t - m_time;
169  }
170 }
171 
173 {
175 }
176 
177 void TileCell::setQuality(double quality)
178 {
180 }
181 
182 int TileCell::gain1(void) const
183 {
184  int gain = m_gain & 3;
185 
186  return ( ( gain < 2) ? gain : CaloGain::INVALIDGAIN);
187 }
188 
189 int TileCell::gain2(void) const
190 {
191  int gain = (m_gain >> 2) & 3;
192 
193  return ( ( gain < 2) ? gain : CaloGain::INVALIDGAIN);
194 }
195 
196 //=========================
197 // Supporting functions
198 //=========================
199 
200 void TileCell::print() const
201 {
202  std::cout << (std::string) (*this) << std::endl;
203 }
204 
205 TileCell::operator std::string() const
206 {
207  std::ostringstream text(std::ostringstream::out);
208 
209  text << whoami();
210  text << " Id = " << s_cabling->getTileID()->to_string(subcalo_hash(),-2); // two levels above adc_id
211  text << " ener = " << energy();
212  text << " gain = " << gain();
213  text << " time = " << time();
214  text << " qual = " << quality();
215  text << " prov = " << provenance();
216  text << " E1 = " << ene1();
217  text << " G1 = " << gain1();
218  text << " T1 = " << time1();
219  text << " Q1 = " << (int)qual1() << " " << (int)qbit1();
220  text << " E2 = " << ene2();
221  text << " G2 = " << gain2();
222  text << " T2 = " << time2();
223  text << " Q2 = " << (int)qual2() << " " << (int)qbit2();
224  text << " eta = " << eta();
225  text << " phi = " << phi();
226  text << " r = " << caloDDE()->r();
227 
228  return text.str();
229 }
230 
TileCell
Definition: TileCell.h:57
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TileCell::setTime
virtual void setTime(float t) override final
set cell time, reset timeDiff
Definition: TileCell.h:257
CaloCell::m_tileQual
uint8_t m_tileQual[4]
Definition: CaloCell.h:231
TileCell::clone
virtual std::unique_ptr< CaloCell > clone() const override final
clone
Definition: TileCell.cxx:106
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TileCell::TileCell
TileCell()
default constructor
Definition: TileCell.cxx:40
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition: TileCablingService.cxx:24
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
egammaEnergyPositionAllSamples::e1
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
ReadBchFromCool.pmt
pmt
Definition: ReadBchFromCool.py:62
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
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
CaloTime_fillDB.gain2
gain2
Definition: CaloTime_fillDB.py:357
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:338
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
TileCell::~TileCell
virtual ~TileCell()
destructor
Definition: TileCell.cxx:102
CaloGain
Definition: CaloGain.h:10
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
TileID.h
CaloCell::energy
double energy() const
get energy (data member)
Definition: CaloCell.h:311
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition: CaloGain.h:18
TileCell::timeDiff
float timeDiff(void) const
get time diff for two PMTs (data member)
Definition: TileCell.h:190
TileCell::qual2
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition: TileCell.h:206
TileCell::print
void print(void) const
print all cell data memebers to stdout
Definition: TileCell.cxx:200
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
TileCablingService.h
CaloCell::setQuality
virtual void setQuality(uint16_t quality)
set quality
Definition: CaloCell.cxx:156
CaloGain::TILEONELOW
@ TILEONELOW
Definition: CaloGain.h:16
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CaloCell::m_gain
CaloGain::CaloGain m_gain
gain
Definition: CaloCell.h:237
TileCell.h
CaloCell::m_energy
float m_energy
energy (in MeV)
Definition: CaloCell.h:214
TileCell::qbit1
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
Definition: TileCell.h:209
TileCablingService
Definition: TileCablingService.h:23
TileCell::gain1
int gain1(void) const
get gain of first PMT
Definition: TileCell.cxx:182
TileCell::eneDiff
float eneDiff(void) const
all get methods
Definition: TileCell.h:188
CaloCell::quality
uint16_t quality() const
get quality (data member)
Definition: CaloCell.h:332
CaloTime_fillDB.gain1
gain1
Definition: CaloTime_fillDB.py:356
TileCell::setQuality
void setQuality(unsigned char qual, unsigned char qbit, int pmt)
set quality value and quality bits for one PMT
Definition: TileCell.h:286
TileCell::m_timeDiff
float m_timeDiff
timeDiff = (time1 - time2)/2.
Definition: TileCell.h:243
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
TileCell::addEnergy
virtual void addEnergy(float e) override final
add energy, keep eneDiff
Definition: TileCell.cxx:140
TileCell::setEnergy
virtual void setEnergy(float ene) override final
set total energy, reset eneDiff to zero
Definition: TileCell.cxx:123
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
TileCell::qbit2
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
Definition: TileCell.h:212
TileCell::gain2
int gain2(void) const
get gain of second PMT
Definition: TileCell.cxx:189
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
egammaEnergyPositionAllSamples::e2
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
TileCell::qual1
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition: TileCell.h:203
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
TileCell::scaleEnergy
virtual void scaleEnergy(float scale) override final
scale energy and eneDiff
Definition: TileCell.cxx:144
TileCell::m_eneDiff
float m_eneDiff
eneDiff = ene1 - ene2
Definition: TileCell.h:241
CaloGain::TILEONEHIGH
@ TILEONEHIGH
Definition: CaloGain.h:17
Identifier
Definition: IdentifierFieldParser.cxx:14