23 return StatusCode::FAILURE;
29 return StatusCode::FAILURE;
44 for (
unsigned bec : {0,1}) {
46 for (
unsigned iside=0;iside<2;++iside) {
47 for (
unsigned iphi=0; iphi!=
m_MAXphi; ++iphi) {
52 return StatusCode::SUCCESS;
63 ATH_MSG_ERROR(
"Key list is empty! No containers to process!" );
64 return StatusCode::FAILURE;
69 unsigned nSaturation=0;
75 ATH_MSG_ERROR(
"Failed to retrieve FebErrorSummary object!" );
81 ATH_MSG_WARNING(
"No FebErrorSummaryObject found! Feb errors not checked!" );
86 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping");
87 return StatusCode::FAILURE;
101 for (
const std::string& key :
m_keylist) {
103 sc =
evtStore()->retrieve(larAccumulatedCalibDigitContainer,key);
105 ATH_MSG_WARNING(
"Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << key );
116 if(larAccumulatedCalibDigitContainer->
empty()) {
117 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key = " << key <<
" is empty " );
121 ATH_MSG_DEBUG(
"Processing LArAccumulatedCalibDigitContainer with key = " << key
122 <<
". Size: " << larAccumulatedCalibDigitContainer->
size() );
132 for (
int bec : {0,1}) {
133 for (
unsigned ieta=0;ieta!=
m_MAXeta[bec];++ieta) {
134 for (
unsigned iphi=0;iphi!=
m_MAXphi;++iphi) {
135 for (
unsigned iside=0;iside<2;++iside) {
147 if (!cabling->isOnlineConnected(chid))
continue;
150 const Identifier id=cabling->cnvToIdentifier(chid);
151 if (
m_emId->sampling(
id)!=1)
continue;
155 const uint16_t febErrs=febErrSum->
feb_error(febid);
157 if (febid!=lastFailedFEB) {
160 <<
" reports error(s):" << febErrSum->
error_to_string(febErrs) <<
". Data ignored." );
173 << ieta <<
"(max " <<
m_MAXeta[bec] <<
")" );
174 return StatusCode::FAILURE;
180 bool saturated=
false;
182 const std::vector<uint64_t>& samples=dig->sampleSum();
183 const size_t& nS=samples.size();
185 for (
size_t i=0;i<nS;++i) {
189 <<
", <ADC> = " << samples[i]/dig->nTriggers()
190 <<
", DAC = " << dig->DAC()
191 <<
") for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
223 neighbours[0].
dist=-2;
224 neighbours[1].
dist=-1;
225 neighbours[2].
dist=1;
226 neighbours[3].
dist=2;
228 for (
unsigned bec : {0,1}) {
229 for (
unsigned iside=0; iside<2; iside++) {
230 for (
int ieta=0; ieta<(int)
m_MAXeta[bec]; ieta++) {
231 for (
unsigned iphi=0; iphi<
m_MAXphi; iphi++) {
232 const unsigned iphi2=iphi+
m_MAXphi*iside;
234 if (currDig==
nullptr || currDig==&febErrorDummy)
continue;
241 << iphi2 <<
") should not be touched accoring to jobConfig");
245 const unsigned NtotSamples = currDig->
nsamples();
246 const unsigned NbTriggers = currDig->
nTriggers();
250 for (
unsigned i=0;i<4;i++) {
252 neighbours[i].
dig=
nullptr;
253 neighbours[i].
ped=0.;
254 const int neigbEtaItx=neighbours[i].
dist+(int)ieta;
257 ATH_MSG_DEBUG(
"Neighbour " << neighbours[i].dist <<
" , ieta=" << neigbEtaItx
258 <<
" doesn't exist. (min="<<
m_MINeta[bec] <<
" ,max=" <<
m_MAXeta[bec] <<
")");
259 neighbours[i].
dig=&inexistingDummy;
267 if (
msgLvl(MSG::WARNING)) {
269 ATH_MSG_DEBUG(
"FEB missing for neighbour " << neighbours[i].dist <<
" to be added to strip 0x"
270 <<
m_onlineHelper->channel_name(chid) <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
")");
273 ATH_MSG_WARNING(
"Cannot find neighbour " << neighbours[i].dist <<
" to be added to strip 0x"
274 <<
m_onlineHelper->channel_name(chid) <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
")" );
279 if (neighDig==&febErrorDummy) {
281 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
"), has a FEB error. Ignored.");
288 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
", " <<
printMaxSample(neighDig)
289 <<
") is pulsed. Not used for correction." );
296 <<
" (Eta = " << ieta <<
", Phi = " << iphi
297 <<
") is flagged by the LArBadChannelMaskingTool. Not used for correction.");
304 ATH_MSG_ERROR(
"No pedestal are available for neighbour " << neighbours[i].dist <<
" of strip "
305 <<
m_onlineHelper->channel_name(chid) <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
"). Not used for correction!" );
309 neighbours[i].
dig=neighDig;
310 neighbours[i].
ped=pedestal;
315 const int nnEta=ieta+2*neighbours[i].
dist;
318 if (nnDig!=
nullptr) {
322 <<
" has another pulsed cell in the neighborhood. Setting weight to 0.5");
331 std::vector<double> SampleSums(NtotSamples);
332 for (std::size_t SampleIndex=0;SampleIndex<NtotSamples; ++SampleIndex ) {
333 SampleSums[SampleIndex]=(double)currDig->
sampleSum()[SampleIndex];
334 ATH_MSG_VERBOSE(
"SampleSum " << SampleIndex <<
" (" << SampleSums[SampleIndex] <<
" ADC counts / " << NbTriggers <<
" Ntriggers)");
337 for (
unsigned i=0;i<4;i++) {
338 if (neighbours[i].dig==&inexistingDummy) {
340 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
") does not exist.");
345 if (neighbours[i].dig) {
348 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
") is used for correction");
353 <<
" cannot be used. Taking mirrored neighbour " << neighbours[j].
dist <<
" instead." );
354 if (neighbours[j].dig!=
nullptr && neighbours[j].dig!=&inexistingDummy){
357 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
") is used for correction");
361 <<
" cannot be used too. No correction applied" );
367 std::vector<uint64_t> SampleSumInt(NtotSamples);
368 bool unresonable=
false;
370 for (std::size_t SampleIndex=0;SampleIndex<NtotSamples; ++SampleIndex ) {
371 const double& thisSampleSum=SampleSums[SampleIndex];
372 const uint32_t& oldVal=currDig->
sampleSum()[SampleIndex];
373 if (thisSampleSum<0) {
376 <<
" (Eta = " << ieta <<
", Phi = " << iphi <<
") Resulting ADC sample " << SampleIndex <<
" negative! "
377 << thisSampleSum <<
" instead of " << oldVal <<
" Not corrected." );
381 if (SampleIndex==iPeak) {
382 const float dev=(thisSampleSum-oldVal)/oldVal;
387 <<
") DAC=" << currDig->
DAC() <<
": Resulting ADC sample " << SampleIndex <<
" looks unreasonable: "
388 << thisSampleSum <<
" instead of " << oldVal <<
" (off by " << dev*100 <<
"%)"
389 <<
" (=" << thisSampleSum/NbTriggers <<
" -> " << oldVal/NbTriggers <<
", ped="
390 << larPedestal->
pedestal(chid,t_gain)
391 <<
" Not Corrected.");
395 SampleSumInt[SampleIndex] = (uint64_t)(thisSampleSum);
405 << currDig->
sampleSum()[2] <<
"->" << SampleSumInt[2]);
417 ATH_MSG_INFO(
"Found " << nSaturation <<
" saturating digits in this event." );
419 return StatusCode::SUCCESS;
433 for (;it!=it_e;++it) {
442 return StatusCode::SUCCESS;
448 const std::vector<uint64_t>&
ss=thisDig->
sampleSum();
449 std::vector<uint64_t>::const_iterator
imax=std::max_element(
ss.begin(),
ss.end());
450 std::ostringstream output;
459 for (
unsigned bec : {0,1}) {
469 return StatusCode::FAILURE;
474 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping");
475 return StatusCode::FAILURE;
479 for (
const auto& entry : bfCont->
fullCont()) {
485 LArBadChannelDBTools::BadFebVec::const_iterator it=mf.begin();
486 LArBadChannelDBTools::BadFebVec::const_iterator it_e=mf.end();
487 for (;it!=it_e;++it) {
495 for (
int c=0;c<nChan;++c) {
497 const Identifier id=cabling->cnvToIdentifier(chid);
503 << ieta <<
"(max " <<
m_MAXeta[bec] <<
")" );
504 return StatusCode::FAILURE;
512 ATH_MSG_INFO(
"Number of known missing strip cells: "<< nMissing );
514 return StatusCode::SUCCESS;
526 unsigned iBin=(unsigned)(std::fabs(reldiff)/
m_binwidth);
536 const unsigned nBins=
m_diffs.size();
537 if (nBins==0)
return;
538 out << lvl <<
"Cross Talk Correction Summary:" <<
endmsg;
539 for (
unsigned i=0;i<nBins-1;++i)
545 out << lvl <<
"Data points with the highes correction:" <<
endmsg;
546 std::vector<maxlistitem>::const_iterator it=
m_maxlist.begin();
547 std::vector<maxlistitem>::const_iterator it_e=
m_maxlist.end();
549 out << lvl <<
" " << onlId->
channel_name(it->chid) <<
" DAC=" << it->dac <<
" Delay=" << it->delay <<
" Deviation:" << it->reldiff <<
endmsg;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define maxValue(current, test)
LArBadXCont< LArBadFeb > LArBadFebCont
LArBadXCont< LArBadChannel > LArBadChannelCont
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
virtual float pedestal(const HWIdentifier &id, int gain) const =0
value_type get_compact() const
Get the compact id.
Container class for LArAccumulatedCalibDigit.
Data class for calibration ADC samples preprocessed by the DSP.
bool isPulsed() const
Tell if this channel was pulsed.
CaloGain::CaloGain gain() const
return gain value
int delay() const
return the setting of the delay
const HWIdentifier & hardwareID() const
Return HWIdentifier.
const std::vector< uint64_t > & sampleSum() const
return a reference to a stl vector containing the sample-sums
int DAC() const
return the number of samples
unsigned nTriggers() const
return the number of triggers
size_t nsamples() const
return number of samples
bool deadAll() const
FEB is completely missing, e.g. powered off.
bool deactivatedInOKS() const
Deactivated in OKS.
bool deadReadout() const
FEB is not sending readout data, but the L1 trigger path is working.
const BadChanVec & fullCont() const
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
Holds information from the FEB Error Summary.
static std::string error_to_string(uint16_t error)
interpret the error in string
uint16_t feb_error(HWIdentifier febid) const
get error for feb
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
void correctSamples(std::vector< double > &dest, const neighbour_t &neighbor) const
SG::ReadCondHandleKey< ILArPedestal > m_pedKey
std::set< HWIdentifier > m_uncorrectedIds
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
virtual StatusCode finalize() override final
const LArOnlineID * m_onlineHelper
unsigned int m_event_counter
std::array< std::vector< std::bitset< 128 > >, 2 > m_knownMissingFebs
SG::ReadCondHandleKey< LArBadFebCont > m_BFKey
size_t getEtaIndex(const Identifier) const
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
Gaudi::Property< std::vector< std::string > > m_dontUseForCorr
Gaudi::Property< float > m_acceptableDifference
StatusCode initKnownMissingFebs()
XtalkCorrHisto m_differences
uint16_t m_fatalFebErrorPattern
virtual StatusCode execute() override final
const unsigned int m_MAXphi
static std::string printMaxSample(const LArAccumulatedCalibDigit *thisDig)
size_t getPhiIndex(const Identifier) const
std::array< std::vector< std::vector< const LArAccumulatedCalibDigit * > >, 2 > m_stripsLookUp
Gaudi::Property< std::vector< std::string > > m_keylist
static constexpr auto m_MAXeta
LArBadChannelMask m_dontUseForCorrMask
LArBadChannelMask m_dontCorrMask
static constexpr auto m_MINeta
virtual StatusCode initialize() override final
Gaudi::Property< std::vector< std::string > > m_dontCorr
Gaudi::Property< unsigned int > m_ADCsatur
std::string stringStatus(const LArBadChannel &bc) const
void add(const LArAccumulatedCalibDigit *dig, const float reldiff)
std::vector< unsigned > m_diffs
void print(MsgStream &stream, const LArOnlineID *onlId, MSG::Level lvl=MSG::INFO)
std::vector< maxlistitem > m_maxlist
XtalkCorrHisto(const unsigned nBins, const float maxbin)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
std::pair< HWIdentifier, LArBadFeb > BadFebEntry
std::vector< BadFebEntry > BadFebVec
const LArAccumulatedCalibDigit * dig