26#include "GaudiKernel/ConcurrencyFlags.h"
63 if (Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
65 ATH_MSG_ERROR(
"Property 'DoDspTestDump' must not be true if nThreads>1");
66 return StatusCode::FAILURE;
69 ATH_MSG_ERROR(
"Property 'DoCellsDump' must not be true if nThreads>1");
70 return StatusCode::FAILURE;
75 auto pairCmp = [](
const std::pair<int,int>& p1,
const std::pair<int,int>& p2) {
return (p1.first<p2.first);};
77 ATH_MSG_ERROR(
"Configuration problem: Energy ranges not in ascending order!");
78 return StatusCode::FAILURE;
82 ATH_MSG_ERROR(
"Configuration problem: Time ranges not in ascending order!");
83 return StatusCode::FAILURE;
87 ATH_MSG_ERROR(
"Configuration problem: Quality ranges not in ascending order!");
88 return StatusCode::FAILURE;
102 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;
138 bool isEventFlaggedByLArNoisyROAlg =
false;
139 bool isEventFlaggedByLArNoisyROAlgInTimeW =
false;
142 isEventFlaggedByLArNoisyROAlg =
true;
147 isEventFlaggedByLArNoisyROAlgInTimeW =
true;
148 ATH_MSG_DEBUG(
" !!! Noisy event found by LArNoisyROAlg in Time window of 500ms!!!" );
152 if (
m_removeNoiseBursts && (isEventFlaggedByLArNoisyROAlg || isEventFlaggedByLArNoisyROAlgInTimeW))
return StatusCode::SUCCESS;
158 lb = thisEventInfo->lumiBlock();
161 const int streamsize = nStreams + 1;
162 std::vector<int> hasStream(streamsize,0);
165 bool hasstrlist =
false;
166 const std::vector< xAOD::EventInfo::StreamTag >& evtStreamTags=thisEventInfo->streamTags();
167 for (
const auto& evtStreamTag : evtStreamTags) {
168 std::vector<std::string>::const_iterator evtStreamTagIt=std::find(
m_streams.begin(),
m_streams.end(),evtStreamTag.name());
171 ATH_MSG_VERBOSE(
"Keeping Stream Tag: " << evtStreamTag.type() <<
"_" << evtStreamTag.name());
176 if (! hasstrlist) hasStream[nStreams] = 1;
185 std::set<HWIdentifier> ignoreFEBs;
192 for (
const auto* febH : *febCont) {
193 if (((
m_doCheckSum && febH->ChecksumVerification()==
false)) ||
195 ignoreFEBs.insert(febH->FEBId());
198 ATH_MSG_DEBUG(
"Found " << ignoreFEBs.size() <<
" FEBs with checksum errors or statatus errors. Will ignore these FEBs.");
204 std::vector<unsigned> errsPerFEB;
207 const bool ignoreFebs=(ignoreFEBs.size()>0);
208 std::set<HWIdentifier>::const_iterator ignoreFebsEnd=ignoreFEBs.end();
217 LArRawChannelContainer::const_iterator rcDigIt=rawColl_fromDigits->begin();
218 LArRawChannelContainer::const_iterator rcDigIt_e=rawColl_fromDigits->end();
219 LArRawChannelContainer::const_iterator rcBSIt=rawColl_fromBytestream->begin();
220 LArRawChannelContainer::const_iterator rcBSIt_e=rawColl_fromBytestream->end();
229 for (;rcDigIt!=rcDigIt_e;++rcDigIt) {
234 if (ignoreFEBs.find(febId)!=ignoreFebsEnd)
continue;
241 ATH_MSG_WARNING(
"gain {} is out of range for the ERRCOUNTER array size, {}",
242 static_cast<std::underlying_type_t<CaloGain::CaloGain>
>(gain),
ERRCOUNTER::N);
243 return StatusCode::FAILURE;
247 const float ped = pedestals->
pedestal(idDig,gain);
252 LArRawChannelContainer::const_iterator currIt=rcBSIt;
253 for (;rcBSIt!=rcBSIt_e && rcBSIt->hardwareID() != idDig; ++rcBSIt);
254 if (rcBSIt==rcBSIt_e) {
255 ATH_MSG_WARNING(
"LArDigitContainer not in the expected order. Change of LArByteStream format?" );
257 for (rcBSIt=rawColl_fromBytestream->begin();rcBSIt!=currIt && rcBSIt->hardwareID() != idDig; ++rcBSIt);
258 if (rcBSIt==currIt) {
260 return StatusCode::FAILURE;
268 for (;digIt!=digIt_e && (*digIt)->hardwareID() != idDig; ++digIt);
269 if (digIt==digIt_e) {
270 ATH_MSG_WARNING(
"LArRawChannelContainer not in the expected order. Change of LArRawChannelBuilder behavior?" );
272 for (digIt=pLArDigitContainer->begin();digIt!=currDigIt && (*digIt)->hardwareID() != idDig; ++digIt);
273 if (digIt==currDigIt) {
275 return StatusCode::FAILURE;
279 const std::vector<short>& samples=dig->
samples();
280 const auto [minSamplesIt, maxSamplesIt] = std::minmax_element(samples.begin(),samples.end());
283 if (compRes.e_on!=compRes.e_off || compRes.t_on!=compRes.t_off || compRes.q_on!=compRes.q_off) {
294 if (compRes.e_on!=compRes.e_off) {
295 ++(errcounters[p].errors_E[gain]);
296 ++(allEC.errors_E[gain]);
299 ++(errsPerFEB[febHash]);
301 if (compRes.t_on!=compRes.t_off) {
302 ++(errcounters[p].errors_T[gain]);
303 ++(allEC.errors_T[gain]);
306 if (compRes.q_on!=compRes.q_off) {
307 ++(errcounters[p].errors_Q[gain]);
308 ++(allEC.errors_Q[gain]);
313 ATH_MSG_DEBUG(
"Samples : "<< *maxSamplesIt <<
" " << *minSamplesIt );
322 sweetc = errsPerFEB[i];
341 unsigned allErrsPartE=0;
342 unsigned allErrsPartT=0;
343 unsigned allErrsPartQ=0;
345 for (
unsigned g=0;g<3;++g) {
347 weight_e = (float)errcounters[p].errors_E[g];
348 weight_q = (float)errcounters[p].errors_Q[g];
349 weight_t = (float)errcounters[p].errors_T[g];
352 allErrsPartE+=errcounters[p].errors_E[g];
353 allErrsPartT+=errcounters[p].errors_T[g];
354 allErrsPartQ+=errcounters[p].errors_Q[g];
357 numE = (float)allErrsPartE;
358 numT = (float)allErrsPartT;
359 numQ = (float)allErrsPartQ;
375 return StatusCode::SUCCESS;
388 const float& en_fB=rcBS.
energy();
389 const float& en_fD=rcDig.
energy();
402 auto pairValueCmp = [](
const int&
a,
const std::pair<int,int>& b){
return a<b.first;};
415 if (std::abs(en_fD-en_fB) > e_Precision->second) {
423 const float q_fB=rcBS.
quality();
424 const float q_fD=rcDig.
quality();
425 const float t_fB=rcBS.
time();
427 if ((rcDig.
provenance() & 0x2000) == 0 || q_fD==0 || t_fB==0 || q_fB==0 || timeOffline==0) {
433 ATH_MSG_VERBOSE(
"Skip time/Quality comparison, not computed either online or offline");
445 if (fabs(DiffT) > t_Precision->second) {
449 result.t_off=timeOffline;
454 float qdiff = 65535.0;
455 if (q_fD > 0.) qdiff = (q_fD - q_fB)/std::sqrt(q_fD);
466 if (fabs(DiffQ) > q_Precision->second) {
477 const EventContext& ctx)
const{
481 const auto gain=dig.
gain();
504 const auto& polynom_adc2mev=adc2mev->
ADC2MEV(chid,gain);
505 const float escale = (polynom_adc2mev)[1];
506 float ramp0 = (polynom_adc2mev)[0];
510 const float hvscale = hvScaleCorrs->
HVScaleCorr(chid);
513 const std::vector<short>& samples=dig.
samples();
514 if (gain == 0) ramp0 = 0.;
521 <<
", run " << ctx.eventID().run_number() <<
", evt " << ctx.eventID().event_number());
522 if (cmp.e_on!=cmp.e_off) {
525 <<
" , Eoff - Eonl = " << cmp.e_off-cmp.e_on);
530 if(cmp.t_off!=cmp.t_on ) {
533 <<
" , Toff - Tonl = " << cmp.t_off - cmp.t_on);
535 if (cmp.q_off!=cmp.q_on) {
538 <<
" (Qoff - Qnl)/sqrt(Qoff) = " << (cmp.q_off - cmp.q_on)/std::sqrt(cmp.q_off));
544 for (
const short s : samples) {output+=std::to_string(s)+
" ";}
548 for (
const auto o : OFCa) {output+=std::to_string(o)+
" ";}
552 for (
const auto o : OFCb) {output+=std::to_string(o)+
" ";}
556 for (
const auto s : shape) {output+=std::to_string(s)+
" ";}
559 output=
"ShapeDer : ";
560 for (
const auto s : shapeDer) {output+=std::to_string(s)+
" ";}
563 ATH_MSG_INFO(
"Escale: "<<escale<<
" intercept: "<<ramp0<<
" pedestal: "<<ped<<
" gain: "<<dig.
gain() );
564 const Identifier cellid=cabling->cnvToIdentifier(chid);
565 const float noise=noisep->
getNoise(cellid,gain);
569 const unsigned nOFCSamp=std::min(samples.size(),OFCa.size());
570 for (
unsigned k=0; k<nOFCSamp; ++k) emon += (samples.at(k)-ped)*OFCa.at(k);
573 ATH_MSG_INFO(
"intercept + Escale*Sum[(sample-ped)*OFCa] "<<emon);
578 for (
const float a : OFCa) {sumai +=
a;}
579 float pedplusoffset=0;
580 if (escale*sumai != 0) pedplusoffset = ped - ramp0/(escale*sumai);
581 else pedplusoffset = 0;
582 const float inv_Escale = 1. / escale;
584 m_fai << channel<<
"\t"<< ped<<
"\t"<< pedplusoffset<<
"\t"
585 << OFCa[0]*escale<<
"\t"<< OFCa[1]*escale<<
"\t"<< OFCa[2]*escale<<
"\t"<< OFCa[3]*escale<<
"\t"<< OFCa[4]*escale<<
"\t"
586 << OFCb[0]*escale<<
"\t"<< OFCb[1]*escale<<
"\t"<< OFCb[2]*escale<<
"\t"<< OFCb[3]*escale<<
"\t"<< OFCb[4]*escale<<
"\t"
587 << 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"
588 << 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;
591 m_fen <<
m_ndump <<
" " << cmp.e_off <<
" " << cmp.e_on ;
592 m_fen <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
595 m_fdig << channel <<
" ";
596 for (
const short d : samples) {
599 m_fdig <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
606 const EventContext& ctx,
607 const diff_t & cmp)
const {
618 <<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)
619 <<
" " << 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;
635 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(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)