LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lariov::SIOVPmtGainProvider Class Reference

Retrieves information: pmt gain. More...

#include "SIOVPmtGainProvider.h"

Inheritance diagram for lariov::SIOVPmtGainProvider:
lariov::DatabaseRetrievalAlg

Public Member Functions

 SIOVPmtGainProvider (fhicl::ParameterSet const &p)
 Constructors. More...
 
void Reconfigure (fhicl::ParameterSet const &p) override
 Reconfigure function called by fhicl constructor. More...
 
bool Update (DBTimeStamp_t ts)
 Update Snapshot and inherited DBFolder if using database. Return true if updated. More...
 
const PmtGain & PmtGainObject (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
 
bool UpdateFolder (DBTimeStamp_t ts)
 Return true if fFolder is successfully updated. More...
 
const std::string & URL () const
 Get connection information. More...
 
const std::string & FolderName () const
 
const std::string & Tag () const
 
const IOVTimeStamp & Begin () const
 Get Timestamp information. More...
 
const IOVTimeStamp & End () const
 

Protected Attributes

std::unique_ptr< DBFolderfFolder
 

Private Attributes

DataSource::ds fDataSource
 
Snapshot< PmtGain > fData
 

Detailed Description

Retrieves information: pmt gain.

Configuration parameters

  • DatabaseRetrievalAlg (parameter set, mandatory): configuration for the database; see lariov::DatabaseRetrievalAlg
  • UseDB (boolean, default: false): retrieve information from the database
  • UseFile (boolean, default: false): retrieve information from a file; not implemented yet
  • DefaultGain (real, default: ): Gain returned when /UseDB/ and /UseFile/ parameters are false
  • DefaultGainErr (real, default: ): Gain uncertainty returned when /UseDB/ and /UseFile/ parameters are false

Definition at line 38 of file SIOVPmtGainProvider.h.

Constructor & Destructor Documentation

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

Constructors.

Definition at line 17 of file SIOVPmtGainProvider.cxx.

References Reconfigure().

17  :
18  DatabaseRetrievalAlg(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg")) {
19 
20  this->Reconfigure(p);
21  }
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.

Member Function Documentation

const IOVTimeStamp& lariov::DatabaseRetrievalAlg::Begin ( ) const
inlineinherited
const IOVTimeStamp& lariov::DatabaseRetrievalAlg::End ( ) const
inlineinherited
CalibrationExtraInfo const & lariov::SIOVPmtGainProvider::ExtraInfo ( DBChannelID_t  ch) const
override

Definition at line 137 of file SIOVPmtGainProvider.cxx.

References PmtGainObject().

137  {
138  return this->PmtGainObject(ch).ExtraInfo();
139  }
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
const std::string& lariov::DatabaseRetrievalAlg::FolderName ( ) const
inlineinherited

Definition at line 55 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

55 {return fFolder->FolderName();}
std::unique_ptr< DBFolder > fFolder
float lariov::SIOVPmtGainProvider::Gain ( DBChannelID_t  ch) const
override

Definition at line 129 of file SIOVPmtGainProvider.cxx.

References PmtGainObject().

129  {
130  return this->PmtGainObject(ch).Gain();
131  }
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
float lariov::SIOVPmtGainProvider::GainErr ( DBChannelID_t  ch) const
override

Definition at line 133 of file SIOVPmtGainProvider.cxx.

References PmtGainObject().

133  {
134  return this->PmtGainObject(ch).GainErr();
135  }
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 125 of file SIOVPmtGainProvider.cxx.

References fData.

Referenced by ExtraInfo(), Gain(), and GainErr().

125  {
126  return fData.GetRow(ch);
127  }
void lariov::SIOVPmtGainProvider::Reconfigure ( fhicl::ParameterSet const &  p)
overridevirtual

Reconfigure function called by fhicl constructor.

Reimplemented from lariov::DatabaseRetrievalAlg.

Definition at line 23 of file SIOVPmtGainProvider.cxx.

References fData, fDataSource, file, fhicl::ParameterSet::get(), geo::GeometryCore::IsValidOpChannel(), geo::GeometryCore::NOpDets(), lariov::DatabaseRetrievalAlg::Reconfigure(), and tmp.

Referenced by SIOVPmtGainProvider().

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

Definition at line 56 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

56 {return fFolder->Tag();}
std::unique_ptr< DBFolder > fFolder
bool lariov::SIOVPmtGainProvider::Update ( DBTimeStamp_t  ts)

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

Definition at line 96 of file SIOVPmtGainProvider.cxx.

References lariov::DatabaseRetrievalAlg::Begin(), lariov::DatabaseRetrievalAlg::End(), fData, fDataSource, lariov::DatabaseRetrievalAlg::fFolder, and lariov::DatabaseRetrievalAlg::UpdateFolder().

Referenced by lariov::SIOVPmtGainService::PreProcessEvent().

96  {
97 
98  if (fDataSource != DataSource::Database) return false;
99 
100  if (!this->UpdateFolder(ts)) return false;
101 
102  //DBFolder was updated, so now update the Snapshot
103  fData.Clear();
104  fData.SetIoV(this->Begin(), this->End());
105 
106  std::vector<DBChannelID_t> channels;
107  fFolder->GetChannelList(channels);
108  for (auto it = channels.begin(); it != channels.end(); ++it) {
109 
110  double gain, gain_err;
111  fFolder->GetNamedChannelData(*it, "gain", gain);
112  fFolder->GetNamedChannelData(*it, "gain_sigma", gain_err);
113 
114  PmtGain pg(*it);
115  pg.SetGain( (float)gain );
116  pg.SetGainErr( (float)gain_err );
117  pg.SetExtraInfo(CalibrationExtraInfo("PmtGain"));
118 
119  fData.AddOrReplaceRow(pg);
120  }
121 
122  return true;
123  }
std::unique_ptr< DBFolder > fFolder
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
const IOVTimeStamp & End() const
const IOVTimeStamp & Begin() const
Get Timestamp information.
bool lariov::DatabaseRetrievalAlg::UpdateFolder ( DBTimeStamp_t  ts)
inlineinherited

Return true if fFolder is successfully updated.

Definition at line 49 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

Referenced by Update(), lariov::SIOVElectronicsCalibProvider::Update(), lariov::DetPedestalRetrievalAlg::Update(), and lariov::SIOVChannelStatusProvider::Update().

49  {
50  return fFolder->UpdateData(ts);
51  }
std::unique_ptr< DBFolder > fFolder
const std::string& lariov::DatabaseRetrievalAlg::URL ( ) const
inlineinherited

Get connection information.

Definition at line 54 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

54 {return fFolder->URL();}
std::unique_ptr< DBFolder > fFolder

Member Data Documentation

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

Definition at line 61 of file SIOVPmtGainProvider.h.

Referenced by PmtGainObject(), Reconfigure(), and Update().

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

Definition at line 59 of file SIOVPmtGainProvider.h.

Referenced by Reconfigure(), and Update().


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