ATLAS Offline Software
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 
27 #include "TileSimEvent/TileHit.h"
29 
30 // Calo includes
31 #include "CaloIdentifier/TileID.h"
32 
33 // Atlas includes
34 #include "StoreGate/ReadHandle.h"
35 #include "StoreGate/WriteHandle.h"
38 // access all RawChannels inside container
40 
41 #include <memory>
42 
43 //
44 // Constructor
45 //
46 TileRawChannelToHit::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 
56 {}
57 
58 //****************************************************************************
59 //* Initialization
60 //****************************************************************************
61 
63 
64  if (m_useSamplFract)
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
72 
73  //=== get TileCondToolEmscale
74  ATH_CHECK( m_tileToolEmscale.retrieve() );
75 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileSamplingFraction::getSamplingFraction
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
Definition: TileSamplingFraction.h:53
TileRawChannel.h
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
hitVector
std::vector< FPGATrackSimHit > hitVector
Definition: FPGATrackSimCluster.h:23
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
TileRawChannelToHit::m_hitVectorKey
SG::WriteHandleKey< TileHitVector > m_hitVectorKey
Definition: TileRawChannelToHit.h:75
TileFragHash.h
TileInfo.h
TileCalibUtils.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
TileRawChannelToHit::~TileRawChannelToHit
virtual ~TileRawChannelToHit()
Definition: TileRawChannelToHit.cxx:55
TileHWID::HIGHGAIN
@ HIGHGAIN
Definition: TileHWID.h:73
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
ReadCondHandle.h
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
TileRawChannelToHit::execute
StatusCode execute()
Definition: TileRawChannelToHit.cxx:91
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
WriteHandle.h
Handle class for recording to StoreGate.
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
TileRawChannelToHit::finalize
StatusCode finalize()
Definition: TileRawChannelToHit.cxx:215
TileHWID.h
TileRawChannelToHit::m_tileToolEmscale
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
main Tile Calibration tool
Definition: TileRawChannelToHit.h:91
TileSamplingFraction
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
Definition: TileSamplingFraction.h:16
TileRawChannelToHit::m_rawChannelContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition: TileRawChannelToHit.h:71
TileCondToolEmscale.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TileRawChannelToHit::TileRawChannelToHit
TileRawChannelToHit(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileRawChannelToHit.cxx:46
TileRawChannelUnit::MegaElectronVolts
@ MegaElectronVolts
Definition: TileRawChannelUnit.h:20
TileRawChannel
Definition: TileRawChannel.h:35
TileRawChannelToHit::m_useSamplFract
bool m_useSamplFract
Definition: TileRawChannelToHit.h:86
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
TileRawChannelUnit::UNIT
UNIT
Definition: TileRawChannelUnit.h:16
AthAlgorithm
Definition: AthAlgorithm.h:47
TileHWID::drawer_id
HWIdentifier drawer_id(int frag) const
ROS HWIdentifer.
Definition: TileHWID.cxx:186
TileHit.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TileRawChannelToHit::m_tileID
const TileID * m_tileID
Definition: TileRawChannelToHit.h:88
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TileRawChannelCollection
Definition: TileRawChannelCollection.h:12
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileHit
Definition: TileSimEvent/TileSimEvent/TileHit.h:30
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TileRawChannelToHit.h
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TileRawChannelToHit::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition: TileRawChannelToHit.h:82
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
Tile_Base_ID::to_string
std::string to_string(const Identifier &id, int level=0) const
Definition: Tile_Base_ID.cxx:52
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TileRawChannelToHit::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileRawChannelToHit.h:89
TileRawChannelToHit::initialize
StatusCode initialize()
Definition: TileRawChannelToHit.cxx:62
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
TileAANtupleConfig.rawChannelContainer
rawChannelContainer
Definition: TileAANtupleConfig.py:120
SelectAllObject.h
TileHWID::to_string
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
Definition: TileHWID.cxx:49
ReadHandle.h
Handle class for reading from StoreGate.
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67