Public Member Functions | Protected Attributes | Private Member Functions | List of all members
nova::dbi::RunHistoryService Class Reference

Simple service to provide a RunHistory configured to the right run. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-15/RunHistory/service/RunHistoryService.h"

Inheritance diagram for nova::dbi::RunHistoryService:
nova::dbi::RunHistory

Public Member Functions

 RunHistoryService (const fhicl::ParameterSet &pset, art::ActivityRegistry &reg)
 
virtual ~RunHistoryService ()
 
void reconfigure (const fhicl::ParameterSet &pset)
 
void preBeginRun (const art::Run &run)
 
void preBeginSubrun (const art::SubRun &subrun)
 
void SetDBInfo (std::string dbname="", std::string dbhost="", std::string user="", std::string port="")
 
bool LoadDAQRunHistory ()
 
bool LoadHardwareInfo ()
 
bool LoadDCSAlarms (int subrun=-1)
 
bool LoadCoolingInfo ()
 
bool LoadPixelInfo (int nAttempt=0)
 
bool LoadPixelMasks ()
 
bool LoadFEBMasks ()
 
bool LoadFEBMasksFromDAQDB ()
 
bool LoadPedestals ()
 
bool LoadAPDSettings ()
 
bool LoadPOT ()
 
bool LoadGoodDiBlockMask ()
 
bool LoadDataEpoch ()
 
bool LoadAllDetInfo ()
 
bool IsRHC ()
 
void Dump ()
 
void SetNDRHCRunStart (std::vector< int > r)
 
void SetNDRHCRunStop (std::vector< int > r)
 
void SetFDRHCRunStart (std::vector< int > r)
 
void SetFDRHCRunStop (std::vector< int > r)
 
void SetTimeQueries (bool f)
 
void SetTimeParsing (bool f)
 
void SetIfAnyMasking (bool f)
 set from fcl: do we want to use any masking at all? If no, other masking options irrelevant More...
 
void SetAnalysisDiBlockMasking (bool f)
 set from fcl: do we want to use the analysis rules when we mask (not for custom masking)? More...
 
void SetIfCustomMasking (bool f)
 set from fcl: do we want to use a custom mask? More...
 
void SetCustomMask (std::vector< bool > f)
 set from fcl: what is our custom mask? More...
 
void SetGetDiBlockMaskFromCondb (bool f)
 
bool GetDiBlockMaskFromCondb () const
 
void SetSubrunDiBlockMask (int isr, int m)
 
int ApplyAnalysisDiBlockMask (const int mask) const
 converts normal mask to analysis rules mask (any continuous chunk of four or more diblocks kept) More...
 
std::string DiBlockMaskToString (const int mask) const
 
int RunNumber () const
 
int NSubruns ()
 
std::string Detector () const
 
int Partition ()
 
std::string RunType ()
 
time_t TStart ()
 
time_t TStop ()
 
std::string TStartAsString ()
 
std::string TStopAsString ()
 
time_t SubrunTStart (int isr)
 
time_t SubrunTStop (int isr)
 
int Duration ()
 in units of seconds More...
 
int NTriggers ()
 
float NPOT ()
 
float AvgPOTPerSpill ()
 
int NDiBlocks ()
 gives number of active diblocks only, may be less than 14 More...
 
int NDCMs ()
 
int NLiveDCMs ()
 
int NBNEVBs ()
 
std::vector< BNEVBGetBNEVBList ()
 
int NAnalysisChannels (int sr=0)
 
int NAnalysisDiBlocks (int sr=0)
 
int NActiveChannels ()
 
int NTotalChannels ()
 
int NFEBs ()
 
int GoodDiBlockMask (int subrun=-1, bool reload=false)
 
int GetConfiguration ()
 
void SetGoodDiBlockMask (int newmask)
 
bool IsGoodDiBlock (int idb, int subrun=-1)
 
DiBlock GetDiBlock (int i, bool loadAll=true)
 get ith diblock is RH list (which only includes diblocks with activity), starting with i=0. Set loadAll = false to prevent loading in pixel masks if not needed, as it can be very slow More...
 
int NAPDInstalled ()
 
bool IsDiBlockFullyInstrumented (int idb)
 returns true if nInstrumentedFEBs in diblock (which counts FEBs that are instrumented, active, and unmasked only) is >= 700 More...
 
bool HasAPD (const geo::OfflineChan &)
 basic check for if a channel should be live. Used by BadChannels. Checks if channel has instrumented APD, is active in run, and is not masked More...
 
bool HasAPD (const daqchannelmap::dchan &)
 
bool IsCooled (const geo::OfflineChan &)
 
bool IsCooled (const daqchannelmap::dchan &)
 
int GetThreshold (const geo::OfflineChan &, bool &)
 
int GetThreshold (const daqchannelmap::dchan &, bool &)
 
int GetPedestal (const geo::OfflineChan &, bool &)
 
int GetPedestal (const daqchannelmap::dchan &, bool &)
 
FEB GetFEB (geo::OfflineChan const &, bool &)
 
FEB GetFEB (daqchannelmap::dchan const &, bool &)
 
float GetGain (const geo::OfflineChan &, bool &)
 
float GetGain (const daqchannelmap::dchan &, bool &)
 
float GetPixelGain (geo::OfflineChan const &, bool &)
 
float GetPixelGain (daqchannelmap::dchan const &, bool &)
 
std::vector< float > GetPixelGains (geo::OfflineChan const &, bool &)
 
std::vector< float > GetPixelGains (daqchannelmap::dchan const &, bool &)
 
std::vector< DQSubrunInfoGetDQSubrunInfo ()
 
void SetDataType (nova::dbi::DataType dt)
 
void SetAbort (bool abort)
 
void SetAbortIfMissingRunInDB (bool abort)
 
nova::dbi::DataType GetDataType ()
 
void SetIsBad (geo::OfflineChan, bool, time_t)
 
bool IsBad (geo::OfflineChan, time_t)
 
void ClearBadChan ()
 
void SetChanInfo (geo::OfflineChan, float, float, time_t)
 
float Occupancy (geo::OfflineChan, time_t)
 
float Coincidence (geo::OfflineChan, time_t)
 
void ClearChanInfo ()
 
void PrintChanInfo ()
 
std::string BadChanVersion ()
 
void SetBadChanVersion (std::string v)
 
int NRetryLoads ()
 
void SetNRetryLoads (int n)
 
void SetDiBlockMaskTag (std::string s)
 
int DetGainSetting ()
 
void SetGainSettingTag (std::string tag)
 
std::string GainSettingTag ()
 
bool DetFineTimingSetting () const
 
void SetVerbosity (int i)
 
int Verbosity () const
 
void SetCurrentSubrun (int isr)
 
int CurrentSubrun () const
 
DataEpoch GetDataEpoch ()
 

Protected Attributes

int fFakeRunNumber
 
bool fTimeQueries
 
bool fUseMasking
 
bool fAnalysisDiBlockMasking
 
bool fCustomMasking
 
std::vector< intfCustomMask
 
std::string fCalHitLabel
 
bool fAbort
 
bool fAbortIfMissingRunInDB
 
bool _getDiBlockMaskFromCondb
 
std::string _dbMaskTag
 

Private Member Functions

void SetRunNumber (int run)
 
void SetDetector (const std::string &det)
 
void SetDetector (novadaq::cnv::DetId det)
 

Detailed Description

Simple service to provide a RunHistory configured to the right run.

Definition at line 22 of file RunHistoryService.h.

Constructor & Destructor Documentation

nova::dbi::RunHistoryService::RunHistoryService ( const fhicl::ParameterSet pset,
art::ActivityRegistry reg 
)

Definition at line 30 of file RunHistory_service.cc.

References preBeginRun(), preBeginSubrun(), reconfigure(), art::ActivityRegistry::sPreBeginRun, and art::ActivityRegistry::sPreBeginSubRun.

32  {
33  reconfigure(pset);
36  }
void preBeginSubrun(const art::SubRun &subrun)
void preBeginRun(const art::Run &run)
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
void reconfigure(const fhicl::ParameterSet &pset)
GlobalSignal< detail::SignalResponseType::FIFO, void(SubRun const &)> sPreBeginSubRun
nova::dbi::RunHistoryService::~RunHistoryService ( )
virtual

Definition at line 40 of file RunHistory_service.cc.

41  {
42  }

Member Function Documentation

int nova::dbi::RunHistory::ApplyAnalysisDiBlockMask ( const int  mask) const
inherited

converts normal mask to analysis rules mask (any continuous chunk of four or more diblocks kept)

Definition at line 1467 of file RunHistory.cxx.

Referenced by nova::dbi::RunHistory::LoadGoodDiBlockMask().

1468  {
1469 
1470  // for convenience and clarity below, define dib[]...
1471  const int NUMDIB = 14;
1472  bool dib[NUMDIB];
1473  for (int iD=0;iD<NUMDIB;iD++) {
1474  dib[iD] = (mask&(1<<iD));
1475  }
1476 
1477  int answer = 0;
1478  int partial_answer = 0;
1479  int iStart = -1;
1480  for (int iD=0;iD<NUMDIB;iD++) {
1481 
1482  if (iStart<0&&dib[iD]) {
1483  // starting a string of diblocks
1484  iStart = iD;
1485  }
1486 
1487  if (iStart>=0&&dib[iD]) {
1488  // contributes to partial_answer
1489  partial_answer += (1<<iD);
1490  }
1491 
1492  if (iStart>=0&&(!dib[iD]||iD==NUMDIB-1)) {
1493  // just left a string of diblocks, or at last diblock
1494  int curr_size = iD-iStart;
1495  if (dib[iD]&&iD==NUMDIB-1) curr_size++;
1496  if (curr_size>=4) {
1497  // okay to keep
1498  answer += partial_answer;
1499  }
1500  iStart = -1;
1501  partial_answer = 0;
1502  }
1503 
1504  } // iD
1505 
1506  return answer;
1507  }
float nova::dbi::RunHistory::AvgPOTPerSpill ( )
inlineinherited

Definition at line 392 of file RunHistory.h.

392 { LoadPOT(); return _avgpot; }
std::string nova::dbi::RunHistory::BadChanVersion ( )
inlineinherited

Definition at line 464 of file RunHistory.h.

464 { return _badChanVersion;}
std::string _badChanVersion
Definition: RunHistory.h:553
void nova::dbi::RunHistory::ClearBadChan ( )
inlineinherited

Definition at line 456 of file RunHistory.h.

456 { _badChan.clear(); }
std::map< geo::OfflineChan, std::vector< BadChan_t > > _badChan
Definition: RunHistory.h:557
void nova::dbi::RunHistory::ClearChanInfo ( )
inlineinherited

Definition at line 461 of file RunHistory.h.

461 { _chanInfo.clear(); }
std::map< geo::OfflineChan, std::vector< ChanInfo_t > > _chanInfo
Definition: RunHistory.h:558
float nova::dbi::RunHistory::Coincidence ( geo::OfflineChan  chan,
time_t  t 
)
inherited

Definition at line 2161 of file RunHistory.cxx.

References nova::dbi::RunHistory::_chanInfo, febshutoff_auto::chan, MECModelEnuComparisons::i, and confusionMatrixTree::t.

2162  {
2163  const std::vector<ChanInfo_t>& cis = _chanInfo[chan];
2164 
2165  unsigned int i=0;
2166  for (; i<cis.size() && cis[i].tstart<t; ++i);
2167  if (i>0)
2168  return cis[i-1].coinc;
2169  else
2170  return 0.;
2171  }
std::map< geo::OfflineChan, std::vector< ChanInfo_t > > _chanInfo
Definition: RunHistory.h:558
int nova::dbi::RunHistory::CurrentSubrun ( ) const
inlineinherited

Definition at line 482 of file RunHistory.h.

482 { return _currentSR; }
std::string nova::dbi::RunHistory::Detector ( ) const
inlineinherited

Definition at line 376 of file RunHistory.h.

Referenced by comi::NearlineAna::analyze(), preBeginRun(), preBeginSubrun(), and ifdb::IFDBSpillInfo::produce().

376 { return _detector; }
std::string _detector
Definition: RunHistory.h:550
bool nova::dbi::RunHistory::DetFineTimingSetting ( ) const
inherited

Definition at line 1051 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_runNumber, and novadaq::cnv::kFARDET.

Referenced by caf::CAFMaker::produce().

1052  {
1053  // TODO. This really should be implemented by a database table like
1054  // DetGainSetting, but this is the best that can be done on short notice.
1055 
1056  // ND has always been fine-timing in any runs used for physics
1057  if(_detId != novadaq::cnv::kFARDET) return true;
1058 
1059  // FD switched at some point and never switched back. Ideal conditions
1060  // runs up at high run numbers are all fine timing. We use magic number
1061  // up there for gains, but so far not for timing. If that ever changes
1062  // will have to add more logic here.
1063 
1064  // https://cdcvs.fnal.gov/redmine/projects/novawatchdog/wiki/Far_Detector
1065  return _runNumber >= 17212;
1066  }
Far Detector at Ash River, MN.
int nova::dbi::RunHistory::DetGainSetting ( )
inherited

Definition at line 1007 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_detGainSetting, nova::dbi::RunHistory::_detGainTag, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, om::cerr, novadaq::cnv::DetInfo::DetNameOk(), allTimeWatchdog::endl, nova::dbi::kDataOnly, nova::dbi::kMCOnly, LOG_ERROR, LOG_INFO, LOG_WARNING, and confusionMatrixTree::t.

Referenced by rsim::CommonParameters::CommonParameters(), calib::Calibrator::postBeginRun(), and caf::CAFMaker::produce().

1008  {
1009  if (!_detGainSetting) {
1010  std::unique_ptr<db::Table> t;
1011  t.reset(new db::Table("RunHistory/tables/GainSetting.xml"));
1012 
1014  t->SetDetector(_detector);
1015  else
1016  return 0;
1017 
1018  int gainIdx = t->GetColIndex("gain");
1019 
1020  t->SetDataTypeMask(nova::dbi::kMCOnly|nova::dbi::kDataOnly);
1021  t->SetTag(_detGainTag);
1022  t->SetMinTSVld(_runNumber);
1023  t->SetMaxTSVld(_runNumber);
1024  t->SetTimeQueries(_timeQueries);
1025  t->SetTimeParsing(_timeParsing);
1026  t->SetVerbosity(_verbosity);
1027  if (!t->Load()) {
1028  std::cerr << __PRETTY_FUNCTION__ << "No gain setting found in DB!";
1029  if(_abort) std::abort();
1030  LOG_WARNING("RunHistory") << "WARNING: RunHistory::DetGainSetting(): No detector gain setting\n"
1031  " info found for run " << _runNumber << ", so setting gain to 1";
1032  _detGainSetting = 1;
1033  // get from the dB
1034  }
1035  else {
1036  if (t->NRow() != 1) {
1037  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << ": failed to get 1 row from database. Aborting." << std::endl;
1038  abort();
1039  }
1040  t->GetRow(0)->Col(gainIdx).Get(_detGainSetting);
1041  LOG_INFO("RunHistory") << "Gain setting for run " << _runNumber
1042  << " is " << _detGainSetting << std::endl;
1043  }
1044  }
1045 
1046  return _detGainSetting;
1047  }
std::string _detGainTag
Definition: RunHistory.h:548
OStream cerr
Definition: OStream.cxx:7
std::string _detector
Definition: RunHistory.h:550
#define LOG_WARNING(category)
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
std::string nova::dbi::RunHistory::DiBlockMaskToString ( const int  mask) const
inherited

Definition at line 1446 of file RunHistory.cxx.

References string.

Referenced by nova::dbi::RunHistory::LoadGoodDiBlockMask(), preBeginRun(), and preBeginSubrun().

1447  {
1448  std::string answer = "";
1449  for (int iD=0;iD<14;iD++) {
1450  if (mask&(1<<(iD))) {
1451  answer += "#";
1452  }
1453  else {
1454  answer += "-";
1455  }
1456  }
1457  return answer;
1458  }
enum BeamMode string
void nova::dbi::RunHistory::Dump ( )
inherited

Definition at line 2234 of file RunHistory.cxx.

References nova::dbi::RunHistory::_bnevbList, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_nActiveChannels, nova::dbi::RunHistory::_nsubrun, nova::dbi::RunHistory::_nTotalChannels, nova::dbi::RunHistory::_nTotTrig, nova::dbi::RunHistory::_runNumber, om::cout, febshutoff_auto::dcm, allTimeWatchdog::endl, MECModelEnuComparisons::i, calib::j, nova::dbi::RunHistory::NLiveDCMs(), nova::dbi::RunHistory::TStartAsString(), and nova::dbi::RunHistory::TStopAsString().

2234  {
2235  std::cout << "****************************************" << std::endl;
2236  std::cout << "Dump of run " << _runNumber << std::endl;
2237  std::cout << "****************************************\n" << std::endl;
2238  std::cout << "Num Subruns : " << _nsubrun << std::endl;
2239  std::cout << "Start time : " << TStartAsString() << std::endl;
2240  std::cout << "End time : " << TStopAsString() << std::endl;
2241  std::cout << "Trig Tot : " << _nTotTrig << std::endl;
2242  std::cout << "Num Active Channels: " << _nActiveChannels << std::endl;
2243  std::cout << "Num Total Channels: " << _nTotalChannels << std::endl;
2244  std::cout << "Num DCMs : " << NLiveDCMs() << std::endl;
2245  for (unsigned int i=0; i<_dbList.size(); ++i)
2246  for (unsigned int j=0; j<_dbList[i].dcm.size(); ++j)
2247  if (_dbList[i].dcm[j].isActive)
2248  std::cout << "\t" << _dbList[i].dcm[j].appname << std::endl;
2249  std::cout << "Num BNEVBs : " << _bnevbList.size() << std::endl;
2250  for (unsigned int i=0; i<_bnevbList.size(); ++i)
2251  std::cout << "\t" << _bnevbList[i].appname << std::endl;
2252 
2253  }
std::vector< BNEVB > _bnevbList
Definition: RunHistory.h:556
std::string TStopAsString()
Definition: RunHistory.h:384
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
std::string TStartAsString()
Definition: RunHistory.h:383
int nova::dbi::RunHistory::Duration ( )
inlineinherited
std::string nova::dbi::RunHistory::GainSettingTag ( )
inlineinherited

Definition at line 474 of file RunHistory.h.

474 {return _detGainTag;}
std::string _detGainTag
Definition: RunHistory.h:548
std::vector<BNEVB> nova::dbi::RunHistory::GetBNEVBList ( )
inlineinherited

Definition at line 398 of file RunHistory.h.

References sr.

Referenced by zcl::FmmTrackerAna::endJob(), and mono::DataCheckMonopole::farm70_in_configuration().

398 { return _bnevbList; }
std::vector< BNEVB > _bnevbList
Definition: RunHistory.h:556
int nova::dbi::RunHistory::GetConfiguration ( )
inherited

Definition at line 1413 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, gen_hdf5record::config, runNovaSAM::detId, novadaq::cnv::DetInfo::GetId(), MECModelEnuComparisons::i, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, and nova::dbi::RunHistory::LoadHardwareInfo().

Referenced by remid::ReMIdTrain::analyze(), numue::NumuEAna::analyze(), skim::CellHitSkimmer::CheckEvent(), skim::Evaluator::CheckSliceQuality(), skim::CosmicBeamComparison::FillNumuHistograms(), skim::ParametersNue::ParametersNue(), and skim::ParametersNumu::ParametersNumu().

1414  {
1415  LoadHardwareInfo();
1417  if(detId==novadaq::cnv::kNEARDET) {
1418  bool diblocks[4] = {0};
1419  int config = 0;
1420  for(unsigned int i = 0; i < _dbList.size(); i++) {
1421  if(_dbList[i].nInstrumentedFEBs>=175 && i < 3) diblocks[_dbList[i].num-1] = true;
1422  if(_dbList[i].nInstrumentedFEBs>=45 && i == 3) diblocks[_dbList[i].num-1] = true;
1423  }
1424  for(int i = 0; i < 4; i++) {
1425  if(diblocks[i]) config+=1<<i;
1426  }
1427  return config;
1428  }
1429  if(detId==novadaq::cnv::kFARDET) {
1430  bool diblocks[14] = {0};
1431  int config = 0;
1432  for(unsigned int i = 0; i < _dbList.size(); i++) {
1433  if(_dbList[i].nInstrumentedFEBs>=700) diblocks[_dbList[i].num-1] = true;
1434  }
1435  for(int i = 0; i < 14; i++) {
1436  if(diblocks[i]) config+=1<<i;
1437  }
1438  return config;
1439  }
1440  return 0;
1441  }
Definition: config.py:1
Far Detector at Ash River, MN.
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
Near Detector in the NuMI cavern.
static int GetId(std::string name)
DataEpoch nova::dbi::RunHistory::GetDataEpoch ( )
inlineinherited

Definition at line 484 of file RunHistory.h.

Referenced by skim::CellHitSkimmer::endRun(), and skim::POTSummary::event().

484 { LoadDataEpoch(); return _dataEpoch; }
nova::dbi::DataType nova::dbi::RunHistory::GetDataType ( )
inlineinherited
RunHistory::DiBlock nova::dbi::RunHistory::GetDiBlock ( int  i,
bool  loadAll = true 
)
inherited

get ith diblock is RH list (which only includes diblocks with activity), starting with i=0. Set loadAll = false to prevent loading in pixel masks if not needed, as it can be very slow

Definition at line 1760 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, allTimeWatchdog::endl, MECModelEnuComparisons::i, nova::dbi::RunHistory::LoadAllDetInfo(), nova::dbi::RunHistory::LoadHardwareInfo(), and LOG_ERROR.

Referenced by chaninfo::BadChanValidate::BadChansFromOM(), calib::PEResponse::beginRun(), comi::NearlineAna::beginRun(), comi::DataCheck::beginSubRun(), comi::DataCheck::endJob(), nova::dbi::RunHistory::GetFEB(), geo::LiveGeometry::GetRHInfo(), chaninfo::BadChanList::NBadInSubRun(), and geo::LiveGeometry::SetInstrumentation().

1761  {
1762  LoadHardwareInfo();
1763  if (i >= int(_dbList.size())) {
1764  LOG_ERROR("RunHistory")<<"RunHistory::GetDiBlock: invalid diblock!"<<std::endl;
1765  std::abort();
1766  }
1767  if (loadAll) LoadAllDetInfo();
1768  return _dbList[i];
1769  }
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool nova::dbi::RunHistory::GetDiBlockMaskFromCondb ( ) const
inlineinherited
std::vector< DQSubrunInfo > nova::dbi::RunHistory::GetDQSubrunInfo ( )
inherited

Definition at line 2072 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_dqSRInfo, nova::dbi::DQSubrunInfo::_flag, nova::dbi::RunHistory::_gotDQSubrunInfo, nova::dbi::DQSubrunInfo::_miprate, nova::dbi::DQSubrunInfo::_ngooddb, nova::dbi::DQSubrunInfo::_numslc, nova::dbi::DQSubrunInfo::_run, nova::dbi::RunHistory::_runNumber, nova::dbi::DQSubrunInfo::_subrun, nova::dbi::DQSubrunInfo::_trkfrac, nova::dbi::RunHistory::_verbosity, nova::dbi::DQSubrunInfo::_version, MECModelEnuComparisons::i, and string.

2073  {
2074  if (!_gotDQSubrunInfo) {
2075  _dqSRInfo.clear();
2076 
2077  std::unique_ptr<db::Table> dqTable(new nova::dbi::Table("RunHistory/tables/DQSubrunInfo.xml"));
2078  dqTable->SetDetector(_detector);
2079  dqTable->SetValidityRange("run",_runNumber);
2080  dqTable->AddOrderColumn("version");
2081  dqTable->SetOrderDesc();
2082  dqTable->AddExcludeCol(std::string("comment"));
2083  dqTable->AddExcludeCol(std::string("inserttime"));
2084  dqTable->AddExcludeCol(std::string("insertuser"));
2085  dqTable->SetVerbosity(_verbosity);
2086  dqTable->Load();
2087 
2088  std::map<std::string,int> colName = dqTable->GetColNameToIndexMap();
2089 
2090  int version=0;
2091  int nextVersion=0;
2092  for (int i=0; i<dqTable->NRow(); ++i) {
2093  // make sure we only use rows with the latest version number
2094  if (i==0) {
2095  dqTable->GetRow(i)->Col(colName["version"]).Get(version);
2096  nextVersion=version;
2097  }
2098  else
2099  dqTable->GetRow(i)->Col(colName["version"]).Get(nextVersion);
2100 
2101  if (nextVersion != version) break;
2102 
2103  DQSubrunInfo sri;
2104  sri._run = _runNumber;
2105  sri._version = version;
2106  dqTable->GetRow(i)->Col(colName["subrun"]).Get(sri._subrun);
2107  dqTable->GetRow(i)->Col(colName["flag"]).Get(sri._flag);
2108  dqTable->GetRow(i)->Col(colName["miprate"]).Get(sri._miprate);
2109  dqTable->GetRow(i)->Col(colName["ngooddb"]).Get(sri._ngooddb);
2110  dqTable->GetRow(i)->Col(colName["numslc"]).Get(sri._numslc);
2111  dqTable->GetRow(i)->Col(colName["trkfrac"]).Get(sri._trkfrac);
2112  _dqSRInfo.push_back(sri);
2113  }
2114  _gotDQSubrunInfo = true;
2115  }
2116 
2117  return _dqSRInfo;
2118  }
std::vector< DQSubrunInfo > _dqSRInfo
Definition: RunHistory.h:560
std::string _detector
Definition: RunHistory.h:550
const XML_Char * version
Definition: expat.h:187
enum BeamMode string
RunHistory::FEB nova::dbi::RunHistory::GetFEB ( geo::OfflineChan const &  oChan,
bool &  ok 
)
inherited

Definition at line 1927 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

Referenced by nova::dbi::RunHistory::GetGain(), nova::dbi::RunHistory::GetPixelGain(), and nova::dbi::RunHistory::GetPixelGains().

1929  {
1931  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
1932  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
1933 
1934  return this->GetFEB(daqChan, ok);
1935  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
FEB GetFEB(geo::OfflineChan const &, bool &)
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
RunHistory::FEB nova::dbi::RunHistory::GetFEB ( daqchannelmap::dchan const &  daqChan,
bool &  ok 
)
inherited

Definition at line 1884 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::DiBlock::dcm, APDHVSetting::feb, nova::dbi::RunHistory::DCM::feb, nova::dbi::RunHistory::DCM::febMask, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), nova::dbi::RunHistory::GetDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), nova::dbi::RunHistory::FEB::hasAPD, nova::dbi::RunHistory::DiBlock::hasNoAPDs, nova::dbi::RunHistory::FEB::isEnabled, nova::dbi::RunHistory::LoadAPDSettings(), num, and nova::dbi::RunHistory::DCM::position.

1886  {
1887  FEB feb;
1888  ok = false;
1889 
1890  if (!LoadAPDSettings()) return feb;
1891 
1893  daqchannelmap::diblock_t diblk = dmap->getDiBlock(daqChan);
1894  daqchannelmap::dcm_id_t dcmId = dmap->getDCM(daqChan);
1895  daqchannelmap::feb_t ifeb = dmap->getFEB(daqChan);
1896 
1897  for (size_t iDB = 0; iDB < _dbList.size(); ++iDB) {
1898  if (_dbList[iDB].num == (short)diblk) {
1899  DiBlock currDiBlock = GetDiBlock(iDB);
1900  if (currDiBlock.hasNoAPDs) return feb;
1901  int iDCM = dcmId-1;
1902  if (iDCM >= (int)currDiBlock.dcm.size()) return feb;
1903 
1904  DCM currDCM = currDiBlock.dcm[iDCM];
1905  if (currDCM.position == -1) return feb;
1906 
1907  std::bitset<64> febSet(currDCM.febMask);
1908  if (ifeb >= currDCM.feb.size()) return feb;
1909 
1910  FEB currFEB = currDCM.feb[ifeb];
1911  if (!febSet[ifeb] || !currFEB.isEnabled) return feb;
1912 
1913  if ( !currFEB.hasAPD ) return feb;
1914 
1915  //everything is fine
1916  ok = true;
1917  feb = currFEB;
1918 
1919  break;
1920  }
1921  }
1922 
1923  return feb;
1924  }
DiBlock GetDiBlock(int i, bool loadAll=true)
get ith diblock is RH list (which only includes diblocks with activity), starting with i=0...
static DAQChannelMap * getInstance(int detID)
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
uint32_t feb_t
Type for DCM link port. Counts from 0.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
int num
Definition: f2_nu.C:119
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
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.
float nova::dbi::RunHistory::GetGain ( const geo::OfflineChan oChan,
bool &  ok 
)
inherited

Definition at line 1951 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

1952  {
1954  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
1955  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
1956 
1957  return GetGain(daqChan, ok);
1958  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
float GetGain(const geo::OfflineChan &, bool &)
unsigned short Plane() const
Definition: OfflineChan.h:31
unsigned short Cell() const
Definition: OfflineChan.h:32
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
float nova::dbi::RunHistory::GetGain ( const daqchannelmap::dchan daqChan,
bool &  ok 
)
inherited

Definition at line 1939 of file RunHistory.cxx.

References APDHVSetting::feb, nova::dbi::RunHistory::FEB::gain, and nova::dbi::RunHistory::GetFEB().

1940  {
1941  float gain=0.;
1942 
1943  FEB feb = this->GetFEB(daqChan, ok);
1944 
1945  if(ok) return feb.gain;
1946 
1947  return gain;
1948  }
FEB GetFEB(geo::OfflineChan const &, bool &)
int nova::dbi::RunHistory::GetPedestal ( const geo::OfflineChan oChan,
bool &  ok 
)
inherited

Definition at line 632 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_diblockIndex, geo::OfflineChan::Cell(), febshutoff_auto::dcm, daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), APDHVSetting::feb, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPixel(), makeTrainCVSamples::int, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadHardwareInfo(), nova::dbi::RunHistory::LoadPedestals(), and geo::OfflineChan::Plane().

Referenced by rsim::IFPGAAlgorithm::FetchThresholds(), and chaninfo::BadChanList::IsBadUncached().

633  {
634  if (!LoadDAQRunHistory()) {
635  if (_abort) std::abort();
636  return -1;
637  }
638  if (!LoadHardwareInfo()) {
639  if (_abort) std::abort();
640  return -1;
641  }
642  if (!LoadFEBMasks()) {
643  if (_abort) std::abort();
644  return -1;
645  }
646  if (!LoadPedestals()) {
647  if (_abort) std::abort();
648  return -1;
649  }
650 
652  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
653  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
654 
655  int diblk = int(dmap->getDiBlock(daqChan));
656  int dcmId = int(dmap->getDCM(daqChan));
657  int ifeb = int(dmap->getFEB(daqChan));
658  int ipix = int(dmap->getPixel(daqChan));
659 
660  int idb = _diblockIndex[diblk];
661  if (idb < (int)_dbList.size())
662  return _dbList[idb].dcm[dcmId-1].feb[ifeb].pixelThresh[ipix];
663 
664  return 0;
665  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
std::map< int, int > _diblockIndex
Definition: RunHistory.h:495
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
unsigned short Plane() const
Definition: OfflineChan.h:31
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
unsigned short Cell() const
Definition: OfflineChan.h:32
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.
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
int nova::dbi::RunHistory::GetPedestal ( const daqchannelmap::dchan daqChan,
bool &  ok 
)
inherited

Definition at line 669 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_diblockIndex, febshutoff_auto::dcm, APDHVSetting::feb, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPixel(), makeTrainCVSamples::int, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadHardwareInfo(), nova::dbi::RunHistory::LoadPedestals(), and nova::dbi::RunHistory::LoadPixelMasks().

670  {
671  if (!LoadDAQRunHistory()) {
672  if (_abort) std::abort();
673  return -1;
674  }
675  if (!LoadHardwareInfo()) {
676  if (_abort) std::abort();
677  return -1;
678  }
679  if (!LoadFEBMasks()) {
680  if (_abort) std::abort();
681  return -1;
682  }
683  if (!LoadPixelMasks()) {
684  if (_abort) std::abort();
685  return -1;
686  }
687  if (!LoadPedestals()) {
688  if (_abort) std::abort();
689  return -1;
690  }
691 
693 
694  int diblk = int(dmap->getDiBlock(daqChan));
695  int dcmId = int(dmap->getDCM(daqChan));
696  int ifeb = int(dmap->getFEB(daqChan));
697  int ipix = int(dmap->getPixel(daqChan));
698 
699  int idb = _diblockIndex[diblk];
700  if (idb < (int)_dbList.size())
701  return _dbList[idb].dcm[dcmId-1].feb[ifeb].pixelThresh[ipix];
702 
703  return 0;
704 
705  }
static DAQChannelMap * getInstance(int detID)
std::map< int, int > _diblockIndex
Definition: RunHistory.h:495
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
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.
float nova::dbi::RunHistory::GetPixelGain ( geo::OfflineChan const &  oChan,
bool &  ok 
)
inherited

Definition at line 1974 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

1976  {
1978  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
1979  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
1980 
1981  return this->GetPixelGain(daqChan, ok);
1982  }
float GetPixelGain(geo::OfflineChan const &, bool &)
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
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
float nova::dbi::RunHistory::GetPixelGain ( daqchannelmap::dchan const &  daqChan,
bool &  ok 
)
inherited

Definition at line 1961 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, APDHVSetting::feb, nova::dbi::RunHistory::GetFEB(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPixel(), and nova::dbi::RunHistory::FEB::pixelGain.

1963  {
1964 
1965  FEB feb = this->GetFEB(daqChan, ok);
1967  daqchannelmap::pixel_t pixel = dmap->getPixel(daqChan);
1968  if(ok && pixel < feb.pixelGain.size()) return feb.pixelGain[pixel];
1969 
1970  return 0.;
1971  }
uint32_t pixel_t
Type for physical pixel on APD.
static DAQChannelMap * getInstance(int detID)
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
FEB GetFEB(geo::OfflineChan const &, bool &)
std::vector< float > nova::dbi::RunHistory::GetPixelGains ( geo::OfflineChan const &  oChan,
bool &  ok 
)
inherited

Definition at line 1997 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

1999  {
2001  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
2002  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
2003 
2004  return this->GetPixelGains(daqChan, ok);
2005  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
std::vector< float > GetPixelGains(geo::OfflineChan const &, bool &)
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< float > nova::dbi::RunHistory::GetPixelGains ( daqchannelmap::dchan const &  daqChan,
bool &  ok 
)
inherited

Definition at line 1985 of file RunHistory.cxx.

References APDHVSetting::feb, nova::dbi::RunHistory::GetFEB(), and nova::dbi::RunHistory::FEB::pixelGain.

1987  {
1988 
1989  FEB feb = this->GetFEB(daqChan, ok);
1990 
1991  if(ok) return feb.pixelGain;
1992 
1993  return std::vector<float>(32, 0.);
1994  }
FEB GetFEB(geo::OfflineChan const &, bool &)
int nova::dbi::RunHistory::GetThreshold ( const geo::OfflineChan oChan,
bool &  ok 
)
inherited

Definition at line 2057 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_gotPixelInfo, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), nova::dbi::RunHistory::LoadPixelInfo(), geo::OfflineChan::Plane(), and dump_to_simple_cpp::threshold.

2058  {
2059  if (! _gotPixelInfo)
2060  LoadPixelInfo();
2061 
2063  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
2064  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
2065 
2066  int threshold = GetThreshold(daqChan, ok);
2067  return threshold;
2068  }
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
unsigned short Plane() const
Definition: OfflineChan.h:31
unsigned short Cell() const
Definition: OfflineChan.h:32
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
int GetThreshold(const geo::OfflineChan &, bool &)
int nova::dbi::RunHistory::GetThreshold ( const daqchannelmap::dchan daqChan,
bool &  ok 
)
inherited

Definition at line 2008 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_gotPixelInfo, nova::dbi::RunHistory::DCM::feb, nova::dbi::RunHistory::DCM::febMask, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPixel(), nova::dbi::RunHistory::FEB::hasAPD, nova::dbi::RunHistory::FEB::isEnabled, nova::dbi::RunHistory::LoadPixelInfo(), num, nova::dbi::RunHistory::FEB::pixelMask, nova::dbi::RunHistory::FEB::pixelThresh, nova::dbi::RunHistory::DCM::position, and dump_to_simple_cpp::threshold.

2009  {
2010  if (! _gotPixelInfo)
2011  LoadPixelInfo();
2012 
2013  ok = false;
2014  int threshold(4095);
2016  daqchannelmap::diblock_t diblk = dmap->getDiBlock(daqChan);
2017  daqchannelmap::dcm_id_t dcmId = dmap->getDCM(daqChan);
2018  daqchannelmap::feb_t ifeb = dmap->getFEB(daqChan);
2019  daqchannelmap::pixel_t ipix = dmap->getPixel(daqChan);
2020 
2021  //if (diblk > 2) return threshold;
2022 
2023  //daqchannelmap::diblock_t ranges from 1 to 17 -> subtract 1 to get c++ index
2024  for (unsigned int iDB=0; iDB<_dbList.size(); ++iDB) {
2025  if (_dbList[iDB].num == (short)diblk) {
2026  if (_dbList[iDB].hasNoAPDs) return threshold;
2027  //daqchannelmap::dcm_id_t ranges from 1 to 12 -> subtract 1 to get c++ index
2028  int iDCM = dcmId-1;
2029  if (iDCM >= (int)_dbList[iDB].dcm.size()) break;
2030 
2031  DCM& currDCM = _dbList[iDB].dcm[iDCM];
2032  if (currDCM.position == -1) break;
2033 
2034  std::bitset<64> febSet(currDCM.febMask);
2035  if (ifeb >= currDCM.feb.size()) break;
2036 
2037  FEB& currFEB = currDCM.feb[ifeb];
2038  if (!febSet[ifeb] || !currFEB.isEnabled) break;
2039 
2040  std::bitset<32> pixSet(currFEB.pixelMask);
2041  if (!pixSet[ipix]) break;
2042 
2043  if ( !currFEB.hasAPD ) break;
2044 
2045  //everything is fine
2046  ok = true;
2047  threshold = currFEB.pixelThresh[ipix];
2048  break;
2049  }
2050 
2051  }
2052 
2053  return threshold;
2054  }
uint32_t pixel_t
Type for physical pixel on APD.
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
static DAQChannelMap * getInstance(int detID)
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
uint32_t feb_t
Type for DCM link port. Counts from 0.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
int num
Definition: f2_nu.C:119
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
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.
int nova::dbi::RunHistory::GoodDiBlockMask ( int  subrun = -1,
bool  reload = false 
)
inherited

Definition at line 1167 of file RunHistory.cxx.

References nova::dbi::RunHistory::_currentSR, nova::dbi::RunHistory::_getDiBlockMaskFromCondb, nova::dbi::RunHistory::_gotGoodDiBlockMask, nova::dbi::RunHistory::_subrunList, allTimeWatchdog::endl, nova::dbi::RunHistory::LoadGoodDiBlockMask(), LOG_WARNING, and getGoodRuns4SAM::subrun.

Referenced by remid::ReMIdTrain::analyze(), numue::NumuEAna::analyze(), calhit::RemoveBadChannels::beginRun(), calhit::CalHit::beginRun(), caf::CAFMaker::beginRun(), calhit::RemoveBadChannels::beginSubRun(), calhit::CalHit::beginSubRun(), caf::CAFMaker::beginSubRun(), skim::CellHitSkimmer::CheckEvent(), skim::Evaluator::CheckSliceQuality(), CondenseRunList(), skim::CosmicBeamComparison::FillNumuHistograms(), caf::CAFMaker::FillSpillVars(), skim::ParametersNue::ParametersNue(), skim::ParametersNumu::ParametersNumu(), preBeginRun(), preBeginSubrun(), and caf::CAFMaker::produce().

1168  {
1169  if(reload)
1170  _gotGoodDiBlockMask=false;
1172 
1174  subrun = 0;
1175  else {
1176  if (subrun < 0 || subrun > 63) {
1177  if (subrun > 63)
1178  LOG_WARNING("RunHistory") << __PRETTY_FUNCTION__ << " invalid subrun " << subrun << ". Converted to subrun " << subrun << std::endl;
1179  subrun = _currentSR;
1180  }
1181 
1182  }
1183 
1184  return _subrunList[subrun].goodDiBlockMask;
1185  }
#define LOG_WARNING(category)
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
bool nova::dbi::RunHistory::HasAPD ( const geo::OfflineChan oChan)
inherited

basic check for if a channel should be live. Used by BadChannels. Checks if channel has instrumented APD, is active in run, and is not masked

Definition at line 1802 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

Referenced by chaninfo::BadChanList::IsBadUncached().

1803  {
1805  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
1806  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
1807 
1808  return HasAPD(daqChan);
1809 
1810  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
unsigned short Plane() const
Definition: OfflineChan.h:31
unsigned short Cell() const
Definition: OfflineChan.h:32
bool HasAPD(const geo::OfflineChan &)
basic check for if a channel should be live. Used by BadChannels. Checks if channel has instrumented ...
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 nova::dbi::RunHistory::HasAPD ( const daqchannelmap::dchan daqChan)
inherited

Definition at line 1772 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_gotHardwareInfo, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_useMasking, febshutoff_auto::dcm, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), MECModelEnuComparisons::i, nova::dbi::RunHistory::IsGoodDiBlock(), nova::dbi::RunHistory::LoadHardwareInfo(), and num.

1773  {
1774  if (! _gotHardwareInfo)
1775  LoadHardwareInfo();
1776 
1778  daqchannelmap::diblock_t diblk = daqcmap->getDiBlock(daqChan);
1779  daqchannelmap::dcm_id_t dcmId = daqcmap->getDCM(daqChan);
1780  daqchannelmap::feb_t ifeb = daqcmap->getFEB(daqChan);
1781 
1782  if(_runNumber >= 1000000 || _runNumber < 10000) { // it's MC - assume perfect + mask
1783  if(_useMasking) {if(IsGoodDiBlock(diblk)) return true;}
1784  else return true;
1785  }
1786 
1787  else {
1788  for (unsigned int i=0; i<_dbList.size(); ++i)
1789  if (_dbList[i].num == (short)diblk) {
1790  if (_dbList[i].hasNoAPDs) return false;
1791  if (_useMasking && IsGoodDiBlock(diblk)==false) return false;
1792  if (! _dbList[i].dcm[dcmId-1].isActive)
1793  return false;
1794  else
1795  return _dbList[i].dcm[dcmId-1].feb[ifeb].hasAPD;
1796  }
1797  }
1798  return false;
1799  }
static DAQChannelMap * getInstance(int detID)
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
uint32_t feb_t
Type for DCM link port. Counts from 0.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
bool IsGoodDiBlock(int idb, int subrun=-1)
int num
Definition: f2_nu.C:119
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
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 nova::dbi::RunHistory::IsBad ( geo::OfflineChan  chan,
time_t  t 
)
inherited

Definition at line 2185 of file RunHistory.cxx.

References nova::dbi::RunHistory::_badChan, febshutoff_auto::chan, MECModelEnuComparisons::i, and confusionMatrixTree::t.

2186  {
2187  unsigned int i=0;
2188  for (; i<_badChan[chan].size() && _badChan[chan][i].tstart<t; ++i);
2189  return _badChan[chan][i-1].isBad;
2190  }
std::map< geo::OfflineChan, std::vector< BadChan_t > > _badChan
Definition: RunHistory.h:557
bool nova::dbi::RunHistory::IsCooled ( const geo::OfflineChan oChan)
inherited

Definition at line 1874 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, geo::OfflineChan::Cell(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), daqchannelmap::DAQChannelMap::getInstance(), and geo::OfflineChan::Plane().

1875  {
1877  daqchannelmap::lchan logChan = dmap->encodeLChan(_detId, oChan.Plane(), oChan.Cell());
1878  daqchannelmap::dchan daqChan = dmap->encodeDChan(logChan);
1879 
1880  return IsCooled(daqChan);
1881  }
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
static DAQChannelMap * getInstance(int detID)
bool IsCooled(const geo::OfflineChan &)
unsigned short Plane() const
Definition: OfflineChan.h:31
unsigned short Cell() const
Definition: OfflineChan.h:32
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 nova::dbi::RunHistory::IsCooled ( const daqchannelmap::dchan daqChan)
inherited

Definition at line 1834 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detId, om::cerr, febshutoff_auto::dcm, allTimeWatchdog::endl, APDHVSetting::feb, daqchannelmap::DAQChannelMap::getDCM(), daqchannelmap::DAQChannelMap::getDiBlock(), daqchannelmap::DAQChannelMap::getFEB(), daqchannelmap::DAQChannelMap::getInstance(), nova::dbi::RunHistory::FEB::hasAPD, nova::dbi::RunHistory::FEB::isCooled, nova::dbi::RunHistory::FEB::isEnabled, nova::dbi::RunHistory::LoadPixelInfo(), and num.

1835  {
1836  std::cerr << __PRETTY_FUNCTION__ << " is not yet implemented!"
1837  << std::endl;
1838 
1839  bool iscooled = false;
1840 
1841  if (!LoadPixelInfo()) return false;
1842 
1844  daqchannelmap::diblock_t diblk = dmap->getDiBlock(daqChan);
1845  daqchannelmap::dcm_id_t dcmId = dmap->getDCM(daqChan);
1846  daqchannelmap::feb_t ifeb = dmap->getFEB(daqChan);
1847 
1848  for (unsigned int iDB=0; iDB<_dbList.size(); ++iDB) {
1849  if (_dbList[iDB].num == (short)diblk) {
1850  if (_dbList[iDB].hasNoAPDs) return iscooled;
1851  int iDCM = dcmId-1;
1852  if (iDCM >= (int)_dbList[iDB].dcm.size()) return iscooled;
1853 
1854  if (!_dbList[iDB].dcm[iDCM].isActive) return iscooled;
1855  if (_dbList[iDB].dcm[iDCM].position == -1) return iscooled;
1856 
1857  if (ifeb >= _dbList[iDB].dcm[iDCM].feb.size()) return iscooled;
1858 
1859  FEB& currFEB = _dbList[iDB].dcm[iDCM].feb[ifeb];
1860  if (!currFEB.isEnabled) return iscooled;
1861 
1862  if ( !currFEB.hasAPD ) return iscooled;
1863 
1864  //everything is fine
1865  iscooled = currFEB.isCooled;
1866  break;
1867  }
1868  }
1869 
1870  return iscooled;
1871  }
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
OStream cerr
Definition: OStream.cxx:7
static DAQChannelMap * getInstance(int detID)
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
uint32_t feb_t
Type for DCM link port. Counts from 0.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
int num
Definition: f2_nu.C:119
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
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 nova::dbi::RunHistory::IsDiBlockFullyInstrumented ( int  idb)
inherited

returns true if nInstrumentedFEBs in diblock (which counts FEBs that are instrumented, active, and unmasked only) is >= 700

Definition at line 1814 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, runNovaSAM::detId, novadaq::cnv::DetInfo::GetId(), MECModelEnuComparisons::i, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, nova::dbi::RunHistory::LoadHardwareInfo(), and num.

Referenced by comi::NearlineAna::beginRun(), and geo::LiveGeometry::SetInstrumentation().

1815  {
1816  LoadHardwareInfo();
1817 
1819 
1820  for (unsigned int i=0; i<_dbList.size(); ++i) {
1821  if (_dbList[i].num == idb) {
1822  if (detId==novadaq::cnv::kFARDET && _dbList[i].nInstrumentedFEBs >= 700) return true;
1823  if (detId==novadaq::cnv::kNEARDET && idb < 4 && _dbList[i].nInstrumentedFEBs >= 175) return true;
1824  if (detId==novadaq::cnv::kNEARDET && idb == 4 && _dbList[i].nInstrumentedFEBs >= 45) return true;
1825  return false;
1826  }
1827  }
1828 
1829  return false;
1830 
1831  }
Far Detector at Ash River, MN.
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
Near Detector in the NuMI cavern.
static int GetId(std::string name)
int num
Definition: f2_nu.C:119
bool nova::dbi::RunHistory::IsGoodDiBlock ( int  idb,
int  subrun = -1 
)
inherited

< Is diblock kept when applying mask? Generally don't use this, just ask for HasAPD (for a channel) or for nInstrumentedFEBs (in a DCM or Diblock) and any mask asked for will already be applied. Always returns good if masking turned off. Diblock number argument 1-14

Definition at line 1188 of file RunHistory.cxx.

References nova::dbi::RunHistory::_currentSR, nova::dbi::RunHistory::_getDiBlockMaskFromCondb, nova::dbi::RunHistory::_subrunList, nova::dbi::RunHistory::_useMasking, allTimeWatchdog::endl, nova::dbi::RunHistory::LoadGoodDiBlockMask(), LOG_WARNING, and x1.

Referenced by nova::dbi::RunHistory::BuildMC(), nova::dbi::RunHistory::HasAPD(), nova::dbi::RunHistory::LoadHardwareInfo(), nova::dbi::RunHistory::NAnalysisChannels(), nova::dbi::RunHistory::NAnalysisDiBlocks(), and chaninfo::BadChanList::NBadInSubRun().

1189  {
1190 
1191  ///< Is diblock kept when applying mask? Generally don't use this, just ask for HasAPD (for a channel) or for nInstrumentedFEBs (in a DCM or Diblock) and any mask asked for will already be applied. Always returns good if masking turned off. Diblock number argument 1-14
1192  if(!_useMasking) return true;
1193 
1195  if (idb < 1) return false;
1196 
1198  subrun = 0;
1199  else {
1200  if (subrun < 0 || subrun > 63) {
1201  if (subrun>63)
1202  LOG_WARNING("RunHistory") << __PRETTY_FUNCTION__ << " invalid subrun " << subrun << ". Converted to subrun " << subrun << std::endl;
1203  subrun = _currentSR;
1204  }
1205 
1206  }
1207 
1208  return ((_subrunList[subrun].goodDiBlockMask >> (idb-1))&0x1);
1209  }
Float_t x1[n_points_granero]
Definition: compare.C:5
#define LOG_WARNING(category)
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
bool nova::dbi::RunHistory::IsRHC ( )
inherited

Definition at line 354 of file RunHistory.cxx.

References nova::dbi::RunHistory::_detId, nova::dbi::RunHistory::_fdRHCRunStart, nova::dbi::RunHistory::_fdRHCRunStop, nova::dbi::RunHistory::_ndRHCRunStart, nova::dbi::RunHistory::_ndRHCRunStop, nova::dbi::RunHistory::_runNumber, om::cerr, allTimeWatchdog::endl, MECModelEnuComparisons::i, novadaq::cnv::kFARDET, and novadaq::cnv::kNEARDET.

Referenced by ifdb::IFDBSpillInfo::produce().

355  {
356  if (_detId == novadaq::cnv::kFARDET) {
357  if (_fdRHCRunStart.empty() || _fdRHCRunStop.empty()) {
358  std::cerr << __PRETTY_FUNCTION__ << " Empty FD RHC run list!" << std::endl;
359  std::abort();
360  }
361  if (_fdRHCRunStart.size() != _fdRHCRunStop.size() ) {
362  std::cerr << __PRETTY_FUNCTION__ << " FD RHC run start list is not the same length as the run stop list. Something is wrong..." << std::endl;
363  std::abort();
364  }
365 
366  for ( size_t i=0; i<_fdRHCRunStart.size(); ++i) {
367  if (_runNumber >= _fdRHCRunStart[i] &&
369  return true;
370  }
371  return false;
372  }
373  else if (_detId == novadaq::cnv::kNEARDET) {
374  if (_ndRHCRunStart.empty() || _ndRHCRunStop.empty()) {
375  std::cerr << __PRETTY_FUNCTION__ << " Empty ND RHC run list!" << std::endl;
376  std::abort();
377  }
378  if (_ndRHCRunStart.size() != _ndRHCRunStop.size() ) {
379  std::cerr << __PRETTY_FUNCTION__ << " ND RHC run start list is not the same length as the run stop list. Something is wrong..." << std::endl;
380  std::abort();
381  }
382 
383  for ( size_t i=0; i<_ndRHCRunStart.size(); ++i) {
384  if (_runNumber >= _ndRHCRunStart[i] &&
386  return true;
387  }
388  return false;
389  }
390  else {
391  std::cerr << __PRETTY_FUNCTION__ << " Unknown detector. Why are asking for beam mode?" << std::endl;
392 
393  }
394  return false;
395  }
OStream cerr
Definition: OStream.cxx:7
Far Detector at Ash River, MN.
Near Detector in the NuMI cavern.
std::vector< int > _fdRHCRunStart
Definition: RunHistory.h:563
std::vector< int > _fdRHCRunStop
Definition: RunHistory.h:564
std::vector< int > _ndRHCRunStart
Definition: RunHistory.h:561
std::vector< int > _ndRHCRunStop
Definition: RunHistory.h:562
bool nova::dbi::RunHistory::LoadAllDetInfo ( )
inlineinherited

Definition at line 349 of file RunHistory.h.

Referenced by nova::dbi::RunHistory::GetDiBlock().

349  { return (LoadDAQRunHistory() &&
350  LoadHardwareInfo() &&
351  LoadPixelInfo() &&
352  LoadAPDSettings()); };
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
bool nova::dbi::RunHistory::LoadAPDSettings ( )
inherited

Definition at line 1070 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gCfgId, nova::dbi::RunHistory::_gotAPDSettings, nova::dbi::RunHistory::_nInstalledAPDs, std::abs(), febshutoff_auto::apd, nova::dbi::RunHistory::FEB::apdV, febshutoff_auto::dcm, runNovaSAM::detId, MakeMiniprodValidationCuts::f, novadaq::cnv::DetInfo::GetId(), dbutils::dcs::APDSettings::getTemperature(), dbutils::dcs::APDSettings::getTemperatureEnable(), dbutils::dcs::APDSettings::getVoltage(), novadaq::cnv::kFARDET, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), LOG_WARNING, nova::dbi::RunHistory::MapHardwareToLocation(), num, string, APDHVSetting::temp, nova::dbi::RunHistory::FEB::tempEnabled, and nova::dbi::RunHistory::FEB::temperature.

Referenced by nova::dbi::RunHistory::GetFEB().

1071  {
1072  if (_gotAPDSettings) return true;
1073 
1074  if (!LoadDAQRunHistory()) return false;
1075 
1076  if (!LoadHardwareInfo()) return false;
1077 
1078  std::vector<std::string> tmpDCMList;
1079  for (unsigned int idb=0; idb<_dbList.size(); ++idb)
1080  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm)
1081  if (_dbList[idb].dcm[idcm].isActive)
1082  tmpDCMList.push_back(_dbList[idb].dcm[idcm].appname);
1083 
1084  char daqEnv[128];
1085  sprintf(daqEnv,"NOVADAQ_ENVIRONMENT=%s",_detector.c_str());
1086  putenv(daqEnv);
1087 
1088  dcscfg::APDSettings apdSettings(_gCfgId, tmpDCMList);
1089 
1090  for (unsigned int idb=0; idb < _dbList.size(); ++idb) {
1091  for (unsigned int idcm = 0; idcm < _dbList[idb].dcm.size(); ++idcm) {
1092  if (! _dbList[idb].dcm[idcm].isActive) continue;
1093  std::string dcmName = _dbList[idb].dcm[idcm].appname;
1094  for (int ifeb = 0; ifeb < 64; ++ifeb) {
1095  FEB& f = _dbList[idb].dcm[idcm].feb[ifeb];
1096  apdSettings.getTemperatureEnable(dcmName,ifeb,f.tempEnabled);
1097  double temp;
1098  apdSettings.getTemperature (dcmName,ifeb,temp);
1099  f.temperature = temp;
1100  apdSettings.getVoltage (dcmName,ifeb,f.apdV);
1101  // apdSettings.getCoolingEnableFlag(dcmName,ifeb,f.isCooled);
1102  }
1103  }
1104  }
1105 
1106  // now get the gains
1107 
1109 
1110  if (detId == novadaq::cnv::kFARDET) {
1111 
1112  // get a map of the hardware locations to the installed APDs and FEBs
1113  this->MapHardwareToLocation();
1114 
1115  _nInstalledAPDs = gLocToFA.size();
1116 
1117  // loop over the gLocToFA map to fill the necessary information
1118  for(auto const& locitr : gLocToFA){
1119 
1120  auto const& hl = locitr.first;
1121  auto const& apd = locitr.second.second;
1122 
1123  if(hl._diblock > _dbList.size() ) continue;
1124  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
1125  if (_dbList[idb].num == (int)hl._diblock) {
1126 
1127  if(_dbList[idb].dcm[hl._dcm-1].isActive) {
1128  if(!_dbList[idb].dcm[hl._dcm-1].feb[hl._feb].hasAPD)
1129  continue;
1130 
1131  auto pixGain = apd._pixelGain;
1132  float avGain = 0.;
1133  float pGain = 0.;
1134  for(size_t p = 0; p < pixGain.size(); ++p){
1135  pGain = pixGain.at(p);
1136  _dbList[idb].dcm[hl._dcm-1].feb[hl._feb].pixelGain.at(p) = pGain;
1137  avGain += pGain;
1138  }
1139  avGain /= 32.;
1140  _dbList[idb].dcm[hl._dcm-1].feb[hl._feb].gain = avGain;
1141 
1142  if(std::abs(100. - avGain) > 10.){
1143  LOG_WARNING("RunHistory") << "average gain for APD "
1144  << apd._sn
1145  << " connected to "
1146  << "dcm-2-" << hl._diblock
1147  << "-" << hl._dcm
1148  << "-" << hl._feb
1149  << " is " << avGain
1150  << " : 100 expected so default to that";
1151  _dbList[idb].dcm[hl._dcm-1].feb[hl._feb].gain = 100.;
1152  for(size_t p = 0; p < pixGain.size(); ++p)
1153  _dbList[idb].dcm[hl._dcm-1].feb[hl._feb].pixelGain.at(p) = 100.;
1154  }
1155  }
1156  }
1157  } // end if the dcm is active
1158  } // end loop over location map
1159  } // end if far detector
1160 
1161  _gotAPDSettings = true;
1162 
1163  return true;
1164  }
const char * p
Definition: xmltok.h:285
std::map< HardwareLocation, std::pair< FEBInfo, APDInfo > > gLocToFA
Definition: RunHistory.cxx:32
float abs(float number)
Definition: d0nt_math.hpp:39
Far Detector at Ash River, MN.
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
#define LOG_WARNING(category)
static int GetId(std::string name)
int num
Definition: f2_nu.C:119
enum BeamMode string
bool nova::dbi::RunHistory::LoadCoolingInfo ( )
inherited

Definition at line 992 of file RunHistory.cxx.

References nova::dbi::RunHistory::_gotCoolingInfo.

993  {
994  if (_gotCoolingInfo) return true;
995 
996  /*
997  if (!_gotDAQRunHistory) {
998  if (!LoadDAQRunHistory()) return false;
999  }
1000  */
1001 
1002  return false;
1003  }
bool nova::dbi::RunHistory::LoadDAQRunHistory ( )
inherited

Definition at line 1551 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_abortIfMissingRunInDB, nova::dbi::RunHistory::_bnevbList, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_diblockIndex, nova::dbi::RunHistory::_failedToFindRun, nova::dbi::RunHistory::_gCfgId, nova::dbi::RunHistory::_gotDAQRunHistory, nova::dbi::RunHistory::_isMC, nova::dbi::RunHistory::_nActiveChannels, nova::dbi::RunHistory::_nDCMs, nova::dbi::RunHistory::_nsubrun, nova::dbi::RunHistory::_partition, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_runType, nova::dbi::RunHistory::_tEnd, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_tStart, nova::dbi::RunHistory::_verbosity, nova::dbi::RunHistory::DCM::appname, nova::dbi::RunHistory::BNEVB::appname, b, nova::dbi::RunHistory::BuildMC(), om::cerr, nova::dbi::Row::Col(), d, febshutoff_auto::db, nova::dbi::RunHistory::DiBlock::dcm, runNovaSAM::detector, runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), nova::dbi::RunHistory::DCM::diblock, allTimeWatchdog::endl, nova::dbi::RunHistory::DCM::feb, Get, nova::dbi::Column::Get(), novadaq::cnv::DetInfo::GetId(), nova::dbi::RunHistory::DiBlock::hasNoAPDs, MECModelEnuComparisons::i, nova::dbi::RunHistory::DCM::isActive, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, LOG_ERROR, LOG_INFO, nova::dbi::RunHistory::DCM::nInstrumentedFEBs, nova::dbi::RunHistory::DiBlock::nInstrumentedFEBs, num, nova::dbi::RunHistory::DiBlock::num, elec2geo::pos, nova::dbi::RunHistory::DCM::position, check_grl::row, nova::dbi::SortDiBlocks(), and string.

Referenced by comi::NearlineAna::beginRun(), comi::DataCheck::beginSubRun(), comi::DataCheck::endJob(), nova::dbi::RunHistory::GetPedestal(), nova::dbi::RunHistory::LoadAPDSettings(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadFEBMasksFromDAQDB(), nova::dbi::RunHistory::LoadHardwareInfo(), nova::dbi::RunHistory::LoadPedestals(), nova::dbi::RunHistory::LoadPixelInfo(), nova::dbi::RunHistory::LoadPixelMasks(), nova::dbi::RunHistory::NAnalysisChannels(), nova::dbi::RunHistory::NAnalysisDiBlocks(), nova::dbi::RunHistory::SubrunTStart(), nova::dbi::RunHistory::SubrunTStop(), nova::dbi::RunHistory::TStart(), and nova::dbi::RunHistory::TStop().

1552  {
1553  if (_gotDAQRunHistory) return true;
1554 
1555  if (_failedToFindRun) {
1556  if (_abortIfMissingRunInDB){
1557  LOG_ERROR("RunHistory")<<"LoadDAQRunHistory: failed to find the run in the runs table." << std::endl;
1558  std::abort();
1559  }
1560  else std::cerr << __PRETTY_FUNCTION__ << " failed to find the run in the runs table." << std::endl;
1561  return false;
1562 
1563  }
1564 
1565  if(_runNumber >= 1000000 || _runNumber < 10000) { // it's MC - assume perfect + mask
1566  LOG_INFO("RunHistory") << "Looks like a MC run number - assume perfect + any mask" << std::endl;
1567  _isMC = true;
1568  BuildMC();
1569  return true;
1570  }
1571 
1572  _nDCMs = 0;
1573 
1574  std::unique_ptr<db::Table> runsTable;
1575  std::unique_ptr<db::Table> resTable;
1576  std::unique_ptr<db::Table> srTable;
1577 
1578  runsTable.reset(new db::Table("RunHistory/tables/Runs.xml"));
1579  srTable.reset(new db::Table("RunHistory/tables/Subruns.xml"));
1580  resTable.reset(new db::Table("RunHistory/tables/DAQResourcesByRun.xml"));
1581  runsTable->SetTimeQueries(_timeQueries);
1582  runsTable->SetTimeParsing(_timeParsing);
1583  srTable->SetTimeQueries(_timeQueries);
1584  srTable->SetTimeParsing(_timeParsing);
1585  resTable->SetTimeQueries(_timeQueries);
1586  resTable->SetTimeParsing(_timeParsing);
1587  resTable->SetVerbosity(100);
1588 
1590  runsTable->SetDetector(_detector);
1591  srTable->SetDetector(_detector);
1592  resTable->SetDetector(_detector);
1593  }
1594  else {
1595  LOG_ERROR("RunHistory")<<"RunHistory::LoadDAQRun: invalid detector name!"<<std::endl;
1596  std::abort();
1597 
1598  }
1599 
1600  runsTable->SetSubSchema("daq");
1601  runsTable->SetValidityRange("run",_runNumber);
1602  runsTable->AddExcludeCol(std::string("nevents"));
1603  runsTable->AddExcludeCol(std::string("begin_comment"));
1604  runsTable->AddExcludeCol(std::string("end_comment"));
1605  runsTable->AddExcludeCol(std::string("shifter"));
1606  runsTable->SetVerbosity(_verbosity);
1607  if (!runsTable->Load()){
1608  LOG_ERROR("RunHistory")<<"LoadDAQRunHistory: failed to load the runs table." << std::endl;
1609  if(_detector=="TestBeam" && _abort) std::abort();
1610  else if (_detector!="TestBeam") std::abort();
1611  }
1612 
1613  if (runsTable->NRow() == 0) {
1614  std::cerr << __PRETTY_FUNCTION__ << " no entry found the runs table!" << std::endl;
1615  _failedToFindRun = true;
1616  return false;
1617  }
1618  db::Row* row = runsTable->GetRow(0);
1619  if (row) {
1620  std::string timeStr;
1621  if (row->Col(runsTable->GetColIndex("tstart")).Get(timeStr)) _tStart = timeStr;
1622  if (row->Col(runsTable->GetColIndex("tstop")).Get(timeStr)) _tEnd = timeStr;
1623  // row->Col(runsTable->GetColIndex("nevents")).Get(_nTotTrig);
1624  row->Col(runsTable->GetColIndex("configid")).Get(_gCfgId);
1625  row->Col(runsTable->GetColIndex("nsubruns")).Get(_nsubrun);
1626  row->Col(runsTable->GetColIndex("nactivechan")).Get(_nActiveChannels);
1627  row->Col(runsTable->GetColIndex("partition")).Get(_partition);
1628  row->Col(runsTable->GetColIndex("runtype")).Get(_runType);
1629  }
1630 
1631  // Load subrun information
1632  /*
1633  srTable->SetSubSchema("daq");
1634  srTable->SetValidityRange("run",_runNumber);
1635  srTable->Load();
1636  std::cout << srTable->NRow() << std::endl;
1637  std::cout << "_nsubrun = " << _nsubrun << std::endl;
1638  */
1639  /*
1640  if (srTable->NRow() == _nsubrun-1) {
1641  int srnum;
1642  std::string tstr1, tstr2;
1643 
1644  int numIdx = srTable->GetColIndex("subrun");
1645  int tstartIdx = srTable->GetColIndex("tstart");
1646  int tstopIdx = srTable->GetColIndex("tstop");
1647 
1648  for (int irow=0; irow<_nsubrun-1; ++irow) {
1649  row = srTable->GetRow(irow);
1650  if (row->Col(numIdx).Get(srnum) &&
1651  row->Col(tstartIdx).Get(tstr1) &&
1652  row->Col(tstopIdx).Get(tstr2)) {
1653  std::cout << srnum << ", " << tstr1 << ", " << tstr2 << std::endl;
1654  nova::dbi::Util::TimeAsStringToTime_t(tstr1,_subrunList[srnum].tstart);
1655  nova::dbi::Util::TimeAsStringToTime_t(tstr2,_subrunList[srnum].tstop);
1656  }
1657  }
1658  }
1659  */
1660 
1661  resTable->SetSubSchema("daq");
1662  resTable->SetValidityRange("run",_runNumber);
1663  resTable->AddOrderColumn("appname");
1664  resTable->SetVerbosity(_verbosity);
1665  if (!resTable->Load())
1666  {
1667  LOG_ERROR("RunHistory")<<"LoadDAQRunHistory: failed to load the resources table." << std::endl;
1668  std::abort();
1669  }
1670 
1671 
1672  int nResources = resTable->NRow();
1673  if (nResources == 0){
1674  LOG_ERROR("RunHistory")<<"LoadDAQRunHistory: no resources found for run " << _runNumber << std::endl;
1675  std::abort();
1676  }
1677 
1678  int rtIdx = resTable->GetColIndex("resource_type");
1679  int anIdx = resTable->GetColIndex("appname");
1680  int detIdx = resTable->GetColIndex("detector");
1681 
1683 
1684  for (int i=0; i<nResources; ++i) {
1685  row = resTable->GetRow(i);
1686  std::string rtype;
1687  std::string appname;
1689  if (row->Col(rtIdx).Get(rtype)) {
1690  row->Col(detIdx).Get(detector);
1691  if(detId == novadaq::cnv::kFARDET&&detector!="FarDet") continue;
1692  if(detId == novadaq::cnv::kNEARDET&&detector!="NearDet") continue;
1693  if (rtype == "bnevb") {
1694  BNEVB b;
1695  row->Col(anIdx).Get(appname);
1696  b.appname = appname;
1697  _bnevbList.push_back(b);
1698  }
1699  else if (rtype == "dcm") {
1700  row->Col(anIdx).Get(appname);
1701  bool foundDiBlock = false;
1702  short dbnum = atoi(appname.substr(6,2).c_str());
1703  short pos = atoi(appname.substr(9,2).c_str());
1704  _nDCMs++;
1705  /*
1706  JMP, 2015-11-03: this is strange logic, and created an infinite loop,
1707  since IsGoodDiBlock requires loading the DAQRunHistory. Removing.
1708  if(_useMasking && IsGoodDiBlock(int(dbnum))==false) {
1709  continue; // ignore masked diblocks
1710  }
1711  */
1712 
1713  for (unsigned int idb=0; idb < _dbList.size(); ++idb) {
1714  if (_dbList[idb].num == dbnum) {
1715  _dbList[idb].dcm[pos-1].appname = appname;
1716  _dbList[idb].dcm[pos-1].position = pos;
1717  _dbList[idb].dcm[pos-1].diblock = dbnum;
1718  _dbList[idb].dcm[pos-1].isActive = true;
1719  _dbList[idb].dcm[pos-1].feb.resize(64);
1720  _dbList[idb].dcm[pos-1].nInstrumentedFEBs = 0;
1721  foundDiBlock = true;
1722  break;
1723  }
1724  }
1725  if (!foundDiBlock) {
1726  // diblock does not yet exist, build it
1727  unsigned int ndcms=12;
1728  if (detId == novadaq::cnv::kNEARDET)
1729  ndcms=4;
1730  DiBlock db(ndcms);
1731  db.num = dbnum;
1732  _diblockIndex[dbnum] = _dbList.size();
1733  db.hasNoAPDs = true;
1734  db.nInstrumentedFEBs = 0;
1735  DCM d;
1736  d.appname = appname;
1737  d.diblock = dbnum;
1738  d.position = pos;
1739  d.isActive = true;
1740  d.feb.resize(64);
1741  d.nInstrumentedFEBs = 0;
1742  db.dcm[d.position-1] = d;
1743 
1744  _dbList.push_back(db);
1745  }
1746  }
1747  }
1748  }
1749  std::sort(_dbList.begin(), _dbList.end(), SortDiBlocks);
1750  for (size_t i=0; i<_dbList.size(); ++i)
1751  _diblockIndex[_dbList[i].num] = i;
1752 
1753 
1754  _gotDAQRunHistory = true;
1755  return true;
1756  }
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
std::string _tStart
Definition: RunHistory.h:551
std::string _runType
Definition: RunHistory.h:547
OStream cerr
Definition: OStream.cxx:7
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
std::vector< BNEVB > _bnevbList
Definition: RunHistory.h:556
bool Get(T &val) const
Definition: Column.h:85
Far Detector at Ash River, MN.
bool SortDiBlocks(RunHistory::DiBlock db1, RunHistory::DiBlock db2)
Definition: RunHistory.cxx:72
std::map< int, int > _diblockIndex
Definition: RunHistory.h:495
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
Near Detector in the NuMI cavern.
Float_t d
Definition: plot.C:236
static int GetId(std::string name)
int num
Definition: f2_nu.C:119
const hit & b
Definition: hits.cxx:21
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
enum BeamMode string
bool nova::dbi::RunHistory::LoadDataEpoch ( )
inherited

Definition at line 1214 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dataEpoch, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gotDataEpoch, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, novadaq::cnv::DetInfo::DetNameOk(), allTimeWatchdog::endl, MECModelEnuComparisons::i, LOG_ERROR, nova::dbi::DataEpoch::name, nova::dbi::DataEpoch::run_end, nova::dbi::DataEpoch::run_start, and confusionMatrixTree::t.

1215  {
1216  if (_gotDataEpoch) return true;
1217 
1218  std::unique_ptr<db::Table> t;
1219  t.reset(new db::Table("RunHistory/tables/DataEpochs.xml"));
1220 
1222  t->SetDetector(_detector);
1223  else
1224  return false;
1225 
1226  int nameIdx = t->GetColIndex("name");
1227  int rstartIdx = t->GetColIndex("run_start");
1228  int rendIdx = t->GetColIndex("run_end");
1229 
1230  t->SetVerbosity(_verbosity);
1231  t->SetTimeQueries(_timeQueries);
1232  t->SetTimeParsing(_timeParsing);
1233 
1234  bool loadFailed = false;
1235 
1236  // exclude these columns in case of formatting issues (,\', etc.)
1237  if (! t->Load()) loadFailed = true;
1238 
1239  if (loadFailed) {
1240  LOG_ERROR("RunHistory") << "Loading of data epoch info from database failed." << std::endl;
1241  return false;
1242  }
1243 
1244  int nRow = t->NRow();
1245  int runStart = 0;
1246  int runEnd = 0;
1247 
1248  for (int i=0; i<nRow; ++i) {
1249  t->GetRow(i)->Col(rstartIdx).Get(runStart);
1250  if (! t->GetRow(i)->Col(rendIdx).Get(runEnd))
1251  runEnd = 0;
1252  if (_runNumber >= runStart && (_runNumber <= runEnd || runEnd==0 )) {
1253  _dataEpoch.run_start = runStart;
1254  _dataEpoch.run_end = runEnd;
1255  t->GetRow(i)->Col(nameIdx).Get(_dataEpoch.name);
1256  _gotDataEpoch = true;
1257  break;
1258  }
1259  }
1260 
1261  if (!_gotDataEpoch) {
1262  LOG_ERROR("RunHistory") << "Failed to find data epoch in the database!" << std::endl;
1263  _gotDataEpoch = true;
1264  return false;
1265  }
1266 
1267  _gotDataEpoch = true;
1268  return true;
1269  }
std::string _detector
Definition: RunHistory.h:550
std::string name
Definition: RunHistory.h:59
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool nova::dbi::RunHistory::LoadDCSAlarms ( int  subrun = -1)
inherited

Definition at line 399 of file RunHistory.cxx.

400  {
401  /*
402  if (!_gotDAQRunHistory) {
403  if (!LoadDAQRunHistory()) return false;
404  }
405  */
406 
407  return false;
408  }
bool nova::dbi::RunHistory::LoadFEBMasks ( )
inherited

Definition at line 785 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gotFEBMasks, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, om::cerr, nova::dbi::Row::Col(), febshutoff_auto::dcm, runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), allTimeWatchdog::endl, nova::dbi::Column::Get(), novadaq::cnv::DetInfo::GetId(), nova::dbi::kDataOnly, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), LOG_ERROR, LOG_INFO, LOG_WARNING, check_grl::row, and confusionMatrixTree::t.

Referenced by nova::dbi::RunHistory::GetPedestal(), nova::dbi::RunHistory::LoadPedestals(), and nova::dbi::RunHistory::LoadPixelMasks().

786  {
787  if (_gotFEBMasks) return true;
788 
789  if (! LoadDAQRunHistory()) return false;
790  if (! LoadHardwareInfo()) return false;
791 
792  std::unique_ptr<db::Table> t;
793  t.reset(new db::Table("RunHistory/tables/FEBMasksByRun.xml"));
794 
796  t->SetDetector(_detector);
797  else
798  return false;
799 
800  int maskIdx = t->GetColIndex("mask");
801 
802  t->SetDataTypeMask(nova::dbi::kDataOnly);
803  t->SetMinTSVld(_runNumber);
804  t->SetMaxTSVld(_runNumber);
805  t->SetTimeQueries(_timeQueries);
806  t->SetTimeParsing(_timeParsing);
807  t->SetVerbosity(_verbosity);
808 
809  LOG_INFO("RunHistory") << "RunHistory: loading FEB enable masks" << std::endl;
810 
811  if (!t->Load()) {
812  std::cerr << __PRETTY_FUNCTION__ << "No pixel masks found in DB!";
813  if(_abort) std::abort();
814  return false;
815  }
816  else {
817  if (t->NRow() == 0) {
818  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << ": failed to get any rows from database, which should not happen." << std::endl;
819  if (_abort) std::abort();
820  }
821  }
822 
823  t->FillChanRowMap();
825 
826  // int nrow = t->NRow();
828  int64_t pMask;
829 
830  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
831  int dbNum = _dbList[idb].num;
832  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm) {
833  if (! _dbList[idb].dcm[idcm].isActive) continue;
834  int dcmNum = _dbList[idb].dcm[idcm].position;
835  int tchan = detId*1000000 + 10000*dbNum + 100*dcmNum;
836  row = t->GetVldRow(tchan,_runNumber);
837  if (!row) {
838  LOG_WARNING("RunHistory") << "No row found for channel " << tchan << std::endl;
839  continue;
840  }
841  row->Col(maskIdx).Get(pMask);
842  _dbList[idb].dcm[idcm].febMask = pMask;
843  }
844  }
845  _gotFEBMasks = true;
846 
847  return true;
848 
849  }
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
OStream cerr
Definition: OStream.cxx:7
bool Get(T &val) const
Definition: Column.h:85
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
#define LOG_WARNING(category)
static int GetId(std::string name)
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool nova::dbi::RunHistory::LoadFEBMasksFromDAQDB ( )
inherited

Definition at line 853 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gCfgId, nova::dbi::RunHistory::_gotFEBMasks, nova::dbi::RunHistory::_gotPixelInfo, nova::dbi::RunHistory::_nTotalChannels, nova::dbi::RunHistory::_nTotalFEBs, febshutoff_auto::dcm, allTimeWatchdog::endl, dbutils::daqconfig::PixelEnableMasks::getFEBEnableMask(), dbutils::daqconfig::PixelEnableMasks::hasValidData(), MECModelEnuComparisons::i, calib::j, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), LOG_INFO, and string.

854  {
855  if (_gotPixelInfo) return true;
856  if (_gotFEBMasks) return true;
857 
858  if (! LoadDAQRunHistory()) return false;
859  if (! LoadHardwareInfo()) return false;
860 
861  _nTotalChannels=0;
862  _nTotalFEBs=0;
863 
864  char daqEnv[128];
865  sprintf(daqEnv,"NOVADAQ_ENVIRONMENT=%s",_detector.c_str());
866  putenv(daqEnv);
867 
868  std::vector<std::string> tmpDCMList;
869  for (unsigned int i=0; i<_dbList.size(); ++i)
870  for (unsigned int j=0; j < _dbList[i].dcm.size(); ++j) {
871  if (_dbList[i].dcm[j].isActive)
872  tmpDCMList.push_back(_dbList[i].dcm[j].appname);
873  }
874 
875  //TStopwatch ts;
876  //ts.Start();
877  LOG_INFO("RunHistory") << "RunHistory: loading pixel enable masks" << std::endl;
878  daqcfg::PixelEnableMasks pixelEnableMasks(_gCfgId, tmpDCMList);
879 
880  bool hasValidData = pixelEnableMasks.hasValidData();
881  if (hasValidData) {
882  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
883  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm) {
884  if (! _dbList[idb].dcm[idcm].isActive) continue;
885 
886  std::string dcmName = _dbList[idb].dcm[idcm].appname;
887  int64_t febMask = 0;
888  pixelEnableMasks.getFEBEnableMask(dcmName, febMask);
889  _dbList[idb].dcm[idcm].febMask = febMask;
890  }
891  }
892  }
893  else {
894  return false;
895  }
896 
897  _gotFEBMasks = true;
898  return true;
899  }
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
const double j
Definition: BetheBloch.cxx:29
#define LOG_INFO(stream)
Definition: Messenger.h:144
enum BeamMode string
bool nova::dbi::RunHistory::LoadGoodDiBlockMask ( )
inherited

Definition at line 1273 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_analysisDiBlockMasking, nova::dbi::RunHistory::_customMask, nova::dbi::RunHistory::_customMasking, nova::dbi::RunHistory::_dbMaskTag, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_getDiBlockMaskFromCondb, nova::dbi::RunHistory::_gotGoodDiBlockMask, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_subrunList, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_useMasking, nova::dbi::RunHistory::_verbosity, nova::dbi::RunHistory::ApplyAnalysisDiBlockMask(), om::cerr, nova::dbi::Row::Col(), runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), nova::dbi::RunHistory::DiBlockMaskToString(), allTimeWatchdog::endl, nova::dbi::Column::Get(), novadaq::cnv::DetInfo::GetId(), nova::dbi::kDataOnly, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, check_grl::row, string, and confusionMatrixTree::t.

Referenced by nova::dbi::RunHistory::GoodDiBlockMask(), and nova::dbi::RunHistory::IsGoodDiBlock().

1274  {
1275  if (_gotGoodDiBlockMask) return true;
1276 
1277  // if (!LoadDAQRunHistory()) return false;
1278 
1279  if(_useMasking==false) { // if masking is turned off, set the mask so the CAFs see this
1280  _subrunList[0].goodDiBlockMask = (1<<17)-1;
1281  _gotGoodDiBlockMask = true;
1282  return true;
1283  }
1284 
1286 
1287  if(detId==novadaq::cnv::kNEARDET) { // switch masking off for ND for now
1288  _useMasking = false;
1289  _gotGoodDiBlockMask = true;
1290  return true;
1291  }
1292 
1293  if(_customMasking && detId==novadaq::cnv::kFARDET) {
1294  for (int isr=0; isr<64; ++isr)
1295  _subrunList[isr].goodDiBlockMask = _customMask;
1296  _gotGoodDiBlockMask = true;
1297  LOG_INFO("RunHistory") << __PRETTY_FUNCTION__ << "Applying custom mask: " << DiBlockMaskToString(_subrunList[0].goodDiBlockMask) << std::endl;
1298  return true;
1299  }
1300 
1301  if(_runNumber >= 1000000 || _runNumber < 10000) { // for MC-like run numbers, leave these with no mask. no need to access DB and cause crashes in MC sim or old ideal MC
1302  _useMasking = false;
1303  _subrunList[0].goodDiBlockMask = (1<<17)-1;
1304  for (int isr=1; isr<64; ++isr)
1305  _subrunList[isr].goodDiBlockMask = _subrunList[0].goodDiBlockMask;
1306  _gotGoodDiBlockMask = true;
1307  return true;
1308  }
1309 
1310  bool fallback = false;
1311 
1312  std::unique_ptr<db::Table> t;
1313 
1315  t.reset(new db::Table("RunHistory/tables/DQValidity.xml"));
1316  else
1317  t.reset(new db::Table("RunHistory/tables/GoodDiBlocksVsRun.xml"));
1318 
1320  t->SetDetector(_detector);
1321  else
1322  return false;
1323 
1324  int maskIdx = t->GetColIndex("dbmask");
1325  t->SetVerbosity(_verbosity);
1326  t->SetTimeQueries(_timeQueries);
1327  t->SetTimeParsing(_timeParsing);
1328 
1329  if (!_getDiBlockMaskFromCondb) {
1330  t->SetValidityRange("run",_runNumber);
1331  t->AddOrderColumn("inserttime");
1332  t->SetOrderDesc();
1333  }
1334  else {
1335  t->SetTag(_dbMaskTag);
1336  t->SetMinTSVld(_runNumber*100);
1337  t->SetMaxTSVld((_runNumber+1)*100-1);
1338  t->SetDataTypeMask(nova::dbi::kDataOnly);
1339  t->AddExcludeCol(std::string("comment"));
1340  t->AddExcludeCol(std::string("flag"));
1341  t->AddExcludeCol(std::string("miprate"));
1342  t->AddExcludeCol(std::string("ngooddb"));
1343  t->AddExcludeCol(std::string("numslc"));
1344  t->AddExcludeCol(std::string("trkfrac"));
1345  }
1346  bool loadFailed = false;
1347 
1348  // exclude these columns in case of formatting issues (,\', etc.)
1349  if (! t->Load()) loadFailed = true;
1350 
1351  if (loadFailed || t->NRow() == 0) {
1352  std::cerr << __PRETTY_FUNCTION__ << "No mask found in DB!";
1353  if(_abort) std::abort();
1354  LOG_WARNING("RunHistory") << __PRETTY_FUNCTION__ << ": RunHistory::LoadGoodDiBlockMask(): No good diblock mask";
1355  LOG_WARNING("RunHistory") << " info found for run " << _runNumber << ", so assuming all";
1356  LOG_WARNING("RunHistory") << " good diblocks" << std::endl;
1357  fallback = true;
1358  // use a wide open mask; added benefit: the mask will appear in CAF files downstream as unphysical
1359  }
1360  else {
1361  if (!_getDiBlockMaskFromCondb) {
1362  t->GetRow(0)->Col(maskIdx).Get(_subrunList[0].goodDiBlockMask);
1363  for (size_t isr=1; isr<64; ++isr)
1364  _subrunList[isr].goodDiBlockMask = _subrunList[0].goodDiBlockMask;
1365  }
1366  else {
1367  t->FillChanRowMap();
1368  int tmask;
1369  for (int isr=0; isr<64; ++isr) {
1370  int tvld = _runNumber*100+isr;
1371  nova::dbi::Row* row = t->GetVldRow(0,tvld);
1372  row->Col(maskIdx).Get(tmask);
1373  _subrunList[isr].goodDiBlockMask = tmask;
1374  }
1375  }
1376  }
1377 
1378  // if asked for in the .fcl, modify the mask to meet analysis requirements
1379  // (far det only, and only if we found a real mask to begin with)
1380  if ( _analysisDiBlockMasking && detId==novadaq::cnv::kFARDET && !fallback) {
1381  LOG_DEBUG("RunHistory") << __PRETTY_FUNCTION__ << ": Applying analysis diblock masking: ";
1382  for (int isr=0; isr<64; ++isr) {
1383  int newMask = ApplyAnalysisDiBlockMask(_subrunList[isr].goodDiBlockMask);
1384  if (newMask==_subrunList[isr].goodDiBlockMask) {
1385  LOG_DEBUG("RunHistory") << "mask [" << isr << "] unchanged from " <<
1386  DiBlockMaskToString(_subrunList[isr].goodDiBlockMask) << std::endl;
1387  }
1388  else {
1389  LOG_INFO("RunHistory") << "mask [" << isr << "] modified from "
1390  << DiBlockMaskToString(_subrunList[isr].goodDiBlockMask)
1391  << " to "
1392  << DiBlockMaskToString(newMask) << std::endl;
1393  }
1394  _subrunList[isr].goodDiBlockMask = newMask;
1395 
1396  if (!_subrunList[isr].goodDiBlockMask) {
1397  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << "WARNING: entire detector masked off by analysis requirements!" << std::endl;
1398  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << "No analyzable detector region found for run " << _runNumber << ", subrun " << isr << std::endl;
1399  //// Not returning here, as this return value doesn't seem to be trapped by the invokers, so best
1400  //// to let the code fail gracefully downstream when it sees no hits.
1401  // return false;
1402  }
1403  }
1404  }
1405 
1406  _gotGoodDiBlockMask = true;
1407 
1408  return true;
1409  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
int ApplyAnalysisDiBlockMask(const int mask) const
converts normal mask to analysis rules mask (any continuous chunk of four or more diblocks kept) ...
OStream cerr
Definition: OStream.cxx:7
bool Get(T &val) const
Definition: Column.h:85
Far Detector at Ash River, MN.
std::string DiBlockMaskToString(const int mask) const
std::string _detector
Definition: RunHistory.h:550
Near Detector in the NuMI cavern.
#define LOG_WARNING(category)
static int GetId(std::string name)
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
std::string _dbMaskTag
Definition: RunHistory.h:488
enum BeamMode string
bool nova::dbi::RunHistory::LoadHardwareInfo ( )
inherited

Definition at line 412 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_diblockIndex, nova::dbi::RunHistory::_gotHardwareInfo, nova::dbi::RunHistory::_nInstalledAPDs, nova::dbi::RunHistory::_nRetryLoads, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_tStart, nova::dbi::RunHistory::_useMasking, nova::dbi::RunHistory::_verbosity, om::cerr, febshutoff_auto::dcm, runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), geo2elec::diblock, allTimeWatchdog::endl, APDHVSetting::feb, novadaq::cnv::DetInfo::GetId(), MECModelEnuComparisons::i, nova::dbi::RunHistory::IsGoodDiBlock(), novadaq::cnv::kFARDET, nova::dbi::kHardwareTable, novadaq::cnv::kNEARDET, nova::dbi::RunHistory::LoadDAQRunHistory(), LOG_ERROR, LOG_INFO, febshutoff_auto::query, and string.

Referenced by nova::dbi::RunHistory::GetConfiguration(), nova::dbi::RunHistory::GetDiBlock(), nova::dbi::RunHistory::GetPedestal(), nova::dbi::RunHistory::HasAPD(), nova::dbi::RunHistory::IsDiBlockFullyInstrumented(), nova::dbi::RunHistory::LoadAPDSettings(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadFEBMasksFromDAQDB(), nova::dbi::RunHistory::LoadPedestals(), nova::dbi::RunHistory::LoadPixelInfo(), nova::dbi::RunHistory::LoadPixelMasks(), nova::dbi::RunHistory::NAnalysisChannels(), nova::dbi::RunHistory::NAnalysisDiBlocks(), nova::dbi::RunHistory::NDCMs(), and nova::dbi::RunHistory::NLiveDCMs().

413  {
414  if (_gotHardwareInfo) return true;
415 
416  if (!LoadDAQRunHistory()) return false;
417 
418  LOG_INFO("RunHistory") << "RunHistory: Loading FEB and APD installation information" << std::endl;
419 
421 
422  std::unique_ptr<db::Table> hwTable;
423 
424  hwTable.reset(new db::Table());
425 
427  hwTable->SetDetector(_detector);
428  else
429  return false;
430 
431  hwTable->SetTableType(nova::dbi::kHardwareTable);
432  hwTable->SetTimeQueries(_timeQueries);
433  hwTable->SetVerbosity(_verbosity);
434 
435  bool gotConnection = hwTable->GetConnection(_nRetryLoads);
436 
437  if (!gotConnection) {
438  LOG_ERROR("RunHistory") <<"RunHistory::LoadHardwareInfo(): Failed to connect to hardware database! Failed to load hardware info." << std::endl;
439  std::abort();
440  }
441 
443  PGresult* res;
444 
445  if (detId == novadaq::cnv::kNEARDET) {
446  query="SELECT dcm_name,dcm_port,block,plane,module_position from hardware_position where detector='NearDet' and install_date at time zone 'UTC' < '" + _tStart + "' and (remove_date is NULL or remove_date at time zone 'UTC' > '" + _tStart + "') and hw_type='APD' order by dcm_name,dcm_port";
447 
448  if (hwTable->ExecuteSQL(query,res)) {
449  if (PQresultStatus(res) != PGRES_TUPLES_OK) {
450  std::cerr << __PRETTY_FUNCTION__ << " Query failed: " << query << std::endl;
451  PQclear(res);
452  hwTable->CloseConnection();
453  return false;
454  }
455 
456  std::string dcmName;
457 
458  int nRow = PQntuples(res);
459  for (int i=0; i < nRow; i++) {
460  dcmName = PQgetvalue(res,i,0);
461  int ifeb = atoi(PQgetvalue(res,i,1));
462  short diblock = atoi(dcmName.substr(6,2).c_str());
463  // if(_useMasking && IsGoodDiBlock(int(diblock))==false) break; // ignore masked diblocks
464  unsigned int idcm = atoi(dcmName.substr(9,2).c_str());
465  int idb = _diblockIndex[diblock];
466  if (_dbList[idb].dcm[idcm-1].isActive) {
467  if (_dbList[idb].hasNoAPDs)
468  _dbList[idb].hasNoAPDs = false;
469  if (_dbList[idb].dcm[idcm-1].feb[ifeb].hasAPD) continue;
470  _dbList[idb].dcm[idcm-1].feb[ifeb].hasAPD = true;
471  _dbList[idb].dcm[idcm-1].feb[ifeb].block = atoi(PQgetvalue(res,i,2));
472  _dbList[idb].dcm[idcm-1].feb[ifeb].layer = atoi(PQgetvalue(res,i,3));
473  _dbList[idb].dcm[idcm-1].feb[ifeb].pos_in_layer = atoi(PQgetvalue(res,i,4));
474  _dbList[idb].dcm[idcm-1].nInstrumentedFEBs++;
475  _dbList[idb].nInstrumentedFEBs++;
476  ++_nInstalledAPDs;
477  }
478  }
479  PQclear(res);
480  }
481 
482  }
483  else if (detId == novadaq::cnv::kFARDET) {
484 
485  // get locations of installed APDs
486 
487  query="SELECT btrim(fcom.location1,'DIBLK:') diblk, btrim(fcom.position1,'DCM:') pos, CAST(btrim(fcom.port1,'PRT:') AS INT) feb, mod.block AS block, mod.layer AS plane, mod.position_in_layer AS position FROM public.feb_comm_cables fcom, ashriverprod_factory.module mod LEFT OUTER JOIN ashriverprod_factory.barcoded_item bm ON (mod.barcoded_item_id = bm.barcoded_item_id) LEFT OUTER JOIN ashriverprod_factory.module_apd_connection ON (mod.barcoded_item_id = module_apd_connection.module) LEFT OUTER JOIN ashriverprod_factory.apd ON (module_apd_connection.apd = apd.barcoded_item_id) LEFT OUTER JOIN ashriverprod_factory.barcoded_item ba ON (apd.barcoded_item_id = ba.barcoded_item_id) LEFT OUTER JOIN ashriverprod_factory.nova_connection mac ON (mac.connection_id = module_apd_connection.connection_id) WHERE mac.date_created AT TIME ZONE 'CDT' < '" + _tStart + "' and (mac.date_removed is NULL or mac.date_removed AT TIME ZONE 'CDT' > '" + _tStart + "') and (mod.block=CAST(btrim(fcom.location2,'BLK:') AS INT) and mod.layer=CAST(btrim(fcom.position2,'PLN:') AS INT) and mod.position_in_layer=CAST(btrim(fcom.port2,'POS:') AS INT)) ORDER BY diblk,pos,feb";
488 
489  if (hwTable->ExecuteSQL(query,res)) {
490  if (PQresultStatus(res) != PGRES_TUPLES_OK) {
491  std::cerr << __PRETTY_FUNCTION__ << " Query failed: " << query << std::endl;
492  PQclear(res);
493  hwTable->CloseConnection();
494  return false;
495  }
496 
497  std::string dcmName;
498 
499  int nRow = PQntuples(res);
500  for (int i=0; i < nRow; i++) {
501  int diblock = atoi(PQgetvalue(res,i,0));
502  if(_useMasking && IsGoodDiBlock(diblock)==false) continue; // ignore masked diblocks
503  unsigned int idcm = atoi(PQgetvalue(res,i,1));
504  // if(std::string(PQgetvalue(res,i,6)).compare(0,3,"S11") != 0) // one possible way of checking for permanently bad APDs, depending on DB
505  int idb = _diblockIndex[diblock];
506  int ifeb = atoi(PQgetvalue(res,i,2));
507  if( (diblock==4 &&idcm==7 &&ifeb==15) || // hard code list of permanently bad APDs to ignore
508  (diblock==5 &&idcm==7 &&ifeb==59) ||
509  (diblock==14&&idcm==6 &&ifeb==42) ) continue;
510  if (_dbList[idb].dcm[idcm-1].isActive) {
511  if (_dbList[idb].hasNoAPDs)
512  _dbList[idb].hasNoAPDs = false;
513  if (_dbList[idb].dcm[idcm-1].feb[ifeb].hasAPD) continue;
514  _dbList[idb].dcm[idcm-1].feb[ifeb].hasAPD = true;
515  _dbList[idb].dcm[idcm-1].feb[ifeb].block = atoi(PQgetvalue(res,i,3));
516  _dbList[idb].dcm[idcm-1].feb[ifeb].layer = atoi(PQgetvalue(res,i,4));
517  _dbList[idb].dcm[idcm-1].feb[ifeb].pos_in_layer = atoi(PQgetvalue(res,i,5));
518  _dbList[idb].dcm[idcm-1].nInstrumentedFEBs++;
519  _dbList[idb].nInstrumentedFEBs++;
520  ++_nInstalledAPDs;
521  }
522  }
523  PQclear(res);
524  }
525  else {
526  std::cerr << __PRETTY_FUNCTION__ << " SQL error, failed query: " << query << std::endl;
527  PQclear(res);
528  hwTable->CloseConnection();
529  return false;
530  }
531  }
532 
533  hwTable->CloseConnection();
534  _gotHardwareInfo = true;
535 
536  return true;
537  }
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
std::string _tStart
Definition: RunHistory.h:551
OStream cerr
Definition: OStream.cxx:7
pg_result PGresult
Definition: Table.h:25
Far Detector at Ash River, MN.
std::map< int, int > _diblockIndex
Definition: RunHistory.h:495
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
Near Detector in the NuMI cavern.
static int GetId(std::string name)
bool IsGoodDiBlock(int idb, int subrun=-1)
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
enum BeamMode string
bool nova::dbi::RunHistory::LoadPedestals ( )
inherited

Definition at line 541 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gotPedestals, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, getBrightness::cell, om::cerr, febshutoff_auto::chan, nova::dbi::Row::Col(), febshutoff_auto::dcm, runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), daqchannelmap::DAQChannelMap::encodeDChan(), daqchannelmap::DAQChannelMap::encodeLChan(), allTimeWatchdog::endl, nova::dbi::Column::Get(), daqchannelmap::DAQChannelMap::getCell(), novadaq::cnv::DetInfo::GetId(), daqchannelmap::DAQChannelMap::getInstance(), daqchannelmap::DAQChannelMap::getPlane(), ip, nova::dbi::kDataOnly, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadHardwareInfo(), nova::dbi::RunHistory::LoadPixelMasks(), LOG_ERROR, LOG_INFO, LOG_WARNING, NDAPDHVSetting::plane, check_grl::row, confusionMatrixTree::t, geo::OfflineChan::ToDBValidityChan(), and x1.

Referenced by nova::dbi::RunHistory::GetPedestal().

542  {
543  if (_runNumber >= 1000000 || _runNumber < 10000) {
544  LOG_ERROR("RunHistory") << "Ideal run number not acceptable for this method. Aborting.";
545  std::abort();
546  }
547 
548  if (_gotPedestals) return true;
549 
550  if (! LoadDAQRunHistory()) return false;
551  if (! LoadHardwareInfo()) return false;
552  if (! LoadFEBMasks()) return false;
553  if (! LoadPixelMasks()) return false;
554 
555  std::unique_ptr<db::Table> t;
556  t.reset(new db::Table("RunHistory/tables/PedestalsByRun.xml"));
557 
559  t->SetDetector(_detector);
560  else
561  return false;
562 
563  int pedIdx = t->GetColIndex("ped");
564 
565  t->SetDataTypeMask(nova::dbi::kDataOnly);
566  t->SetMinTSVld(_runNumber);
567  t->SetMaxTSVld(_runNumber);
568  t->SetTimeQueries(_timeQueries);
569  t->SetTimeParsing(_timeParsing);
570  t->SetVerbosity(_verbosity);
571 
572  LOG_INFO("RunHistory") << "RunHistory: loading channel pedestals" << std::endl;
573 
574  if (!t->Load()) {
575  std::cerr << __PRETTY_FUNCTION__ << "No pedestals found in DB!";
576  if(_abort) std::abort();
577  return false;
578  }
579  else {
580  if (t->NRow() == 0) {
581  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << ": failed to get any rows from database, which should not happen." << std::endl;
582  if (_abort) std::abort();
583  }
584  }
585 
586  t->FillChanRowMap();
588  // int nrow = t->NRow();
590  int16_t ped = 0;
592 
593  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
594  int dbNum = _dbList[idb].num;
595  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm) {
596  if (! _dbList[idb].dcm[idcm].isActive) continue;
597  int dcmNum = _dbList[idb].dcm[idcm].position;
598  int nfebs = _dbList[idb].dcm[idcm].feb.size();
599  int64_t febmask = _dbList[idb].dcm[idcm].febMask;
600  for (int ifeb=0; ifeb<nfebs; ++ifeb) {
601  if (!(febmask >> ifeb)&0x1) continue;
602  for (int ip=0; ip<32; ++ip) {
603  daqchannelmap::dchan daqChan = daqcmap->encodeDChan(detId,dbNum,
604  dcmNum,ifeb,ip);
605  daqchannelmap::lchan logChan = daqcmap->encodeLChan(daqChan);
606 
607  int plane = daqcmap->getPlane(logChan);
608  int cell = daqcmap->getCell(logChan);
609  geo::OfflineChan chan(plane, cell);
610  int tchan = chan.ToDBValidityChan();
611 
612  row = t->GetVldRow(tchan,_runNumber);
613  if (!row) {
614  LOG_WARNING("RunHistory") << "No row found for channel " << tchan << std::endl;
615  continue;
616  }
617  row->Col(pedIdx).Get(ped);
618  _dbList[idb].dcm[idcm].feb[ifeb].pixelThresh[ip] = ped;
619  }
620  }
621  }
622  }
623  LOG_INFO("RunHistory") << "done!" << std::endl;
624 
625  _gotPedestals = true;
626 
627  return true;
628  }
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
Float_t x1[n_points_granero]
Definition: compare.C:5
OStream cerr
Definition: OStream.cxx:7
TString ip
Definition: loadincs.C:5
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
static DAQChannelMap * getInstance(int detID)
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
#define LOG_WARNING(category)
static int GetId(std::string name)
A (plane, cell) pair.
Definition: OfflineChan.h:17
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
#define LOG_INFO(stream)
Definition: Messenger.h:144
uint32_t dchan
< DAQ Channel Map Package
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool nova::dbi::RunHistory::LoadPixelInfo ( int  nAttempt = 0)
inherited

Definition at line 903 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gCfgId, nova::dbi::RunHistory::_gotPixelInfo, nova::dbi::RunHistory::_nRetryLoads, nova::dbi::RunHistory::_nTotalChannels, nova::dbi::RunHistory::_nTotalFEBs, om::cerr, febshutoff_auto::dcm, allTimeWatchdog::endl, MakeMiniprodValidationCuts::f, dbutils::daqconfig::PixelEnableMasks::febIsEnabled(), dbutils::daqconfig::PixelEnableMasks::getFEBEnableMask(), dbutils::daqconfig::PixelEnableMasks::getPixelEnableMask(), dbutils::daqconfig::PixelThresholds::getThresholdsForFEB(), dbutils::daqconfig::PixelThresholds::hasValidData(), dbutils::daqconfig::PixelEnableMasks::hasValidData(), MECModelEnuComparisons::i, nova::dbi::RunHistory::FEB::isEnabled, calib::j, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), LOG_INFO, nova::dbi::RunHistory::FEB::nActivePix, nova::dbi::RunHistory::FEB::pixelMask, nova::dbi::RunHistory::FEB::pixelThresh, and string.

Referenced by calib::PEResponse::beginRun(), nova::dbi::RunHistory::GetThreshold(), and nova::dbi::RunHistory::IsCooled().

904  {
905  if (nAttempt > _nRetryLoads) {
906  std::cerr << __PRETTY_FUNCTION__ << " giving up!"
907  << std::endl;
908  return false;
909  }
910 
911  if (_gotPixelInfo) return true;
912 
913  if (! LoadDAQRunHistory()) return false;
914  if (! LoadHardwareInfo()) return false;
915 
916  _nTotalChannels=0;
917  _nTotalFEBs=0;
918 
919  char daqEnv[128];
920  sprintf(daqEnv,"NOVADAQ_ENVIRONMENT=%s",_detector.c_str());
921  putenv(daqEnv);
922 
923  std::vector<std::string> tmpDCMList;
924  for (unsigned int i=0; i<_dbList.size(); ++i)
925  for (unsigned int j=0; j < _dbList[i].dcm.size(); ++j) {
926  if (_dbList[i].dcm[j].isActive)
927  tmpDCMList.push_back(_dbList[i].dcm[j].appname);
928  }
929 
930  //TStopwatch ts;
931  //ts.Start();
932  LOG_INFO("RunHistory") << "RunHistory: loading pixel enable masks" << std::endl;
933  daqcfg::PixelEnableMasks pixelEnableMasks(_gCfgId, tmpDCMList);
934  LOG_INFO("RunHistory") << "RunHistory: loading pixel thresholds" << std::endl;
935  daqcfg::PixelThresholds pixelThresholds(_gCfgId, tmpDCMList);
936  LOG_INFO("RunHistory") << "done!" << std::endl;
937  //ts.Stop();
938  //ts.Print();
939 
940  bool hasValidData = (pixelEnableMasks.hasValidData() &&
941  pixelThresholds.hasValidData());
942 
943  if (hasValidData) {
944  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
945  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm) {
946  if (! _dbList[idb].dcm[idcm].isActive) continue;
947 
948  std::string dcmName = _dbList[idb].dcm[idcm].appname;
949  int64_t febMask = 0;
950  pixelEnableMasks.getFEBEnableMask(dcmName, febMask);
951  _dbList[idb].dcm[idcm].febMask = febMask;
952  int nfeb = _dbList[idb].dcm[idcm].feb.size();
953  for (int ifeb = 0; ifeb < nfeb; ++ifeb) {
954  if (pixelEnableMasks.febIsEnabled(dcmName, ifeb)) {
955  _nTotalChannels += 32;
956  ++_nTotalFEBs;
957 
958  FEB& f = _dbList[idb].dcm[idcm].feb[ifeb];
959  f.isEnabled = true;
960  int32_t pixelMask;
961  pixelEnableMasks.getPixelEnableMask(dcmName, ifeb, pixelMask);
962  f.pixelMask = pixelMask;
963  f.nActivePix = pixelEnableMasks.
964  getEnabledPixelCountForFEB(dcmName, ifeb);
965  if (pixelThresholds.hasValidData())
966  pixelThresholds.getThresholdsForFEB(dcmName, ifeb,
967  f.pixelThresh);
968  } // end if (febIsEnabled)
969  } // end loop over FEBs
970  } // end loop over DCMs
971  } // end loop over DiBlocks
972  } // end if hasValidData
973  else {
974  std::cerr << __PRETTY_FUNCTION__ << " failed to get valid data"
975  << std::endl;
976  if (_nRetryLoads > 0) {
977  int sleepTime = 1 + ((double)random()/(double)RAND_MAX)*(1 << nAttempt++);
978  sleep(sleepTime);
979  return this->LoadPixelInfo(nAttempt+1);
980  }
981  else {
982  return false;
983  }
984  }
985 
986  _gotPixelInfo = true;
987 
988  return true;
989  }
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
OStream cerr
Definition: OStream.cxx:7
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
const double j
Definition: BetheBloch.cxx:29
#define LOG_INFO(stream)
Definition: Messenger.h:144
enum BeamMode string
bool nova::dbi::RunHistory::LoadPixelMasks ( )
inherited

Definition at line 709 of file RunHistory.cxx.

References nova::dbi::RunHistory::_abort, nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gotPixelMasks, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, om::cerr, nova::dbi::Row::Col(), febshutoff_auto::dcm, runNovaSAM::detId, novadaq::cnv::DetInfo::DetNameOk(), allTimeWatchdog::endl, nova::dbi::Column::Get(), novadaq::cnv::DetInfo::GetId(), nova::dbi::kDataOnly, nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadFEBMasks(), nova::dbi::RunHistory::LoadHardwareInfo(), LOG_ERROR, LOG_INFO, LOG_WARNING, check_grl::row, and confusionMatrixTree::t.

Referenced by nova::dbi::RunHistory::GetPedestal(), and nova::dbi::RunHistory::LoadPedestals().

710  {
711  if (_runNumber >= 1000000 || _runNumber < 10000) {
712  LOG_ERROR("RunHistory") << "Ideal run number not acceptable for this method. Aborting.";
713  std::abort();
714  }
715 
716 
717  if (_gotPixelMasks) return true;
718 
719  if (! LoadDAQRunHistory()) return false;
720  if (! LoadHardwareInfo()) return false;
721  if (! LoadFEBMasks()) return false;
722 
723  std::unique_ptr<db::Table> t;
724  t.reset(new db::Table("RunHistory/tables/PixelMasksByRun.xml"));
725 
727  t->SetDetector(_detector);
728  else
729  return false;
730 
731  int maskIdx = t->GetColIndex("mask");
732 
733  t->SetDataTypeMask(nova::dbi::kDataOnly);
734  t->SetMinTSVld(_runNumber);
735  t->SetMaxTSVld(_runNumber);
736  t->SetTimeQueries(_timeQueries);
737  t->SetTimeParsing(_timeParsing);
738  t->SetVerbosity(_verbosity);
739 
740  LOG_INFO("RunHistory") << "RunHistory: loading pixel enable masks" << std::endl;
741 
742  if (!t->Load()) {
743  std::cerr << __PRETTY_FUNCTION__ << "No pixel masks found in DB!";
744  if(_abort) std::abort();
745  return false;
746  }
747  else {
748  if (t->NRow() == 0) {
749  LOG_ERROR("RunHistory") << __PRETTY_FUNCTION__ << ": failed to get any rows from database, which should not happen." << std::endl;
750  if (_abort) std::abort();
751  }
752  }
753 
754  t->FillChanRowMap();
756  // int nrow = t->NRow();
758  int32_t pMask;
759 
760  for (unsigned int idb=0; idb<_dbList.size(); ++idb) {
761  int dbNum = _dbList[idb].num;
762  for (unsigned int idcm=0; idcm<_dbList[idb].dcm.size(); ++idcm) {
763  if (! _dbList[idb].dcm[idcm].isActive) continue;
764  int dcmNum = _dbList[idb].dcm[idcm].position;
765  int nfebs = _dbList[idb].dcm[idcm].feb.size();
766  for (int ifeb=0; ifeb<nfebs; ++ifeb) {
767  int tchan = detId*1000000 + 10000*dbNum + 100*dcmNum + ifeb;
768  row = t->GetVldRow(tchan,_runNumber);
769  if (!row) {
770  LOG_WARNING("RunHistory") << "No row found for channel " << tchan << std::endl;
771  continue;
772  }
773  row->Col(maskIdx).Get(pMask);
774  _dbList[idb].dcm[idcm].feb[ifeb].pixelMask = pMask;
775  }
776  }
777  }
778  _gotPixelMasks = true;
779 
780  return true;
781  }
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
OStream cerr
Definition: OStream.cxx:7
bool Get(T &val) const
Definition: Column.h:85
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
std::string _detector
Definition: RunHistory.h:550
#define LOG_WARNING(category)
static int GetId(std::string name)
#define LOG_INFO(stream)
Definition: Messenger.h:144
static bool DetNameOk(std::string name)
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool nova::dbi::RunHistory::LoadPOT ( )
inherited

Definition at line 1511 of file RunHistory.cxx.

References nova::dbi::RunHistory::_avgpot, nova::dbi::RunHistory::_detector, nova::dbi::RunHistory::_gotPOT, nova::dbi::RunHistory::_npot, nova::dbi::RunHistory::_runNumber, nova::dbi::RunHistory::_timeParsing, nova::dbi::RunHistory::_timeQueries, nova::dbi::RunHistory::_verbosity, om::cerr, novadaq::cnv::DetInfo::DetNameOk(), and allTimeWatchdog::endl.

1512  {
1513  if (_gotPOT) return true;
1514 
1515  _npot = 0.;
1516 
1517  std::unique_ptr<db::Table> potTable;
1518 
1519  potTable.reset(new db::Table("RunHistory/tables/POTByRun.xml"));
1520 
1522  potTable->SetDetector(_detector);
1523  else
1524  return false;
1525 
1526  int potIdx = potTable->GetColIndex("npot");
1527  int avgIdx = potTable->GetColIndex("avg_i");
1528  potTable->SetTimeQueries(_timeQueries);
1529  potTable->SetTimeParsing(_timeParsing);
1530  potTable->SetVerbosity(_verbosity);
1531 
1532  potTable->SetValidityRange("run",_runNumber);
1533  potTable->Load();
1534  if (potTable->NRow() == 0) {
1535  std::cerr << __PRETTY_FUNCTION__ << " No POT info found for run "
1536  << _runNumber << std::endl;
1537  return false;
1538  }
1539  else {
1540  potTable->GetRow(0)->Col(potIdx).Get(_npot);
1541  potTable->GetRow(0)->Col(avgIdx).Get(_avgpot);
1542  }
1543 
1544  _gotPOT = true;
1545  return true;
1546 
1547  }
OStream cerr
Definition: OStream.cxx:7
std::string _detector
Definition: RunHistory.h:550
static bool DetNameOk(std::string name)
int nova::dbi::RunHistory::NActiveChannels ( )
inlineinherited
int nova::dbi::RunHistory::NAnalysisChannels ( int  sr = 0)
inherited

Definition at line 285 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_subrunList, MECModelEnuComparisons::i, nova::dbi::RunHistory::IsGoodDiBlock(), nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), and sr.

Referenced by caf::CAFMaker::produce().

286  {
287  if (_subrunList[sr].gotNAnalysisChannels) return _subrunList[sr].nAnalysisChannels;
288 
289  _subrunList[sr].nAnalysisChannels=0;
292  for (size_t i=0; i<_dbList.size(); ++i) {
293  int db = _dbList[i].num;
294  if (this->IsGoodDiBlock(db,sr))
295  _subrunList[sr].nAnalysisChannels += 32*_dbList[i].nInstrumentedFEBs;
296  }
297 
298  _subrunList[sr].gotNAnalysisChannels=true;
299  return _subrunList[sr].nAnalysisChannels;
300 
301  }
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
caf::StandardRecord * sr
bool IsGoodDiBlock(int idb, int subrun=-1)
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
int nova::dbi::RunHistory::NAnalysisDiBlocks ( int  sr = 0)
inherited

Definition at line 256 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_subrunList, MECModelEnuComparisons::i, nova::dbi::RunHistory::IsGoodDiBlock(), nova::dbi::RunHistory::LoadDAQRunHistory(), nova::dbi::RunHistory::LoadHardwareInfo(), and sr.

257  {
258  if (_subrunList[sr].gotNAnalysisDiBlocks) return _subrunList[sr].nAnalysisDiBlocks;
259 
260  _subrunList[sr].nAnalysisDiBlocks=0;
263  for (size_t i=0; i<_dbList.size(); ++i) {
264  int db = _dbList[i].num;
265  if (this->IsGoodDiBlock(db,sr))
266  _subrunList[sr].nAnalysisDiBlocks++;
267  }
268 
269  _subrunList[sr].gotNAnalysisDiBlocks=true;
270  return _subrunList[sr].nAnalysisDiBlocks;
271 
272  }
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
caf::StandardRecord * sr
bool IsGoodDiBlock(int idb, int subrun=-1)
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
int nova::dbi::RunHistory::NAPDInstalled ( )
inlineinherited

Definition at line 413 of file RunHistory.h.

int nova::dbi::RunHistory::NBNEVBs ( )
inlineinherited

Definition at line 397 of file RunHistory.h.

Referenced by mono::DataCheckMonopole::endSubRun().

397 { LoadDAQRunHistory(); return _bnevbList.size(); }
std::vector< BNEVB > _bnevbList
Definition: RunHistory.h:556
int nova::dbi::RunHistory::NDCMs ( )
inherited
int nova::dbi::RunHistory::NDiBlocks ( )
inlineinherited
int nova::dbi::RunHistory::NFEBs ( )
inlineinherited

Definition at line 404 of file RunHistory.h.

References getGoodRuns4SAM::subrun.

404 { LoadPixelInfo(); return _nTotalFEBs; }
bool LoadPixelInfo(int nAttempt=0)
Definition: RunHistory.cxx:903
int nova::dbi::RunHistory::NLiveDCMs ( )
inherited

Definition at line 243 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbList, nova::dbi::RunHistory::_gotHardwareInfo, febshutoff_auto::dcm, MECModelEnuComparisons::i, calib::j, and nova::dbi::RunHistory::LoadHardwareInfo().

Referenced by nova::dbi::RunHistory::Dump(), and mono::DataCheckMonopole::endSubRun().

244  {
246  int ndcm=0;
247  for (unsigned int i=0; i<_dbList.size(); ++i)
248  for (unsigned int j=0; j<_dbList[i].dcm.size(); ++j)
249  if (_dbList[i].dcm[j].isActive)
250  ++ndcm;
251 
252  return ndcm;
253  }
std::vector< DiBlock > _dbList
Definition: RunHistory.h:555
const double j
Definition: BetheBloch.cxx:29
float nova::dbi::RunHistory::NPOT ( )
inlineinherited

Definition at line 391 of file RunHistory.h.

Referenced by CondenseRunList().

391 { LoadPOT(); return _npot; }
int nova::dbi::RunHistory::NRetryLoads ( )
inlineinherited

Definition at line 467 of file RunHistory.h.

467 { return _nRetryLoads; }
int nova::dbi::RunHistory::NSubruns ( )
inlineinherited
int nova::dbi::RunHistory::NTotalChannels ( )
inlineinherited

Definition at line 403 of file RunHistory.h.

int nova::dbi::RunHistory::NTriggers ( )
inlineinherited

Definition at line 390 of file RunHistory.h.

Referenced by mono::DataCheckMonopole::endSubRun().

float nova::dbi::RunHistory::Occupancy ( geo::OfflineChan  chan,
time_t  t 
)
inherited

Definition at line 2147 of file RunHistory.cxx.

References nova::dbi::RunHistory::_chanInfo, febshutoff_auto::chan, MECModelEnuComparisons::i, and confusionMatrixTree::t.

2148  {
2149  const std::vector<ChanInfo_t>& cis = _chanInfo[chan];
2150 
2151  unsigned int i=0;
2152  for (; i<cis.size() && cis[i].tstart<t; ++i);
2153  if (i>0)
2154  return cis[i-1].occ;
2155  else
2156  return -6.;
2157  }
std::map< geo::OfflineChan, std::vector< ChanInfo_t > > _chanInfo
Definition: RunHistory.h:558
int nova::dbi::RunHistory::Partition ( )
inlineinherited

Definition at line 378 of file RunHistory.h.

Referenced by mono::DataCheckMonopole::endSubRun().

void nova::dbi::RunHistoryService::preBeginRun ( const art::Run run)

Definition at line 68 of file RunHistory_service.cc.

References art::Run::beginTime(), nova::dbi::RunHistory::Detector(), ds::DetectorService::DetId(), nova::dbi::RunHistory::DiBlockMaskToString(), allTimeWatchdog::endl, fAbort, fAbortIfMissingRunInDB, art::Handle< T >::failedToGet(), fAnalysisDiBlockMasking, fCalHitLabel, fCustomMask, fCustomMasking, fFakeRunNumber, fTimeQueries, fUseMasking, art::DataViewImpl::getByLabel(), novadaq::cnv::DetInfo::GetId(), nova::dbi::RunHistory::GoodDiBlockMask(), MECModelEnuComparisons::i, nova::dbi::kDataOnly, novadaq::cnv::kFARDET, nova::dbi::kMCOnly, nova::dbi::kNDataType, novadaq::cnv::kNEARDET, LOG_DEBUG, LOG_INFO, LOG_WARNING, lem_server::mask, art::Run::run(), nova::dbi::RunHistory::SetAbort(), nova::dbi::RunHistory::SetAbortIfMissingRunInDB(), nova::dbi::RunHistory::SetAnalysisDiBlockMasking(), nova::dbi::RunHistory::SetCurrentSubrun(), nova::dbi::RunHistory::SetCustomMask(), nova::dbi::RunHistory::SetDataType(), nova::dbi::RunHistory::SetDetector(), nova::dbi::RunHistory::SetGoodDiBlockMask(), nova::dbi::RunHistory::SetIfAnyMasking(), nova::dbi::RunHistory::SetIfCustomMasking(), nova::dbi::RunHistory::SetRunNumber(), nova::dbi::RunHistory::SetTimeParsing(), nova::dbi::RunHistory::SetTimeQueries(), art::Timestamp::timeHigh(), art::Timestamp::timeLow(), and Munits::year.

Referenced by RunHistoryService().

69  {
72  int runNumber = (fFakeRunNumber == 0) ? run.run() : fFakeRunNumber;
73 
74  RunHistory::SetRunNumber(runNumber);
75 
81  this->SetAbort(fAbort);
83  this->SetCurrentSubrun(0);
84 
85  // determine whether we are dealing with MC, data, or a mixture of the two
86  // for now just test on the date of the file. MC has a timestamp before 2010
87  art::Timestamp ts = run.beginTime();
88 
89  // make it into a TTimeStamp
90  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
91 
92  // Get the year of the timestamp from YYYYMMDD format
93  uint32_t year = tts.GetDate()/10000;
94 
96  if(year < 2010) this->SetDataType(nova::dbi::kMCOnly);
98 
99  if (runNumber > 1000000 || runNumber < 10000) {
101  this->SetIfAnyMasking(false);
102  }
103 
104  // get detector diblock masks
105 
107  this->SetIfAnyMasking(false);
108  }
109 
110  if (novadaq::cnv::DetInfo::GetId(RunHistory::Detector()) == novadaq::cnv::kFARDET) { // only worry about masking for FD
111  std::vector<bool> cmask; // let people put 1s and 0s into fcl instead of trues and falses
112 
113  for(unsigned int i = 0; i < 14; i++) {
114  if(fCustomMask[i] == 1) cmask.push_back(true);
115  else cmask.push_back(false);
116  }
117  this->SetCustomMask(cmask);
118 
120  run.getByLabel(fCalHitLabel,mask);
121 
122  if(mask.failedToGet()) {
123  if(fCustomMasking) {
124  LOG_WARNING("RunHistoryService") << "RunHistory: No mask in file. Custom mask requested." << std::endl;
126  }
127  else if(runNumber >= 1000000 || runNumber < 10000) { // clear MC that can't access DB
128  LOG_INFO("RunHistoryService") << __PRETTY_FUNCTION__
129  << ": this looks like ideal conditions MC. No mask applied: "
132  }
133  else {
134  if(fAbort) {
135  if (!(RunHistory::GoodDiBlockMask()!=(1<<16)-1))
136  // running in mode that absolutely requires a mask, and there was not one
137  std::abort();
138  }
139 
141  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__
142  << ": did not find mask in file, using current fcl settings of: detector fully masked off! "
144  else
145  LOG_DEBUG("RunHistoryService") << __PRETTY_FUNCTION__
146  << ": did not find mask in file, using current fcl settings of: "
148  << std::endl;
149  }
150  }
151  else { // got mask from file
152  // running in mode that absolutely requires a mask, and there was not one
153  if(fAbort && runNumber < 1000000 && runNumber > 10000) {if(!(*mask!= (1<<16)-1)) std::abort();}
154 
156  if(*mask==0) {
157  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__
158  << ": found mask in file: detector fully masked off! "
160  << std::endl;
161  }
162  else if(*mask==(1<<16)-1) {
163  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__
164  << ": no run was found in good runs DB when this file was processed, "
165  << "so we assume perfect. LiveGeometry should still catch any empty "
166  << "regions, but check badboxes in the event display to be sure."
167  << std::endl;
168  }
169  else if(*mask==(1<<17)-1) {
170  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__
171  << ": masking was turned off when file was processed, so apply no mask. "
173  << std::endl;
174  }
175  else {
176  LOG_INFO("RunHistoryService") << __PRETTY_FUNCTION__
177  << ": found mask in file: "
179  }
180  }
181  }
182 
183  return;
184  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
novadaq::cnv::DetId DetId() const
What detector are we in?
void SetTimeQueries(bool f)
Definition: RunHistory.h:361
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:30
std::vector< int > fCustomMask
void SetAbort(bool abort)
Definition: RunHistory.h:449
void SetDetector(novadaq::cnv::DetId det)
Definition: RunHistory.cxx:325
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:35
void SetIfCustomMasking(bool f)
set from fcl: do we want to use a custom mask?
Definition: RunHistory.h:365
RunNumber_t run() const
Definition: Run.h:47
void SetRunNumber(int run)
Definition: RunHistory.cxx:317
void SetAbortIfMissingRunInDB(bool abort)
Definition: RunHistory.h:450
Far Detector at Ash River, MN.
std::string DiBlockMaskToString(const int mask) const
void SetDataType(nova::dbi::DataType dt)
Definition: RunHistory.h:448
Near Detector in the NuMI cavern.
void SetCustomMask(std::vector< bool > f)
set from fcl: what is our custom mask?
Definition: RunHistory.h:366
void SetCurrentSubrun(int isr)
Definition: RunHistory.h:481
A very simple service to remember what detector we&#39;re working in.
#define LOG_WARNING(category)
static int GetId(std::string name)
void SetTimeParsing(bool f)
Definition: RunHistory.h:362
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Timestamp const & beginTime() const
Definition: Run.h:52
void SetGoodDiBlockMask(int newmask)
Definition: RunHistory.h:408
#define LOG_INFO(stream)
Definition: Messenger.h:144
int GoodDiBlockMask(int subrun=-1, bool reload=false)
void SetAnalysisDiBlockMasking(bool f)
set from fcl: do we want to use the analysis rules when we mask (not for custom masking)?
Definition: RunHistory.h:364
bool failedToGet() const
Definition: Handle.h:196
std::string Detector() const
Definition: RunHistory.h:376
void SetIfAnyMasking(bool f)
set from fcl: do we want to use any masking at all? If no, other masking options irrelevant ...
Definition: RunHistory.h:363
static constexpr Double_t year
Definition: Munits.h:185
void nova::dbi::RunHistoryService::preBeginSubrun ( const art::SubRun subrun)

Definition at line 187 of file RunHistory_service.cc.

References nova::dbi::RunHistory::_getDiBlockMaskFromCondb, DEFINE_ART_SERVICE, nova::dbi::RunHistory::Detector(), nova::dbi::RunHistory::DiBlockMaskToString(), allTimeWatchdog::endl, fAbort, art::Handle< T >::failedToGet(), fCalHitLabel, fCustomMasking, art::DataViewImpl::getByLabel(), novadaq::cnv::DetInfo::GetId(), nova::dbi::RunHistory::GoodDiBlockMask(), novadaq::cnv::kFARDET, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING, lem_server::mask, nova::dbi::RunHistory::RunNumber(), nova::dbi::RunHistory::SetCurrentSubrun(), nova::dbi::RunHistory::SetSubrunDiBlockMask(), and art::SubRun::subRun().

Referenced by RunHistoryService().

188  {
189  if (novadaq::cnv::DetInfo::GetId(RunHistory::Detector()) != novadaq::cnv::kFARDET) // only worry about masking for FD
190  return;
191 
192  // don't do anything if we're not using subrun-by-subrun diblock masks
193  if (!this->_getDiBlockMaskFromCondb) return;
194 
195  int isr = subrun.subRun();
196  int runNumber = this->RunNumber();
197 
198  LOG_DEBUG("RunHistory")
199  << "runNumber = " << runNumber;
200 
201  // use a realistic subrun number for ideal conditions
202  if (runNumber >= 1000000) {
203  isr = isr%64;
204  }
205 
206  this->SetCurrentSubrun(isr);
207 
209  subrun.getByLabel(fCalHitLabel,mask);
210 
211  if(mask.failedToGet()) {
212  if(fCustomMasking) {
213  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__
214  << ": No mask in file. Custom mask requested." << std::endl;
216  }
217  else if(runNumber >= 1000000 || runNumber < 10000) { // clear MC that can't access DB
218  LOG_INFO("RunHistoryService") << __PRETTY_FUNCTION__ << ": this looks like ideal conditions MC. No mask applied: "
221  }
222  else {
223  // running in mode that absolutely requires a mask, and there was not one
224  if(fAbort) {
225  if (!(RunHistory::GoodDiBlockMask()!=(1<<16)-1)) {
226  // running in mode that absolutely requires a mask, and there was not one
227  LOG_ERROR("RunHistoryService") << __PRETTY_FUNCTION__ << ": failed to get subrun diblock mask, aborting." << std::endl;
228  std::abort();
229  }
230  else
231  LOG_DEBUG("RunHistoryService") << __PRETTY_FUNCTION__ << ": did not find subrun mask in file, using mask: "
233  }
234  }
235  }
236  else { // got mask from file
237 
238  if(fAbort && runNumber < 1000000 && runNumber > 10000) {
239  if (!(*mask!= (1<<16)-1))
240  // running in mode that absolutely requires a mask, and there was not one
241  std::abort();
242  }
243 
245  if(*mask==0) {
246  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__ << ": found subrun diblock mask in file: detector fully masked off! "
248  }
249  else if(*mask==(1<<16)-1) {
250  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__ << ": no run was found in good runs DB when this file was processed, "
251  << "so we assume perfect. LiveGeometry should still catch any empty regions, but check badboxes in "
252  << "the event display to be sure." << std::endl;
253  }
254  else if(*mask==(1<<17)-1) {
255  LOG_WARNING("RunHistoryService") << __PRETTY_FUNCTION__ << ": masking was turned off when file was processed, so apply no mask. "
257  }
258  else {
259  LOG_INFO("RunHistoryService") << __PRETTY_FUNCTION__ << ": subrun diblock found mask in file: "
261  }
262  }
263 
264  return;
265  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
SubRunNumber_t subRun() const
Definition: SubRun.h:44
Far Detector at Ash River, MN.
std::string DiBlockMaskToString(const int mask) const
void SetCurrentSubrun(int isr)
Definition: RunHistory.h:481
#define LOG_WARNING(category)
void SetSubrunDiBlockMask(int isr, int m)
Definition: RunHistory.h:370
static int GetId(std::string name)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
#define LOG_INFO(stream)
Definition: Messenger.h:144
int GoodDiBlockMask(int subrun=-1, bool reload=false)
int RunNumber() const
Definition: RunHistory.h:374
#define LOG_ERROR(stream)
Definition: Messenger.h:129
bool failedToGet() const
Definition: Handle.h:196
std::string Detector() const
Definition: RunHistory.h:376
void nova::dbi::RunHistory::PrintChanInfo ( )
inherited

Definition at line 2121 of file RunHistory.cxx.

References nova::dbi::RunHistory::_chanInfo, geo::OfflineChan::Cell(), febshutoff_auto::chan, om::cout, allTimeWatchdog::endl, it, calib::j, and geo::OfflineChan::Plane().

2122  {
2123  std::map<geo::OfflineChan,std::vector<ChanInfo_t> >::iterator it = _chanInfo.begin();
2124  for (; it != _chanInfo.end(); ++it) {
2125  std::vector<ChanInfo_t>& ci = it->second;
2126  geo::OfflineChan chan = it->first;
2127  for (unsigned int j=0; j<ci.size(); ++j)
2128  std::cout << chan.Plane() << "," << chan.Cell() << "," << ci[j].occ
2129  << std::endl;
2130  }
2131  }
set< int >::iterator it
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
unsigned short Plane() const
Definition: OfflineChan.h:31
unsigned short Cell() const
Definition: OfflineChan.h:32
A (plane, cell) pair.
Definition: OfflineChan.h:17
std::map< geo::OfflineChan, std::vector< ChanInfo_t > > _chanInfo
Definition: RunHistory.h:558
void nova::dbi::RunHistoryService::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 45 of file RunHistory_service.cc.

References nova::dbi::RunHistory::_dbMaskTag, nova::dbi::RunHistory::_getDiBlockMaskFromCondb, fAbort, fAbortIfMissingRunInDB, fAnalysisDiBlockMasking, fCalHitLabel, fCustomMask, fCustomMasking, fFakeRunNumber, fTimeQueries, fUseMasking, fhicl::ParameterSet::get(), nova::dbi::RunHistory::SetFDRHCRunStart(), nova::dbi::RunHistory::SetFDRHCRunStop(), nova::dbi::RunHistory::SetGainSettingTag(), nova::dbi::RunHistory::SetNDRHCRunStart(), nova::dbi::RunHistory::SetNDRHCRunStop(), nova::dbi::RunHistory::SetVerbosity(), and string.

Referenced by RunHistoryService().

46  {
47  fCalHitLabel = pset.get< std::string >("CalHitLabel");
48  fFakeRunNumber = pset.get< int >("FakeRunNumber", 0);
49  fTimeQueries = pset.get< bool >("TimeQueries", false);
50  fUseMasking = pset.get< bool >("UseMasking", false);
51  fAnalysisDiBlockMasking = pset.get< bool >("AnalysisDiBlockMasking", false);
52  fCustomMasking = pset.get< bool >("CustomMasking", false);
53  fCustomMask = pset.get< std::vector<int> >("CustomMask");
54  fAbort = pset.get< bool >("AbortIfNoMask", false);
55  fAbortIfMissingRunInDB = pset.get< bool >("AbortIfMissingRunInDB", true);
56  this->_getDiBlockMaskFromCondb = pset.get< bool >("GetDiBlockMaskFromCondb", false);
57  this->_dbMaskTag = pset.get< std::string >("DiBlockMaskTag");
58  this->SetGainSettingTag(pset.get< std::string >("DetGainTag"));
59  this->SetVerbosity(pset.get< int >("Verbosity"));
60  this->SetNDRHCRunStart(pset.get<std::vector<int> >("NDRHCRunStart"));
61  this->SetNDRHCRunStop(pset.get<std::vector<int> >("NDRHCRunStop"));
62  this->SetFDRHCRunStart(pset.get<std::vector<int> >("FDRHCRunStart"));
63  this->SetFDRHCRunStop(pset.get<std::vector<int> >("FDRHCRunStop"));
64 
65  }
std::vector< int > fCustomMask
T get(std::string const &key) const
Definition: ParameterSet.h:231
void SetGainSettingTag(std::string tag)
Definition: RunHistory.h:473
void SetNDRHCRunStart(std::vector< int > r)
Definition: RunHistory.h:356
void SetNDRHCRunStop(std::vector< int > r)
Definition: RunHistory.h:357
void SetFDRHCRunStop(std::vector< int > r)
Definition: RunHistory.h:359
void SetVerbosity(int i)
Definition: RunHistory.h:478
void SetFDRHCRunStart(std::vector< int > r)
Definition: RunHistory.h:358
std::string _dbMaskTag
Definition: RunHistory.h:488
enum BeamMode string
int nova::dbi::RunHistory::RunNumber ( ) const
inlineinherited
std::string nova::dbi::RunHistory::RunType ( )
inlineinherited

Definition at line 379 of file RunHistory.h.

379 { LoadDAQRunHistory(); return _runType; }
std::string _runType
Definition: RunHistory.h:547
void nova::dbi::RunHistory::SetAbort ( bool  abort)
inlineinherited

Definition at line 449 of file RunHistory.h.

Referenced by preBeginRun().

449 { _abort=abort; }
void nova::dbi::RunHistory::SetAbortIfMissingRunInDB ( bool  abort)
inlineinherited

Definition at line 450 of file RunHistory.h.

Referenced by preBeginRun().

450 { _abortIfMissingRunInDB=abort; }
void nova::dbi::RunHistory::SetAnalysisDiBlockMasking ( bool  f)
inlineinherited

set from fcl: do we want to use the analysis rules when we mask (not for custom masking)?

Definition at line 364 of file RunHistory.h.

References MakeMiniprodValidationCuts::f.

Referenced by preBeginRun().

void nova::dbi::RunHistory::SetBadChanVersion ( std::string  v)
inlineinherited

Definition at line 465 of file RunHistory.h.

References registry_explorer::v.

void nova::dbi::RunHistory::SetChanInfo ( geo::OfflineChan  chan,
float  occ,
float  coinc,
time_t  t 
)
inherited

Definition at line 2135 of file RunHistory.cxx.

References nova::dbi::RunHistory::_chanInfo, febshutoff_auto::chan, nova::dbi::ChanInfo_t::coinc, nova::dbi::ChanInfo_t::occ, confusionMatrixTree::t, and nova::dbi::ChanInfo_t::tstart.

2137  {
2138  ChanInfo_t ci;
2139  ci.occ = occ;
2140  ci.coinc = coinc;
2141  ci.tstart = t;
2142  _chanInfo[chan].push_back(ci);
2143  }
std::map< geo::OfflineChan, std::vector< ChanInfo_t > > _chanInfo
Definition: RunHistory.h:558
void nova::dbi::RunHistory::SetCurrentSubrun ( int  isr)
inlineinherited

Definition at line 481 of file RunHistory.h.

Referenced by preBeginRun(), and preBeginSubrun().

481 { _currentSR = isr; }
void nova::dbi::RunHistory::SetCustomMask ( std::vector< bool >  f)
inlineinherited

set from fcl: what is our custom mask?

Definition at line 366 of file RunHistory.h.

References MECModelEnuComparisons::i.

Referenced by preBeginRun().

void nova::dbi::RunHistory::SetDataType ( nova::dbi::DataType  dt)
inlineinherited

Definition at line 448 of file RunHistory.h.

References makeHTMLView::dt.

Referenced by CondenseRunList(), and preBeginRun().

448 { _dataType = dt; }
nova::dbi::DataType _dataType
Definition: RunHistory.h:532
void nova::dbi::RunHistory::SetDBInfo ( std::string  dbname = "",
std::string  dbhost = "",
std::string  user = "",
std::string  port = "" 
)
inherited

Definition at line 305 of file RunHistory.cxx.

References nova::dbi::RunHistory::_dbhost, nova::dbi::RunHistory::_dbname, nova::dbi::RunHistory::_dbport, nova::dbi::RunHistory::_dbuser, and drop_table::user.

307  {
308  _dbname = dbname;
309  _dbhost = dbhost;
310  _dbuser = user;
311  _dbport = dbport;
312 
313  }
std::string _dbuser
Definition: RunHistory.h:545
std::string _dbhost
Definition: RunHistory.h:544
std::string _dbport
Definition: RunHistory.h:546
std::string _dbname
Definition: RunHistory.h:543
void nova::dbi::RunHistoryService::SetDetector ( const std::string det)
private
void nova::dbi::RunHistoryService::SetDetector ( novadaq::cnv::DetId  det)
private
void nova::dbi::RunHistory::SetDiBlockMaskTag ( std::string  s)
inlineinherited

Definition at line 470 of file RunHistory.h.

470 { _dbMaskTag = s; }
const XML_Char * s
Definition: expat.h:262
std::string _dbMaskTag
Definition: RunHistory.h:488
void nova::dbi::RunHistory::SetFDRHCRunStart ( std::vector< int r)
inlineinherited

Definition at line 358 of file RunHistory.h.

References r().

Referenced by reconfigure().

358 { _fdRHCRunStart = r; }
std::vector< int > _fdRHCRunStart
Definition: RunHistory.h:563
TRandom3 r(0)
void nova::dbi::RunHistory::SetFDRHCRunStop ( std::vector< int r)
inlineinherited

Definition at line 359 of file RunHistory.h.

References r().

Referenced by reconfigure().

359 { _fdRHCRunStop = r; }
std::vector< int > _fdRHCRunStop
Definition: RunHistory.h:564
TRandom3 r(0)
void nova::dbi::RunHistory::SetGainSettingTag ( std::string  tag)
inlineinherited

Definition at line 473 of file RunHistory.h.

References getGoodRuns4SAM::tag.

Referenced by reconfigure().

void nova::dbi::RunHistory::SetGetDiBlockMaskFromCondb ( bool  f)
inlineinherited
void nova::dbi::RunHistory::SetGoodDiBlockMask ( int  newmask)
inlineinherited

Definition at line 408 of file RunHistory.h.

References MECModelEnuComparisons::i, and getGoodRuns4SAM::subrun.

Referenced by preBeginRun().

408 {for (size_t isr=0; isr<64; ++isr) _subrunList[isr].goodDiBlockMask=newmask; _gotGoodDiBlockMask=true;}
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
void nova::dbi::RunHistory::SetIfAnyMasking ( bool  f)
inlineinherited

set from fcl: do we want to use any masking at all? If no, other masking options irrelevant

Definition at line 363 of file RunHistory.h.

References MakeMiniprodValidationCuts::f.

Referenced by CondenseRunList(), and preBeginRun().

void nova::dbi::RunHistory::SetIfCustomMasking ( bool  f)
inlineinherited

set from fcl: do we want to use a custom mask?

Definition at line 365 of file RunHistory.h.

References MakeMiniprodValidationCuts::f.

Referenced by CondenseRunList(), and preBeginRun().

void nova::dbi::RunHistory::SetIsBad ( geo::OfflineChan  chan,
bool  isBad,
time_t  t 
)
inherited

Definition at line 2175 of file RunHistory.cxx.

References nova::dbi::RunHistory::_badChan, b, febshutoff_auto::chan, nova::dbi::BadChan_t::isBad, confusionMatrixTree::t, and nova::dbi::BadChan_t::tstart.

2176  {
2177  BadChan_t b;
2178  b.isBad = isBad;
2179  b.tstart = t;
2180  _badChan[chan].push_back(b);
2181  }
std::map< geo::OfflineChan, std::vector< BadChan_t > > _badChan
Definition: RunHistory.h:557
const hit & b
Definition: hits.cxx:21
void nova::dbi::RunHistory::SetNDRHCRunStart ( std::vector< int r)
inlineinherited

Definition at line 356 of file RunHistory.h.

References r().

Referenced by reconfigure().

356 { _ndRHCRunStart = r; }
std::vector< int > _ndRHCRunStart
Definition: RunHistory.h:561
TRandom3 r(0)
void nova::dbi::RunHistory::SetNDRHCRunStop ( std::vector< int r)
inlineinherited

Definition at line 357 of file RunHistory.h.

References r().

Referenced by reconfigure().

357 { _ndRHCRunStop = r; }
std::vector< int > _ndRHCRunStop
Definition: RunHistory.h:562
TRandom3 r(0)
void nova::dbi::RunHistory::SetNRetryLoads ( int  n)
inlineinherited

Definition at line 468 of file RunHistory.h.

References getGoodRuns4SAM::n.

void nova::dbi::RunHistoryService::SetRunNumber ( int  run)
private
void nova::dbi::RunHistory::SetSubrunDiBlockMask ( int  isr,
int  m 
)
inlineinherited

Definition at line 370 of file RunHistory.h.

References m, lem_server::mask, and string.

Referenced by preBeginSubrun().

370 { _subrunList[isr].goodDiBlockMask=m; }
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
void nova::dbi::RunHistory::SetTimeParsing ( bool  f)
inlineinherited
void nova::dbi::RunHistory::SetTimeQueries ( bool  f)
inlineinherited
void nova::dbi::RunHistory::SetVerbosity ( int  i)
inlineinherited

Definition at line 478 of file RunHistory.h.

References MECModelEnuComparisons::i.

Referenced by reconfigure().

time_t nova::dbi::RunHistory::SubrunTStart ( int  isr)
inherited

Definition at line 2193 of file RunHistory.cxx.

References nova::dbi::RunHistory::_nsubrun, nova::dbi::RunHistory::_subrunList, nova::dbi::RunHistory::LoadDAQRunHistory(), and nova::dbi::RunHistory::TStart().

2193  {
2195  if (isr < 0 || isr > _nsubrun) return 0;
2196  if (isr == 0) return this->TStart();
2197  return _subrunList[isr].tstart;
2198  }
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
time_t nova::dbi::RunHistory::SubrunTStop ( int  isr)
inherited

Definition at line 2201 of file RunHistory.cxx.

References nova::dbi::RunHistory::_nsubrun, nova::dbi::RunHistory::_subrunList, nova::dbi::RunHistory::LoadDAQRunHistory(), and nova::dbi::RunHistory::TStop().

2201  {
2203  if (isr < 0 || isr > _nsubrun) return 0;
2204  if (isr == _nsubrun-1) return this->TStop();
2205  return _subrunList[isr+1].tstart;
2206  }
std::vector< Subrun > _subrunList
Definition: RunHistory.h:559
time_t nova::dbi::RunHistory::TStart ( )
inherited
std::string nova::dbi::RunHistory::TStartAsString ( )
inlineinherited

Definition at line 383 of file RunHistory.h.

Referenced by nova::dbi::RunHistory::Dump().

383 { LoadDAQRunHistory(); return _tStart;}
std::string _tStart
Definition: RunHistory.h:551
time_t nova::dbi::RunHistory::TStop ( )
inherited