26#include "GaudiKernel/ConcurrencyFlags.h"
62 if (Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
64 ATH_MSG_ERROR(
"Property 'DoDspTestDump' must not be true if nThreads>1");
65 return StatusCode::FAILURE;
68 ATH_MSG_ERROR(
"Property 'DoCellsDump' must not be true if nThreads>1");
69 return StatusCode::FAILURE;
74 auto pairCmp = [](
const std::pair<int,int>& p1,
const std::pair<int,int>& p2) {
return (p1.first<p2.first);};
76 ATH_MSG_ERROR(
"Configuration problem: Energy ranges not in ascending order!");
77 return StatusCode::FAILURE;
81 ATH_MSG_ERROR(
"Configuration problem: Time ranges not in ascending order!");
82 return StatusCode::FAILURE;
86 ATH_MSG_ERROR(
"Configuration problem: Quality ranges not in ascending order!");
87 return StatusCode::FAILURE;
101 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;
137 bool isEventFlaggedByLArNoisyROAlg =
false;
138 bool isEventFlaggedByLArNoisyROAlgInTimeW =
false;
141 isEventFlaggedByLArNoisyROAlg =
true;
146 isEventFlaggedByLArNoisyROAlgInTimeW =
true;
147 ATH_MSG_DEBUG(
" !!! Noisy event found by LArNoisyROAlg in Time window of 500ms!!!" );
151 if (
m_removeNoiseBursts && (isEventFlaggedByLArNoisyROAlg || isEventFlaggedByLArNoisyROAlgInTimeW))
return StatusCode::SUCCESS;
157 lb = thisEventInfo->lumiBlock();
160 const int streamsize = nStreams + 1;
161 std::vector<int> hasStream(streamsize,0);
164 bool hasstrlist =
false;
165 const std::vector< xAOD::EventInfo::StreamTag >& evtStreamTags=thisEventInfo->streamTags();
166 for (
const auto& evtStreamTag : evtStreamTags) {
167 std::vector<std::string>::const_iterator evtStreamTagIt=std::find(
m_streams.begin(),
m_streams.end(),evtStreamTag.name());
170 ATH_MSG_VERBOSE(
"Keeping Stream Tag: " << evtStreamTag.type() <<
"_" << evtStreamTag.name());
175 if (! hasstrlist) hasStream[nStreams] = 1;
184 std::set<HWIdentifier> ignoreFEBs;
191 for (
const auto* febH : *febCont) {
192 if (((
m_doCheckSum && febH->ChecksumVerification()==
false)) ||
194 ignoreFEBs.insert(febH->FEBId());
197 ATH_MSG_DEBUG(
"Found " << ignoreFEBs.size() <<
" FEBs with checksum errors or statatus errors. Will ignore these FEBs.");
203 std::vector<unsigned> errsPerFEB;
206 const bool ignoreFebs=(ignoreFEBs.size()>0);
207 std::set<HWIdentifier>::const_iterator ignoreFebsEnd=ignoreFEBs.end();
216 LArRawChannelContainer::const_iterator rcDigIt=rawColl_fromDigits->begin();
217 LArRawChannelContainer::const_iterator rcDigIt_e=rawColl_fromDigits->end();
218 LArRawChannelContainer::const_iterator rcBSIt=rawColl_fromBytestream->begin();
219 LArRawChannelContainer::const_iterator rcBSIt_e=rawColl_fromBytestream->end();
228 for (;rcDigIt!=rcDigIt_e;++rcDigIt) {
233 if (ignoreFEBs.find(febId)!=ignoreFebsEnd)
continue;
241 const float ped = pedestals->
pedestal(idDig,gain);
246 LArRawChannelContainer::const_iterator currIt=rcBSIt;
247 for (;rcBSIt!=rcBSIt_e && rcBSIt->hardwareID() != idDig; ++rcBSIt);
248 if (rcBSIt==rcBSIt_e) {
249 ATH_MSG_WARNING(
"LArDigitContainer not in the expected order. Change of LArByteStream format?" );
251 for (rcBSIt=rawColl_fromBytestream->begin();rcBSIt!=currIt && rcBSIt->hardwareID() != idDig; ++rcBSIt);
252 if (rcBSIt==currIt) {
254 return StatusCode::FAILURE;
262 for (;digIt!=digIt_e && (*digIt)->hardwareID() != idDig; ++digIt);
263 if (digIt==digIt_e) {
264 ATH_MSG_WARNING(
"LArRawChannelContainer not in the expected order. Change of LArRawChannelBuilder behavior?" );
266 for (digIt=pLArDigitContainer->begin();digIt!=currDigIt && (*digIt)->hardwareID() != idDig; ++digIt);
267 if (digIt==currDigIt) {
269 return StatusCode::FAILURE;
273 const std::vector<short>& samples=dig->
samples();
274 const auto [minSamplesIt, maxSamplesIt] = std::minmax_element(samples.begin(),samples.end());
277 if (compRes.e_on!=compRes.e_off || compRes.t_on!=compRes.t_off || compRes.q_on!=compRes.q_off) {
288 if (compRes.e_on!=compRes.e_off) {
289 ++(errcounters[p].errors_E[gain]);
290 ++(allEC.errors_E[gain]);
293 ++(errsPerFEB[febHash]);
295 if (compRes.t_on!=compRes.t_off) {
296 ++(errcounters[p].errors_T[gain]);
297 ++(allEC.errors_T[gain]);
300 if (compRes.q_on!=compRes.q_off) {
301 ++(errcounters[p].errors_Q[gain]);
302 ++(allEC.errors_Q[gain]);
307 ATH_MSG_DEBUG(
"Samples : "<< *maxSamplesIt <<
" " << *minSamplesIt );
316 sweetc = errsPerFEB[i];
335 unsigned allErrsPartE=0;
336 unsigned allErrsPartT=0;
337 unsigned allErrsPartQ=0;
339 for (
unsigned g=0;g<3;++g) {
341 weight_e = (float)errcounters[p].errors_E[g];
342 weight_q = (float)errcounters[p].errors_Q[g];
343 weight_t = (float)errcounters[p].errors_T[g];
346 allErrsPartE+=errcounters[p].errors_E[g];
347 allErrsPartT+=errcounters[p].errors_T[g];
348 allErrsPartQ+=errcounters[p].errors_Q[g];
351 numE = (float)allErrsPartE;
352 numT = (float)allErrsPartT;
353 numQ = (float)allErrsPartQ;
369 return StatusCode::SUCCESS;
382 const float& en_fB=rcBS.
energy();
383 const float& en_fD=rcDig.
energy();
396 auto pairValueCmp = [](
const int&
a,
const std::pair<int,int>& b){
return a<b.first;};
409 if (std::abs(en_fD-en_fB) > e_Precision->second) {
417 const float q_fB=rcBS.
quality();
418 const float q_fD=rcDig.
quality();
419 const float t_fB=rcBS.
time();
421 if ((rcDig.
provenance() & 0x2000) == 0 || q_fD==0 || t_fB==0 || q_fB==0 || timeOffline==0) {
427 ATH_MSG_VERBOSE(
"Skip time/Quality comparison, not computed either online or offline");
439 if (fabs(DiffT) > t_Precision->second) {
448 float qdiff = 65535.0;
449 if (q_fD > 0.) qdiff = (q_fD - q_fB)/std::sqrt(q_fD);
460 if (fabs(DiffQ) > q_Precision->second) {
471 const EventContext& ctx)
const{
475 const auto gain=dig.
gain();
498 const auto& polynom_adc2mev=adc2mev->
ADC2MEV(chid,gain);
499 const float escale = (polynom_adc2mev)[1];
500 float ramp0 = (polynom_adc2mev)[0];
504 const float hvscale = hvScaleCorrs->
HVScaleCorr(chid);
507 const std::vector<short>& samples=dig.
samples();
508 if (gain == 0) ramp0 = 0.;
515 <<
", run " << ctx.eventID().run_number() <<
", evt " << ctx.eventID().event_number());
516 if (cmp.e_on!=cmp.e_off) {
519 <<
" , Eoff - Eonl = " << cmp.e_off-cmp.e_on);
524 if(cmp.t_off!=cmp.t_on ) {
527 <<
" , Toff - Tonl = " << cmp.t_off - cmp.t_on);
529 if (cmp.q_off!=cmp.q_on) {
532 <<
" (Qoff - Qnl)/sqrt(Qoff) = " << (cmp.q_off - cmp.q_on)/std::sqrt(cmp.q_off));
538 for (
const short s : samples) {output+=std::to_string(s)+
" ";}
542 for (
const auto o : OFCa) {output+=std::to_string(o)+
" ";}
546 for (
const auto o : OFCb) {output+=std::to_string(o)+
" ";}
550 for (
const auto s : shape) {output+=std::to_string(s)+
" ";}
553 output=
"ShapeDer : ";
554 for (
const auto s : shapeDer) {output+=std::to_string(s)+
" ";}
557 ATH_MSG_INFO(
"Escale: "<<escale<<
" intercept: "<<ramp0<<
" pedestal: "<<ped<<
" gain: "<<dig.
gain() );
558 const Identifier cellid=cabling->cnvToIdentifier(chid);
559 const float noise=noisep->
getNoise(cellid,gain);
563 const unsigned nOFCSamp=std::min(samples.size(),OFCa.size());
564 for (
unsigned k=0; k<nOFCSamp; ++k) emon += (samples.at(k)-ped)*OFCa.at(k);
567 ATH_MSG_INFO(
"intercept + Escale*Sum[(sample-ped)*OFCa] "<<emon);
572 for (
const float a : OFCa) {sumai +=
a;}
573 float pedplusoffset=0;
574 if (escale*sumai != 0) pedplusoffset = ped - ramp0/(escale*sumai);
575 else pedplusoffset = 0;
576 const float inv_Escale = 1. / escale;
578 m_fai << channel<<
"\t"<< ped<<
"\t"<< pedplusoffset<<
"\t"
579 << OFCa[0]*escale<<
"\t"<< OFCa[1]*escale<<
"\t"<< OFCa[2]*escale<<
"\t"<< OFCa[3]*escale<<
"\t"<< OFCa[4]*escale<<
"\t"
580 << OFCb[0]*escale<<
"\t"<< OFCb[1]*escale<<
"\t"<< OFCb[2]*escale<<
"\t"<< OFCb[3]*escale<<
"\t"<< OFCb[4]*escale<<
"\t"
581 << 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"
582 << 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;
585 m_fen <<
m_ndump <<
" " << cmp.e_off <<
" " << cmp.e_on ;
586 m_fen <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
589 m_fdig << channel <<
" ";
590 for (
const short d : samples) {
593 m_fdig <<
" // FEB " << febid.
get_identifier32().
get_compact() <<
" ( channel " << channel <<
" ), event " << ctx.eventID().event_number() << std::endl;
600 const EventContext& ctx,
601 const diff_t & cmp)
const {
612 <<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)
613 <<
" " << 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;
629 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, 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
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)