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 static constexpr int N = 3;
63 std::array<unsigned,N> errors_E{},errors_T{},errors_Q{};
64 };
65
66
67
68 PARTITION getPartition(const HWIdentifier chid) const;
69 const char* getPartitionName(const HWIdentifier chid) const;
70
71 struct diff_t {
72 float e_on=0;
73 float e_off=0;
74 float t_on=0;
75 float t_off=0;
76 float q_on=0;
77 float q_off=0;
78 };
79
80 diff_t compareChannel(const LArRawChannel& rcDig,
81 const LArRawChannel& rcBS) const;
82
83
85 const LArDigit& dig,
86 const EventContext& ctx) const;
87
88
90 void dumpCellInfo(const HWIdentifier chid, // Channel HW ID
91 const int gain,
92 const EventContext& ctx,
93 const diff_t & comp)const;
94
95
96
97
98 SG::ReadHandleKey<LArRawChannelContainer> m_channelKey_fromBytestream{this,"LArRawChannelKey_fromBytestream","LArRawChannels","SG key of LArRawChannels produced by teh DSP"};
99 SG::ReadHandleKey<LArRawChannelContainer> m_channelKey_fromDigits{this,"LArRawChannelKey_fromDigits","LArRawChannels_FromDigits","SG key of LArRawChannels produced offline"};
100
101 SG::ReadHandleKey<LArDigitContainer> m_digitContainerKey{this,"LArDigitContainerKey","FREE","SG key of LArDigitContainer read from Bytestream"};
102 SG::ReadHandleKey<LArFebHeaderContainer> m_headerContainerKey{this,"LArFebHeaderKey","LArFebHeader","SG key of LArFebHeader"};
103
104
105 SG::ReadCondHandleKey<ILArOFC> m_keyOFC{this,"KeyOFC","LArOFC","SG key of LArOFC CDO"};
106 SG::ReadCondHandleKey<ILArShape> m_keyShape{this,"KeyShape","LArShape","SG key of LArShape CDO"};
107 SG::ReadCondHandleKey<ILArHVScaleCorr> m_keyHVScaleCorr{this,"KeyHVScaleCorr","LArHVScaleCorr","SG key of LArHVScaleCorr CDO"};
108 SG::ReadCondHandleKey<ILArPedestal> m_keyPedestal{this,"LArPedestalKey","LArPedestal","SG key of LArPedestal CDO"};
109
110 SG::ReadCondHandleKey<LArADC2MeV> m_adc2mevKey{this,"LArADC2MeVKey","LArADC2MeV","SG Key of the LArADC2MeV CDO"};
111
113 SG::ReadCondHandleKey<LArBadChannelCont> m_bcContKey {this, "BadChanKey", "LArBadChannel", "SG key for LArBadChan object"};
114 Gaudi::Property<std::vector<std::string> > m_problemsToMask{this,"ProblemsToMask",{}, "Bad-Channel categories to mask"};
115
116
117 SG::ReadCondHandleKey<CaloNoise> m_noiseCDOKey{this,"CaloNoiseKey","totalNoise","SG Key of CaloNoise data object"};
118 SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping CDO"};
119
120 //To get the data-dependency right ...
121 SG::ReadDecorHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "LArStatusFlag", "EventInfo.larFlags", "Key for EventInfo object"};
122
123 //declaration variables used in joboptions
124 Gaudi::Property<std::string> m_MonGroupName {this, "MonGroup", "RODMon"};
125 Gaudi::Property<std::vector<std::string> > m_SubDetNames {this, "LArRODSubDetNames", {} };
126 Gaudi::Property<std::vector<std::string> > m_partitions {this, "LArRODPartitionNames", {} };
127 Gaudi::Property<std::vector<int> > m_Nslots {this, "LArRODNslots", {} };
128
129 // Output files names
130 Gaudi::Property<std::string> m_DigitsFileName{this, "DigitsFileName","digits.txt","Digits dump output filename"};
131 Gaudi::Property<std::string> m_EnergyFileName{this,"EnergyFileName","energy.txt"," Energies dump output filename"};
132 Gaudi::Property<std::string> m_AiFileName{this,"AiFileName","Calib_ai.dat","dump output filename"};
133 Gaudi::Property<std::string> m_DumpCellsFileName{this,"DumpCellsFileName","dumpCells.txt","Cells dump output filename"};
134
135 Gaudi::Property<bool> m_doDspTestDump{this, "DoDspTestDump", false, "dsp dump switch"};
136 Gaudi::Property<bool> m_doCellsDump{this, "DoCellsDump", false, "cell dump switch"};
137 Gaudi::Property<bool> m_doCheckSum{this, "DoCheckSum", true, "checksum test switch"};
138 Gaudi::Property<bool> m_doRodStatus{this, "DoRodStatus", true, "ROD status test switch"};
139 Gaudi::Property<bool> m_printEnergyErrors{this, "PrintEnergyErrors", true, "energy errors printing"};
140 Gaudi::Property<bool> m_removeNoiseBursts{this, "RemoveNoiseBursts", true, "removing events with noise bursts"};
141
142
143 Gaudi::Property<bool> m_skipKnownProblematicChannels{this, "SkipKnownProblematicChannels", false, "skipping known problems?"};
144 Gaudi::Property<bool> m_skipNullPed{this, "SkipNullPed", false, "skipping no pedestal channels ?"};
145 Gaudi::Property<bool> m_skipNullQT{this, "SkipNullQT", false, "skipping no quality channe4ls ?"};
146
147 Gaudi::Property<float> m_timeOffset{this, "TimeOffset", 0.};
148 Gaudi::Property<short> m_adc_th{this, "ADCthreshold", 50, "Minimal number of ADC amplitude among samples required to compare online/offline"};
149 Gaudi::Property<float> m_peakTime_cut{this, "peakTimeCut", 5., "Cut on abs(peak time) to compare online/offline (all quantities)"};
150
151
152 // Expected precision for energy calculation, depending on energy (ranges) :
153 // Adding 1 MeV on request of Alexis (truncating difference) (May 2016)
154 // Between -213 and 213 MeV (~ 8 GeV) 2**0=1 MeV precision (range 0)
155 // Between -216 and 216 MeV (~ 64 GeV) 2**3=8 MeV precision (range 1)
156 // Between -219 and 219 MeV (~ 512 GeV) 2**6=64 MeV precision (range 2)
157 // Between -222 and 222 MeV (~ 4 TeV) 2**9=512 MeV precision (range 3)
158
159 Gaudi::Property<std::vector<std::pair<int, int>>> m_E_precision{this,"EnergyPrecisionRanges",
160 {{8192,2},{65536,9},{524288,65},{4194304,513},{std::numeric_limits<int>::max(),8193}},
161 "Energy precision ranges vector<pair<upperLimit,ExpectedPrecision>"};
162 Gaudi::Property<std::vector<std::pair<int, int>>> m_T_precision{this,"TimePrecisionRanges",
163 {{1000,340},{5000,340},{25000,340},{50000,340},{std::numeric_limits<int>::max(),340}},
164 "Time precision ranges as vector<pair<upperLImit,ExpectedPrecision"};
165 Gaudi::Property<std::vector<std::pair<int, int>>> m_Q_precision{this,"QualityPrecisionRanges",
166 {{std::numeric_limits<int>::max(),3}},
167 "Quality precision ranges as vector<pair<upperLImit,ExpectedPrecision"};
168 const float m_BC=25000; // value of 1 bunch-crossing = 25ns
169
170 /* Histogram grouping (part) */
171 std::map<std::string,int> m_histoGroups;
172
173 Gaudi::Property<std::vector<std::string> > m_streams{this, "Streams", {} };
174
175 Gaudi::Property<unsigned> m_max_dump{this, "MaxEvDump", 0, "max number of channels for detailed log-output"};
176 mutable std::atomic<unsigned> m_ndump{0};
177
178
179 //Streams for dump-files. Explicitly disabled in an MT-environment
180 mutable std::ofstream m_fai ATLAS_THREAD_SAFE;
181 mutable std::ofstream m_fdig ATLAS_THREAD_SAFE;
182 mutable std::ofstream m_fen ATLAS_THREAD_SAFE;
183 mutable std::ofstream m_fdump ATLAS_THREAD_SAFE;
184
185};
186
187
188inline
190 const int side=m_LArOnlineIDHelper->pos_neg(chid);
191 if (m_LArOnlineIDHelper->isEMBchannel(chid)) {
192 if (side==0)
193 return EMBC;
194 else
195 return EMBA;
196 }
197 if (m_LArOnlineIDHelper->isEMECchannel(chid)) {
198 if (side==0)
199 return EMECC;
200 else
201 return EMECA;
202 }
203 if (m_LArOnlineIDHelper->isHECchannel(chid)){
204 if (side==0)
205 return HECC;
206 else
207 return HECA;
208 }
209 if (m_LArOnlineIDHelper->isFCALchannel(chid)) {
210 if (side==0)
211 return FCALC;
212 else
213 return FCALA;
214 }
215
216 ATH_MSG_FATAL(std::format("Channel {:#x} neither EMB nor EMEC nor HEC nor FCAL???",chid.get_identifier32().get_compact()));
217 return N_PARTITIONS;
218}
219
220inline
221const char* LArRODMonAlg::getPartitionName(const HWIdentifier chid) const{
222 return m_PARTNAMES[getPartition(chid)];
223}
224
225#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, N > errors_E
std::array< unsigned, N > errors_T
static constexpr int N
std::array< unsigned, N > errors_Q
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()