ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelFlxMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Tile includes
9
10// Athena includes
12
13#include <cstring>
14
15
17
19
20 ATH_MSG_INFO("in initialize()");
21
22 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
25
26 std::ostringstream os;
27
28 if ( m_fragIDsToCompare.size() != 0) {
30 for (int fragID : m_fragIDsToCompare) {
31 unsigned int ros = fragID >> 8;
32 unsigned int drawer = fragID & 0xFF;
33 std::string module = TileCalibUtils::getDrawerString(ros, drawer);
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
46StatusCode TileRawChannelFlxMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
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;
72 std::string module = TileCalibUtils::getDrawerString(ros, drawer);
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 auto monitoredChannel = Monitored::Scalar<float>(moduleName[gain] + "_channel", channel);
87
88 auto monitoredAmplitude = Monitored::Scalar<float>(moduleName[gain] + "_amplitude", rawChannel->amplitude());
89 fill("TileRawChannelAmpLegacy", monitoredChannel, monitoredAmplitude);
90 }
91
92 // FELIX amplitudes
93 const TileRawChannelCollection* rawChannelCollectionFlx = rawChannelContainerFlx->indexFindPtr(hash);
94 for (const TileRawChannel* rawChannel : *rawChannelCollectionFlx) {
95
96 HWIdentifier adcId = rawChannel->adc_HWID();
97 int channel = m_tileHWID->channel(adcId);
98 int gain = m_tileHWID->adc(adcId);
99
100 found[channel][gain] |= 2;
101 amplitudeFlx[channel][gain] = rawChannel->amplitude();
102
103 auto monitoredChannel = Monitored::Scalar<float>(moduleName[gain] + "_channel", channel);
104
105 auto monitoredAmplitude = Monitored::Scalar<float>(moduleName[gain] + "_amplitude", rawChannel->amplitude());
106 fill("TileRawChannelAmpFlx", monitoredChannel, monitoredAmplitude);
107 }
108
109 // Compare amplitude and amplitudeFlx arrays and put results into histograms
110 for(unsigned int gain = 0; gain<TileCalibUtils::MAX_GAIN; ++gain) {
111
112 auto monitoredChannel = Monitored::Scalar<float>(moduleName[gain] + "_channel", 0.0F);
113 auto monitoredAmplitude = Monitored::Scalar<float>(moduleName[gain] + "_amplitude", 0.0F);
114 auto monitoredAmplitudeDiff = Monitored::Scalar<float>(moduleName[gain] + "_amplitude_diff", 0.0F);
115
116 for(unsigned int channel = 0; channel<TileCalibUtils::MAX_CHAN; ++channel) {
117
118 if (found[channel][gain] == 3) {
119
120 monitoredChannel = channel;
121 monitoredAmplitude = amplitude[channel][gain];
122 monitoredAmplitudeDiff = amplitudeFlx[channel][gain] - amplitude[channel][gain] * m_felixScale;
123
124 fill("TileRawChannelAmpDiff", monitoredChannel, monitoredAmplitudeDiff);
125 fill("TileRawChannelAmpDiffVsLegacy", monitoredAmplitude, monitoredAmplitudeDiff);
126 }
127 }
128 }
129 }
130
131 fill("TileRawChannelFlxMonExecuteTime", timer);
132
133 return StatusCode::SUCCESS;
134}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Handle class for reading from StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
This is a "hash" representation of an Identifier.
Declare a monitored scalar variable.
A monitored timer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static const unsigned int MAX_GAIN
Number of gains per channel.
static const unsigned int MAX_CHAN
Number of channels in drawer.
Hash table for Tile fragments (==drawers ==collections in StoreGate)
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKeyLegacy
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKeyFlx
Gaudi::Property< std::vector< int > > m_fragIDsToCompare
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void fill(H5::Group &out_file, size_t iterations)