Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
calib::LinCalibProtoDUNE Class Reference

#include <LinCalibProtoDUNE.h>

Inheritance diagram for calib::LinCalibProtoDUNE:
calib::LinCalib

Public Member Functions

 LinCalibProtoDUNE ()
 
 LinCalibProtoDUNE (fhicl::ParameterSet const &pset)
 
 LinCalibProtoDUNE (LinCalibProtoDUNE const &)=delete
 
virtual ~LinCalibProtoDUNE ()=default
 
bool Configure (fhicl::ParameterSet const &pset)
 
bool Update (uint64_t ts=0)
 
LinConsts_t GetLinConsts (int chanId)
 
void SetIsMC (bool v)
 
void SetUseCondb (bool v)
 
void SetCSVFileName (std::string f)
 
void SetTag (std::string t)
 
- Public Member Functions inherited from calib::LinCalib
 LinCalib (const LinCalib &)=delete
 
 LinCalib (LinCalib &&)=delete
 
LinCaliboperator= (const LinCalib &)=delete
 
LinCaliboperator= (LinCalib &&)=delete
 
virtual ~LinCalib ()=default
 

Protected Member Functions

bool LoadConsts ()
 
- Protected Member Functions inherited from calib::LinCalib
 LinCalib ()=default
 

Protected Attributes

bool fUseCondb
 
bool fConstsLoaded
 
bool fIsMC
 
uint64_t fCurrentTS
 
std::string fCSVFileName
 
std::string fDBTag
 
std::map< int, LinConsts_tfLinConsts
 

Detailed Description

Definition at line 42 of file LinCalibProtoDUNE.h.

Constructor & Destructor Documentation

calib::LinCalibProtoDUNE::LinCalibProtoDUNE ( )

Definition at line 30 of file LinCalibProtoDUNE.cxx.

31 {
32  fIsMC = true;
33  fConstsLoaded = false;
34  fCurrentTS = 0;
35  fCSVFileName="";
36  fDBTag="";
37 }
calib::LinCalibProtoDUNE::LinCalibProtoDUNE ( fhicl::ParameterSet const &  pset)

Definition at line 41 of file LinCalibProtoDUNE.cxx.

44 {
45  fIsMC = true;
46  fConstsLoaded = false;
47  fCurrentTS = 0;
48  fCSVFileName="";
49  fDBTag="";
50 }
calib::LinCalibProtoDUNE::LinCalibProtoDUNE ( LinCalibProtoDUNE const &  )
delete
virtual calib::LinCalibProtoDUNE::~LinCalibProtoDUNE ( )
virtualdefault

Member Function Documentation

bool calib::LinCalibProtoDUNE::Configure ( fhicl::ParameterSet const &  pset)

Definition at line 53 of file LinCalibProtoDUNE.cxx.

54 {
55  fUseCondb = pset.get<bool>("UseCondb");
56  fCSVFileName = pset.get<std::string>("CSVFileName");
57  fDBTag = pset.get<std::string>("DBTag");
58 
59  return true;
60 }
std::string string
Definition: nybbler.cc:12
calib::LinConsts_t calib::LinCalibProtoDUNE::GetLinConsts ( int  chanId)

Definition at line 78 of file LinCalibProtoDUNE.cxx.

79 {
80  if (!fConstsLoaded) this->LoadConsts();
81 
82  if (fLinConsts.find(chanId) == fLinConsts.end()) {
83  mf::LogError("LinCalibProtoDUNE") << "Channel " << chanId
84  << "not found!";
85  std::abort();
86  }
87 
88  return fLinConsts[chanId];
89 }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::map< int, LinConsts_t > fLinConsts
bool calib::LinCalibProtoDUNE::LoadConsts ( )
protected

Definition at line 92 of file LinCalibProtoDUNE.cxx.

93 {
94  if (!fUseCondb) return true;
95 
96  if (fConstsLoaded) return true;
97 
98  nutools::dbi::Table t;
99 
100  t.SetDetector("pdunesp");
101  t.SetTableName("linconsts");
102  t.SetTableType(nutools::dbi::kConditionsTable);
103  t.SetDataTypeMask(nutools::dbi::kDataOnly);
104  if (fIsMC)
105  t.SetDataTypeMask(nutools::dbi::kMCOnly);
106 
107  int statusIdx = t.AddCol("status","int");
108  int gainIdx = t.AddCol("gain","float");
109  int offsetIdx = t.AddCol("offset","float");
110  int shapeIdx = t.AddCol("shape","float");
111  int chi2Idx = t.AddCol("chi2","float");
112  int adcLowIdx = t.AddCol("adc_low","int");
113  int adcHiIdx = t.AddCol("adc_high","int");
114  int nlIdx[20];
115  char buff[64];
116  for (int i=0; i<20; ++i) {
117  sprintf(buff,"nl%d",i);
118  nlIdx[i] = t.AddCol(buff,"float");
119  }
120 
121  t.SetMinTSVld(fCurrentTS);
122  t.SetMaxTSVld(fCurrentTS);
123  t.SetTag(fDBTag);
124 
125  t.SetVerbosity(100);
126 
127  bool readOk = false;
128  if (!fCSVFileName.empty())
129  readOk = t.LoadFromCSV(fCSVFileName);
130  else
131  readOk = t.Load();
132 
133  if (! readOk) {
134  mf::LogError("LinCalibProtoDUNE") << "Load from norm linconsts database table failed.";
135 
136  return false; //std::abort();
137 
138  }
139 
140  if (t.NRow() == 0) {
141  mf::LogError("LinCalibProtoDUNE") << "Number of rows in linconsts calib table is 0. This should never be the case!";
142  return false;
143  }
144 
145  nutools::dbi::Row* row;
146  uint64_t chan;
147  for (int i=0; i<t.NRow(); ++i) {
148  LinConsts_t c;
149  row = t.GetRow(i);
150  chan = row->Channel();
151  row->Col(statusIdx).Get(c.status);
152  row->Col(gainIdx).Get(c.gain);
153  row->Col(offsetIdx).Get(c.offset);
154  row->Col(shapeIdx).Get(c.shape);
155  row->Col(chi2Idx).Get(c.chi2);
156  row->Col(adcLowIdx).Get(c.adc_low);
157  row->Col(adcHiIdx).Get(c.adc_high);
158  for (int j=0; j<20; ++j) {
159  row->Col(nlIdx[j]).Get(c.nl[j]);
160  }
161 
162  fLinConsts[chan] = c;
163  }
164 
165  fConstsLoaded = true;
166  return true;
167 }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::map< int, LinConsts_t > fLinConsts
void calib::LinCalibProtoDUNE::SetCSVFileName ( std::string  f)
inline
void calib::LinCalibProtoDUNE::SetIsMC ( bool  v)
inline

Definition at line 56 of file LinCalibProtoDUNE.h.

void calib::LinCalibProtoDUNE::SetTag ( std::string  t)
inline

Definition at line 60 of file LinCalibProtoDUNE.h.

void calib::LinCalibProtoDUNE::SetUseCondb ( bool  v)
inline

Definition at line 58 of file LinCalibProtoDUNE.h.

bool calib::LinCalibProtoDUNE::Update ( uint64_t  ts = 0)

Definition at line 63 of file LinCalibProtoDUNE.cxx.

64 {
65 
66  if (fConstsLoaded && ts != fCurrentTS) {
67  fLinConsts.clear();
68  fConstsLoaded = false;
69  }
70 
71  fCurrentTS = ts;
72  // all done!
73 
74  return true;
75 }
std::map< int, LinConsts_t > fLinConsts

Member Data Documentation

bool calib::LinCalibProtoDUNE::fConstsLoaded
protected

Definition at line 66 of file LinCalibProtoDUNE.h.

std::string calib::LinCalibProtoDUNE::fCSVFileName
protected

Definition at line 70 of file LinCalibProtoDUNE.h.

uint64_t calib::LinCalibProtoDUNE::fCurrentTS
protected

Definition at line 68 of file LinCalibProtoDUNE.h.

std::string calib::LinCalibProtoDUNE::fDBTag
protected

Definition at line 71 of file LinCalibProtoDUNE.h.

bool calib::LinCalibProtoDUNE::fIsMC
protected

Definition at line 67 of file LinCalibProtoDUNE.h.

std::map<int,LinConsts_t> calib::LinCalibProtoDUNE::fLinConsts
protected

Definition at line 73 of file LinCalibProtoDUNE.h.

bool calib::LinCalibProtoDUNE::fUseCondb
protected

Definition at line 65 of file LinCalibProtoDUNE.h.


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