ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelToHit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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
29
30// Calo includes
32
33// Atlas includes
38// access all RawChannels inside container
40
41#include <memory>
42
43//
44// Constructor
45//
46TileRawChannelToHit::TileRawChannelToHit(const std::string& name, ISvcLocator* pSvcLocator)
47 : AthAlgorithm(name, pSvcLocator)
48 , m_tileToolEmscale("TileCondToolEmscale")
49{
50 declareProperty("UseSamplFract", m_useSamplFract = false); // if true energy in TileHit is the as it is coming from G4 simulation
51 // and by default it is equal to final - TileCell energy
52 declareProperty("TileCondToolEmscale" , m_tileToolEmscale);
53}
54
57
58//****************************************************************************
59//* Initialization
60//****************************************************************************
61
63
65 ATH_MSG_INFO( "Sampling fraction is taken into account for TileHit energy" );
66 else
67 ATH_MSG_INFO( "TileHit will contain CELL energy (not divided by sampling fraction)" );
68
69 // retrieve TileID helper and TileIfno from det store
70 ATH_CHECK( detStore()->retrieve(m_tileID) );
71 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
72
73 //=== get TileCondToolEmscale
74 ATH_CHECK( m_tileToolEmscale.retrieve() );
75
76 ATH_CHECK( m_rawChannelContainerKey.initialize() );
77 ATH_CHECK( m_hitVectorKey.initialize() );
78
80
81 ATH_MSG_INFO( "TileRawChannelToHit initialization completed" );
82
83 return StatusCode::SUCCESS;
84}
85
86
87//****************************************************************************
88//* Execution
89//****************************************************************************
90
92
93 /* zero all counters and sums */
94 int nHit = 0;
95 int nChan = 0;
96 float eCh = 0.0;
97 float eHitTot = 0.0;
98
99 const TileSamplingFraction* samplingFraction = nullptr;
100 if (m_useSamplFract) {
102 ATH_CHECK( samplingFractionHandle.isValid() );
103 samplingFraction = samplingFractionHandle.cptr();
104 }
105
107
108 /* Register the set of TileHits to the event store. */
109 ATH_CHECK( hitVector.record(std::make_unique<TileHitVector>()) );
110
111 //**
112 //* Get TileRawChannels
113 //**
115
116 if (!rawChannelContainer.isValid()) {
117 ATH_MSG_WARNING( " Could not find container " << m_rawChannelContainerKey.key() );
118 ATH_MSG_WARNING( " creating empty TileHitVector container " );
119
120 } else {
121
122 TileRawChannelUnit::UNIT rChUnit = rawChannelContainer->get_unit();
123 //TileFragHash::TYPE rChType = rawChannelContainer->get_type();
124
125 // iterate over all collections in a container
126 for(const TileRawChannelCollection* rawChannelCollection : *rawChannelContainer) {
127
128 HWIdentifier drawer_id = m_tileHWID->drawer_id(rawChannelCollection->identify());
129 int ros = m_tileHWID->ros(drawer_id);
130 int drawer = m_tileHWID->drawer(drawer_id);
131 int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
132
133 bool is_calibration = (rawChannelCollection->size() == 96);
134 if (is_calibration)
135 ATH_MSG_DEBUG( "Calibration mode, ignore high gain" );
136
137 // iterate over all raw channels in a collection, creating new TileHits
138 // Add each new TileHit to the TileHitContainer.
139
140 for (const TileRawChannel* rawChannel : *rawChannelCollection) {
141
142 HWIdentifier adc_id = rawChannel->adc_HWID();
143 int channel = m_tileHWID->channel(adc_id);
144 int adc = m_tileHWID->adc(adc_id);
145
146 // skip high gain in calibration mode
147 if (is_calibration && TileHWID::HIGHGAIN == adc)
148 continue;
149
150 float amp = rawChannel->amplitude();
151 float time = rawChannel->time();
152
153 ++nChan;
154 eCh += amp;
155
156 Identifier pmt_id = rawChannel->pmt_ID();
157 if (pmt_id.is_valid()) {
158
159 float ener = m_tileToolEmscale->channelCalib(drawerIdx, channel, adc,
160 amp, rChUnit,
162
163 if (m_useSamplFract) { // divide by sampling fraction (about 40)
164 ener /= samplingFraction->getSamplingFraction(drawerIdx, channel);
165 }
166
167 TileHit hit(pmt_id, ener, time);
168 eHitTot += ener;
169 ++nHit;
170
171 ATH_MSG_VERBOSE( "TileRawChannelToHit: "
172 << " pmt_id=" << m_tileID->to_string(pmt_id, -1)
173 << " adc_id=" << m_tileHWID->to_string(adc_id)
174 << " nHit=" << nHit
175 << " amp=" << amp
176 << " ene=" << ener
177 << " time=" << time );
178
179 hitVector->push_back(hit);
180
181 } else {
182
183 ATH_MSG_VERBOSE( "TileRawChannelToHit: "
184 << " channel with adc_id=" << m_tileHWID->to_string(adc_id)
185 << " is not connected" );
186 }
187 }
188 }
189 }
190
191
192
193
194 // Execution completed.
195 ATH_MSG_DEBUG( "TileRawChannelToHit execution completed." );
196 ATH_MSG_DEBUG( " nChan=" << nChan
197 << " RawChSum=" << eCh
198 << " nHit=" << nHit
199 << " eneTot=" << eHitTot );
200
201
202 ATH_MSG_VERBOSE( "TileHitVector container registered to the TES with name"
203 << m_hitVectorKey.key() );
204
205 return StatusCode::SUCCESS;
206}
207
208//************************************************************************
209
210
211//****************************************************************************
212//* Finalize
213//****************************************************************************
214
216
217 ATH_MSG_INFO( "TileRawChannelToHit::finalize() end" );
218
219 return StatusCode::SUCCESS;
220}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
std::vector< FPGATrackSimHit > hitVector
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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
TileRawChannelToHit(const std::string &name, ISvcLocator *pSvcLocator)
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.