26#include "GaudiKernel/ConcurrencyFlags.h"
64 if (Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
66 ATH_MSG_ERROR(
"Property 'DoDspTestDump' must not be true if nThreads>1");
67 return StatusCode::FAILURE;
70 ATH_MSG_ERROR(
"Property 'DoCellsDump' must not be true if nThreads>1");
71 return StatusCode::FAILURE;
76 auto pairCmp = [](
const std::pair<int,int>& p1,
const std::pair<int,int>& p2) {
return (p1.first<p2.first);};
78 ATH_MSG_ERROR(
"Configuration problem: Energy ranges not in ascending order!");
79 return StatusCode::FAILURE;
83 ATH_MSG_ERROR(
"Configuration problem: Time ranges not in ascending order!");
84 return StatusCode::FAILURE;
88 ATH_MSG_ERROR(
"Configuration problem: Quality ranges not in ascending order!");
89 return StatusCode::FAILURE;
103 m_fdump<<
"febid channel CellID slot FT barrel_ec posneg partition E_off E_on T_off T_on Q_off Q_on event "<<std::endl;
139 bool isEventFlaggedByLArNoisyROAlg =
false;
140 bool isEventFlaggedByLArNoisyROAlgInTimeW =
false;
143 isEventFlaggedByLArNoisyROAlg =
true;
148 isEventFlaggedByLArNoisyROAlgInTimeW =
true;
149 ATH_MSG_DEBUG(
" !!! Noisy event found by LArNoisyROAlg in Time window of 500ms!!!" );
153 if (
m_removeNoiseBursts && (isEventFlaggedByLArNoisyROAlg || isEventFlaggedByLArNoisyROAlgInTimeW))
return StatusCode::SUCCESS;
159 lb = thisEventInfo->lumiBlock();
162 const int streamsize = nStreams + 1;
163 std::vector<int> hasStream(streamsize,0);
166 bool hasstrlist =
false;
167 const std::vector< xAOD::EventInfo::StreamTag >& evtStreamTags=thisEventInfo->streamTags();
168 for (
const auto& evtStreamTag : evtStreamTags) {
169 std::vector<std::string>::const_iterator evtStreamTagIt=std::find(
m_streams.begin(),
m_streams.end(),evtStreamTag.name());
172 ATH_MSG_VERBOSE(
"Keeping Stream Tag: " << evtStreamTag.type() <<
"_" << evtStreamTag.name());
177 if (! hasstrlist) hasStream[nStreams] = 1;
186 std::set<HWIdentifier> ignoreFEBs;
193 for (
const auto* febH : *febCont) {
194 if (((
m_doCheckSum && febH->ChecksumVerification()==
false)) ||
196 ignoreFEBs.insert(febH->FEBId());
199 ATH_MSG_DEBUG(
"Found " << ignoreFEBs.size() <<
" FEBs with checksum errors or statatus errors. Will ignore these FEBs.");
205 std::vector<unsigned> errsPerFEB;
208 const bool ignoreFebs=(ignoreFEBs.size()>0);
209 std::set<HWIdentifier>::const_iterator ignoreFebsEnd=ignoreFEBs.end();
218 LArRawChannelContainer::const_iterator rcDigIt=rawColl_fromDigits->begin();
219 LArRawChannelContainer::const_iterator rcDigIt_e=rawColl_fromDigits->end();
220 LArRawChannelContainer::const_iterator rcBSIt=rawColl_fromBytestream->begin();
221 LArRawChannelContainer::const_iterator rcBSIt_e=rawColl_fromBytestream->end();
230 for (;rcDigIt!=rcDigIt_e;++rcDigIt) {
235 if (ignoreFEBs.find(febId)!=ignoreFebsEnd)
continue;
242 ATH_MSG_WARNING( std::format(
"gain {} is out of range for the ERRCOUNTER array size, {}",
243 static_cast<std::underlying_type_t<CaloGain::CaloGain>
>(gain),
ERRCOUNTER::N));
244 return StatusCode::FAILURE;
248 const float ped = pedestals->
pedestal(idDig,gain);
253 LArRawChannelContainer::const_iterator currIt=rcBSIt;
254 for (;rcBSIt!=rcBSIt_e && rcBSIt->hardwareID() != idDig; ++rcBSIt);
255 if (rcBSIt==rcBSIt_e) {
256 ATH_MSG_WARNING(
"LArDigitContainer not in the expected order. Change of LArByteStream format?" );
258 for (rcBSIt=rawColl_fromBytestream->begin();rcBSIt!=currIt && rcBSIt->hardwareID() != idDig; ++rcBSIt);
259 if (rcBSIt==currIt) {
261 return StatusCode::FAILURE;
269 for (;digIt!=digIt_e && (*digIt)->hardwareID() != idDig; ++digIt);
270 if (digIt==digIt_e) {
271 ATH_MSG_WARNING(
"LArRawChannelContainer not in the expected order. Change of LArRawChannelBuilder behavior?" );
273 for (digIt=pLArDigitContainer->begin();digIt!=currDigIt && (*digIt)->hardwareID() != idDig; ++digIt);
274 if (digIt==currDigIt) {
276 return StatusCode::FAILURE;
280 const std::vector<short>& samples=dig->
samples();
281 const auto [minSamplesIt, maxSamplesIt] = std::minmax_element(samples.begin(),samples.end());
284 if (compRes.e_on!=compRes.e_off || compRes.t_on!=compRes.t_off || compRes.q_on!=compRes.q_off) {
295 if (compRes.e_on!=compRes.e_off) {
296 ++(errcounters[p].errors_E[gain]);
297 ++(allEC.errors_E[gain]);
300 ++(errsPerFEB[febHash]);
302 if (compRes.t_on!=compRes.t_off) {
303 ++(errcounters[p].errors_T[gain]);
304 ++(allEC.errors_T[gain]);
307 if (compRes.q_on!=compRes.q_off) {
308 ++(errcounters[p].errors_Q[gain]);
309 ++(allEC.errors_Q[gain]);
314 ATH_MSG_DEBUG(
"Samples : "<< *maxSamplesIt <<
" " << *minSamplesIt );
323 sweetc = errsPerFEB[i];
342 unsigned allErrsPartE=0;
343 unsigned allErrsPartT=0;
344 unsigned allErrsPartQ=0;
346 for (
unsigned g=0;g<3;++g) {
348 weight_e = (float)errcounters[p].errors_E[g];
349 weight_q = (float)errcounters[p].errors_Q[g];
350 weight_t = (float)errcounters[p].errors_T[g];
353 allErrsPartE+=errcounters[p].errors_E[g];
354 allErrsPartT+=errcounters[p].errors_T[g];
355 allErrsPartQ+=errcounters[p].errors_Q[g];
358 numE = (float)allErrsPartE;
359 numT = (float)allErrsPartT;
360 numQ = (float)allErrsPartQ;
376 return StatusCode::SUCCESS;
389 const float& en_fB=rcBS.
energy();
390 const float& en_fD=rcDig.
energy();
403 auto pairValueCmp = [](
const int&
a,
const std::pair<int,int>& b){
return a<b.first;};
416 if (std::abs(en_fD-en_fB) > e_Precision->second) {
424 const float q_fB=rcBS.
quality();
425 const float q_fD=rcDig.
quality();
426 const float t_fB=rcBS.
time();
428 if ((rcDig.
provenance() & 0x2000) == 0 || q_fD==0 || t_fB==0 || q_fB==0 || timeOffline==0) {
434 ATH_MSG_VERBOSE(
"Skip time/Quality comparison, not computed either online or offline");
446 if (fabs(DiffT) > t_Precision->second) {
450 result.t_off=timeOffline;
455 float qdiff = 65535.0;
456 if (q_fD > 0.) qdiff = (q_fD - q_fB)/std::sqrt(q_fD);
467 if (fabs(DiffQ) > q_Precision->second) {
478 const EventContext& ctx)
const{
482 const auto gain=dig.
gain();
505 const auto& polynom_adc2mev=adc2mev->
ADC2MEV(chid,gain);
506 const float escale = (polynom_adc2mev)[1];
507 float ramp0 = (polynom_adc2mev)[0];
511 const float hvscale = hvScaleCorrs->
HVScaleCorr(chid);
514 const std::vector<short>& samples=dig.
samples();
515 if (gain == 0) ramp0 = 0.;
522 <<
", run " << ctx.eventID().run_number() <<
", evt " << ctx.eventID().event_number());
523 if (cmp.e_on!=cmp.e_off) {
526 <<
" , Eoff - Eonl = " << cmp.e_off-cmp.e_on);
531 if(cmp.t_off!=cmp.t_on ) {
534 <<
" , Toff - Tonl = " << cmp.t_off - cmp.t_on);
536 if (cmp.q_off!=cmp.q_on) {
539 <<
" (Qoff - Qnl)/sqrt(Qoff) = " << (cmp.q_off - cmp.q_on)/std::sqrt(cmp.q_off));
545 for (
const short s : samples) {output+=std::to_string(s)+
" ";}
549 for (
const auto o : OFCa) {output+=std::to_string(o)+
" ";}
553 for (
const auto o : OFCb) {output+=std::to_string(o)+
" ";}
557 for (
const auto s : shape) {output+=std::to_string(s)+
" ";}
560 output=
"ShapeDer : ";
561 for (
const auto s : shapeDer) {output+=std::to_string(s)+
" ";}
564 ATH_MSG_INFO(
"Escale: "<<escale<<
" intercept: "<<ramp0<<
" pedestal: "<<ped<<
" gain: "<<dig.
gain() );
565 const Identifier cellid=cabling->cnvToIdentifier(chid);
566 const float noise=noisep->
getNoise(cellid,gain);
570 const unsigned nOFCSamp=std::min(samples.size(),OFCa.size());
571 for (
unsigned k=0; k<nOFCSamp; ++k) emon += (samples.at(k)-ped)*OFCa.at(k);
574 ATH_MSG_INFO(
"intercept + Escale*Sum[(sample-ped)*OFCa] "<<emon);
579 for (
const float a : OFCa) {sumai +=
a;}
580 float pedplusoffset=0;
581 if (escale*sumai != 0) pedplusoffset = ped - ramp0/(escale*sumai);
582 else pedplusoffset = 0;
583 const float inv_Escale = 1. / escale;
585 m_fai << channel<<
"\t"<< ped<<
"\t"<< pedplusoffset<<
"\t"
586 << OFCa[0]*escale<<
"\t"<< OFCa[1]*escale<<
"\t"<< OFCa[2]*escale<<
"\t"<< OFCa[3]*escale<<
"\t"<< OFCa[4]*escale<<
"\t"
587 << OFCb[0]*escale<<
"\t"<< OFCb[1]*escale<<
"\t"<< OFCb[2]*escale<<
"\t"<< OFCb[3]*escale<<
"\t"<< OFCb[4]*escale<<
"\t"
588 << shape[0]*inv_Escale<<
"\t"<< shape[1]*inv_Escale<<
"\t"<< shape[2]*inv_Escale<<
"\t"<< shape[3]*inv_Escale<<
"\t"<< shape[4]*inv_Escale<<
"\t"
589 << shapeDer[0]*inv_Escale<<
"\t"<< shapeDer[1]*inv_Escale<<
"\t"<< shapeDer[2]*inv_Escale<<
"\t"<< shape[3]*inv_Escale<<
"\t"<< shapeDer[4]*inv_Escale << std::endl;
592 m_fen <<
m_ndump <<
" " << cmp.e_off <<
" " << cmp.e_on ;
593 m_fen <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
596 m_fdig << channel <<
" ";
597 for (
const short d : samples) {
600 m_fdig <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
607 const EventContext& ctx,
608 const diff_t & cmp)
const {
619 <<std::dec << std::setw(3) << std::right << slot << std::setw(3) << std::right << FT << std::setw(3) << std::right << barrel_ec << std::setw(3) << std::right<< posneg << std::setw(6) << std::right <<
getPartitionName(chid)
620 <<
" " << gain <<
" " <<
" " << cmp.e_off <<
" "<< cmp.e_on <<
" "<<cmp.t_off <<
" "<<cmp.t_on <<
" "<<cmp.q_off <<
" "<<cmp.q_on <<ctx.eventID().event_number()<<std::endl;
636 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.).
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
DataModel_detail::const_iterator< DataVector > const_iterator
virtual const float & HVScaleCorr(const HWIdentifier &id) const =0
virtual OFCRef_t OFC_b(const HWIdentifier &id, int gain, int tbin=0) const =0
virtual OFCRef_t OFC_a(const HWIdentifier &id, int gain, int tbin=0) const =0
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
LArVectorProxy OFCRef_t
This class defines the interface for accessing Optimal Filtering coefficients for each channel provid...
virtual float pedestal(const HWIdentifier &id, int gain) const =0
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
Liquid Argon digit base class.
CaloGain::CaloGain gain() const
const std::vector< short > & samples() const
const HWIdentifier & channelID() const
std::array< unsigned, N > errors_E
std::array< unsigned, N > errors_T
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
const char * getPartitionName(const HWIdentifier chid) const
virtual StatusCode initialize() override final
initialize
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
virtual ~LArRODMonAlg()
Default destructor.
Gaudi::Property< float > m_peakTime_cut
PARTITION getPartition(const HWIdentifier chid) const
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
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
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.
uint16_t provenance() const
HWIdentifier channelID() const
Declare a monitored scalar variable.
@ LAr
The LAr calorimeter.
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case).
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void fill(H5::Group &out_file, size_t iterations)