ATLAS Offline Software
Loading...
Searching...
No Matches
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
26#include "CaloDetDescr/CaloDetDescrElement.h"
27
28#include <iostream>
29#include <sstream>
30#include <iomanip>
31
32// get cabling
33namespace {
34const 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
55
57 const Identifier & cell_ID,
58 float energy, float time, uint16_t quality,
62 , m_timeDiff(0.0)
63{
64}
65
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) ))
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
92 const Identifier & cell_ID,
93 float energy, float time, uint16_t quality,
95 float eneDiff, float timeDiff)
99{
100}
101
104
105// clone this cell
106std::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//=========================
123void 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}
134void TileCell::setEnergy(float e1, float e2)
135{
136 m_eneDiff = e1-e2;
137 m_energy = e1+e2;
138}
139
140void TileCell::scaleEnergy(float scale)
141{
142 m_energy *= scale;
143 m_eneDiff *= scale;
144}
145void TileCell::addEnergy(float e, int pmt, int gain)
146{
147 if (pmt > 0) { // second pmt
148 m_eneDiff -= e;
149 m_gain = (CaloGain::CaloGain)( (m_gain & 0xFFFFFFF3) | ((gain & 3) << 2) );
150 } else { // first PMT
151 m_eneDiff += e;
152 m_gain = (CaloGain::CaloGain)( (m_gain & 0xFFFFFFFC) | ( gain & 3 ) );
153 }
154 m_energy += e;
155}
156
157void TileCell::setTime(float t, int pmt) // works only for second PMT in a cell
158{
159 if (pmt > 0) { // second pmt in a cell with index "1",
160 m_time = (m_time + t)/2.;
161 m_timeDiff = m_time - t;
162 } else { // second in a cell pmt with index "0"
163 m_time = (t + m_time)/2.;
164 m_timeDiff = t - m_time;
165 }
166}
167
168int TileCell::gain1(void) const
169{
170 int gain = m_gain & 3;
171
172 return ( ( gain < 2) ? gain : CaloGain::INVALIDGAIN);
173}
174
175int TileCell::gain2(void) const
176{
177 int gain = (m_gain >> 2) & 3;
178
179 return ( ( gain < 2) ? gain : CaloGain::INVALIDGAIN);
180}
181
182//=========================
183// Supporting functions
184//=========================
185
186void TileCell::print() const
187{
188 std::cout << (std::string) (*this) << std::endl;
189}
190
191TileCell::operator std::string() const
192{
193 std::ostringstream text(std::ostringstream::out);
194
195 text << whoami();
196 text << " Id = " << s_cabling->getTileID()->to_string(subcalo_hash(),-2); // two levels above adc_id
197 text << " ener = " << energy();
198 text << " gain = " << gain();
199 text << " time = " << time();
200 text << " qual = " << quality();
201 text << " prov = " << provenance();
202 text << " E1 = " << ene1();
203 text << " G1 = " << gain1();
204 text << " T1 = " << time1();
205 text << " Q1 = " << (int)qual1() << " " << (int)qbit1();
206 text << " E2 = " << ene2();
207 text << " G2 = " << gain2();
208 text << " T2 = " << time2();
209 text << " Q2 = " << (int)qual2() << " " << (int)qbit2();
210 text << " eta = " << eta();
211 text << " phi = " << phi();
212 text << " r = " << caloDDE()->r();
213
214 return text.str();
215}
216
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
float time() const
get time (data member)
Definition CaloCell.h:368
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
uint8_t m_tileQual[4]
Definition CaloCell.h:247
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
double energy() const
get energy (data member)
Definition CaloCell.h:327
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
uint16_t quality() const
get quality (data member)
Definition CaloCell.h:348
float m_time
time
Definition CaloCell.h:232
CaloGain::CaloGain gain() const
get gain (data member )
Definition CaloCell.h:361
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
This class groups all DetDescr information related to a CaloCell.
static const TileCablingService * getInstance()
get pointer to service instance
uint8_t qual1(void) const
get quality of first PMT (data member)
Definition TileCell.h:197
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
float time1(void) const
get time of first PMT
Definition TileCell.h:192
TileCell()
default constructor
Definition TileCell.cxx:40
virtual std::unique_ptr< CaloCell > clone() const override final
clone
Definition TileCell.cxx:106
void print(void) const
print all cell data memebers to stdout
Definition TileCell.cxx:186
float eneDiff(void) const
all get methods
Definition TileCell.h:182
virtual ~TileCell()
destructor
Definition TileCell.cxx:102
virtual void setEnergy(float ene) override final
set total energy, reset eneDiff to zero (final override of CaloCell method)
Definition TileCell.cxx:123
int gain2(void) const
get gain of second PMT
Definition TileCell.cxx:175
IdentifierHash subcalo_hash(void) const
get subcalo hash for TileCal cells
Definition TileCell.h:222
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
Definition TileCell.h:206
std::string whoami(void) const
get name of the object
Definition TileCell.h:225
int gain1(void) const
get gain of first PMT
Definition TileCell.cxx:168
uint8_t qual2(void) const
get quality of second PMT (data member)
Definition TileCell.h:200
float m_eneDiff
eneDiff = ene1 - ene2
Definition TileCell.h:235
float m_timeDiff
timeDiff = (time1 - time2)/2.
Definition TileCell.h:237
float ene1(void) const
get energy of first PMT
Definition TileCell.h:187
virtual void setTime(float t) override final
set cell time, reset timeDiff
Definition TileCell.h:251
float timeDiff(void) const
get time diff for two PMTs (data member)
Definition TileCell.h:184
float time2(void) const
get time of second PMT
Definition TileCell.h:194
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
Definition TileCell.h:203
float ene2(void) const
get energy of second PMT
Definition TileCell.h:189
@ INVALIDGAIN
Definition CaloGain.h:18
@ TILEONEHIGH
Definition CaloGain.h:17
@ TILEONELOW
Definition CaloGain.h:16