ATLAS Offline Software
Loading...
Searching...
No Matches
LArRODMonAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef LARMONITORING_LArRODMONALG_H
6#define LARMONITORING_LArRODMONALG_H
7
14#include "GaudiKernel/ToolHandle.h"
24
25#include <atomic>
26#include <fstream>
27
28
29class LArDigit;
31
32
34{
35 public:
36
38
40 virtual ~LArRODMonAlg();
41
42 virtual StatusCode initialize() override final;
43
44 virtual StatusCode finalize() override final;
45
46 // Called each event
47 virtual StatusCode fillHistograms(const EventContext& ctx) const override final;
48
49
50private:
52
54 static constexpr auto m_PARTNAMES=std::to_array<const char*>({"EMBC","EMBA","EMECC","EMECA","HECC","HECA","FCalC","FCalA","UNKNOWN"});
55
56 class ERRCOUNTER {
57 public:
59 clear();
60 };
61 void clear();
62 std::array<unsigned,3> errors_E,errors_T,errors_Q;
63 };
64
65
66
67 PARTITION getPartition(const HWIdentifier chid) const;
68 const char* getPartitionName(const HWIdentifier chid) const;
69
70 struct diff_t {
71 float e_on=0;
72 float e_off=0;
73 float t_on=0;
74 float t_off=0;
75 float q_on=0;
76 float q_off=0;
77 };
78
79 diff_t compareChannel(const LArRawChannel& rcDig,
80 const LArRawChannel& rcBS) const;
81
82
84 const LArDigit& dig,
85 const EventContext& ctx) const;
86
87
89 void dumpCellInfo(const HWIdentifier chid, // Channel HW ID
90 const int gain,
91 const EventContext& ctx,
92 const diff_t & comp)const;
93
94
95
96
97 SG::ReadHandleKey<LArRawChannelContainer> m_channelKey_fromBytestream{this,"LArRawChannelKey_fromBytestream","LArRawChannels","SG key of LArRawChannels produced by teh DSP"};
98 SG::ReadHandleKey<LArRawChannelContainer> m_channelKey_fromDigits{this,"LArRawChannelKey_fromDigits","LArRawChannels_FromDigits","SG key of LArRawChannels produced offline"};
99
100 SG::ReadHandleKey<LArDigitContainer> m_digitContainerKey{this,"LArDigitContainerKey","FREE","SG key of LArDigitContainer read from Bytestream"};
101 SG::ReadHandleKey<LArFebHeaderContainer> m_headerContainerKey{this,"LArFebHeaderKey","LArFebHeader","SG key of LArFebHeader"};
102
103
104 SG::ReadCondHandleKey<ILArOFC> m_keyOFC{this,"KeyOFC","LArOFC","SG key of LArOFC CDO"};
105 SG::ReadCondHandleKey<ILArShape> m_keyShape{this,"KeyShape","LArShape","SG key of LArShape CDO"};
106 SG::ReadCondHandleKey<ILArHVScaleCorr> m_keyHVScaleCorr{this,"KeyHVScaleCorr","LArHVScaleCorr","SG key of LArHVScaleCorr CDO"};
107 SG::ReadCondHandleKey<ILArPedestal> m_keyPedestal{this,"LArPedestalKey","LArPedestal","SG key of LArPedestal CDO"};
108
109 SG::ReadCondHandleKey<LArADC2MeV> m_adc2mevKey{this,"LArADC2MeVKey","LArADC2MeV","SG Key of the LArADC2MeV CDO"};
110
112 SG::ReadCondHandleKey<LArBadChannelCont> m_bcContKey {this, "BadChanKey", "LArBadChannel", "SG key for LArBadChan object"};
113 Gaudi::Property<std::vector<std::string> > m_problemsToMask{this,"ProblemsToMask",{}, "Bad-Channel categories to mask"};
114
115
116 SG::ReadCondHandleKey<CaloNoise> m_noiseCDOKey{this,"CaloNoiseKey","totalNoise","SG Key of CaloNoise data object"};
117 SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping CDO"};
118
119 //To get the data-dependency right ...
120 SG::ReadDecorHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "LArStatusFlag", "EventInfo.larFlags", "Key for EventInfo object"};
121
122 //declaration variables used in joboptions
123 Gaudi::Property<std::string> m_MonGroupName {this, "MonGroup", "RODMon"};
124 Gaudi::Property<std::vector<std::string> > m_SubDetNames {this, "LArRODSubDetNames", {} };
125 Gaudi::Property<std::vector<std::string> > m_partitions {this, "LArRODPartitionNames", {} };
126 Gaudi::Property<std::vector<int> > m_Nslots {this, "LArRODNslots", {} };
127
128 // Output files names
129 Gaudi::Property<std::string> m_DigitsFileName{this, "DigitsFileName","digits.txt","Digits dump output filename"};
130 Gaudi::Property<std::string> m_EnergyFileName{this,"EnergyFileName","energy.txt"," Energies dump output filename"};
131 Gaudi::Property<std::string> m_AiFileName{this,"AiFileName","Calib_ai.dat","dump output filename"};
132 Gaudi::Property<std::string> m_DumpCellsFileName{this,"DumpCellsFileName","dumpCells.txt","Cells dump output filename"};
133
134 Gaudi::Property<bool> m_doDspTestDump{this, "DoDspTestDump", false, "dsp dump switch"};
135 Gaudi::Property<bool> m_doCellsDump{this, "DoCellsDump", false, "cell dump switch"};
136 Gaudi::Property<bool> m_doCheckSum{this, "DoCheckSum", true, "checksum test switch"};
137 Gaudi::Property<bool> m_doRodStatus{this, "DoRodStatus", true, "ROD status test switch"};
138 Gaudi::Property<bool> m_printEnergyErrors{this, "PrintEnergyErrors", true, "energy errors printing"};
139 Gaudi::Property<bool> m_removeNoiseBursts{this, "RemoveNoiseBursts", true, "removing events with noise bursts"};
140
141
142 Gaudi::Property<bool> m_skipKnownProblematicChannels{this, "SkipKnownProblematicChannels", false, "skipping known problems?"};
143 Gaudi::Property<bool> m_skipNullPed{this, "SkipNullPed", false, "skipping no pedestal channels ?"};
144 Gaudi::Property<bool> m_skipNullQT{this, "SkipNullQT", false, "skipping no quality channe4ls ?"};
145
146 Gaudi::Property<float> m_timeOffset{this, "TimeOffset", 0.};
147 Gaudi::Property<short> m_adc_th{this, "ADCthreshold", 50, "Minimal number of ADC amplitude among samples required to compare online/offline"};
148 Gaudi::Property<float> m_peakTime_cut{this, "peakTimeCut", 5., "Cut on abs(peak time) to compare online/offline (all quantities)"};
149
150
151 // Expected precision for energy calculation, depending on energy (ranges) :
152 // Adding 1 MeV on request of Alexis (truncating difference) (May 2016)
153 // Between -213 and 213 MeV (~ 8 GeV) 2**0=1 MeV precision (range 0)
154 // Between -216 and 216 MeV (~ 64 GeV) 2**3=8 MeV precision (range 1)
155 // Between -219 and 219 MeV (~ 512 GeV) 2**6=64 MeV precision (range 2)
156 // Between -222 and 222 MeV (~ 4 TeV) 2**9=512 MeV precision (range 3)
157
158 Gaudi::Property<std::vector<std::pair<int, int>>> m_E_precision{this,"EnergyPrecisionRanges",
159 {{8192,2},{65536,9},{524288,65},{4194304,513},{std::numeric_limits<int>::max(),8193}},
160 "Energy precision ranges vector<pair<upperLimit,ExpectedPrecision>"};
161 Gaudi::Property<std::vector<std::pair<int, int>>> m_T_precision{this,"TimePrecisionRanges",
162 {{1000,340},{5000,340},{25000,340},{50000,340},{std::numeric_limits<int>::max(),340}},
163 "Time precision ranges as vector<pair<upperLImit,ExpectedPrecision"};
164 Gaudi::Property<std::vector<std::pair<int, int>>> m_Q_precision{this,"QualityPrecisionRanges",
165 {{std::numeric_limits<int>::max(),3}},
166 "Quality precision ranges as vector<pair<upperLImit,ExpectedPrecision"};
167 const float m_BC=25000; // value of 1 bunch-crossing = 25ns
168
169 /* Histogram grouping (part) */
170 std::map<std::string,int> m_histoGroups;
171
172 Gaudi::Property<std::vector<std::string> > m_streams{this, "Streams", {} };
173
174 Gaudi::Property<unsigned> m_max_dump{this, "MaxEvDump", 0, "max number of channels for detailed log-output"};
175 mutable std::atomic<unsigned> m_ndump{0};
176
177
178 //Streams for dump-files. Explicitly disabled in an MT-environment
179 mutable std::ofstream m_fai ATLAS_THREAD_SAFE;
180 mutable std::ofstream m_fdig ATLAS_THREAD_SAFE;
181 mutable std::ofstream m_fen ATLAS_THREAD_SAFE;
182 mutable std::ofstream m_fdump ATLAS_THREAD_SAFE;
183
184};
185
186
187inline
189 const int side=m_LArOnlineIDHelper->pos_neg(chid);
190 if (m_LArOnlineIDHelper->isEMBchannel(chid)) {
191 if (side==0)
192 return EMBC;
193 else
194 return EMBA;
195 }
196 if (m_LArOnlineIDHelper->isEMECchannel(chid)) {
197 if (side==0)
198 return EMECC;
199 else
200 return EMECA;
201 }
202 if (m_LArOnlineIDHelper->isHECchannel(chid)){
203 if (side==0)
204 return HECC;
205 else
206 return HECA;
207 }
208 if (m_LArOnlineIDHelper->isFCALchannel(chid)) {
209 if (side==0)
210 return FCALC;
211 else
212 return FCALA;
213 }
214
215 ATH_MSG_FATAL(std::format("Channel {:#x} neither EMB nor EMEC nor HEC nor FCAL???",chid.get_identifier32().get_compact()));
216 return N_PARTITIONS;
217}
218
219inline
220const char* LArRODMonAlg::getPartitionName(const HWIdentifier chid) const{
221 return m_PARTNAMES[getPartition(chid)];
222}
223
224#endif
#define ATH_MSG_FATAL(x)
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Liquid Argon digit base class.
Definition LArDigit.h:25
Container class for LArFebHeader.
std::array< unsigned, 3 > errors_T
std::array< unsigned, 3 > errors_Q
std::array< unsigned, 3 > errors_E
Gaudi::Property< std::vector< std::pair< int, int > > > m_T_precision
Gaudi::Property< std::vector< std::pair< int, int > > > m_E_precision
std::ofstream m_fai ATLAS_THREAD_SAFE
const char * getPartitionName(const HWIdentifier chid) const
Gaudi::Property< float > m_timeOffset
Gaudi::Property< bool > m_printEnergyErrors
Gaudi::Property< bool > m_doRodStatus
Gaudi::Property< std::string > m_DigitsFileName
Gaudi::Property< std::string > m_AiFileName
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
SG::ReadCondHandleKey< ILArPedestal > m_keyPedestal
Gaudi::Property< std::vector< std::pair< int, int > > > m_Q_precision
void dumpCellInfo(const HWIdentifier chid, const int gain, const EventContext &ctx, const diff_t &comp) const
Dump a cell's information and calculated energies into a txt file.
Gaudi::Property< bool > m_skipNullPed
const LArOnlineID * m_LArOnlineIDHelper
SG::ReadHandleKey< LArFebHeaderContainer > m_headerContainerKey
Gaudi::Property< std::vector< std::string > > m_streams
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override final
adds event to the monitoring histograms
Gaudi::Property< bool > m_removeNoiseBursts
Gaudi::Property< std::vector< std::string > > m_SubDetNames
Gaudi::Property< float > m_peakTime_cut
PARTITION getPartition(const HWIdentifier chid) const
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Property< bool > m_skipNullQT
Gaudi::Property< bool > m_skipKnownProblematicChannels
SG::ReadCondHandleKey< ILArOFC > m_keyOFC
Gaudi::Property< std::string > m_DumpCellsFileName
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< std::vector< std::string > > m_problemsToMask
Gaudi::Property< bool > m_doCellsDump
Gaudi::Property< std::vector< int > > m_Nslots
virtual StatusCode finalize() override final
diff_t compareChannel(const LArRawChannel &rcDig, const LArRawChannel &rcBS) const
SG::ReadHandleKey< LArRawChannelContainer > m_channelKey_fromBytestream
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
LArBadChannelMask m_bcMask
Gaudi::Property< std::string > m_EnergyFileName
SG::ReadCondHandleKey< ILArShape > m_keyShape
Gaudi::Property< unsigned > m_max_dump
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
static constexpr auto m_PARTNAMES
const float m_BC
std::atomic< unsigned > m_ndump
Gaudi::Property< bool > m_doCheckSum
Gaudi::Property< bool > m_doDspTestDump
Gaudi::Property< std::string > m_MonGroupName
Gaudi::Property< std::vector< std::string > > m_partitions
Gaudi::Property< short > m_adc_th
std::map< std::string, int > m_histoGroups
SG::ReadHandleKey< LArDigitContainer > m_digitContainerKey
void detailedOutput(const LArRODMonAlg::diff_t &, const LArDigit &dig, const EventContext &ctx) const
SG::ReadHandleKey< LArRawChannelContainer > m_channelKey_fromDigits
SG::ReadCondHandleKey< ILArHVScaleCorr > m_keyHVScaleCorr
Liquid Argon ROD output object base class.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
void initialize()