Public Member Functions | Private Member Functions | Private Attributes | List of all members
chaninfo::BadChanList Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-23/ChannelInfo/BadChanList.h"

Public Member Functions

 BadChanList (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~BadChanList ()
 
void preBeginRun (art::Run const &run)
 
void postBeginSubRun (art::SubRun const &subrun)
 
void preBeginEvent (art::Event const &evt)
 
int Apply (art::PtrVector< rawdata::RawDigit > &rd)
 
int Apply (std::vector< art::Ptr< rawdata::RawDigit > > &rd)
 
int Apply (std::vector< const rawdata::RawDigit * > &)
 
bool IsBad (int plane, int cell)
 
bool IsLowEfficiency (int plane, int cell)
 
void reconfigure (fhicl::ParameterSet p)
 
void LoadNewData ()
 
int NBadInSubRun (int i)
 

Private Member Functions

bool IsBadUncached (int plane, int cell)
 
bool InDroppedDCM (int plane, int cell)
 
void SetRandomBadChannels ()
 
void LoadCosmicEff (int newrun, int newsubrun)
 
template<class T >
void CountDCMHits (const std::vector< T > &digitcol)
 

Private Attributes

int fApplyBadChan
 Option to activate the bad channels. More...
 
int fMCRunNumber
 Run number for the MC. More...
 
int fMCSubrunNumber
 Subrun number for the MC. More...
 
int fNBadSR
 
int fVldRunGrouping
 
int fPedestalThresholdLow
 
int fPedestalThresholdHigh
 
bool fAbortIfNoneFound
 Option to throw an exception if no channel rate state rows are returned from dB. More...
 
bool fNeedNewData
 
bool fIsPerfect
 
bool fAbortOnSmallRunNum
 
bool fAbortIfNoSubrun
 
std::unordered_set< geo::OfflineChanfLowEfficiency
 set of low eff channels More...
 
std::unordered_set< geo::OfflineChanfRandomBCMap
 random bad channel map More...
 
std::string fBadChanCSVFile
 
bool fEventCheck
 do we check each event for dropped DCMs? More...
 
std::string fRawDigitLabel
 what is the name of the raw digits ART object More...
 
std::string fCellHitLabel
 
bool fNewCosmicEffTable
 Use new-style table? More...
 
float fRandomBadChannelFraction
 If >0, ignore DB and set this fraction bad at random. More...
 
std::vector< std::unordered_set< geo::OfflineChan > > fBadChans
 Vector index is the subrun number, set contains all the bad channels. More...
 
std::vector< std::unordered_set< int > > fDropOuts
 [subrun][tchan] More...
 
int fRun
 
int fSubRun
 
time_t fMinVldTime
 Minimum time used in database request. More...
 
time_t fMaxVldTime
 Maximum time used in database request. More...
 
std::string fValidityTagNearDet
 
std::string fValidityTagFarDet
 
std::string fFEBDropoutTag
 
bool fApplyFEBDropout
 
std::unique_ptr< CLHEP::RandFlatfFlatRand
 
int fDCMHits [12][14]
 count hits in each DCM each event to look for dropped DCMs More...
 
std::vector< std::string > fKBCList
 
std::vector< geo::OfflineChanfKnownBadChannels
 
std::bitset< FD_NUM_PLANES *FD_NUM_CELLSfIsBadCache
 
bool fIsBadCacheValid
 

Detailed Description

Interface to the run-by-run list of bad channels

Definition at line 39 of file BadChanList.h.

Constructor & Destructor Documentation

chaninfo::BadChanList::BadChanList ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 43 of file BadChanList_service.cc.

References fDCMHits, fFlatRand, fIsBadCache, fIsBadCacheValid, fIsPerfect, fMCRunNumber, fMCSubrunNumber, fNBadSR, fNeedNewData, fRandomBCMap, fValidityTagFarDet, fValidityTagNearDet, sim::GetRandomNumberSeed(), MECModelEnuComparisons::i, calib::j, postBeginSubRun(), preBeginEvent(), preBeginRun(), reconfigure(), art::ActivityRegistry::sPostBeginSubRun, art::ActivityRegistry::sPreBeginRun, and art::ActivityRegistry::sPreProcessEvent.

44  :
45  fNewCosmicEffTable(false)
46  {
47  fRandomBCMap.clear();
48  fNeedNewData = true;
50  fValidityTagFarDet = "";
51  fMCRunNumber = -1;
52  fMCSubrunNumber = -1;
53  fNBadSR = -1; // unknown yet
54  fIsPerfect = false;
55  fIsBadCacheValid = false;
56  fIsBadCache.reset();
57 
58  //treat every DCM as occupied at initialization.
59  for(int i = 0; i < 12; i++) { // re-initialize every event
60  for(int j = 0; j < 14; j++) { // just keep array sized 12 x 14; for ND we just won't use it all
61  fDCMHits[i][j] = 1;
62  }
63  }
64 
66  fFlatRand = std::unique_ptr<CLHEP::RandFlat>(new CLHEP::RandFlat(rle));
67 
68  this->reconfigure(pset);
69  reg.sPreBeginRun.watch(this, &BadChanList::preBeginRun);
72  }
void preBeginEvent(art::Event const &evt)
std::string fValidityTagNearDet
Definition: BadChanList.h:127
int fDCMHits[12][14]
count hits in each DCM each event to look for dropped DCMs
Definition: BadChanList.h:135
std::unordered_set< geo::OfflineChan > fRandomBCMap
random bad channel map
Definition: BadChanList.h:101
GlobalSignal< detail::SignalResponseType::LIFO, void(SubRun const &)> sPostBeginSubRun
std::string fValidityTagFarDet
Definition: BadChanList.h:128
std::bitset< FD_NUM_PLANES *FD_NUM_CELLS > fIsBadCache
Definition: BadChanList.h:145
bool fNewCosmicEffTable
Use new-style table?
Definition: BadChanList.h:110
const double j
Definition: BetheBloch.cxx:29
void postBeginSubRun(art::SubRun const &subrun)
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:80
unsigned int GetRandomNumberSeed()
Definition: Simulation.cxx:13
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
void reconfigure(fhicl::ParameterSet p)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
int fMCSubrunNumber
Subrun number for the MC.
Definition: BadChanList.h:81
void preBeginRun(art::Run const &run)
std::unique_ptr< CLHEP::RandFlat > fFlatRand
Definition: BadChanList.h:133
chaninfo::BadChanList::~BadChanList ( )

Definition at line 76 of file BadChanList_service.cc.

77  {
78  }

Member Function Documentation

int chaninfo::BadChanList::Apply ( art::PtrVector< rawdata::RawDigit > &  rd)

Definition at line 692 of file BadChanList_service.cc.

References getBrightness::cell, visualisationForPaperMasterPlot::cmap, cmap::dataprov::CMap::GetCell(), cmap::dataprov::CMap::GetPlane(), update_sam_good_runs_metadata::good, MECModelEnuComparisons::i, IsBad(), NDAPDHVSetting::plane, art::PtrVector< T >::push_back(), art::PtrVector< T >::size(), and art::PtrVector< T >::swap().

Referenced by comi::Leana::analyze(), evd::RawDataDrawer::GetRawDigits(), evd::RawDataDrawer::GetRawDigitsMulti(), evtsum::EventSummary::MakeOutput(), and comi::Cana::produce().

693  {
695  int ch;
697  for(unsigned int i=0; i<rd.size(); ++i) {
698  int plane = cmap->GetPlane(rd[i].get());
699  int cell = cmap->GetCell(rd[i].get());
700  if(!IsBad(plane,cell)) good.push_back(rd[i]);
701  }
702  rd.swap(good);
703  ch=rd.size();
704  return ch;
705  }
void swap(PtrVector &other)
Definition: PtrVector.h:522
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
size_type size() const
Definition: PtrVector.h:308
unsigned short GetCell(const rawdata::RawDigit *dig)
Definition: CMap.cxx:327
bool IsBad(int plane, int cell)
int chaninfo::BadChanList::Apply ( std::vector< art::Ptr< rawdata::RawDigit > > &  rd)

Definition at line 675 of file BadChanList_service.cc.

References getBrightness::cell, visualisationForPaperMasterPlot::cmap, cmap::dataprov::CMap::GetCell(), cmap::dataprov::CMap::GetPlane(), update_sam_good_runs_metadata::good, MECModelEnuComparisons::i, IsBad(), and NDAPDHVSetting::plane.

676  {
678  int ch;
679  std::vector< art::Ptr<rawdata::RawDigit> > good;
680  for(unsigned int i=0; i<rd.size(); ++i) {
681  int plane = cmap->GetPlane(rd[i].get());
682  int cell = cmap->GetCell(rd[i].get());
683  if(!IsBad(plane,cell)) good.push_back(rd[i]);
684  }
685  rd.swap(good);
686  ch=rd.size();
687  return ch;
688  }
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
unsigned short GetCell(const rawdata::RawDigit *dig)
Definition: CMap.cxx:327
bool IsBad(int plane, int cell)
int chaninfo::BadChanList::Apply ( std::vector< const rawdata::RawDigit * > &  rd)

Definition at line 709 of file BadChanList_service.cc.

References getBrightness::cell, visualisationForPaperMasterPlot::cmap, chaninfo::DEFINE_ART_SERVICE(), cmap::dataprov::CMap::GetCell(), cmap::dataprov::CMap::GetPlane(), update_sam_good_runs_metadata::good, MECModelEnuComparisons::i, IsBad(), and NDAPDHVSetting::plane.

710  {
712  int ch;
713  std::vector<const rawdata::RawDigit*> good;
714  for(unsigned int i=0; i<rd.size(); ++i) {
715  int plane = cmap->GetPlane(rd[i]);
716  int cell = cmap->GetCell(rd[i]);
717  if(!IsBad(plane,cell)) good.push_back(rd[i]);
718  }
719  rd.swap(good);
720  ch=rd.size();
721  return ch;
722  }
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
unsigned short GetCell(const rawdata::RawDigit *dig)
Definition: CMap.cxx:327
bool IsBad(int plane, int cell)
template<class T >
void chaninfo::BadChanList::CountDCMHits ( const std::vector< T > &  digitcol)
private

Definition at line 139 of file BadChanList_service.cc.

References febshutoff_auto::dcm, geo::GeometryBase::DetId(), fDCMHits, geom(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getInstance(), MECModelEnuComparisons::i, calib::j, and T.

Referenced by preBeginEvent().

140  {
141  for(int i = 0; i < 12; i++) { // re-initialize every event
142  for(int j = 0; j < 14; j++) { // just keep array sized 12 x 14; for ND we just won't use it all
143  fDCMHits[i][j] = 0;
144  }
145  }
146  int dib, dcm;
149  for(const T& digit: digitcol){
150  // count the number of raw digit hits in each DCM
151  dcm = daqmap->getDCM(digit.DaqChannel());
152  dib = daqmap->getDiBlock(digit.DaqChannel());
153  fDCMHits[dcm-1][dib-1]++;
154  }
155  }
int fDCMHits[12][14]
count hits in each DCM each event to look for dropped DCMs
Definition: BadChanList.h:135
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
const double j
Definition: BetheBloch.cxx:29
void geom(int which=0)
Definition: geom.C:163
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
double T
Definition: Xdiff_gwt.C:5
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
bool chaninfo::BadChanList::InDroppedDCM ( int  plane,
int  cell 
)
private

Definition at line 560 of file BadChanList_service.cc.

References getBrightness::cell, geo::GeometryBase::DetId(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), fDCMHits, fEventCheck, geom(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getInstance(), LOG_DEBUG, and NDAPDHVSetting::plane.

Referenced by IsBad(), and IsBadUncached().

561  {
562  if(!fEventCheck) return false;
563 
566  uint32_t dchan = daqmap->encodeDChan(daqmap->encodeLChan(geom->DetId(), plane, cell));
567  if(fDCMHits[daqmap->getDCM(dchan)-1][daqmap->getDiBlock(dchan)-1]==0) {
568  //***
569  LOG_DEBUG("BadChanList") << "Dropped DCM";
570  //***
571  return true;
572  }
573  return false;
574  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
int fDCMHits[12][14]
count hits in each DCM each event to look for dropped DCMs
Definition: BadChanList.h:135
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:105
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
void geom(int which=0)
Definition: geom.C:163
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t dchan
< DAQ Channel Map Package
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
bool chaninfo::BadChanList::IsBad ( int  plane,
int  cell 
)
bool chaninfo::BadChanList::IsBadUncached ( int  plane,
int  cell 
)
private

Definition at line 577 of file BadChanList_service.cc.

References ana::assert(), getBrightness::cell, febshutoff_auto::chan, confusionMatrixTree::count, febshutoff_auto::dcm, geo::GeometryBase::DetId(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), fApplyBadChan, fApplyFEBDropout, fBadChanCSVFile, fBadChans, fDropOuts, APDHVSetting::feb, fIsPerfect, fKnownBadChannels, fMaxVldTime, fMinVldTime, fNeedNewData, fPedestalThresholdHigh, fPedestalThresholdLow, fRandomBadChannelFraction, fRandomBCMap, fRun, fSubRun, geom(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), nova::dbi::RunHistory::GetPedestal(), nova::dbi::RunHistory::HasAPD(), InDroppedDCM(), novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, LoadNewData(), LOG_DEBUG, LOG_WARNING, nova::dbi::RunHistory::NSubruns(), NDAPDHVSetting::plane, rh, SetRandomBadChannels(), and sr.

Referenced by preBeginEvent().

578  {
579  if(!fApplyBadChan) return false;
580  if (fIsPerfect) return false;
581 
583 
584  for (auto kbc : fKnownBadChannels) {
585  if (kbc == chan) {
586  //***
587  LOG_DEBUG("BadChanList") << "BadChanList_service: known bad channel!";
588  //***
589  return true;
590  }
591  }
592 
595  return fRandomBCMap.count(chan);
596  }
597 
598  if (fNeedNewData) LoadNewData();
599 
602 
603  const int sr = fSubRun%rh->NSubruns();
604  const time_t evtTime = fRun*10000 + sr*100 + 1;
605 
606  // check if event time within validity range, i.e. sane
607  if ( fBadChanCSVFile.empty() && (evtTime < fMinVldTime || evtTime > fMaxVldTime)){
608  throw cet::exception("BadChanList")
609  << "Event time is outside the validity range of the database request. "
610  << fMinVldTime << " " << evtTime << " " << fMaxVldTime
611  << " Database request does not contain complete information, "
612  << "which could lead to unpredictable behavior.";
613  }
614 
615  if(InDroppedDCM(plane, cell)) return true;
616 
617  // check with RH whether this channel was instrumented, part of the partition, or masked
618  if (!rh->HasAPD(chan)) {
619  //***
620  LOG_DEBUG("BadChanList") << "Mmissing APD";
621  //***
622  return true;
623  }
624  // for now, just deal with dB tables for the FarDet and NearDet
625  if (geom->DetId() == novadaq::cnv::kFARDET ||
626  geom->DetId() == novadaq::cnv::kNEARDET) {
627 
628  assert((unsigned int)sr < fBadChans.size());
629  if(fBadChans[sr].count(chan)) return true;
630 
631  if (fApplyFEBDropout) {
633  daqchannelmap::lchan logChan = daqcmap->encodeLChan(geom->DetId(),plane,cell);
634  daqchannelmap::dchan daqChan = daqcmap->encodeDChan(logChan);
635 
636  int db = daqcmap->getDiBlock(daqChan);
637  int dcm = daqcmap->getDCM(daqChan);
638  int feb = daqcmap->getFEB(daqChan);
639 
640  int tchan = db*1000+(dcm-1)*64+feb;
641 
642  assert((unsigned int)sr < fDropOuts.size());
643  if(fDropOuts[sr].count(tchan)) return true;
644  }
645  }
646 
647  // check if we should mask off channels with too low or too high of a pedestal
648  if (fPedestalThresholdLow > 0) {
649  bool pedok;
650  int ped = rh->GetPedestal(chan,pedok);
651  if (pedok) {
652  if (ped < fPedestalThresholdLow ||
654  return true;
655  }
656  else {
657  LOG_WARNING("BadChanList") << "******** Failed to get a pedestal for found channel (" << plane << "," << cell << ")";
658  }
659  }
660  // If we can't find anything wrong with it then it must not be bad
661  return false;
662  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::string fBadChanCSVFile
Definition: BadChanList.h:103
TH2 * rh
Definition: drawXsec.C:5
std::unordered_set< geo::OfflineChan > fRandomBCMap
random bad channel map
Definition: BadChanList.h:101
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
std::vector< std::unordered_set< int > > fDropOuts
[subrun][tchan]
Definition: BadChanList.h:116
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:112
Far Detector at Ash River, MN.
std::vector< geo::OfflineChan > fKnownBadChannels
Definition: BadChanList.h:138
int GetPedestal(const geo::OfflineChan &, bool &)
Definition: RunHistory.cxx:632
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
time_t fMaxVldTime
Maximum time used in database request.
Definition: BadChanList.h:123
Near Detector in the NuMI cavern.
caf::StandardRecord * sr
bool InDroppedDCM(int plane, int cell)
#define LOG_WARNING(category)
A (plane, cell) pair.
Definition: OfflineChan.h:17
bool HasAPD(const geo::OfflineChan &)
basic check for if a channel should be live. Used by BadChannels. Checks if channel has instrumented ...
time_t fMinVldTime
Minimum time used in database request.
Definition: BadChanList.h:121
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:79
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t dchan
< DAQ Channel Map Package
std::vector< std::unordered_set< geo::OfflineChan > > fBadChans
Vector index is the subrun number, set contains all the bad channels.
Definition: BadChanList.h:115
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
bool chaninfo::BadChanList::IsLowEfficiency ( int  plane,
int  cell 
)

Definition at line 665 of file BadChanList_service.cc.

References febshutoff_auto::chan, fApplyBadChan, and fLowEfficiency.

Referenced by trk::KalmanTrack::CheckTrack(), trk::KalmanGeoHelper::CountMissedCellsOnLine(), dt::ViewMerger::CountUnexplainedOnLine(), trk::KalmanTrack::FilterTracker(), and dt::View::View().

666  {
667  if(!fApplyBadChan) return false;
668 
670  return fLowEfficiency.count(chan);
671  }
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:100
A (plane, cell) pair.
Definition: OfflineChan.h:17
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:79
void chaninfo::BadChanList::LoadCosmicEff ( int  newrun,
int  newsubrun 
)
private

Definition at line 291 of file BadChanList_service.cc.

References getBrightness::cell, febshutoff_auto::chan, nova::dbi::Row::Col(), allTimeWatchdog::endl, fLowEfficiency, fNewCosmicEffTable, genie::utils::style::Format(), nova::dbi::Column::Get(), nova::dbi::Table::GetColIndex(), nova::dbi::Table::GetRow(), update_sam_good_runs_metadata::good, MECModelEnuComparisons::i, nova::dbi::Table::Load(), LOG_DEBUG, nova::dbi::Table::NRow(), NDAPDHVSetting::plane, nova::dbi::Table::SetValidityRange(), nova::dbi::Table::SetValiditySQL(), and nova::dbi::Table::SetVerbosity().

292  {
293  fLowEfficiency.clear();
294 
296  "/ChannelInfo/CosmicEffNew.xml" :
297  "/ChannelInfo/CosmicEff.xml");
298  tblEff.SetValidityRange("detector", "ndos");
299  tblEff.SetValiditySQL(TString::Format("(beginrun<%d or (beginrun=%d and beginsubrun<=%d)) and "
300  "(endrun>%d or (endrun=%d and endsubrun>=%d))",
301  newrun, newrun, newsubrun, newrun, newrun, newsubrun).Data());
302  // }
303 
304  // Only ask for the bad channels. We won't get any "good" ones back, so
305  // they won't go in the map, which is fine.
306  tblEff.SetValidityRange("good", false);
307 
308  tblEff.SetVerbosity(100);
309  const bool ok = tblEff.Load();
310  if(!ok){
311  // No safe way to handle this
312  LOG_DEBUG("BadChanList") << "Couldn't load efficiencies channels from DB. Aborting" << std::endl;
313  std::abort();
314  }
315  int planeIdx = tblEff.GetColIndex("plane");
316  int cellIdx = tblEff.GetColIndex("cell");
317  int goodIdx = tblEff.GetColIndex("good");
318 
319  for(int i = 0; i < tblEff.NRow(); ++i){
320  int plane, cell;
321  bool good;
322  bool ok = tblEff.GetRow(i)->Col(planeIdx).Get(plane);
323  ok = ok && tblEff.GetRow(i)->Col(cellIdx).Get(cell);
324  ok = ok && tblEff.GetRow(i)->Col(goodIdx).Get(good);
325  if(!ok) std::abort();
326  geo::OfflineChan chan(plane, cell);
327  if(!good) fLowEfficiency.insert(chan);
328  }
329  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
bool fNewCosmicEffTable
Use new-style table?
Definition: BadChanList.h:110
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:100
A (plane, cell) pair.
Definition: OfflineChan.h:17
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void chaninfo::BadChanList::LoadNewData ( )

Definition at line 379 of file BadChanList_service.cc.

References getBrightness::cell, febshutoff_auto::chan, visualisationForPaperMasterPlot::cmap, nova::dbi::Row::Col(), febshutoff_auto::db, febshutoff_auto::dcm, geo::GeometryBase::DetId(), runNovaSAM::detId, daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), fAbortIfNoneFound, fApplyFEBDropout, fBadChanCSVFile, fBadChans, fDropOuts, APDHVSetting::feb, fFEBDropoutTag, nova::dbi::Table::FillChanRowMap(), fIsPerfect, fKBCList, fKnownBadChannels, fMaxVldTime, fMCRunNumber, fMinVldTime, fNeedNewData, fRun, fValidityTagFarDet, fValidityTagNearDet, fVldRunGrouping, geom(), nova::dbi::Column::Get(), daqchannelmap::DAQChannelMap::getCell(), nova::dbi::Table::GetColIndex(), daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPlane(), nova::dbi::Table::GetVldRow(), makeTrainCVSamples::int, nova::dbi::kDataOnly, novadaq::cnv::kFARDET, nova::dbi::kMCOnly, novadaq::cnv::kNEARDET, nova::dbi::Table::Load(), nova::dbi::Table::LoadFromCSV(), LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, cmap::dataprov::CMap::Map(), updateRunHistoryTables::minrun, geo::PlaneGeo::Ncells(), geo::GeometryBase::NPlanes(), nova::dbi::Table::NRow(), nova::dbi::RunHistory::NSubruns(), geo::GeometryBase::Plane(), NDAPDHVSetting::plane, rh, check_grl::row, nova::dbi::RunHistory::RunNumber(), nova::dbi::Table::SetDataTypeMask(), nova::dbi::Table::SetDetector(), nova::dbi::Table::SetMaxTSVld(), nova::dbi::Table::SetMinTSVld(), nova::dbi::Table::SetTag(), nova::dbi::Table::SetVerbosity(), sr, makeDatasetsPage::state, getGoodRuns4SAM::subrun, and geo::OfflineChan::ToDBValidityChan().

Referenced by IsBadUncached(), and NBadInSubRun().

380  {
381  if (fIsPerfect) return;
382 
384 
385  if (!fKBCList.empty()) {
386 
387  fKnownBadChannels.clear();
389 
390  int idet = geom->DetId();
391  int db, dcm, feb, detId;
392  for (auto k : fKBCList) {
393  sscanf(k.c_str(),"%d-%02d-%02d-%02d",&detId,&db,&dcm,&feb);
394  if (detId == idet) {
395  LOG_DEBUG("BadChanList")<< k << " is known to be bad, all associated channels masked off.";
396  for (int ipix=0; ipix<32; ++ipix) {
397  daqchannelmap::dchan daqChan = cmap->Map()->encodeDChan(idet,db,dcm,feb,ipix);
398  daqchannelmap::dchan logChan = cmap->Map()->encodeLChan(daqChan);
399  int plane = cmap->Map()->getPlane(logChan);
400  int cell = cmap->Map()->getCell(logChan);
401  fKnownBadChannels.push_back(geo::OfflineChan(plane,cell));
402  }
403  }
404  }
405  }
406 
407  fBadChans.clear();
408  fDropOuts.clear();
409 
410  nova::dbi::Table BCTable("/ChannelInfo/ChanRateState.xml");
411  BCTable.SetVerbosity(100);
412  BCTable.SetDetector(geom->DetId());
413  if (geom->DetId() == novadaq::cnv::kNEARDET) {
414  if (fValidityTagNearDet != "")
415  BCTable.SetTag(fValidityTagNearDet);
416  }
417  else if (geom->DetId() == novadaq::cnv::kFARDET) {
418  if (fValidityTagFarDet != "")
419  BCTable.SetTag(fValidityTagFarDet);
420  }
421 
422 
423  const int stateIdx = BCTable.GetColIndex("state");
424 
425  nova::dbi::Table FEBDOTable("/ChannelInfo/FEBDropout.xml");
426  FEBDOTable.SetVerbosity(100);
427  FEBDOTable.SetDetector(geom->DetId());
428  if (fFEBDropoutTag != "")
429  FEBDOTable.SetTag(fFEBDropoutTag);
430  const int FEBStateIdx = FEBDOTable.GetColIndex("state");
431 
432  if (!fBadChanCSVFile.empty())
433  {
434  BCTable.LoadFromCSV(fBadChanCSVFile);
435  LOG_ERROR("BadChanList") << "Read " << BCTable.NRow()
436  << " BadChannel rows from "
437  << fBadChanCSVFile;
438  }
439  else
440  {
441  if (fMCRunNumber > 0)
442  {
444  fMinVldTime = rh.RunNumber()*10000 + 1;
445  fMaxVldTime = fMinVldTime + rh.NSubruns()*100;
446  }
447  else if (geom->DetId() == novadaq::cnv::kFARDET ||
448  geom->DetId() == novadaq::cnv::kNEARDET)
449  {
452  fMinVldTime = minrun*10000 + 1;
453  fMaxVldTime = fMinVldTime - 1 + fVldRunGrouping*10000;
454  }
455 
456  BCTable.SetDataTypeMask(nova::dbi::kMCOnly|nova::dbi::kDataOnly);
457  BCTable.SetMinTSVld(fMinVldTime);
458  BCTable.SetMaxTSVld(fMaxVldTime);
459 
460  if (!BCTable.Load()) {
461  LOG_ERROR("BadChanList") <<"Bad Channels table failed to load data!";
462  std::abort();
463  }
464  if (BCTable.NRow() == 0) {
465  LOG_ERROR("BadChanList") << "******** WARNING: BadChanList_service found no bad channels!";
466  if (fAbortIfNoneFound) {
467  LOG_ERROR("BadChanList") << "Bad Channels table is empty, this should never happen!";
468  std::abort();
469  }
470  }
471 
472  if (fApplyFEBDropout && (geom->DetId() == novadaq::cnv::kNEARDET)) {
473  FEBDOTable.SetMinTSVld(fMinVldTime-480);
474  FEBDOTable.SetMaxTSVld(fMaxVldTime+480);
475  FEBDOTable.Load();
476  if (FEBDOTable.NRow() == 0) {
477  LOG_WARNING("BadChanList") << "******** BadChanList_service found no FEB dropout data!";
478  }
479  }
480  }
481 
482  BCTable.FillChanRowMap();
483  FEBDOTable.FillChanRowMap();
484 
487  fBadChans.resize(rh->NSubruns());
488  fDropOuts.resize(rh->NSubruns());
489 
490  for(int subrun = 0; subrun < rh->NSubruns(); ++subrun){
491  const time_t evtTime = fRun*10000 + subrun*100 + 1;
492 
493  for(unsigned int plane = 0; plane < geom->NPlanes(); ++plane){
494  const geo::PlaneGeo* geoplane = geom->Plane(plane);
495  for(unsigned int cell = 0; cell < geoplane->Ncells(); ++cell){
496  const geo::OfflineChan chan(plane, cell);
497 
498  // get validity row for this timestamp
499  nova::dbi::Row* row = BCTable.GetVldRow(chan.ToDBValidityChan(),
500  evtTime);
501 
502  if(row){
503  // there is an entry for this timestamp (expected behavior), so
504  // make sure that the state is "ok" (==0)
505  int state;
506  const bool ok = row->Col(stateIdx).Get(state);
507  if(!ok) std::abort();
508  if(state != 0) {
509  fBadChans[subrun].insert(geo::OfflineChan(plane, cell));
510  }
511  } // end if row
512 
513  // Now the drop-out table
514 
515  // TODO - one could loop over all the FEBs more efficiently than
516  // this, but it doesn't really matter since this is once per run.
517 
518  daqchannelmap::lchan logChan = daqcmap->encodeLChan(geom->DetId(),
519  plane, cell);
520  daqchannelmap::dchan daqChan = daqcmap->encodeDChan(logChan);
521 
522  const int db = daqcmap->getDiBlock(daqChan);
523  const int dcm = daqcmap->getDCM(daqChan);
524  const int feb = daqcmap->getFEB(daqChan);
525 
526  const int tchan = db*1000+(dcm-1)*64+feb;
527 
528  row = FEBDOTable.GetVldRow(tchan, evtTime);
529 
530  if(row){
531  int state;
532  const bool ok = row->Col(FEBStateIdx).Get(state);
533  if(!ok) std::abort();
534  // a state of "1" means the FEB is live at this point
535  if(state != 1) fDropOuts[subrun].insert(tchan);
536  }
537  } // end for cell
538  } // end for plane
539  } // end for subrun
540 
541  auto info = LOG_INFO("BadChanList");
542  for(int sr = 0; sr < rh->NSubruns(); ++sr){
543  info << "Subrun " << sr << ": "
544  << fBadChans[sr].size() << " bad channels, "
545  << fDropOuts[sr].size() << " DCM dropouts.\n";
546  }
547 
548  fNeedNewData = false;
549  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const XML_Char XML_Encoding * info
Definition: expat.h:530
std::vector< std::string > fKBCList
Definition: BadChanList.h:137
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
std::string fValidityTagNearDet
Definition: BadChanList.h:127
std::string fBadChanCSVFile
Definition: BadChanList.h:103
TH2 * rh
Definition: drawXsec.C:5
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
const PlaneGeo * Plane(unsigned int i) const
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
bool Get(T &val) const
Definition: Column.h:85
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
bool fAbortIfNoneFound
Option to throw an exception if no channel rate state rows are returned from dB.
Definition: BadChanList.h:90
std::string fValidityTagFarDet
Definition: BadChanList.h:128
std::vector< std::unordered_set< int > > fDropOuts
[subrun][tchan]
Definition: BadChanList.h:116
Far Detector at Ash River, MN.
std::vector< geo::OfflineChan > fKnownBadChannels
Definition: BadChanList.h:138
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Geometry information for a single readout plane.
Definition: PlaneGeo.h:36
time_t fMaxVldTime
Maximum time used in database request.
Definition: BadChanList.h:123
Near Detector in the NuMI cavern.
caf::StandardRecord * sr
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:80
#define LOG_WARNING(category)
std::string fFEBDropoutTag
Definition: BadChanList.h:129
A (plane, cell) pair.
Definition: OfflineChan.h:17
time_t fMinVldTime
Minimum time used in database request.
Definition: BadChanList.h:121
void geom(int which=0)
Definition: geom.C:163
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
unsigned int NPlanes() const
#define LOG_INFO(stream)
Definition: Messenger.h:144
uint32_t dchan
< DAQ Channel Map Package
std::vector< std::unordered_set< geo::OfflineChan > > fBadChans
Vector index is the subrun number, set contains all the bad channels.
Definition: BadChanList.h:115
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
int RunNumber() const
Definition: RunHistory.h:374
#define LOG_ERROR(stream)
Definition: Messenger.h:129
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
int chaninfo::BadChanList::NBadInSubRun ( int  i)

Definition at line 206 of file BadChanList_service.cc.

References getBrightness::cell, nova::dbi::RunHistory::DiBlock::dcm, geo::GeometryBase::DetId(), runNovaSAM::detId, daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), fEventCheck, fNBadSR, fNeedNewData, fRun, fSubRun, geom(), daqchannelmap::DAQChannelMap::getCell(), nova::dbi::RunHistory::GetDiBlock(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPlane(), IsBad(), nova::dbi::RunHistory::IsGoodDiBlock(), LoadNewData(), nova::dbi::RunHistory::NDiBlocks(), nova::dbi::RunHistory::NSubruns(), nova::dbi::RunHistory::DiBlock::num, NDAPDHVSetting::plane, rh, and nova::dbi::RunHistory::RunNumber().

Referenced by chaninfo::PedestalThresholdValidation::analyze(), and caf::CAFMaker::produce().

207  {
209 
210  if (isr > rh->NSubruns()) return 0;
211 
212  if (fNeedNewData) LoadNewData();
213 
215  int detId = geom->DetId();
217 
218  if(fNBadSR >= 0) return fNBadSR;
219 
220  // Otherwise, look up the answer
221  int nbad=0;
222  int fRun_save = fRun;
223  int fSubRun_save = fSubRun;
224  fRun = rh->RunNumber();
225  fSubRun = isr;
226 
227  // turn off event checking here, turn it back on when we're done
228  // counting bad channels
229  bool fEventCheck_save = fEventCheck;
230  fEventCheck = false;
231 
232  for (int idb=0; idb<rh->NDiBlocks(); ++idb) {
233  nova::dbi::RunHistory::DiBlock dblk = rh->GetDiBlock(idb,false);
234 
235  if (!rh->IsGoodDiBlock(dblk.num)) continue;
236 
237  for (unsigned int idcm=0; idcm<dblk.dcm.size(); ++idcm) {
238  for (unsigned int ifeb=0; ifeb<dblk.dcm[idcm].feb.size(); ++ifeb) {
239  if (dblk.dcm[idcm].feb[ifeb].hasAPD) {
240  for (int ipix=0; ipix<=31; ++ipix) {
241  //for (int ipix=1; ipix<=32; ++ipix) {
242  daqchannelmap::dchan daqChan = daqmap->encodeDChan(detId,
243  dblk.num,
244  idcm+1,
245  ifeb,
246  ipix);
247  daqchannelmap::lchan logChan = daqmap->encodeLChan(daqChan);
248 
249  int plane = daqmap->getPlane(logChan);
250  int cell = daqmap->getCell(logChan);
251  if (IsBad(plane,cell)) ++nbad;
252  } // end loop over pixels
253  } // end if hasAPD
254  } // end loop over FEBs
255  } // end loop over DCMs
256  } // end loop over DiBlocks
257 
258  fEventCheck = fEventCheck_save;
259  fNBadSR = nbad;
260 
261  fRun = fRun_save;
262  fSubRun = fSubRun_save;
263 
264  return fNBadSR;
265  }
int NDiBlocks()
gives number of active diblocks only, may be less than 14
Definition: RunHistory.h:394
TH2 * rh
Definition: drawXsec.C:5
DiBlock GetDiBlock(int i, bool loadAll=true)
get ith diblock is RH list (which only includes diblocks with activity), starting with i=0...
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:105
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
bool IsGoodDiBlock(int idb, int subrun=-1)
std::vector< DCM > dcm
Definition: RunHistory.h:311
void geom(int which=0)
Definition: geom.C:163
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
uint32_t dchan
< DAQ Channel Map Package
bool IsBad(int plane, int cell)
int RunNumber() const
Definition: RunHistory.h:374
void chaninfo::BadChanList::postBeginSubRun ( art::SubRun const &  subrun)

Definition at line 111 of file BadChanList_service.cc.

References fAbortIfNoSubrun, fIsBadCacheValid, fMCRunNumber, fMCSubrunNumber, fNBadSR, fSubRun, LOG_DEBUG, nova::dbi::RunHistory::NSubruns(), rh, sr, and art::SubRun::subRun().

Referenced by BadChanList().

112  {
114  if (rh->NSubruns() == 0) {
115  LOG_DEBUG("BadChanList") << "RunHistory thinks there are no subruns in this run.";
116  if (fAbortIfNoSubrun)
117  std::abort();
118  }
119 
120  int sr = subrun.subRun();
121 
122  if (fMCRunNumber > 0) {
123  sr = fMCSubrunNumber;
124  }
125 
126  fSubRun = sr;
127 
128  fNBadSR = -1;
129 
130  // As per Teresa Lackey on Slack #nova-offline, 2019-06-10, confirmed by
131  // Jon Paley, the badness status of a channel can only change at subrun
132  // boundaries, or perhaps even less often. Therefore invalidate the cache
133  // at subrun boundaries. Since most production jobs process only one subrun,
134  // trying to invalidate less often doesn't have much impact.
135  fIsBadCacheValid = false;
136  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TH2 * rh
Definition: drawXsec.C:5
caf::StandardRecord * sr
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:80
int fMCSubrunNumber
Subrun number for the MC.
Definition: BadChanList.h:81
void chaninfo::BadChanList::preBeginEvent ( art::Event const &  evt)

Definition at line 158 of file BadChanList_service.cc.

References plot_validation_datamc::c, CountDCMHits(), art::Handle< T >::failedToGet(), fCellHitLabel, chaninfo::FD_NUM_CELLS, chaninfo::FD_NUM_PLANES, fEventCheck, fIsBadCache, fIsBadCacheValid, fRawDigitLabel, geom(), IsBadUncached(), LOG_ERROR, LOG_INFO, geo::PlaneGeo::Ncells(), geo::GeometryBase::NPlanes(), and geo::GeometryBase::Plane().

Referenced by BadChanList().

159  {
160  if(fEventCheck) { // check for dropped DCMs every event
162  event.getByLabel(fRawDigitLabel, digitcol);
163 
164  // We prefer to use the raw digits, but if they've been dropped from the
165  // file we will try the CellHits instead.
166  if(digitcol.failedToGet()){
168  event.getByLabel(fCellHitLabel, chitcol);
169  if(!chitcol.failedToGet()){
170  CountDCMHits(*chitcol);
171  }
172  }
173  else{
174  CountDCMHits(*digitcol);
175  }
176  } // end looking for dropped DCMs
177 
178  if(!fIsBadCacheValid){
179  // turn off event checking here, turn it back on when we're done
180  // building cache
181  bool fEventCheck_save = fEventCheck;
182  fEventCheck = false;
183 
185  const unsigned int nplane = geom->NPlanes();
186 
187  LOG_INFO("BadChanList") << "Initializing bad cell cache for " << nplane << " planes";
188 
189  if(nplane > FD_NUM_PLANES)
190  LOG_ERROR("BadChanList") << "Too many planes " << nplane;
191 
192  for(unsigned int p = 0; p < nplane && p < FD_NUM_PLANES; p++){
193  const unsigned int ncell = geom->Plane(p)->Ncells();
194  if(ncell > FD_NUM_CELLS)
195  LOG_ERROR("BadChanList") << p << ", too many cells: " << ncell;
196 
197  for(unsigned int c = 0; c < ncell && c < FD_NUM_CELLS; c++)
198  fIsBadCache[p*FD_NUM_CELLS + c] = IsBadUncached(p, c);
199  }
200  fIsBadCacheValid = true;
201  fEventCheck = fEventCheck_save;
202  }
203  }
const size_t FD_NUM_CELLS
Definition: BadChanList.h:34
const char * p
Definition: xmltok.h:285
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const PlaneGeo * Plane(unsigned int i) const
void CountDCMHits(const std::vector< T > &digitcol)
std::bitset< FD_NUM_PLANES *FD_NUM_CELLS > fIsBadCache
Definition: BadChanList.h:145
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:105
std::string fRawDigitLabel
what is the name of the raw digits ART object
Definition: BadChanList.h:107
const size_t FD_NUM_PLANES
Definition: BadChanList.h:33
std::string fCellHitLabel
Definition: BadChanList.h:108
void geom(int which=0)
Definition: geom.C:163
unsigned int NPlanes() const
#define LOG_INFO(stream)
Definition: Messenger.h:144
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool failedToGet() const
Definition: Handle.h:196
bool IsBadUncached(int plane, int cell)
void chaninfo::BadChanList::preBeginRun ( art::Run const &  run)

Definition at line 81 of file BadChanList_service.cc.

References fAbortOnSmallRunNum, fIsPerfect, fMCRunNumber, fNBadSR, fNeedNewData, fRun, LOG_DEBUG, and art::Run::run().

Referenced by BadChanList().

82  {
83  fRun = run.run();
84  if (fMCRunNumber > 0) {
86  }
87 
88  if (fRun >= 1000000)
89  fIsPerfect=true;
90  else if (fRun < 10000) {
92  LOG_DEBUG("BadChanList") <<"Bad Channels found a run number below 10000. This should never happen and is dangerous.";
93  std::abort();
94  }
95  else
96  fIsPerfect=true;
97  }
98  else
99  fIsPerfect=false;
100 
101  fNeedNewData = true;
102 
103  LOG_DEBUG("BadChanList")
104  << "Run in BCL is: " << fRun << " " << fNeedNewData;
105 
106  fNBadSR = -1;
107 
108  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
Definition: run.py:1
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:80
void chaninfo::BadChanList::reconfigure ( fhicl::ParameterSet  p)

Definition at line 332 of file BadChanList_service.cc.

References fAbortIfNoneFound, fAbortIfNoSubrun, fAbortOnSmallRunNum, fApplyBadChan, fApplyFEBDropout, fBadChanCSVFile, fCellHitLabel, fEventCheck, fFEBDropoutTag, fKBCList, fMCRunNumber, fMCSubrunNumber, fNewCosmicEffTable, fPedestalThresholdHigh, fPedestalThresholdLow, fRandomBadChannelFraction, fRawDigitLabel, fValidityTagFarDet, fValidityTagNearDet, fVldRunGrouping, fhicl::ParameterSet::get(), and LOG_ERROR.

Referenced by BadChanList().

333  {
334  fApplyBadChan = pset.get<int>("ApplyBadChan");
335  fMCRunNumber = pset.get<int>("MCRunNumber");
336  fMCSubrunNumber = pset.get<int>("MCSubrunNumber");
337  fNewCosmicEffTable = pset.get<bool>("NewCosmicEffTable");
338  fRandomBadChannelFraction= pset.get<float>("RandomBadChannelFraction");
339  fBadChanCSVFile = pset.get<std::string>("BadChanCSVFile");
340  fValidityTagNearDet = pset.get<std::string>("ValidityTagNearDet");
341  fValidityTagFarDet = pset.get<std::string>("ValidityTagFarDet");
342  fAbortIfNoneFound = pset.get<bool>("AbortIfNoneFound");
343  fAbortOnSmallRunNum = pset.get<bool>("AbortOnSmallRunNum");
344  fAbortIfNoSubrun = pset.get<bool>("AbortIfNoSubrun");
345  fEventCheck = pset.get<bool>("EventCheck");
346  fRawDigitLabel = pset.get<std::string>("RawDigitLabel");
347  fCellHitLabel = pset.get<std::string>("CellHitLabel");
348  fApplyFEBDropout = pset.get<bool>("ApplyFEBDropout");
349  fFEBDropoutTag = pset.get<std::string>("FEBDropoutTag");
350  fVldRunGrouping = pset.get<int>("VldRunGrouping");
351  fPedestalThresholdLow = pset.get<int>("PedestalThresholdLow");
352  fPedestalThresholdHigh = pset.get<int>("PedestalThresholdHigh");
353 
354  bool applyKBC = pset.get<bool>("ApplyKnownBadChannels");
355 
356  if (!fValidityTagNearDet.empty()) {
357  float tagNum = atof(fValidityTagNearDet.substr(1).c_str());
358  if (tagNum < 9.0) {
359  LOG_ERROR("BadChanList")<<"This version of Bad Channels requires tag >= 9.0";
360  std::abort();
361  }
362  }
363 
364  if (!fValidityTagFarDet.empty()) {
365  float tagNum = atof(fValidityTagFarDet.substr(1).c_str());
366  if (tagNum < 9.0) {
367  LOG_ERROR("BadChanList")<<"This version of Bad Channels requires tag >= 9.0";
368  std::abort();
369  }
370  }
371 
372  fKBCList.clear();
373  if (applyKBC)
374  fKBCList = pset.get<std::vector<std::string> >("KnownBadChannels");
375 
376  }
std::vector< std::string > fKBCList
Definition: BadChanList.h:137
std::string fValidityTagNearDet
Definition: BadChanList.h:127
std::string fBadChanCSVFile
Definition: BadChanList.h:103
bool fAbortIfNoneFound
Option to throw an exception if no channel rate state rows are returned from dB.
Definition: BadChanList.h:90
std::string fValidityTagFarDet
Definition: BadChanList.h:128
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:112
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:105
bool fNewCosmicEffTable
Use new-style table?
Definition: BadChanList.h:110
std::string fRawDigitLabel
what is the name of the raw digits ART object
Definition: BadChanList.h:107
std::string fCellHitLabel
Definition: BadChanList.h:108
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:80
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string fFEBDropoutTag
Definition: BadChanList.h:129
int fMCSubrunNumber
Subrun number for the MC.
Definition: BadChanList.h:81
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:79
#define LOG_ERROR(stream)
Definition: Messenger.h:129
void chaninfo::BadChanList::SetRandomBadChannels ( )
private

Definition at line 268 of file BadChanList_service.cc.

References getBrightness::cell, febshutoff_auto::chan, fFlatRand, fLowEfficiency, fRandomBadChannelFraction, fRandomBCMap, geom(), geo::GeometryBase::GetPlanesByView(), LOG_ERROR, geo::PlaneGeo::Ncells(), geo::GeometryBase::Plane(), and NDAPDHVSetting::plane.

Referenced by IsBadUncached().

269  {
270  if (!fRandomBCMap.empty()) return;
271 
272  LOG_ERROR("BadChanList")<< " RANDOM BAD CHANNELS at rate "
274 
275  fLowEfficiency.clear();
276 
278  for(unsigned int plane: geom->GetPlanesByView()){
279  const unsigned int nCells = geom->Plane(plane)->Ncells();
280 
281  for(unsigned int cell = 0; cell < nCells; ++cell){
283  if(fFlatRand->fire() < fRandomBadChannelFraction){
284  fRandomBCMap.insert(chan);
285  }
286  }
287  }
288  }
std::unordered_set< geo::OfflineChan > fRandomBCMap
random bad channel map
Definition: BadChanList.h:101
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const PlaneGeo * Plane(unsigned int i) const
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:112
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:100
A (plane, cell) pair.
Definition: OfflineChan.h:17
const std::set< unsigned int > & GetPlanesByView(View_t v=kXorY) const
void geom(int which=0)
Definition: geom.C:163
std::unique_ptr< CLHEP::RandFlat > fFlatRand
Definition: BadChanList.h:133
#define LOG_ERROR(stream)
Definition: Messenger.h:129

Member Data Documentation

bool chaninfo::BadChanList::fAbortIfNoneFound
private

Option to throw an exception if no channel rate state rows are returned from dB.

Definition at line 90 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

bool chaninfo::BadChanList::fAbortIfNoSubrun
private

Definition at line 98 of file BadChanList.h.

Referenced by postBeginSubRun(), and reconfigure().

bool chaninfo::BadChanList::fAbortOnSmallRunNum
private

Definition at line 96 of file BadChanList.h.

Referenced by preBeginRun(), and reconfigure().

int chaninfo::BadChanList::fApplyBadChan
private

Option to activate the bad channels.

Definition at line 79 of file BadChanList.h.

Referenced by IsBadUncached(), IsLowEfficiency(), and reconfigure().

bool chaninfo::BadChanList::fApplyFEBDropout
private

Definition at line 131 of file BadChanList.h.

Referenced by IsBadUncached(), LoadNewData(), and reconfigure().

std::string chaninfo::BadChanList::fBadChanCSVFile
private

Definition at line 103 of file BadChanList.h.

Referenced by IsBadUncached(), LoadNewData(), and reconfigure().

std::vector<std::unordered_set<geo::OfflineChan> > chaninfo::BadChanList::fBadChans
private

Vector index is the subrun number, set contains all the bad channels.

Definition at line 115 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

std::string chaninfo::BadChanList::fCellHitLabel
private

Definition at line 108 of file BadChanList.h.

Referenced by preBeginEvent(), and reconfigure().

int chaninfo::BadChanList::fDCMHits[12][14]
private

count hits in each DCM each event to look for dropped DCMs

Definition at line 135 of file BadChanList.h.

Referenced by BadChanList(), CountDCMHits(), and InDroppedDCM().

std::vector<std::unordered_set<int> > chaninfo::BadChanList::fDropOuts
private

[subrun][tchan]

Definition at line 116 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

bool chaninfo::BadChanList::fEventCheck
private

do we check each event for dropped DCMs?

Definition at line 105 of file BadChanList.h.

Referenced by InDroppedDCM(), NBadInSubRun(), preBeginEvent(), and reconfigure().

std::string chaninfo::BadChanList::fFEBDropoutTag
private

Definition at line 129 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

std::unique_ptr<CLHEP::RandFlat> chaninfo::BadChanList::fFlatRand
private

Definition at line 133 of file BadChanList.h.

Referenced by BadChanList(), and SetRandomBadChannels().

std::bitset<FD_NUM_PLANES*FD_NUM_CELLS> chaninfo::BadChanList::fIsBadCache
private

Definition at line 145 of file BadChanList.h.

Referenced by BadChanList(), IsBad(), and preBeginEvent().

bool chaninfo::BadChanList::fIsBadCacheValid
private

Definition at line 146 of file BadChanList.h.

Referenced by BadChanList(), postBeginSubRun(), and preBeginEvent().

bool chaninfo::BadChanList::fIsPerfect
private

Definition at line 94 of file BadChanList.h.

Referenced by BadChanList(), IsBadUncached(), LoadNewData(), and preBeginRun().

std::vector<std::string> chaninfo::BadChanList::fKBCList
private

Definition at line 137 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

std::vector<geo::OfflineChan> chaninfo::BadChanList::fKnownBadChannels
private

Definition at line 138 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

std::unordered_set<geo::OfflineChan> chaninfo::BadChanList::fLowEfficiency
private

set of low eff channels

Definition at line 100 of file BadChanList.h.

Referenced by IsLowEfficiency(), LoadCosmicEff(), and SetRandomBadChannels().

time_t chaninfo::BadChanList::fMaxVldTime
private

Maximum time used in database request.

Definition at line 123 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

int chaninfo::BadChanList::fMCRunNumber
private

Run number for the MC.

Definition at line 80 of file BadChanList.h.

Referenced by BadChanList(), LoadNewData(), postBeginSubRun(), preBeginRun(), and reconfigure().

int chaninfo::BadChanList::fMCSubrunNumber
private

Subrun number for the MC.

Definition at line 81 of file BadChanList.h.

Referenced by BadChanList(), postBeginSubRun(), and reconfigure().

time_t chaninfo::BadChanList::fMinVldTime
private

Minimum time used in database request.

Definition at line 121 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

int chaninfo::BadChanList::fNBadSR
private

Definition at line 83 of file BadChanList.h.

Referenced by BadChanList(), NBadInSubRun(), postBeginSubRun(), and preBeginRun().

bool chaninfo::BadChanList::fNeedNewData
private

Definition at line 92 of file BadChanList.h.

Referenced by BadChanList(), IsBadUncached(), LoadNewData(), NBadInSubRun(), and preBeginRun().

bool chaninfo::BadChanList::fNewCosmicEffTable
private

Use new-style table?

Definition at line 110 of file BadChanList.h.

Referenced by LoadCosmicEff(), and reconfigure().

int chaninfo::BadChanList::fPedestalThresholdHigh
private

Definition at line 88 of file BadChanList.h.

Referenced by IsBadUncached(), and reconfigure().

int chaninfo::BadChanList::fPedestalThresholdLow
private

Definition at line 87 of file BadChanList.h.

Referenced by IsBadUncached(), and reconfigure().

float chaninfo::BadChanList::fRandomBadChannelFraction
private

If >0, ignore DB and set this fraction bad at random.

Definition at line 112 of file BadChanList.h.

Referenced by IsBadUncached(), reconfigure(), and SetRandomBadChannels().

std::unordered_set<geo::OfflineChan> chaninfo::BadChanList::fRandomBCMap
private

random bad channel map

Definition at line 101 of file BadChanList.h.

Referenced by BadChanList(), IsBadUncached(), and SetRandomBadChannels().

std::string chaninfo::BadChanList::fRawDigitLabel
private

what is the name of the raw digits ART object

Definition at line 107 of file BadChanList.h.

Referenced by preBeginEvent(), and reconfigure().

int chaninfo::BadChanList::fRun
private

Definition at line 118 of file BadChanList.h.

Referenced by IsBadUncached(), LoadNewData(), NBadInSubRun(), and preBeginRun().

int chaninfo::BadChanList::fSubRun
private

Definition at line 119 of file BadChanList.h.

Referenced by IsBadUncached(), NBadInSubRun(), and postBeginSubRun().

std::string chaninfo::BadChanList::fValidityTagFarDet
private

Definition at line 128 of file BadChanList.h.

Referenced by BadChanList(), LoadNewData(), and reconfigure().

std::string chaninfo::BadChanList::fValidityTagNearDet
private

Definition at line 127 of file BadChanList.h.

Referenced by BadChanList(), LoadNewData(), and reconfigure().

int chaninfo::BadChanList::fVldRunGrouping
private

Definition at line 85 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().


The documentation for this class was generated from the following files: