Public Member Functions | Private Member Functions | Private Attributes | List of all members
dune::DetPedestalDUNE Class Reference

#include <DetPedestalDUNE.h>

Inheritance diagram for dune::DetPedestalDUNE:
lariov::DetPedestalProvider lar::UncopiableAndUnmovableClass

Public Member Functions

 DetPedestalDUNE (std::string detName="")
 
 DetPedestalDUNE (fhicl::ParameterSet const &pset)
 
virtual float PedMean (raw::ChannelID_t ch) const
 Retrieve pedestal information. More...
 
virtual float PedRms (raw::ChannelID_t ch) const
 
virtual float PedMeanErr (raw::ChannelID_t ch) const
 
virtual float PedRmsErr (raw::ChannelID_t ch) const
 
bool Configure (fhicl::ParameterSet const &pset)
 
bool Update (uint64_t ts)
 
void SetUseDefaults (bool f)
 
void SetUseDB (bool f)
 
void PrintAllValues ()
 
void SetDetName (std::string detName)
 
std::string DetName ()
 
void SetDefaults (geo::View_t v, float mean, float meanerr, float rms, float rmserr)
 
float DefaultMean (geo::View_t v) const
 
float DefaultMeanErr (geo::View_t v) const
 
float DefaultRms (geo::View_t v) const
 
float DefaultRmsErr (geo::View_t v) const
 
void SetCSVFileName (std::string fname)
 
std::string CSVFileName () const
 
uint64_t VldTimeUsed () const
 
- Public Member Functions inherited from lariov::DetPedestalProvider
virtual ~DetPedestalProvider ()=default
 

Private Member Functions

void LoadFromCSV ()
 

Private Attributes

bool fUseDB
 
bool fUseDefaults
 
bool fAbortIfNoPeds
 
std::map< geo::View_t, float > fDefaultMean
 
std::map< geo::View_t, float > fDefaultMeanErr
 
std::map< geo::View_t, float > fDefaultRms
 
std::map< geo::View_t, float > fDefaultRmsErr
 
uint64_t fVldTime
 
uint64_t fVldTimeUsed
 
std::string fCSVFileName
 
std::string fDetName
 
int fLogLevel
 
std::unordered_map< raw::ChannelID_t, float > fMeanMap
 
std::unordered_map< raw::ChannelID_t, float > fRmsMap
 
std::unordered_map< raw::ChannelID_t, float > fMeanErrMap
 
std::unordered_map< raw::ChannelID_t, float > fRmsErrMap
 
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
 

Detailed Description

Definition at line 23 of file DetPedestalDUNE.h.

Constructor & Destructor Documentation

dune::DetPedestalDUNE::DetPedestalDUNE ( std::string  detName = "")

Definition at line 15 of file DetPedestalDUNE.cxx.

15  {
16  fDetName = detName;
17  fVldTime = fVldTimeUsed = 0;
18  fMeanMap.clear();
19  fRmsMap.clear();
20  fMeanErrMap.clear();
21  fRmsErrMap.clear();
22  fUseDB = false;
23  fAbortIfNoPeds = false;
24  }
std::unordered_map< raw::ChannelID_t, float > fRmsMap
std::unordered_map< raw::ChannelID_t, float > fRmsErrMap
std::unordered_map< raw::ChannelID_t, float > fMeanMap
std::unordered_map< raw::ChannelID_t, float > fMeanErrMap
dune::DetPedestalDUNE::DetPedestalDUNE ( fhicl::ParameterSet const &  pset)

Definition at line 28 of file DetPedestalDUNE.cxx.

28  {
29  fVldTime = fVldTimeUsed = 0;
30  fMeanMap.clear();
31  fRmsMap.clear();
32  fMeanErrMap.clear();
33  fRmsErrMap.clear();
34  fUseDB = false;
35  fAbortIfNoPeds = false;
36  fDetName = "";
37  Configure(pset);
38  }
std::unordered_map< raw::ChannelID_t, float > fRmsMap
std::unordered_map< raw::ChannelID_t, float > fRmsErrMap
std::unordered_map< raw::ChannelID_t, float > fMeanMap
bool Configure(fhicl::ParameterSet const &pset)
std::unordered_map< raw::ChannelID_t, float > fMeanErrMap

Member Function Documentation

bool dune::DetPedestalDUNE::Configure ( fhicl::ParameterSet const &  pset)

Definition at line 42 of file DetPedestalDUNE.cxx.

42  {
43  const string myname = "DetPedestalDUNE::Configure: ";
44  fUseDB = p.get<bool>("UseDB",false);
45  if (!fUseDB) {
46  fVldTime = p.get<int>("Run",0);
47  }
48  fAbortIfNoPeds = p.get<bool>("AbortIfNoPeds",false);
49  fCSVFileName = p.get<std::string>("CSVFile","");
50  fUseDefaults = p.get<bool>("UseDefaults",false);
51  fDefaultMean[geo::kU] = p.get<float>("DefaultMeanU",0.);
52  fDefaultMeanErr[geo::kU] = p.get<float>("DefaultMeanErrU",0.);
53  fDefaultRms[geo::kU] = p.get<float>("DefaultRmsU",0.);
54  fDefaultRmsErr[geo::kU] = p.get<float>("DefaultRmsErrU",0.);
55  fDefaultMean[geo::kV] = p.get<float>("DefaultMeanV",0.);
56  fDefaultMeanErr[geo::kV] = p.get<float>("DefaultMeanErrV",0.);
57  fDefaultRms[geo::kV] = p.get<float>("DefaultRmsV",0.);
58  fDefaultRmsErr[geo::kV] = p.get<float>("DefaultRmsErrV",0.);
59  fDefaultMean[geo::kZ] = p.get<float>("DefaultMeanZ",0.);
60  fDefaultMeanErr[geo::kZ] = p.get<float>("DefaultMeanErrZ",0.);
61  fDefaultRms[geo::kZ] = p.get<float>("DefaultRmsZ",0.);
62  fDefaultRmsErr[geo::kZ] = p.get<float>("DefaultRmsErrZ",0.);
63  fDefaultMean[geo::kUnknown] = p.get<float>("DefaultMean",0.);
64  fDefaultMeanErr[geo::kUnknown] = p.get<float>("DefaultMeanErr",0.);
65  fDefaultRms[geo::kUnknown] = p.get<float>("DefaultRms",0.);
66  fDefaultRmsErr[geo::kUnknown] = p.get<float>("DefaultRmsErr",0.);
67 
68  fLogLevel = p.get<int>("LogLevel", 1);
69  if ( fLogLevel > 0 ) {
70  std::cout << myname << " UseDB: " << fUseDB << std::endl;
71  std::cout << myname << " Run: " << fVldTime << std::endl;
72  std::cout << myname << " CSVFile: " << fCSVFileName << std::endl;
73  std::cout << myname << " UseDefaults: " << fUseDefaults << std::endl;
74  std::cout << myname << " DefaultMean[U]: " << fDefaultMean[geo::kU] << std::endl;
75  std::cout << myname << "DefaultMeanErr[U]: " << fDefaultMeanErr[geo::kU] << std::endl;
76  std::cout << myname << " DefaultRms[U]: " << fDefaultRms[geo::kU] << std::endl;
77  std::cout << myname << " DefaultRmsErr[U]: " << fDefaultRmsErr[geo::kU] << std::endl;
78  std::cout << myname << " DefaultMean[V]: " << fDefaultMean[geo::kV] << std::endl;
79  std::cout << myname << "DefaultMeanErr[V]: " << fDefaultMeanErr[geo::kV] << std::endl;
80  std::cout << myname << " DefaultRms[V]: " << fDefaultRms[geo::kV] << std::endl;
81  std::cout << myname << " DefaultRmsErr[V]: " << fDefaultRmsErr[geo::kV] << std::endl;
82  std::cout << myname << " DefaultMean[Z]: " << fDefaultMean[geo::kZ] << std::endl;
83  std::cout << myname << "DefaultMeanErr[Z]: " << fDefaultMeanErr[geo::kZ] << std::endl;
84  std::cout << myname << " DefaultRms[Z]: " << fDefaultRms[geo::kZ] << std::endl;
85  std::cout << myname << " DefaultRmsErr[Z]: " << fDefaultRmsErr[geo::kZ] << std::endl;
86  std::cout << myname << " LogLevel: " << fLogLevel << std::endl;
87  }
88 
89  return true;
90  }
std::map< geo::View_t, float > fDefaultRmsErr
std::string string
Definition: nybbler.cc:12
Planes which measure V.
Definition: geo_types.h:126
Unknown view.
Definition: geo_types.h:132
Planes which measure Z direction.
Definition: geo_types.h:128
Planes which measure U.
Definition: geo_types.h:125
std::map< geo::View_t, float > fDefaultMeanErr
std::map< geo::View_t, float > fDefaultRms
p
Definition: test.py:223
std::map< geo::View_t, float > fDefaultMean
QTextStream & endl(QTextStream &s)
std::string dune::DetPedestalDUNE::CSVFileName ( ) const
inline

Definition at line 56 of file DetPedestalDUNE.h.

56 {return fCSVFileName; }
float dune::DetPedestalDUNE::DefaultMean ( geo::View_t  v) const

Definition at line 188 of file DetPedestalDUNE.cxx.

188  {
189  float retVal=-1.;
190  auto it = fDefaultMean.find(v);
191  if (it != fDefaultMean.end())
192  return it->second;
193  else
194  return retVal;
195 
196  }
std::map< geo::View_t, float > fDefaultMean
float dune::DetPedestalDUNE::DefaultMeanErr ( geo::View_t  v) const

Definition at line 200 of file DetPedestalDUNE.cxx.

200  {
201  float retVal=-1.;
202  auto it = fDefaultMeanErr.find(v);
203  if (it != fDefaultMeanErr.end())
204  return it->second;
205  else
206  return retVal;
207 
208  }
std::map< geo::View_t, float > fDefaultMeanErr
float dune::DetPedestalDUNE::DefaultRms ( geo::View_t  v) const

Definition at line 212 of file DetPedestalDUNE.cxx.

212  {
213  float retVal=-1.;
214  auto it = fDefaultRms.find(v);
215  if (it != fDefaultRms.end())
216  return it->second;
217  else
218  return retVal;
219 
220  }
std::map< geo::View_t, float > fDefaultRms
float dune::DetPedestalDUNE::DefaultRmsErr ( geo::View_t  v) const

Definition at line 224 of file DetPedestalDUNE.cxx.

224  {
225  float retVal=-1.;
226  auto it = fDefaultRmsErr.find(v);
227  if (it != fDefaultRmsErr.end())
228  return it->second;
229  else
230  return retVal;
231 
232  }
std::map< geo::View_t, float > fDefaultRmsErr
std::string dune::DetPedestalDUNE::DetName ( )
inline

Definition at line 43 of file DetPedestalDUNE.h.

43 { return fDetName; }
void dune::DetPedestalDUNE::LoadFromCSV ( )
private
float dune::DetPedestalDUNE::PedMean ( raw::ChannelID_t  ch) const
virtual

Retrieve pedestal information.

Implements lariov::DetPedestalProvider.

Definition at line 236 of file DetPedestalDUNE.cxx.

236  {
237  float retVal=-1.;
238  if (fUseDefaults) {
239  auto it = fDefaultMean.find(geo::kUnknown);
240  if (it != fDefaultMean.end())
241  return it->second;
242  else
243  return retVal;
244  }
245  if (fVldTime == 0) {
246  std::cerr << "DetPedestalDUNE: Validity time is not set! Aborting." << std::endl;
247  abort();
248  }
249  auto it = fMeanMap.find(ch);
250  if (it != fMeanMap.end())
251  retVal = it->second;
252 
253  return retVal;
254  }
Unknown view.
Definition: geo_types.h:132
std::unordered_map< raw::ChannelID_t, float > fMeanMap
std::map< geo::View_t, float > fDefaultMean
QTextStream & endl(QTextStream &s)
float dune::DetPedestalDUNE::PedMeanErr ( raw::ChannelID_t  ch) const
virtual

Implements lariov::DetPedestalProvider.

Definition at line 258 of file DetPedestalDUNE.cxx.

258  {
259  float retVal=0.;
260  if (fUseDefaults) {
261  auto it = fDefaultMeanErr.find(geo::kUnknown);
262  if (it != fDefaultMeanErr.end())
263  return it->second;
264  else
265  return retVal;
266  }
267 
268  if (fVldTime == 0) {
269  std::cerr << "DetPedestalDUNE: Validity time is not set! Aborting." << std::endl;
270  abort();
271  }
272  auto it = fMeanErrMap.find(ch);
273  if (it != fMeanErrMap.end())
274  retVal = it->second;
275 
276  return retVal;
277  }
Unknown view.
Definition: geo_types.h:132
std::map< geo::View_t, float > fDefaultMeanErr
std::unordered_map< raw::ChannelID_t, float > fMeanErrMap
QTextStream & endl(QTextStream &s)
float dune::DetPedestalDUNE::PedRms ( raw::ChannelID_t  ch) const
virtual

Implements lariov::DetPedestalProvider.

Definition at line 281 of file DetPedestalDUNE.cxx.

281  {
282  float retVal=-1;
283  if (fUseDefaults) {
284  auto it = fDefaultRms.find(geo::kUnknown);
285  if (it != fDefaultRms.end())
286  return it->second;
287  else
288  return retVal;
289  }
290  if (fVldTime == 0) {
291  std::cerr << "DetPedestalDUNE: Validity time is not set! Aborting." << std::endl;
292  abort();
293  }
294  auto it = fRmsMap.find(ch);
295  if (it != fRmsMap.end())
296  retVal = it->second;
297 
298  return retVal;
299  }
std::unordered_map< raw::ChannelID_t, float > fRmsMap
Unknown view.
Definition: geo_types.h:132
std::map< geo::View_t, float > fDefaultRms
QTextStream & endl(QTextStream &s)
float dune::DetPedestalDUNE::PedRmsErr ( raw::ChannelID_t  ch) const
virtual

Implements lariov::DetPedestalProvider.

Definition at line 303 of file DetPedestalDUNE.cxx.

303  {
304  float retVal=0.;
305  if (fUseDefaults) {
306  auto it = fDefaultRmsErr.find(geo::kUnknown);
307  if (it != fDefaultRmsErr.end())
308  return it->second;
309  else
310  return retVal;
311  }
312  if (fVldTime == 0) {
313  std::cerr << "DetPedestalDUNE: Validity time is not set! Aborting." << std::endl;
314  abort();
315  }
316  auto it = fRmsErrMap.find(ch);
317  if (it != fRmsErrMap.end())
318  retVal = it->second;
319 
320  return retVal;
321  }
std::map< geo::View_t, float > fDefaultRmsErr
Unknown view.
Definition: geo_types.h:132
std::unordered_map< raw::ChannelID_t, float > fRmsErrMap
QTextStream & endl(QTextStream &s)
void dune::DetPedestalDUNE::PrintAllValues ( )

Definition at line 325 of file DetPedestalDUNE.cxx.

325  {
326  auto itMean = fMeanMap.begin();
327  for (; itMean != fMeanMap.end(); ++itMean) {
328  std::cout << "Channel: " << itMean->first << ", Mean = " << itMean->second
329  << ", RMS = " << fRmsMap[itMean->first] << std::endl;
330  }
331 
332  }
std::unordered_map< raw::ChannelID_t, float > fRmsMap
std::unordered_map< raw::ChannelID_t, float > fMeanMap
QTextStream & endl(QTextStream &s)
void dune::DetPedestalDUNE::SetCSVFileName ( std::string  fname)
inline

Definition at line 55 of file DetPedestalDUNE.h.

void dune::DetPedestalDUNE::SetDefaults ( geo::View_t  v,
float  mean,
float  meanerr,
float  rms,
float  rmserr 
)
inline

Definition at line 45 of file DetPedestalDUNE.h.

46  {
47  fDefaultMean[v] = mean; fDefaultMeanErr[v] = meanerr;
48  fDefaultRms[v] = rms ; fDefaultRmsErr[v] = rmserr;
49  }
std::map< geo::View_t, float > fDefaultRmsErr
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
std::map< geo::View_t, float > fDefaultMeanErr
std::map< geo::View_t, float > fDefaultRms
std::map< geo::View_t, float > fDefaultMean
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
void dune::DetPedestalDUNE::SetDetName ( std::string  detName)
inline

Definition at line 42 of file DetPedestalDUNE.h.

42 { fDetName = detName;}
void dune::DetPedestalDUNE::SetUseDB ( bool  f)
inline
void dune::DetPedestalDUNE::SetUseDefaults ( bool  f)
inline
bool dune::DetPedestalDUNE::Update ( uint64_t  ts)

Definition at line 94 of file DetPedestalDUNE.cxx.

95  {
96  if (fUseDefaults) return true;
97 
98  if ( fLogLevel > 0 )
99  std::cout << __PRETTY_FUNCTION__ << " Called with run " << ts << std::endl;
100 
101  if (!fUseDB && fCSVFileName.empty()) {
102  std::cout << __PRETTY_FUNCTION__ << " Method of determining pedestals is undefined! Either set UseDB or CSVFileName in fhicl. ";
103  if (fAbortIfNoPeds) {
104  std::cout << "Aborting per request." << std::endl;
105  abort();
106  }
107  return false;
108  }
109 
110  if (ts == fVldTime)
111  return true;
112  else
113  fVldTime = ts;
114 
115  fMeanMap.clear();
116  fMeanErrMap.clear();
117  fRmsMap.clear();
118  fRmsErrMap.clear();
119 
120  std::string tableName = "pedestals";
122 
123  if (fDetName.empty()) {
124  std::cerr << "Detector name is undefined. Aborting." << std::endl;
125  std::abort();
126  }
127 
129  t.SetTableName(tableName);
132 
133  int meanIdx = t.AddCol("mean","float");
134  int rmsIdx = t.AddCol("rms","float");
135  int meanErrIdx = t.AddCol("meanerr","float");
136  int rmsErrIdx = t.AddCol("rmserr","float");
137 
138  t.SetMinTSVld(ts);
139  t.SetMaxTSVld(ts);
140 
141  t.SetVerbosity(100);
142  if (fUseDB)
143  t.Load();
144  else
146 
147  if (t.NRow() == 0) {
148  std::cout << "Number of pedestals from database/CSV file is 0. This should never be the case! ";
149  if (fAbortIfNoPeds) {
150  std::cout << "Aborting, per request." << std::endl;
151  abort();
152  }
153  return false;
154  }
155 
157  float mean, rms, meanerr, rmserr;
158  uint64_t chan, offlineChan;
159  for (int i=0; i<t.NRow(); ++i) {
160  mean = rms = meanerr = rmserr = 0.;
161  row = t.GetRow(i);
162  chan = row->Channel(); // MW: as of 3/1/16, this is now an online channel number
163  offlineChan = fChannelMap->Offline(chan); // Need to map to an offline channel at this point
164  //offlineChan = chan;
165  row->Col(meanIdx).Get(mean);
166  row->Col(meanErrIdx).Get(meanerr);
167  row->Col(rmsIdx).Get(rms);
168  row->Col(rmsErrIdx).Get(rmserr);
169  fMeanMap[offlineChan] = mean;
170  fMeanErrMap[offlineChan] = meanerr;
171  fRmsMap[offlineChan] = rms;
172  fRmsErrMap[offlineChan] = rmserr;
173  if (i==0) { // print out
174  fVldTimeUsed = row->VldTime();
175  if (fLogLevel > 0) {
176  std::cout << __PRETTY_FUNCTION__ << ": using run " << row->VldTime()
177  << " for pedestals." << std::endl;
178  }
179  }
180  }
181 
182  return true;
183  }
float VldTime()
Definition: Row.h:56
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
std::unordered_map< raw::ChannelID_t, float > fRmsMap
std::string string
Definition: nybbler.cc:12
std::unordered_map< raw::ChannelID_t, float > fRmsErrMap
std::unordered_map< raw::ChannelID_t, float > fMeanMap
void SetMaxTSVld(float t)
Definition: Table.h:272
uint64_t Channel()
Definition: Row.h:55
bool Get(T &val) const
Definition: Column.h:72
bool LoadFromCSV(std::string fname)
Definition: Table.cpp:1291
bool SetDetector(std::string det)
Definition: Table.cpp:493
void SetTableName(std::string tname)
Definition: Table.cpp:517
unsigned __int64 uint64_t
Definition: stdint.h:136
int AddCol(std::string cname, std::string ctype)
Definition: Table.cpp:326
std::unordered_map< raw::ChannelID_t, float > fMeanErrMap
nutools::dbi::Row *const GetRow(int i)
Definition: Table.cpp:406
void SetMinTSVld(float t)
Definition: Table.h:271
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
void SetVerbosity(int i)
Definition: Table.h:100
bool SetTableType(int t)
Definition: Table.cpp:451
Column & Col(int i)
Definition: Row.h:53
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
QTextStream & endl(QTextStream &s)
void SetDataTypeMask(int mask)
Definition: Table.h:76
std::string tableName
uint64_t dune::DetPedestalDUNE::VldTimeUsed ( ) const
inline

Definition at line 58 of file DetPedestalDUNE.h.

58 { return fVldTimeUsed; }

Member Data Documentation

bool dune::DetPedestalDUNE::fAbortIfNoPeds
private

Definition at line 65 of file DetPedestalDUNE.h.

art::ServiceHandle<lbne::ChannelMapService> dune::DetPedestalDUNE::fChannelMap
private

Definition at line 80 of file DetPedestalDUNE.h.

std::string dune::DetPedestalDUNE::fCSVFileName
private

Definition at line 72 of file DetPedestalDUNE.h.

std::map<geo::View_t,float> dune::DetPedestalDUNE::fDefaultMean
private

Definition at line 66 of file DetPedestalDUNE.h.

std::map<geo::View_t,float> dune::DetPedestalDUNE::fDefaultMeanErr
private

Definition at line 67 of file DetPedestalDUNE.h.

std::map<geo::View_t,float> dune::DetPedestalDUNE::fDefaultRms
private

Definition at line 68 of file DetPedestalDUNE.h.

std::map<geo::View_t,float> dune::DetPedestalDUNE::fDefaultRmsErr
private

Definition at line 69 of file DetPedestalDUNE.h.

std::string dune::DetPedestalDUNE::fDetName
private

Definition at line 73 of file DetPedestalDUNE.h.

int dune::DetPedestalDUNE::fLogLevel
private

Definition at line 74 of file DetPedestalDUNE.h.

std::unordered_map<raw::ChannelID_t,float> dune::DetPedestalDUNE::fMeanErrMap
private

Definition at line 77 of file DetPedestalDUNE.h.

std::unordered_map<raw::ChannelID_t,float> dune::DetPedestalDUNE::fMeanMap
private

Definition at line 75 of file DetPedestalDUNE.h.

std::unordered_map<raw::ChannelID_t,float> dune::DetPedestalDUNE::fRmsErrMap
private

Definition at line 78 of file DetPedestalDUNE.h.

std::unordered_map<raw::ChannelID_t,float> dune::DetPedestalDUNE::fRmsMap
private

Definition at line 76 of file DetPedestalDUNE.h.

bool dune::DetPedestalDUNE::fUseDB
private

Definition at line 63 of file DetPedestalDUNE.h.

bool dune::DetPedestalDUNE::fUseDefaults
private

Definition at line 64 of file DetPedestalDUNE.h.

uint64_t dune::DetPedestalDUNE::fVldTime
private

Definition at line 70 of file DetPedestalDUNE.h.

uint64_t dune::DetPedestalDUNE::fVldTimeUsed
private

Definition at line 71 of file DetPedestalDUNE.h.


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