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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-14/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, art::ScheduleContext)
 
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

void CacheBadChannels ()
 
bool IsBadUncached (int plane, int cell, bool doDCMCheck=true)
 
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...
 
bool fDroppedDCMCacheValid
 
std::vector< std::stringfKBCList
 
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 42 of file BadChanList_service.cc.

References fDCMHits, fDroppedDCMCacheValid, 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.

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

Definition at line 77 of file BadChanList_service.cc.

78  {
79  }

Member Function Documentation

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

Definition at line 718 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().

719  {
721  int ch;
723  for(unsigned int i=0; i<rd.size(); ++i) {
724  int plane = cmap->GetPlane(rd[i].get());
725  int cell = cmap->GetCell(rd[i].get());
726  if(!IsBad(plane,cell)) good.push_back(rd[i]);
727  }
728  rd.swap(good);
729  ch=rd.size();
730  return ch;
731  }
void swap(PtrVector &other)
Definition: PtrVector.h:518
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
size_type size() const
Definition: PtrVector.h:302
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 701 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.

702  {
704  int ch;
705  std::vector< art::Ptr<rawdata::RawDigit> > good;
706  for(unsigned int i=0; i<rd.size(); ++i) {
707  int plane = cmap->GetPlane(rd[i].get());
708  int cell = cmap->GetCell(rd[i].get());
709  if(!IsBad(plane,cell)) good.push_back(rd[i]);
710  }
711  rd.swap(good);
712  ch=rd.size();
713  return ch;
714  }
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 735 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.

736  {
738  int ch;
739  std::vector<const rawdata::RawDigit*> good;
740  for(unsigned int i=0; i<rd.size(); ++i) {
741  int plane = cmap->GetPlane(rd[i]);
742  int cell = cmap->GetCell(rd[i]);
743  if(!IsBad(plane,cell)) good.push_back(rd[i]);
744  }
745  rd.swap(good);
746  ch=rd.size();
747  return ch;
748  }
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)
void chaninfo::BadChanList::CacheBadChannels ( )
private

Definition at line 195 of file BadChanList_service.cc.

References plot_validation_datamc::c, chaninfo::FD_NUM_CELLS, chaninfo::FD_NUM_PLANES, fIsBadCache, fIsBadCacheValid, geom(), IsBadUncached(), MF_LOG_ERROR, MF_LOG_INFO, geo::PlaneGeo::Ncells(), geo::GeometryBase::NPlanes(), and geo::GeometryBase::Plane().

Referenced by IsBad().

196  {
198  const unsigned int nplane = geom->NPlanes();
199 
200  MF_LOG_INFO("BadChanList") << "Initializing bad cell cache for " << nplane << " planes";
201 
202  if(nplane > FD_NUM_PLANES)
203  MF_LOG_ERROR("BadChanList") << "Too many planes " << nplane;
204 
205  for(unsigned int p = 0; p < nplane && p < FD_NUM_PLANES; p++){
206  const unsigned int ncell = geom->Plane(p)->Ncells();
207  if(ncell > FD_NUM_CELLS)
208  MF_LOG_ERROR("BadChanList") << p << ", too many cells: " << ncell;
209 
210  for(unsigned int c = 0; c < ncell && c < FD_NUM_CELLS; c++)
211  fIsBadCache[p*FD_NUM_CELLS + c] = IsBadUncached(p, c, false); // false = Skip DCM check
212  }
213  fIsBadCacheValid = true;
214  }
bool IsBadUncached(int plane, int cell, bool doDCMCheck=true)
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
#define MF_LOG_ERROR(category)
const PlaneGeo * Plane(unsigned int i) const
std::bitset< FD_NUM_PLANES *FD_NUM_CELLS > fIsBadCache
Definition: BadChanList.h:151
const size_t FD_NUM_PLANES
Definition: BadChanList.h:33
#define MF_LOG_INFO(category)
void geom(int which=0)
Definition: geom.C:163
unsigned int NPlanes() const
template<class T >
void chaninfo::BadChanList::CountDCMHits ( const std::vector< T > &  digitcol)
private

Definition at line 140 of file BadChanList_service.cc.

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

Referenced by preBeginEvent().

141  {
142  for(int i = 0; i < 12; i++) { // re-initialize every event
143  for(int j = 0; j < 14; j++) { // just keep array sized 12 x 14; for ND we just won't use it all
144  fDCMHits[i][j] = 0;
145  }
146  }
147  int dib, dcm;
150  for(const T& digit: digitcol){
151  // count the number of raw digit hits in each DCM
152  dcm = daqmap->getDCM(digit.DaqChannel());
153  dib = daqmap->getDiBlock(digit.DaqChannel());
154  fDCMHits[dcm-1][dib-1]++;
155  }
156 
157  fDroppedDCMCacheValid = true;
158  }
int fDCMHits[12][14]
count hits in each DCM each event to look for dropped DCMs
Definition: BadChanList.h:140
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 577 of file BadChanList_service.cc.

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

Referenced by IsBad(), and IsBadUncached().

578  {
579  if(!fEventCheck) return false;
580 
581  if (!fDroppedDCMCacheValid) {
582  // The missing DCM info was not loaded during preBeginEvent, so
583  // the required data products must be missing.
584  MF_LOG_ERROR("BadChanList") << "EventCheck requested, but neither "
585  << fRawDigitLabel << " nor " << fCellHitLabel
586  << " could be found.";
587  std::abort();
588  }
589 
592  uint32_t dchan = daqmap->encodeDChan(daqmap->encodeLChan(geom->DetId(), plane, cell));
593  if(fDCMHits[daqmap->getDCM(dchan)-1][daqmap->getDiBlock(dchan)-1]==0) {
594  //***
595  MF_LOG_DEBUG("BadChanList") << "Dropped DCM";
596  //***
597  return true;
598  }
599  return false;
600  }
int fDCMHits[12][14]
count hits in each DCM each event to look for dropped DCMs
Definition: BadChanList.h:140
#define MF_LOG_ERROR(category)
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:110
static DAQChannelMap * getInstance(int detID)
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
std::string fRawDigitLabel
what is the name of the raw digits ART object
Definition: BadChanList.h:112
std::string fCellHitLabel
Definition: BadChanList.h:113
void geom(int which=0)
Definition: geom.C:163
#define MF_LOG_DEBUG(id)
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 
)

Definition at line 563 of file BadChanList_service.cc.

References CacheBadChannels(), getBrightness::cell, fApplyBadChan, chaninfo::FD_NUM_CELLS, fIsBadCache, fIsBadCacheValid, fIsPerfect, and InDroppedDCM().

Referenced by calib::PEResponse::analyze(), Apply(), chaninfo::BadChanValidate::BadChansFromDB(), trk::KalmanTrack::CheckTrack(), trk::KalmanGeoHelper::CountMissedCellsOnLine(), dt::ViewMerger::CountUnexplainedOnLine(), evd::GeometryDrawer::DrawCells2D(), chaninfo::CosmicEff::endJob(), rsim::RecordNoiseSpectrumFile::endSubRun(), LightLevels::endSubRun(), trk::KalmanTrack::FilterTracker(), geo::LiveGeometry::GetBCInfo(), calib::HasXYAdjacents(), dt::DiscreteTracker::HighActivity(), NBadInSubRun(), trk::KalmanTrack::produce(), calhit::RemoveBadChannels::produce(), calhit::CalHit::produce(), hough::MultiHoughT::Scrub(), earms::ElasticArmsHS::Scrub(), vdt::VertexDT::Scrub(), fuzz::FuzzyKVertex::Scrub(), and dt::View::View().

564  {
565  if (!fApplyBadChan) return false;
566  if (fIsPerfect) return false;
567 
568  if(InDroppedDCM(plane, cell)) return true;
569 
570  // Fill the cache if needed
572 
574  }
const size_t FD_NUM_CELLS
Definition: BadChanList.h:34
std::bitset< FD_NUM_PLANES *FD_NUM_CELLS > fIsBadCache
Definition: BadChanList.h:151
bool InDroppedDCM(int plane, int cell)
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:84
bool chaninfo::BadChanList::IsBadUncached ( int  plane,
int  cell,
bool  doDCMCheck = true 
)
private

Definition at line 603 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(), MF_LOG_DEBUG, MF_LOG_WARNING, nova::dbi::RunHistory::NSubruns(), NDAPDHVSetting::plane, rh, SetRandomBadChannels(), and sr.

Referenced by CacheBadChannels().

604  {
605  if (!fApplyBadChan) return false;
606  if (fIsPerfect) return false;
607 
609 
610  for (auto kbc : fKnownBadChannels) {
611  if (kbc == chan) {
612  //***
613  MF_LOG_DEBUG("BadChanList") << "BadChanList_service: known bad channel!";
614  //***
615  return true;
616  }
617  }
618 
621  return fRandomBCMap.count(chan);
622  }
623 
624  if (fNeedNewData) LoadNewData();
625 
628 
629  const int sr = fSubRun%rh->NSubruns();
630  const time_t evtTime = fRun*10000 + sr*100 + 1;
631 
632  // check if event time within validity range, i.e. sane
633  if ( fBadChanCSVFile.empty() && (evtTime < fMinVldTime || evtTime > fMaxVldTime)){
634  throw cet::exception("BadChanList")
635  << "Event time is outside the validity range of the database request. "
636  << fMinVldTime << " " << evtTime << " " << fMaxVldTime
637  << " Database request does not contain complete information, "
638  << "which could lead to unpredictable behavior.";
639  }
640 
641  if(doDCMCheck && InDroppedDCM(plane, cell)) return true;
642 
643  // check with RH whether this channel was instrumented, part of the partition, or masked
644  if (!rh->HasAPD(chan)) {
645  //***
646  MF_LOG_DEBUG("BadChanList") << "Mmissing APD";
647  //***
648  return true;
649  }
650  // for now, just deal with dB tables for the FarDet and NearDet
651  if (geom->DetId() == novadaq::cnv::kFARDET ||
652  geom->DetId() == novadaq::cnv::kNEARDET) {
653 
654  assert((unsigned int)sr < fBadChans.size());
655  if(fBadChans[sr].count(chan)) return true;
656 
657  if (fApplyFEBDropout) {
659  daqchannelmap::lchan logChan = daqcmap->encodeLChan(geom->DetId(),plane,cell);
660  daqchannelmap::dchan daqChan = daqcmap->encodeDChan(logChan);
661 
662  int db = daqcmap->getDiBlock(daqChan);
663  int dcm = daqcmap->getDCM(daqChan);
664  int feb = daqcmap->getFEB(daqChan);
665 
666  int tchan = db*1000+(dcm-1)*64+feb;
667 
668  assert((unsigned int)sr < fDropOuts.size());
669  if(fDropOuts[sr].count(tchan)) return true;
670  }
671  }
672 
673  // check if we should mask off channels with too low or too high of a pedestal
674  if (fPedestalThresholdLow > 0) {
675  bool pedok;
676  int ped = rh->GetPedestal(chan,pedok);
677  if (pedok) {
678  if (ped < fPedestalThresholdLow ||
680  return true;
681  }
682  else {
683  MF_LOG_WARNING("BadChanList") << "******** Failed to get a pedestal for found channel (" << plane << "," << cell << ")";
684  }
685  }
686  // If we can't find anything wrong with it then it must not be bad
687  return false;
688  }
std::string fBadChanCSVFile
Definition: BadChanList.h:108
TH2 * rh
Definition: drawXsec.C:5
std::unordered_set< geo::OfflineChan > fRandomBCMap
random bad channel map
Definition: BadChanList.h:106
::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:121
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:117
Far Detector at Ash River, MN.
std::vector< geo::OfflineChan > fKnownBadChannels
Definition: BadChanList.h:144
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:128
Near Detector in the NuMI cavern.
caf::StandardRecord * sr
bool InDroppedDCM(int plane, int cell)
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:126
void geom(int which=0)
Definition: geom.C:163
#define MF_LOG_DEBUG(id)
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:84
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
#define MF_LOG_WARNING(category)
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:120
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 691 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().

692  {
693  if(!fApplyBadChan) return false;
694 
696  return fLowEfficiency.count(chan);
697  }
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:105
A (plane, cell) pair.
Definition: OfflineChan.h:17
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:84
void chaninfo::BadChanList::LoadCosmicEff ( int  newrun,
int  newsubrun 
)
private

Definition at line 302 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(), MF_LOG_DEBUG, nova::dbi::Table::NRow(), NDAPDHVSetting::plane, nova::dbi::Table::SetValidityRange(), nova::dbi::Table::SetValiditySQL(), and nova::dbi::Table::SetVerbosity().

303  {
304  fLowEfficiency.clear();
305 
307  "/ChannelInfo/CosmicEffNew.xml" :
308  "/ChannelInfo/CosmicEff.xml");
309  tblEff.SetValidityRange("detector", "ndos");
310  tblEff.SetValiditySQL(TString::Format("(beginrun<%d or (beginrun=%d and beginsubrun<=%d)) and "
311  "(endrun>%d or (endrun=%d and endsubrun>=%d))",
312  newrun, newrun, newsubrun, newrun, newrun, newsubrun).Data());
313  // }
314 
315  // Only ask for the bad channels. We won't get any "good" ones back, so
316  // they won't go in the map, which is fine.
317  tblEff.SetValidityRange("good", false);
318 
319  tblEff.SetVerbosity(100);
320  const bool ok = tblEff.Load();
321  if(!ok){
322  // No safe way to handle this
323  MF_LOG_DEBUG("BadChanList") << "Couldn't load efficiencies channels from DB. Aborting" << std::endl;
324  std::abort();
325  }
326  int planeIdx = tblEff.GetColIndex("plane");
327  int cellIdx = tblEff.GetColIndex("cell");
328  int goodIdx = tblEff.GetColIndex("good");
329 
330  for(int i = 0; i < tblEff.NRow(); ++i){
331  int plane, cell;
332  bool good;
333  bool ok = tblEff.GetRow(i)->Col(planeIdx).Get(plane);
334  ok = ok && tblEff.GetRow(i)->Col(cellIdx).Get(cell);
335  ok = ok && tblEff.GetRow(i)->Col(goodIdx).Get(good);
336  if(!ok) std::abort();
337  geo::OfflineChan chan(plane, cell);
338  if(!good) fLowEfficiency.insert(chan);
339  }
340  }
bool fNewCosmicEffTable
Use new-style table?
Definition: BadChanList.h:115
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:105
A (plane, cell) pair.
Definition: OfflineChan.h:17
#define MF_LOG_DEBUG(id)
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 390 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(), cmap::dataprov::CMap::Map(), MF_LOG_DEBUG, MF_LOG_ERROR, MF_LOG_INFO, MF_LOG_WARNING, 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().

391  {
392  if (fIsPerfect) return;
393 
395 
396  if (!fKBCList.empty()) {
397 
398  fKnownBadChannels.clear();
400 
401  int idet = geom->DetId();
402  int db, dcm, feb, detId;
403  for (auto k : fKBCList) {
404  sscanf(k.c_str(),"%d-%02d-%02d-%02d",&detId,&db,&dcm,&feb);
405  if (detId == idet) {
406  MF_LOG_DEBUG("BadChanList")<< k << " is known to be bad, all associated channels masked off.";
407  for (int ipix=0; ipix<32; ++ipix) {
408  daqchannelmap::dchan daqChan = cmap->Map()->encodeDChan(idet,db,dcm,feb,ipix);
409  daqchannelmap::dchan logChan = cmap->Map()->encodeLChan(daqChan);
410  int plane = cmap->Map()->getPlane(logChan);
411  int cell = cmap->Map()->getCell(logChan);
412  fKnownBadChannels.push_back(geo::OfflineChan(plane,cell));
413  }
414  }
415  }
416  }
417 
418  fBadChans.clear();
419  fDropOuts.clear();
420 
421  nova::dbi::Table BCTable("/ChannelInfo/ChanRateState.xml");
422  BCTable.SetVerbosity(100);
423  BCTable.SetDetector(geom->DetId());
424  if (geom->DetId() == novadaq::cnv::kNEARDET) {
425  if (fValidityTagNearDet != "")
426  BCTable.SetTag(fValidityTagNearDet);
427  }
428  else if (geom->DetId() == novadaq::cnv::kFARDET) {
429  if (fValidityTagFarDet != "")
430  BCTable.SetTag(fValidityTagFarDet);
431  }
432 
433 
434  const int stateIdx = BCTable.GetColIndex("state");
435 
436  nova::dbi::Table FEBDOTable("/ChannelInfo/FEBDropout.xml");
437  FEBDOTable.SetVerbosity(100);
438  FEBDOTable.SetDetector(geom->DetId());
439  if (fFEBDropoutTag != "")
440  FEBDOTable.SetTag(fFEBDropoutTag);
441  const int FEBStateIdx = FEBDOTable.GetColIndex("state");
442 
443  if (!fBadChanCSVFile.empty())
444  {
445  BCTable.LoadFromCSV(fBadChanCSVFile);
446  MF_LOG_ERROR("BadChanList") << "Read " << BCTable.NRow()
447  << " BadChannel rows from "
448  << fBadChanCSVFile;
449  }
450  else
451  {
452  if (fMCRunNumber > 0)
453  {
455  fMinVldTime = rh.RunNumber()*10000 + 1;
456  fMaxVldTime = fMinVldTime + rh.NSubruns()*100;
457  }
458  else if (geom->DetId() == novadaq::cnv::kFARDET ||
459  geom->DetId() == novadaq::cnv::kNEARDET)
460  {
463  fMinVldTime = minrun*10000 + 1;
464  fMaxVldTime = fMinVldTime - 1 + fVldRunGrouping*10000;
465  }
466 
467  BCTable.SetDataTypeMask(nova::dbi::kMCOnly|nova::dbi::kDataOnly);
468  BCTable.SetMinTSVld(fMinVldTime);
469  BCTable.SetMaxTSVld(fMaxVldTime);
470 
471  if (!BCTable.Load()) {
472  MF_LOG_ERROR("BadChanList") <<"Bad Channels table failed to load data!";
473  std::abort();
474  }
475  if (BCTable.NRow() == 0) {
476  MF_LOG_ERROR("BadChanList") << "******** WARNING: BadChanList_service found no bad channels!";
477  if (fAbortIfNoneFound) {
478  MF_LOG_ERROR("BadChanList") << "Bad Channels table is empty, this should never happen!";
479  std::abort();
480  }
481  }
482 
483  if (fApplyFEBDropout && (geom->DetId() == novadaq::cnv::kNEARDET)) {
484  FEBDOTable.SetMinTSVld(fMinVldTime-480);
485  FEBDOTable.SetMaxTSVld(fMaxVldTime+480);
486  FEBDOTable.Load();
487  if (FEBDOTable.NRow() == 0) {
488  MF_LOG_WARNING("BadChanList") << "******** BadChanList_service found no FEB dropout data!";
489  }
490  }
491  }
492 
493  BCTable.FillChanRowMap();
494  FEBDOTable.FillChanRowMap();
495 
498  fBadChans.resize(rh->NSubruns());
499  fDropOuts.resize(rh->NSubruns());
500 
501  for(int subrun = 0; subrun < rh->NSubruns(); ++subrun){
502  const time_t evtTime = fRun*10000 + subrun*100 + 1;
503 
504  for(unsigned int plane = 0; plane < geom->NPlanes(); ++plane){
505  const geo::PlaneGeo* geoplane = geom->Plane(plane);
506  for(unsigned int cell = 0; cell < geoplane->Ncells(); ++cell){
507  const geo::OfflineChan chan(plane, cell);
508 
509  // get validity row for this timestamp
510  nova::dbi::Row* row = BCTable.GetVldRow(chan.ToDBValidityChan(),
511  evtTime);
512 
513  if(row){
514  // there is an entry for this timestamp (expected behavior), so
515  // make sure that the state is "ok" (==0)
516  int state;
517  const bool ok = row->Col(stateIdx).Get(state);
518  if(!ok) std::abort();
519  if(state != 0) {
520  fBadChans[subrun].insert(geo::OfflineChan(plane, cell));
521  }
522  } // end if row
523 
524  // Now the drop-out table
525 
526  // TODO - one could loop over all the FEBs more efficiently than
527  // this, but it doesn't really matter since this is once per run.
528 
529  daqchannelmap::lchan logChan = daqcmap->encodeLChan(geom->DetId(),
530  plane, cell);
531  daqchannelmap::dchan daqChan = daqcmap->encodeDChan(logChan);
532 
533  const int db = daqcmap->getDiBlock(daqChan);
534  const int dcm = daqcmap->getDCM(daqChan);
535  const int feb = daqcmap->getFEB(daqChan);
536 
537  const int tchan = db*1000+(dcm-1)*64+feb;
538 
539  row = FEBDOTable.GetVldRow(tchan, evtTime);
540 
541  if(row){
542  int state;
543  const bool ok = row->Col(FEBStateIdx).Get(state);
544  if(!ok) std::abort();
545  // a state of "1" means the FEB is live at this point
546  if(state != 1) fDropOuts[subrun].insert(tchan);
547  }
548  } // end for cell
549  } // end for plane
550  } // end for subrun
551 
552  auto info = MF_LOG_INFO("BadChanList");
553  for(int sr = 0; sr < rh->NSubruns(); ++sr){
554  info << "Subrun " << sr << ": "
555  << fBadChans[sr].size() << " bad channels, "
556  << fDropOuts[sr].size() << " DCM dropouts.\n";
557  }
558 
559  fNeedNewData = false;
560  }
const XML_Char XML_Encoding * info
Definition: expat.h:530
std::vector< std::string > fKBCList
Definition: BadChanList.h:143
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:132
std::string fBadChanCSVFile
Definition: BadChanList.h:108
TH2 * rh
Definition: drawXsec.C:5
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
#define MF_LOG_ERROR(category)
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:95
std::string fValidityTagFarDet
Definition: BadChanList.h:133
std::vector< std::unordered_set< int > > fDropOuts
[subrun][tchan]
Definition: BadChanList.h:121
Far Detector at Ash River, MN.
std::vector< geo::OfflineChan > fKnownBadChannels
Definition: BadChanList.h:144
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:128
Near Detector in the NuMI cavern.
caf::StandardRecord * sr
#define MF_LOG_INFO(category)
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:85
std::string fFEBDropoutTag
Definition: BadChanList.h:134
A (plane, cell) pair.
Definition: OfflineChan.h:17
time_t fMinVldTime
Minimum time used in database request.
Definition: BadChanList.h:126
void geom(int which=0)
Definition: geom.C:163
#define MF_LOG_DEBUG(id)
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 MF_LOG_WARNING(category)
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:120
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
int RunNumber() const
Definition: RunHistory.h:374
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
int chaninfo::BadChanList::NBadInSubRun ( int  i)

Definition at line 217 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().

218  {
220 
221  if (isr > rh->NSubruns()) return 0;
222 
223  if (fNeedNewData) LoadNewData();
224 
226  int detId = geom->DetId();
228 
229  if(fNBadSR >= 0) return fNBadSR;
230 
231  // Otherwise, look up the answer
232  int nbad=0;
233  int fRun_save = fRun;
234  int fSubRun_save = fSubRun;
235  fRun = rh->RunNumber();
236  fSubRun = isr;
237 
238  // turn off event checking here, turn it back on when we're done
239  // counting bad channels
240  bool fEventCheck_save = fEventCheck;
241  fEventCheck = false;
242 
243  for (int idb=0; idb<rh->NDiBlocks(); ++idb) {
244  nova::dbi::RunHistory::DiBlock dblk = rh->GetDiBlock(idb,false);
245 
246  if (!rh->IsGoodDiBlock(dblk.num)) continue;
247 
248  for (unsigned int idcm=0; idcm<dblk.dcm.size(); ++idcm) {
249  for (unsigned int ifeb=0; ifeb<dblk.dcm[idcm].feb.size(); ++ifeb) {
250  if (dblk.dcm[idcm].feb[ifeb].hasAPD) {
251  for (int ipix=0; ipix<=31; ++ipix) {
252  //for (int ipix=1; ipix<=32; ++ipix) {
253  daqchannelmap::dchan daqChan = daqmap->encodeDChan(detId,
254  dblk.num,
255  idcm+1,
256  ifeb,
257  ipix);
258  daqchannelmap::lchan logChan = daqmap->encodeLChan(daqChan);
259 
260  int plane = daqmap->getPlane(logChan);
261  int cell = daqmap->getCell(logChan);
262  if (IsBad(plane,cell)) ++nbad;
263  } // end loop over pixels
264  } // end if hasAPD
265  } // end loop over FEBs
266  } // end loop over DCMs
267  } // end loop over DiBlocks
268 
269  fEventCheck = fEventCheck_save;
270  fNBadSR = nbad;
271 
272  fRun = fRun_save;
273  fSubRun = fSubRun_save;
274 
275  return fNBadSR;
276  }
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:110
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 112 of file BadChanList_service.cc.

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

Referenced by BadChanList().

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

Definition at line 161 of file BadChanList_service.cc.

References CountDCMHits(), allTimeWatchdog::endl, art::Handle< T >::failedToGet(), fCellHitLabel, fDroppedDCMCacheValid, fEventCheck, fRawDigitLabel, and MF_LOG_DEBUG.

Referenced by BadChanList().

163  {
164  // Each event, re-fill the missing DCM information
165  fDroppedDCMCacheValid = false;
166 
167  if(fEventCheck) {
168  // check for dropped DCMs every event. Must happen in preBeginEvent (rather than
169  // loading lazily) since we need access to the art::Event.
170 
171  // We prefer to use the raw digits, but if they've been dropped from the
172  // file we will try the CellHits instead. If neither is found,
173  // throw an exception.
175  event.getByLabel(fRawDigitLabel, digitcol);
176  if(!digitcol.failedToGet()){
177  MF_LOG_DEBUG("BadChanList") << "Finding missing DCMs with raw hit label " << fRawDigitLabel << std::endl;
178  CountDCMHits(*digitcol);
179  }
180  else{
182  event.getByLabel(fCellHitLabel, chitcol);
183  if(!chitcol.failedToGet()){
184  MF_LOG_DEBUG("BadChanList") << "Finding missing DCMs with cell hit label " << fCellHitLabel << std::endl;
185  CountDCMHits(*chitcol);
186  }
187  }
188  // If neither is found, do nothing for now, but fDroppedDCMCacheValid is
189  // still set to false, so if we try to access this information later
190  // we can throw an error.
191  } // end looking for dropped DCMs
192  }
void CountDCMHits(const std::vector< T > &digitcol)
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:110
std::string fRawDigitLabel
what is the name of the raw digits ART object
Definition: BadChanList.h:112
std::string fCellHitLabel
Definition: BadChanList.h:113
#define MF_LOG_DEBUG(id)
bool failedToGet() const
Definition: Handle.h:190
void chaninfo::BadChanList::preBeginRun ( art::Run const &  run)

Definition at line 82 of file BadChanList_service.cc.

References fAbortOnSmallRunNum, fIsPerfect, fMCRunNumber, fNBadSR, fNeedNewData, fRun, MF_LOG_DEBUG, and art::DataViewImpl::run().

Referenced by BadChanList().

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

Definition at line 343 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(), MF_LOG_ERROR, and string.

Referenced by BadChanList().

344  {
345  fApplyBadChan = pset.get<int>("ApplyBadChan");
346  fMCRunNumber = pset.get<int>("MCRunNumber");
347  fMCSubrunNumber = pset.get<int>("MCSubrunNumber");
348  fNewCosmicEffTable = pset.get<bool>("NewCosmicEffTable");
349  fRandomBadChannelFraction= pset.get<float>("RandomBadChannelFraction");
350  fBadChanCSVFile = pset.get<std::string>("BadChanCSVFile");
351  fValidityTagNearDet = pset.get<std::string>("ValidityTagNearDet");
352  fValidityTagFarDet = pset.get<std::string>("ValidityTagFarDet");
353  fAbortIfNoneFound = pset.get<bool>("AbortIfNoneFound");
354  fAbortOnSmallRunNum = pset.get<bool>("AbortOnSmallRunNum");
355  fAbortIfNoSubrun = pset.get<bool>("AbortIfNoSubrun");
356  fEventCheck = pset.get<bool>("EventCheck");
357  fRawDigitLabel = pset.get<std::string>("RawDigitLabel");
358  fCellHitLabel = pset.get<std::string>("CellHitLabel");
359  fApplyFEBDropout = pset.get<bool>("ApplyFEBDropout");
360  fFEBDropoutTag = pset.get<std::string>("FEBDropoutTag");
361  fVldRunGrouping = pset.get<int>("VldRunGrouping");
362  fPedestalThresholdLow = pset.get<int>("PedestalThresholdLow");
363  fPedestalThresholdHigh = pset.get<int>("PedestalThresholdHigh");
364 
365  bool applyKBC = pset.get<bool>("ApplyKnownBadChannels");
366 
367  if (!fValidityTagNearDet.empty()) {
368  float tagNum = atof(fValidityTagNearDet.substr(1).c_str());
369  if (tagNum < 9.0) {
370  MF_LOG_ERROR("BadChanList")<<"This version of Bad Channels requires tag >= 9.0";
371  std::abort();
372  }
373  }
374 
375  if (!fValidityTagFarDet.empty()) {
376  float tagNum = atof(fValidityTagFarDet.substr(1).c_str());
377  if (tagNum < 9.0) {
378  MF_LOG_ERROR("BadChanList")<<"This version of Bad Channels requires tag >= 9.0";
379  std::abort();
380  }
381  }
382 
383  fKBCList.clear();
384  if (applyKBC)
385  fKBCList = pset.get<std::vector<std::string> >("KnownBadChannels");
386 
387  }
std::vector< std::string > fKBCList
Definition: BadChanList.h:143
std::string fValidityTagNearDet
Definition: BadChanList.h:132
std::string fBadChanCSVFile
Definition: BadChanList.h:108
#define MF_LOG_ERROR(category)
bool fAbortIfNoneFound
Option to throw an exception if no channel rate state rows are returned from dB.
Definition: BadChanList.h:95
std::string fValidityTagFarDet
Definition: BadChanList.h:133
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:117
bool fEventCheck
do we check each event for dropped DCMs?
Definition: BadChanList.h:110
bool fNewCosmicEffTable
Use new-style table?
Definition: BadChanList.h:115
std::string fRawDigitLabel
what is the name of the raw digits ART object
Definition: BadChanList.h:112
std::string fCellHitLabel
Definition: BadChanList.h:113
int fMCRunNumber
Run number for the MC.
Definition: BadChanList.h:85
std::string fFEBDropoutTag
Definition: BadChanList.h:134
int fMCSubrunNumber
Subrun number for the MC.
Definition: BadChanList.h:86
int fApplyBadChan
Option to activate the bad channels.
Definition: BadChanList.h:84
enum BeamMode string
void chaninfo::BadChanList::SetRandomBadChannels ( )
private

Definition at line 279 of file BadChanList_service.cc.

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

Referenced by IsBadUncached().

280  {
281  if (!fRandomBCMap.empty()) return;
282 
283  MF_LOG_ERROR("BadChanList")<< " RANDOM BAD CHANNELS at rate "
285 
286  fLowEfficiency.clear();
287 
289  for(unsigned int plane: geom->GetPlanesByView()){
290  const unsigned int nCells = geom->Plane(plane)->Ncells();
291 
292  for(unsigned int cell = 0; cell < nCells; ++cell){
294  if(fFlatRand->fire() < fRandomBadChannelFraction){
295  fRandomBCMap.insert(chan);
296  }
297  }
298  }
299  }
std::unordered_set< geo::OfflineChan > fRandomBCMap
random bad channel map
Definition: BadChanList.h:106
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
#define MF_LOG_ERROR(category)
const PlaneGeo * Plane(unsigned int i) const
float fRandomBadChannelFraction
If >0, ignore DB and set this fraction bad at random.
Definition: BadChanList.h:117
std::unordered_set< geo::OfflineChan > fLowEfficiency
set of low eff channels
Definition: BadChanList.h:105
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:138

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 95 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

bool chaninfo::BadChanList::fAbortIfNoSubrun
private

Definition at line 103 of file BadChanList.h.

Referenced by postBeginSubRun(), and reconfigure().

bool chaninfo::BadChanList::fAbortOnSmallRunNum
private

Definition at line 101 of file BadChanList.h.

Referenced by preBeginRun(), and reconfigure().

int chaninfo::BadChanList::fApplyBadChan
private

Option to activate the bad channels.

Definition at line 84 of file BadChanList.h.

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

bool chaninfo::BadChanList::fApplyFEBDropout
private

Definition at line 136 of file BadChanList.h.

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

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

Definition at line 108 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 120 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

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

Definition at line 113 of file BadChanList.h.

Referenced by InDroppedDCM(), 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 140 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 121 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

bool chaninfo::BadChanList::fDroppedDCMCacheValid
private

Definition at line 141 of file BadChanList.h.

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

bool chaninfo::BadChanList::fEventCheck
private

do we check each event for dropped DCMs?

Definition at line 110 of file BadChanList.h.

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

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

Definition at line 134 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

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

Definition at line 138 of file BadChanList.h.

Referenced by BadChanList(), and SetRandomBadChannels().

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

Definition at line 151 of file BadChanList.h.

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

bool chaninfo::BadChanList::fIsBadCacheValid
private

Definition at line 152 of file BadChanList.h.

Referenced by BadChanList(), CacheBadChannels(), IsBad(), and postBeginSubRun().

bool chaninfo::BadChanList::fIsPerfect
private

Definition at line 99 of file BadChanList.h.

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

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

Definition at line 143 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().

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

Definition at line 144 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 105 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 128 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

int chaninfo::BadChanList::fMCRunNumber
private

Run number for the MC.

Definition at line 85 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 86 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 126 of file BadChanList.h.

Referenced by IsBadUncached(), and LoadNewData().

int chaninfo::BadChanList::fNBadSR
private

Definition at line 88 of file BadChanList.h.

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

bool chaninfo::BadChanList::fNeedNewData
private

Definition at line 97 of file BadChanList.h.

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

bool chaninfo::BadChanList::fNewCosmicEffTable
private

Use new-style table?

Definition at line 115 of file BadChanList.h.

Referenced by LoadCosmicEff(), and reconfigure().

int chaninfo::BadChanList::fPedestalThresholdHigh
private

Definition at line 93 of file BadChanList.h.

Referenced by IsBadUncached(), and reconfigure().

int chaninfo::BadChanList::fPedestalThresholdLow
private

Definition at line 92 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 117 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 106 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 112 of file BadChanList.h.

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

int chaninfo::BadChanList::fRun
private

Definition at line 123 of file BadChanList.h.

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

int chaninfo::BadChanList::fSubRun
private

Definition at line 124 of file BadChanList.h.

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

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

Definition at line 133 of file BadChanList.h.

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

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

Definition at line 132 of file BadChanList.h.

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

int chaninfo::BadChanList::fVldRunGrouping
private

Definition at line 90 of file BadChanList.h.

Referenced by LoadNewData(), and reconfigure().


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