ATLAS Offline Software
Loading...
Searching...
No Matches
CaloEstimatedGainTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
10
11
13#include "TileEvent/TileCell.h"
14#include "CaloEvent/CaloCell.h"
16#include "CaloDetDescr/CaloDetDescrElement.h"
19
20
22{
23 m_LowGainThresh[CaloCell_ID::LAREM] = 3900;//ADC counts in MediumGain
24 m_HighGainThresh[CaloCell_ID::LAREM] = 1300;//ADC counts in MediumGain
25 m_LowGainThresh[CaloCell_ID::LARHEC] = 2500;//ADC counts in MediumGain
26 m_HighGainThresh[CaloCell_ID::LARHEC] = 0;//-> high-gain never used for HEC
27 m_LowGainThresh[CaloCell_ID::LARFCAL] = 2000.;//ADC counts
28 m_HighGainThresh[CaloCell_ID::LARFCAL] = 1100.;//ADC counts
31
32 const CaloCell_ID* calocell_id;
33 ATH_CHECK( detStore()->retrieve (calocell_id, "CaloCell_ID") );
34 m_lar_em_id = calocell_id->em_idHelper();
35
36 ATH_CHECK( detStore()->retrieve (m_tileInfo, "TileInfo") );
37
38 ATH_CHECK( m_tileIdTransforms.retrieve() );
39 ATH_CHECK( m_tileToolEmscale.retrieve() );
40 ATH_CHECK( m_tileToolNoiseSample.retrieve() );
41
42 ATH_CHECK( m_adc2mevKey.initialize() );
43
44 return StatusCode::SUCCESS;
45}
46
47
49CaloEstimatedGainTool::estimatedGain (const EventContext& ctx,
50 const CaloCell& caloCell,
51 const Step step) const
52{
53 return estimatedGain (ctx, caloCell, *caloCell.caloDDE(), step);
54}
55
56
58CaloEstimatedGainTool::estimatedGain (const EventContext& ctx,
59 const CaloCell& caloCell,
60 const CaloDetDescrElement& caloDDE,
61 const Step step) const
62{
63 CaloCell_ID::SUBCALO iCalo = caloDDE.getSubCalo();
64
65 if (iCalo == CaloCell_ID::LAREM ||
66 iCalo == CaloCell_ID::LARHEC ||
67 iCalo == CaloCell_ID::LARFCAL)
68 {
69 return estimatedLArGain (ctx, iCalo, caloDDE, caloCell.energy(), step);
70 }
71 else if (iCalo == CaloCell_ID::TILE)
72 {
73 return estimatedTileGain (ctx, caloCell, caloDDE, step);
74 }
75 else
76 {
77 ATH_MSG_WARNING("CaloEstimatedGainTool::estimatedGain wrong id ! "
78 << m_lar_em_id->show_to_string (caloDDE.identify()) );
80 }
81}
82
83
85CaloEstimatedGainTool::estimatedGain (const EventContext& ctx,
86 const CaloDetDescrElement& caloDDE,
87 const float energy,
88 const Step step) const
89{
90 CaloCell_ID::SUBCALO iCalo = caloDDE.getSubCalo();
91
92 if (iCalo == CaloCell_ID::LAREM ||
93 iCalo == CaloCell_ID::LARHEC ||
94 iCalo == CaloCell_ID::LARFCAL)
95 {
96 return estimatedLArGain (ctx, iCalo, caloDDE, energy, step);
97 }
98 else if (iCalo == CaloCell_ID::TILE)
99 {
100 ATH_MSG_WARNING("CaloEstimatedGainTool::estimatedGain NOT IMPLEMENTED FOR TILE "
101 <<"with these arguments! "
102 << m_lar_em_id->show_to_string (caloDDE.identify()) );
104 }
105 else
106 {
107 ATH_MSG_WARNING("CaloEstimatedGainTool::estimatedGain wrong id ! "
108 << m_lar_em_id->show_to_string (caloDDE.identify()) );
110 }
111}
112
113
116 const CaloCell_ID::SUBCALO iCalo,
117 const CaloDetDescrElement& caloDDE,
118 const float energy,
119 const Step step) const
120{
121 //returns the gain of a cell according to the energy
122 //(converts in ADC counts in MediumGain and uses thresholds in ADC counts
123 //to determine the gain)
124
125 // the function could be called before (step=0, RawChannels)
126 // or after (step=1, Cells) LArG3Escale
127
129
130 //--EM/HEC--
131 if( iCalo == CaloCell_ID::LAREM ||
132 iCalo == CaloCell_ID::LARHEC ||
133 iCalo == CaloCell_ID::LARFCAL )
134 {
135 //We choose the gain in applying thresholds on the energy
136 //converted in ADC counts in MediumGain (index "1" of adc2mev(id,1)).
137 //Indeed, thresholds in ADC counts are defined with respect
138 //to the MediumGain.
139 //
140 // 1300 3900
141 // ---------------|----------------|-------------> ADC counts in MediumGain
142 // HighGain <--- MediumGain ---> LowGain
143
144 float adc=0.;
145
146 if (step == Step::CELLS || //Cells (with E scale and weights from LArG3Escale)
147 step == Step::RAWCHANNELS) //RawChannels
148 {
149 float fac = adc2mev (ctx, caloDDE, CaloGain::LARMEDIUMGAIN);
150 if (fac != 0) {
151 adc = energy / fac + 1000;
152 }
153 }
154 else
155 {
156 ATH_MSG_WARNING( "CaloEstimatedGainTool::estimatedGain wrong step" );
157 }
158
159 if (adc < m_HighGainThresh[iCalo]) igain = CaloGain::LARHIGHGAIN;
160 else if (adc > m_LowGainThresh[iCalo]) igain = CaloGain::LARLOWGAIN;
161 else igain = CaloGain::LARMEDIUMGAIN;
162 }
163
164 return igain;
165}
166
167
170 const CaloCell& caloCell,
171 const CaloDetDescrElement& caloDDE,
172 const Step /*step*/) const
173{
174 const TileCell& tileCell = dynamic_cast<const TileCell&> (caloCell);
175
176 // threshold (1023 counts) is the same for all channels
177 double threshold = m_tileInfo->ADCmax();
178
179 // xxx
180 static TileHWID const * const tileHWID = TileCablingService::getInstance()->getTileHWID();
181 static const IdContext chContext = tileHWID->channel_context();
182
183 HWIdentifier hwid1;
184 tileHWID->get_id (caloDDE.onl1(), hwid1, &chContext ); // pmt id
185 hwid1 = tileHWID->adc_id (hwid1, TileHWID::HIGHGAIN); // high gain ADC id
186
187 unsigned int drawerIdx1(0), channel1(0), adc1(0);
188 m_tileIdTransforms->getIndices (hwid1, drawerIdx1, channel1, adc1);
189
190 // first PMT, convert energy to ADC counts
191 double amplitude1 = tileCell.ene1();
192 amplitude1 /= m_tileToolEmscale->channelCalib (drawerIdx1, channel1, adc1, 1.0,
195
196 double pedestal1 = m_tileToolNoiseSample->getPed (drawerIdx1, channel1, adc1, TileRawChannelUnit::ADCcounts, ctx);
197
198 int igain1;
199
200 if (amplitude1 + pedestal1 < threshold ) {
201 igain1 = TileID::HIGHGAIN;
202 } else {
203 igain1 = TileID::LOWGAIN;
204 }
205
206 // second PMT, if it exists
207 if (caloDDE.onl2() != TileID::NOT_VALID_HASH ) {
208
209 HWIdentifier hwid2;
210 tileHWID->get_id( caloDDE.onl2(), hwid2, &chContext ); // pmt id
211 hwid2 = tileHWID->adc_id (hwid2, TileHWID::HIGHGAIN); // high gain ADC id
212
213 unsigned int drawerIdx2(0), channel2(0), adc2(0);
214 m_tileIdTransforms->getIndices (hwid2, drawerIdx2, channel2, adc2);
215
216 // first PMT, convert energy to ADC counts
217 double amplitude2 = tileCell.ene2();
218 amplitude2 /= m_tileToolEmscale->channelCalib (drawerIdx2, channel2, adc2, 1.0,
221
222 double pedestal2 = m_tileToolNoiseSample->getPed (drawerIdx2, channel2, adc2, TileRawChannelUnit::ADCcounts, ctx);
223
224 if (amplitude2 + pedestal2 < threshold) {
225 // igain2 high
227 } else {
228 // igain2 low
230 }
231 // nb. Having HIGHLOW in two places seems wrong, but that's what the
232 // original code was doing.
233 }
234
235 // igain2 doesn't exist.
237}
238
239
240float CaloEstimatedGainTool::adc2mev (const EventContext& ctx,
241 const CaloDetDescrElement& caloDDE,
242 CaloGain::CaloGain gain) const
243{
245 const auto& p = adc2mev->ADC2MEV (caloDDE.identify(), gain);
246 if (p.size() >= 2) {
247 return p[1];
248 }
249 return 0;
250}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
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
This class groups all DetDescr information related to a CaloCell.
Identifier identify() const override final
cell identifier
IdentifierHash onl2() const
cell online identifier 2
IdentifierHash onl1() const
cell online identifier 1
CaloGain::CaloGain estimatedLArGain(const EventContext &ctx, const CaloCell_ID::SUBCALO iCalo, const CaloDetDescrElement &caloDDE, const float energy, const Step step) const
virtual CaloGain::CaloGain estimatedGain(const EventContext &ctx, const CaloCell &caloCell, const Step step) const override
float adc2mev(const EventContext &ctx, const CaloDetDescrElement &caloDDE, const CaloGain::CaloGain gain) const
ToolHandle< TileCondIdTransforms > m_tileIdTransforms
ToolHandle< TileCondToolNoiseSample > m_tileToolNoiseSample
virtual StatusCode initialize() override
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
ICaloEstimatedGainTool::Step Step
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
CaloGain::CaloGain estimatedTileGain(const EventContext &ctx, const CaloCell &caloCell, const CaloDetDescrElement &caloDDE, const Step) const
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
const TileHWID * getTileHWID() const
static const TileCablingService * getInstance()
get pointer to service instance
float ene1(void) const
get energy of first PMT
Definition TileCell.h:187
float ene2(void) const
get energy of second PMT
Definition TileCell.h:189
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
@ HIGHGAIN
Definition TileHWID.h:73
virtual int get_id(const IdentifierHash &hash_id, HWIdentifier &id, const IdContext *context=0) const
create compact HW ID from hash id (return == 0 for OK)
Definition TileHWID.cxx:491
IdContext channel_context() const
idContext for channels
Definition TileHWID.cxx:478
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition TileHWID.cxx:229
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ TILELOWLOW
Definition CaloGain.h:12
@ INVALIDGAIN
Definition CaloGain.h:18
@ LARLOWGAIN
Definition CaloGain.h:18
@ TILEONEHIGH
Definition CaloGain.h:17
@ TILEONELOW
Definition CaloGain.h:16
@ TILEHIGHLOW
Definition CaloGain.h:14
@ TILEHIGHHIGH
Definition CaloGain.h:15
@ LARHIGHGAIN
Definition CaloGain.h:18