CMap_service.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief cmap::CMap class source code
3 /// \author brebel@fnal.gov
4 /// \date Sept. 2010
5 ////////////////////////////////////////////////////////////////////////
7 
8 // NOvA includes
9 #ifdef NOVACMAKE
10 #include <Database/cxx/include/Table.h>
11 #include <Database/cxx/include/Util.h>
12 #else
13 #include <Database/Table.h>
14 #include <Database/Util.h>
15 #endif
17 
18 // ART includes
20 
21 namespace cmap {
22 
23  //----------------------------------------------------------------------
25  : fAbortIfLoadFails(params().AbortIfLoadFails())
26  {
27  this->SetCurrentRun(0);
28  fGotExceptions = false;
29  SetUseExceptions(params().UseExceptions());
30  SetVerbosity(params().Verbosity());
31  reg.sPostBeginRun.watch(this, &CMap::postBeginRun);
32  }
33 
34  //----------------------------------------------------------------------
36  {
37  }
38 
39  //----------------------------------------------------------------------
40 
42  {
45  this->SetCurrentRun(run.run());
46  if (this->UseExceptions() && !fGotExceptions)
48  }
49 
50  //----------------------------------------------------------------------
52  {
53  fGotExceptions = true;
54  this->ClearExceptions();
55  std::unique_ptr<nova::dbi::Table> eTable;
56  eTable.reset(new nova::dbi::Table("CMap/CMapExceptions.xml"));
57  // eTable->SetDetector("FarDet");
58  int chan1Idx = eTable->GetColIndex("chan1");
59  int chan2Idx = eTable->GetColIndex("chan2");
60  if (! eTable->LoadFromCSV("CMap/CMapExceptions.csv")) {
61  if (fAbortIfLoadFails) std::abort();
62  return;
63  }
64  else {
66  int detId = det->DetId();
68  std::string chan1, chan2;
69  for (int i = 0; i<eTable->NRow(); ++i) {
70  row = eTable->GetRow(i);
71  if (int(row->Channel()) == detId) { // add exceptions for the approp. detector
72  if (row->VldTime() >= this->CurrentRun()) {
73  row->Col(chan1Idx).Get(chan1);
74  row->Col(chan2Idx).Get(chan2);
75  this->AddException(detId,chan1,chan2);
76  }
77  }
78  }
79  }
80 
81  }
82 
84 
85 } // end namespace cmap
86 ////////////////////////////////////////////////////////////////////////
novadaq::cnv::DetId DetId() const
What detector are we in?
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
void LoadExceptions()
Definition: CMap_service.cc:51
void SetVerbosity(int v)
Definition: CMap.h:77
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:93
time_t VldTime()
Definition: Row.h:69
void SetUseExceptions(bool v)
Definition: CMap.h:74
int Verbosity()
Definition: CMap.h:78
void ClearExceptions()
Definition: CMap.h:69
GlobalSignal< detail::SignalResponseType::LIFO, void(Run const &)> sPostBeginRun
Channel masks are defined in DAQChannelMap package.
Definition: CMapService.h:19
virtual ~CMap()
Definition: CMap_service.cc:35
RunNumber_t run() const
Definition: Run.h:47
bool Get(T &val) const
Definition: Column.h:85
Definition: Run.h:31
void postBeginRun(const art::Run &run)
Definition: CMap_service.cc:41
void SetCurrentRun(int run)
Definition: CMap.h:71
static DAQChannelMap * getInstance(int detID)
bool fAbortIfLoadFails
Definition: CMapService.h:40
void AddException(int idet, geo::OfflineChan chan1, geo::OfflineChan chan2)
Definition: CMap.cxx:102
Definition: run.py:1
bool UseExceptions()
Definition: CMap.h:75
unsigned long long Channel()
Definition: Row.h:68
cmap::CMap class source code
Definition: CMap.cxx:17
int CurrentRun()
Definition: CMap.h:72
bool fGotExceptions
Definition: CMapService.h:39
void SetStdMap(const daqchannelmap::DAQChannelMap *m)
Definition: CMap.h:36
enum BeamMode string