ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelToHit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileRawChannelToHit.cxx
7// Author : Alexander Solodkov
8// Created : Feb, 2005
9//
10// DESCRIPTION:
11// Implementation comments only. Class level comments go in .h file.
12//
13// HISTORY:
14//
15// BUGS:
16//
17//*****************************************************************************
18
19// Tile includes
20#include "TileRawChannelToHit.h"
21
28
29// Calo includes
31
32// Atlas includes
37// access all RawChannels inside container
39
40#include <memory>
41
42//
43// Constructor
44//
45TileRawChannelToHit::TileRawChannelToHit(const std::string& name, ISvcLocator* pSvcLocator)
46 : AthAlgorithm(name, pSvcLocator)
47{
48}
49
52
53//****************************************************************************
54//* Initialization
55//****************************************************************************
56
58
60 ATH_MSG_INFO( "Sampling fraction is taken into account for TileHit energy" );
61 else
62 ATH_MSG_INFO( "TileHit will contain CELL energy (not divided by sampling fraction)" );
63
64 // retrieve TileID helper and TileIfno from det store
65 ATH_CHECK( detStore()->retrieve(m_tileID) );
66 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
67
68 //=== get TileCondToolEmscale
69 ATH_CHECK( m_tileToolEmscale.retrieve() );
70
71 ATH_CHECK( m_rawChannelContainerKey.initialize() );
72 ATH_CHECK( m_hitVectorKey.initialize() );
73
75
76 ATH_MSG_INFO( "TileRawChannelToHit initialization completed" );
77
78 return StatusCode::SUCCESS;
79}
80
81
82//****************************************************************************
83//* Execution
84//****************************************************************************
85
86StatusCode TileRawChannelToHit::execute(const EventContext& ctx) {
87
88 /* zero all counters and sums */
89 int nHit = 0;
90 int nChan = 0;
91 float eCh = 0.0;
92 float eHitTot = 0.0;
93
94 const TileSamplingFraction* samplingFraction = nullptr;
95 if (m_useSamplFract) {
97 ATH_CHECK( samplingFractionHandle.isValid() );
98 samplingFraction = samplingFractionHandle.cptr();
99 }
100
102
103 /* Register the set of TileHits to the event store. */
104 ATH_CHECK( hitVector.record(std::make_unique<TileHitVector>()) );
105
106 //**
107 //* Get TileRawChannels
108 //**
110
111 if (!rawChannelContainer.isValid()) {
112 ATH_MSG_WARNING( " Could not find container " << m_rawChannelContainerKey.key() );
113 ATH_MSG_WARNING( " creating empty TileHitVector container " );
114
115 } else {
116
117 TileRawChannelUnit::UNIT rChUnit = rawChannelContainer->get_unit();
118 //TileFragHash::TYPE rChType = rawChannelContainer->get_type();
119
120 // iterate over all collections in a container
121 for(const TileRawChannelCollection* rawChannelCollection : *rawChannelContainer) {
122
123 HWIdentifier drawer_id = m_tileHWID->drawer_id(rawChannelCollection->identify());
124 int ros = m_tileHWID->ros(drawer_id);
125 int drawer = m_tileHWID->drawer(drawer_id);
126 int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
127
128 bool is_calibration = (rawChannelCollection->size() == 96);
129 if (is_calibration)
130 ATH_MSG_DEBUG( "Calibration mode, ignore high gain" );
131
132 // iterate over all raw channels in a collection, creating new TileHits
133 // Add each new TileHit to the TileHitContainer.
134
135 for (const TileRawChannel* rawChannel : *rawChannelCollection) {
136
137 HWIdentifier adc_id = rawChannel->adc_HWID();
138 int channel = m_tileHWID->channel(adc_id);
139 int adc = m_tileHWID->adc(adc_id);
140
141 // skip high gain in calibration mode
142 if (is_calibration && TileHWID::HIGHGAIN == adc)
143 continue;
144
145 float amp = rawChannel->amplitude();
146 float time = rawChannel->time();
147
148 ++nChan;
149 eCh += amp;
150
151 Identifier pmt_id = rawChannel->pmt_ID();
152 if (pmt_id.is_valid()) {
153
154 float ener = m_tileToolEmscale->channelCalib(drawerIdx, channel, adc,
155 amp, rChUnit,
157
158 if (m_useSamplFract) { // divide by sampling fraction (about 40)
159 ener /= samplingFraction->getSamplingFraction(drawerIdx, channel);
160 }
161
162 TileHit hit(pmt_id, ener, time);
163 eHitTot += ener;
164 ++nHit;
165
166 ATH_MSG_VERBOSE( "TileRawChannelToHit: "
167 << " pmt_id=" << m_tileID->to_string(pmt_id, -1)
168 << " adc_id=" << m_tileHWID->to_string(adc_id)
169 << " nHit=" << nHit
170 << " amp=" << amp
171 << " ene=" << ener
172 << " time=" << time );
173
174 hitVector->push_back(hit);
175
176 } else {
177
178 ATH_MSG_VERBOSE( "TileRawChannelToHit: "
179 << " channel with adc_id=" << m_tileHWID->to_string(adc_id)
180 << " is not connected" );
181 }
182 }
183 }
184 }
185
186
187
188
189 // Execution completed.
190 ATH_MSG_DEBUG( "TileRawChannelToHit execution completed." );
191 ATH_MSG_DEBUG( " nChan=" << nChan
192 << " RawChSum=" << eCh
193 << " nHit=" << nHit
194 << " eneTot=" << eHitTot );
195
196
197 ATH_MSG_VERBOSE( "TileHitVector container registered to the TES with name"
198 << m_hitVectorKey.key() );
199
200 return StatusCode::SUCCESS;
201}
202
203//************************************************************************
204
205
206//****************************************************************************
207//* Finalize
208//****************************************************************************
209
211
212 ATH_MSG_INFO( "TileRawChannelToHit::finalize() end" );
213
214 return StatusCode::SUCCESS;
215}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
Helpers for checking error return status codes and reporting errors.
std::vector< FPGATrackSimHit > hitVector
bool hit(const Container &ids, int pdgId)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const ServiceHandle< StoreGateSvc > & detStore() const
bool is_valid() const
Check if id is in a valid state.
const_pointer_type cptr()
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
@ HIGHGAIN
Definition TileHWID.h:73
SG::WriteHandleKey< TileHitVector > m_hitVectorKey
const TileHWID * m_tileHWID
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
main Tile Calibration tool
StatusCode execute(const EventContext &ctx)
Execute method.
TileRawChannelToHit(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_useSamplFract
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.