ATLAS Offline Software
TileRawChannelFlxMonitorAlgorithm.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 // Tile includes
9 
10 // Athena includes
11 #include "StoreGate/ReadHandle.h"
12 
13 #include <cstring>
14 
15 
17 
19 
20  ATH_MSG_INFO("in initialize()");
21 
25 
26  std::ostringstream os;
27 
28  if ( m_fragIDsToCompare.size() != 0) {
29  std::sort(m_fragIDsToCompare.begin(), m_fragIDsToCompare.end());
30  for (int fragID : m_fragIDsToCompare) {
31  unsigned int ros = fragID >> 8;
32  unsigned int drawer = fragID & 0xFF;
34  os << " " << module << "/0x" << std::hex << fragID << std::dec;
35  }
36  } else {
37  os << "NONE";
38  }
39 
40  ATH_MSG_INFO("Monitored modules/frag ID:" << os.str());
41 
42  return StatusCode::SUCCESS;
43 }
44 
45 
47 
48  // In case you want to measure the execution time
49  auto timer = Monitored::Timer("TIME_execute");
50 
52  ATH_CHECK( rawChannelContainerLegacy.isValid() );
53 
55  ATH_CHECK( rawChannelContainerFlx.isValid() );
56 
57  std::array<std::string, 2> gainName{"_LG", "_HG"};
58 
62 
63  const TileFragHash& hashFunc = rawChannelContainerFlx->hashFunc();
64 
65  for (int fragID : m_fragIDsToCompare) {
66 
67  memset(found,0,sizeof(found));
68 
69  IdentifierHash hash = static_cast<IdentifierHash>(hashFunc(fragID));
70  unsigned int drawer = (fragID & 0x3F);
71  unsigned int ros = fragID >> 8;
73  std::array<std::string, 2> moduleName{module+gainName[0], module+gainName[1]};
74 
75  // Legacy amplitudes
76  const TileRawChannelCollection* rawChannelCollectionLegacy = rawChannelContainerLegacy->indexFindPtr(hash);
77  for (const TileRawChannel* rawChannel : *rawChannelCollectionLegacy) {
78 
79  HWIdentifier adcId = rawChannel->adc_HWID();
80  int channel = m_tileHWID->channel(adcId);
81  int gain = m_tileHWID->adc(adcId);
82 
83  found[channel][gain] |= 1;
84  amplitude[channel][gain] = rawChannel->amplitude();
85 
86  std::string channelName = moduleName[gain] + "_channel";
87  auto monitoredChannel = Monitored::Scalar<float>(channelName, channel);
88 
89  std::string amplitudeName = moduleName[gain] + "_amplitude";
90  auto monitoredAmplitude = Monitored::Scalar<float>(amplitudeName, rawChannel->amplitude());
91  fill("TileRawChannelAmpLegacy", monitoredChannel, monitoredAmplitude);
92  }
93 
94  // FELIX amplitudes
95  const TileRawChannelCollection* rawChannelCollectionFlx = rawChannelContainerFlx->indexFindPtr(hash);
96  for (const TileRawChannel* rawChannel : *rawChannelCollectionFlx) {
97 
98  HWIdentifier adcId = rawChannel->adc_HWID();
99  int channel = m_tileHWID->channel(adcId);
100  int gain = m_tileHWID->adc(adcId);
101 
102  found[channel][gain] |= 2;
103  amplitudeFlx[channel][gain] = rawChannel->amplitude();
104 
105  std::string channelName = moduleName[gain] + "_channel";
106  auto monitoredChannel = Monitored::Scalar<float>(channelName, channel);
107 
108  std::string amplitudeName = moduleName[gain] + "_amplitude";
109  auto monitoredAmplitude = Monitored::Scalar<float>(amplitudeName, rawChannel->amplitude());
110  fill("TileRawChannelAmpFlx", monitoredChannel, monitoredAmplitude);
111  }
112 
113  // Compare amplitude and amplitudeFlx arrays and put results into histograms
114  for(unsigned int gain = 0; gain<TileCalibUtils::MAX_GAIN; ++gain) {
115 
116  std::string channelName = moduleName[gain] + "_channel";
117  std::string amplitudeName = moduleName[gain] + "_amplitude";
118  std::string amplitudeDiffName = moduleName[gain] + "_amplitude_diff";
119 
120  auto monitoredChannel = Monitored::Scalar<float>(channelName, 0.0F);
121  auto monitoredAmplitude = Monitored::Scalar<float>(amplitudeName, 0.0F);
122  auto monitoredAmplitudeDiff = Monitored::Scalar<float>(amplitudeDiffName, 0.0F);
123 
124  for(unsigned int channel = 0; channel<TileCalibUtils::MAX_CHAN; ++channel) {
125 
126  if (found[channel][gain] == 3) {
127 
128  monitoredChannel = channel;
129  monitoredAmplitude = amplitude[channel][gain];
130  monitoredAmplitudeDiff = amplitudeFlx[channel][gain] - amplitude[channel][gain] * m_felixScale;
131 
132  fill("TileRawChannelAmpDiff", monitoredChannel, monitoredAmplitudeDiff);
133  fill("TileRawChannelAmpDiffVsLegacy", monitoredAmplitude, monitoredAmplitudeDiff);
134  }
135  }
136  }
137  }
138 
139  fill("TileRawChannelFlxMonExecuteTime", timer);
140 
141  return StatusCode::SUCCESS;
142 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
RunTileTBMonitoring.fragID
fragID
Definition: RunTileTBMonitoring.py:212
TileRawChannelFlxMonitorAlgorithm::m_felixScale
Gaudi::Property< unsigned int > m_felixScale
Definition: TileRawChannelFlxMonitorAlgorithm.h:40
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileRawChannelFlxMonitorAlgorithm::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileRawChannelFlxMonitorAlgorithm.h:36
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TileRawChannelFlxMonitorAlgorithm::m_rawChannelContainerKeyFlx
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKeyFlx
Definition: TileRawChannelFlxMonitorAlgorithm.h:33
TileCalibUtils.h
TileFragHash
Hash table for Tile fragments (==drawers ==collections in StoreGate)
Definition: TileFragHash.h:24
HWIdentifier
Definition: HWIdentifier.h:13
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
python.PyAthena.module
module
Definition: PyAthena.py:134
TileHWID::adc
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
Definition: TileHWID.h:193
TileRawChannelFlxMonitorAlgorithm::m_fragIDsToCompare
Gaudi::Property< std::vector< int > > m_fragIDsToCompare
Definition: TileRawChannelFlxMonitorAlgorithm.h:38
TileHWID.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TileRawChannelFlxMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileRawChannelFlxMonitorAlgorithm.cxx:46
TileRawChannel
Definition: TileRawChannel.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
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
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileRawChannelCollection
Definition: TileRawChannelCollection.h:12
TileRawDataContainer::hashFunc
const TileFragHash & hashFunc() const
Definition: TileRawDataContainer.h:66
TileRawChannelFlxMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileRawChannelFlxMonitorAlgorithm.cxx:16
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
TileRawChannelFlxMonitorAlgorithm::m_rawChannelContainerKeyLegacy
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKeyLegacy
Definition: TileRawChannelFlxMonitorAlgorithm.h:30
TileCalibUtils::getDrawerString
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
Definition: TileCalibUtils.cxx:145
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
F
#define F(x, y, z)
Definition: MD5.cxx:112
TileRawChannelFlxMonitorAlgorithm.h
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
Definition: IdentifierHash.h:38
TileCalibUtils::MAX_CHAN
static const unsigned int MAX_CHAN
Number of channels in drawer.
Definition: TileCalibUtils.h:141
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
TileCalibUtils::MAX_GAIN
static const unsigned int MAX_GAIN
Number of gains per channel
Definition: TileCalibUtils.h:142