Public Member Functions | Private Member Functions | Private Attributes | List of all members
lariov::SIOVPmtGainProvider Class Reference

Retrieves information: pmt gain. More...

#include <SIOVPmtGainProvider.h>

Inheritance diagram for lariov::SIOVPmtGainProvider:
lariov::DatabaseRetrievalAlg lariov::PmtGainProvider lar::UncopiableAndUnmovableClass

Public Member Functions

 SIOVPmtGainProvider (fhicl::ParameterSet const &p)
 Constructors. More...
 
void Reconfigure (fhicl::ParameterSet const &p) override
 Reconfigure function called by fhicl constructor. More...
 
void UpdateTimeStamp (DBTimeStamp_t ts)
 Update event time stamp. More...
 
bool Update (DBTimeStamp_t ts)
 Update Snapshot and inherited DBFolder if using database. Return true if updated. More...
 
const PmtGainPmtGainObject (DBChannelID_t ch) const
 Retrieve gain information. More...
 
float Gain (DBChannelID_t ch) const override
 
float GainErr (DBChannelID_t ch) const override
 
CalibrationExtraInfo const & ExtraInfo (DBChannelID_t ch) const override
 
- Public Member Functions inherited from lariov::DatabaseRetrievalAlg
 DatabaseRetrievalAlg (const std::string &foldername, const std::string &url, const std::string &url2="", const std::string &tag="", bool usesqlite=false, bool testmode=false)
 Constructors. More...
 
 DatabaseRetrievalAlg (fhicl::ParameterSet const &p)
 
virtual ~DatabaseRetrievalAlg ()
 Default destructor. More...
 
bool UpdateFolder (DBTimeStamp_t ts)
 Return true if fFolder is successfully updated. More...
 
const std::stringURL () const
 Get connection information. More...
 
const std::stringFolderName () const
 
const std::stringTag () const
 
const IOVTimeStampBegin () const
 Get Timestamp information. More...
 
const IOVTimeStampEnd () const
 
- Public Member Functions inherited from lariov::PmtGainProvider
virtual ~PmtGainProvider ()=default
 
virtual float Gain (raw::ChannelID_t ch) const =0
 Retrieve pmt gain information. More...
 
virtual float GainErr (raw::ChannelID_t ch) const =0
 
virtual CalibrationExtraInfo const & ExtraInfo (raw::ChannelID_t ch) const =0
 

Private Member Functions

bool DBUpdate () const
 Do actual database updates. More...
 
bool DBUpdate (DBTimeStamp_t ts) const
 

Private Attributes

DBTimeStamp_t fEventTimeStamp
 
DBTimeStamp_t fCurrentTimeStamp
 
DataSource::ds fDataSource
 
Snapshot< PmtGainfData
 

Additional Inherited Members

- Protected Attributes inherited from lariov::DatabaseRetrievalAlg
std::unique_ptr< DBFolderfFolder
 

Detailed Description

Retrieves information: pmt gain.

Configuration parameters

Definition at line 38 of file SIOVPmtGainProvider.h.

Constructor & Destructor Documentation

lariov::SIOVPmtGainProvider::SIOVPmtGainProvider ( fhicl::ParameterSet const &  p)

Constructors.

Definition at line 13 of file SIOVPmtGainProvider.cxx.

13  :
14  DatabaseRetrievalAlg(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg")),
15  fEventTimeStamp(0),
17 
18  this->Reconfigure(p);
19  }
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &url2="", const std::string &tag="", bool usesqlite=false, bool testmode=false)
Constructors.
p
Definition: test.py:223
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.

Member Function Documentation

bool lariov::SIOVPmtGainProvider::DBUpdate ( ) const
private

Do actual database updates.

Definition at line 111 of file SIOVPmtGainProvider.cxx.

111  {
112  return DBUpdate(fEventTimeStamp);
113  }
bool DBUpdate() const
Do actual database updates.
bool lariov::SIOVPmtGainProvider::DBUpdate ( DBTimeStamp_t  ts) const
private

Definition at line 118 of file SIOVPmtGainProvider.cxx.

118  {
119 
120  bool result = false;
122 
123  mf::LogInfo("SIOVPmtGainProvider") << "SIOVPmtGainProvider::DBUpdate called with new timestamp.";
124 
125  fCurrentTimeStamp = ts;
126 
127  // Call non-const base class method.
128 
129  result = const_cast<SIOVPmtGainProvider*>(this)->UpdateFolder(ts);
130  if(result) {
131  //DBFolder was updated, so now update the Snapshot
132  fData.Clear();
133  fData.SetIoV(this->Begin(), this->End());
134 
135  std::vector<DBChannelID_t> channels;
136  fFolder->GetChannelList(channels);
137  for (auto it = channels.begin(); it != channels.end(); ++it) {
138 
139  double gain, gain_err;
140  fFolder->GetNamedChannelData(*it, "gain", gain);
141  fFolder->GetNamedChannelData(*it, "gain_sigma", gain_err);
142 
143  PmtGain pg(*it);
144  pg.SetGain( (float)gain );
145  pg.SetGainErr( (float)gain_err );
146  pg.SetExtraInfo(CalibrationExtraInfo("PmtGain"));
147 
148  fData.AddOrReplaceRow(pg);
149  }
150  }
151  }
152 
153  return result;
154  }
std::unique_ptr< DBFolder > fFolder
static QCString result
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
SIOVPmtGainProvider(fhicl::ParameterSet const &p)
Constructors.
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
const IOVTimeStamp & End() const
const IOVTimeStamp & Begin() const
Get Timestamp information.
CalibrationExtraInfo const & lariov::SIOVPmtGainProvider::ExtraInfo ( DBChannelID_t  ch) const
override

Definition at line 169 of file SIOVPmtGainProvider.cxx.

169  {
170  return this->PmtGainObject(ch).ExtraInfo();
171  }
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
CalibrationExtraInfo const & ExtraInfo() const
Definition: PmtGain.h:38
float lariov::SIOVPmtGainProvider::Gain ( DBChannelID_t  ch) const
override

Definition at line 161 of file SIOVPmtGainProvider.cxx.

161  {
162  return this->PmtGainObject(ch).Gain();
163  }
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
float Gain() const
Definition: PmtGain.h:36
float lariov::SIOVPmtGainProvider::GainErr ( DBChannelID_t  ch) const
override

Definition at line 165 of file SIOVPmtGainProvider.cxx.

165  {
166  return this->PmtGainObject(ch).GainErr();
167  }
float GainErr() const
Definition: PmtGain.h:37
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
const PmtGain & lariov::SIOVPmtGainProvider::PmtGainObject ( DBChannelID_t  ch) const

Retrieve gain information.

Definition at line 156 of file SIOVPmtGainProvider.cxx.

156  {
157  DBUpdate();
158  return fData.GetRow(ch);
159  }
bool DBUpdate() const
Do actual database updates.
void lariov::SIOVPmtGainProvider::Reconfigure ( fhicl::ParameterSet const &  p)
overridevirtual

Reconfigure function called by fhicl constructor.

Reimplemented from lariov::DatabaseRetrievalAlg.

Definition at line 21 of file SIOVPmtGainProvider.cxx.

21  {
22 
23  this->DatabaseRetrievalAlg::Reconfigure(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg"));
24  fData.Clear();
25  IOVTimeStamp tmp = IOVTimeStamp::MaxTimeStamp();
26  tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
27  fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
28 
29  bool UseDB = p.get<bool>("UseDB", false);
30  bool UseFile = p.get<bool>("UseFile", false);
31  std::string fileName = p.get<std::string>("FileName", "");
32 
33  //priority: (1) use db, (2) use table, (3) use defaults
34  //If none are specified, use defaults
35  if ( UseDB ) fDataSource = DataSource::Database;
36  else if (UseFile) fDataSource = DataSource::File;
38 
40  float default_gain = p.get<float>("DefaultGain");
41  float default_gain_err = p.get<float>("DefaultGainErr");
42 
43  PmtGain defaultGain(0);
44 
45  defaultGain.SetGain(default_gain);
46  defaultGain.SetGainErr(default_gain_err);
47  defaultGain.SetExtraInfo(CalibrationExtraInfo("PmtGain"));
48 
50  for (unsigned int od=0; od!=geo->NOpDets(); ++od) {
51  if (geo->IsValidOpChannel(od)) {
52  defaultGain.SetChannel(od);
53  fData.AddOrReplaceRow(defaultGain);
54  }
55  }
56 
57  }
58  else if (fDataSource == DataSource::File) {
59  cet::search_path sp("FW_SEARCH_PATH");
60  std::string abs_fp = sp.find_file(fileName);
61  std::cout << "Using pmt gains from local file: "<<abs_fp<<"\n";
62  std::ifstream file(abs_fp);
63  if (!file) {
64  throw cet::exception("SIOVPmtGainProvider")
65  << "File "<<abs_fp<<" is not found.";
66  }
67 
69  PmtGain dp(0);
70  while (std::getline(file, line)) {
71  if (line[0] == '#') continue;
72  size_t current_comma = line.find(',');
73  DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
74  float gain = std::stof( line.substr(current_comma+1, line.find(',',current_comma+1)-(current_comma+1)) );
75 
76  current_comma = line.find(',',current_comma+1);
77  float gain_err = std::stof( line.substr(current_comma+1) );
78 
79  CalibrationExtraInfo info("PmtGain");
80 
81  dp.SetChannel(ch);
82  dp.SetGain(gain);
83  dp.SetGainErr(gain_err);
84  dp.SetExtraInfo(info);
85 
86  fData.AddOrReplaceRow(dp);
87  }
88  }
89  else {
90  std::cout << "Using pmt gains from conditions database"<<std::endl;
91  }
92  }
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
std::string string
Definition: nybbler.cc:12
std::uint32_t DBChannelID_t
fileName
Definition: dumpTree.py:9
p
Definition: test.py:223
string tmp
Definition: languages.py:63
unsigned int NOpDets() const
Number of OpDets in the whole detector.
void line(double t, double *p, double &x, double &y, double &z)
static IOVTimeStamp MaxTimeStamp()
LArSoft geometry interface.
Definition: ChannelGeo.h:16
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
bool lariov::SIOVPmtGainProvider::Update ( DBTimeStamp_t  ts)

Update Snapshot and inherited DBFolder if using database. Return true if updated.

Definition at line 103 of file SIOVPmtGainProvider.cxx.

103  {
104 
105  fEventTimeStamp = ts;
106  return DBUpdate(ts);
107  }
bool DBUpdate() const
Do actual database updates.
void lariov::SIOVPmtGainProvider::UpdateTimeStamp ( DBTimeStamp_t  ts)

Update event time stamp.

Definition at line 96 of file SIOVPmtGainProvider.cxx.

96  {
97  mf::LogInfo("SIOVPmtGainProvider") << "SIOVPmtGainProvider::UpdateTimeStamp called.";
98  fEventTimeStamp = ts;
99  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo

Member Data Documentation

DBTimeStamp_t lariov::SIOVPmtGainProvider::fCurrentTimeStamp
mutableprivate

Definition at line 70 of file SIOVPmtGainProvider.h.

Snapshot<PmtGain> lariov::SIOVPmtGainProvider::fData
mutableprivate

Definition at line 74 of file SIOVPmtGainProvider.h.

DataSource::ds lariov::SIOVPmtGainProvider::fDataSource
private

Definition at line 72 of file SIOVPmtGainProvider.h.

DBTimeStamp_t lariov::SIOVPmtGainProvider::fEventTimeStamp
private

Definition at line 69 of file SIOVPmtGainProvider.h.


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