LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lariov::DetPedestalRetrievalAlg Class Reference

Retrieves channel information: pedestal and RMS. More...

#include "DetPedestalRetrievalAlg.h"

Inheritance diagram for lariov::DetPedestalRetrievalAlg:
lariov::DatabaseRetrievalAlg

Public Member Functions

 DetPedestalRetrievalAlg (const std::string &foldername, const std::string &url, const std::string &tag="")
 Constructors. More...
 
 DetPedestalRetrievalAlg (fhicl::ParameterSet const &p)
 
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 DetPedestal & Pedestal (DBChannelID_t ch) const
 Retrieve pedestal information. More...
 
float PedMean (DBChannelID_t ch) const override
 
float PedRms (DBChannelID_t ch) const override
 
float PedMeanErr (DBChannelID_t ch) const override
 
float PedRmsErr (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
 

Static Public Attributes

static constexpr unsigned int NCOLUMNS = 5
 
static constexpr const char * FIELD_NAMES [NCOLUMNS] = {"channel", "mean", "mean_err", "rms", "rms_err"}
 
static constexpr const char * FIELD_TYPES [NCOLUMNS] = {"unsigned int", "float", "float", "float", "float"}
 

Protected Attributes

std::unique_ptr< DBFolderfFolder
 

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< DetPedestal > fData
 

Detailed Description

Retrieves channel information: pedestal and RMS.

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
  • DefaultCollMean (real, default: 400.0): pedestal value returned for collection plane channels when /UseDB/ and /UseFile/ parameters are false
  • DefaultIndMean (real, default: 2048.0): pedestal value returned for induction plane channels when /UseDB/ and /UseFile/ parameters are false
  • DefaultCollRms (real, default: 0.3): pedestal RMS value returned for collection plane channels when /UseDB/ and /UseFile/ parameters are false
  • DefaultIndRms (real, default: 0.3): pedestal RMS value returned for induction plane channels when /UseDB/ and /UseFile/ parameters are false
  • DefaultMeanErr (real, default: 0.0): error on the pedestal value for all channels returned when /UseDB/ and /UseFile/ parameters are false
  • DefaultRmsErr (real, default: 0.0): error on the RMS value for all channels returned when /UseDB/ and /UseFile/ parameters are false

Definition at line 54 of file DetPedestalRetrievalAlg.h.

Constructor & Destructor Documentation

lariov::DetPedestalRetrievalAlg::DetPedestalRetrievalAlg ( const std::string &  foldername,
const std::string &  url,
const std::string &  tag = "" 
)

Constructors.

Definition at line 20 of file DetPedestalRetrievalAlg.cxx.

References fData, and tmp.

22  :
23  DatabaseRetrievalAlg(foldername, url, tag),
24  fEventTimeStamp(0),
26  fDataSource(DataSource::Database) {
27 
28  fData.Clear();
29  IOVTimeStamp tmp = IOVTimeStamp::MaxTimeStamp();
30  tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
31  fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
32  }
Float_t tmp
Definition: plot.C:37
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.
lariov::DetPedestalRetrievalAlg::DetPedestalRetrievalAlg ( fhicl::ParameterSet const &  p)

Definition at line 35 of file DetPedestalRetrievalAlg.cxx.

References Reconfigure().

35  :
36  DatabaseRetrievalAlg(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg")) {
37 
38  this->Reconfigure(p);
39  }
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.

Member Function Documentation

const IOVTimeStamp& lariov::DatabaseRetrievalAlg::Begin ( ) const
inlineinherited
bool lariov::DetPedestalRetrievalAlg::DBUpdate ( ) const
private

Do actual database updates.

Definition at line 154 of file DetPedestalRetrievalAlg.cxx.

References fEventTimeStamp.

Referenced by Pedestal(), and Update().

154  {
155  return DBUpdate(fEventTimeStamp);
156  }
bool DBUpdate() const
Do actual database updates.
bool lariov::DetPedestalRetrievalAlg::DBUpdate ( DBTimeStamp_t  ts) const
private

Definition at line 161 of file DetPedestalRetrievalAlg.cxx.

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

161  {
162 
163  bool result = false;
164  if(fDataSource == DataSource::Database && ts != fCurrentTimeStamp) {
165 
166  mf::LogInfo("DetPedestalRetrievalAlg") << "DetPedestalRetrievalAlg::DBUpdate called with new timestamp.";
167  fCurrentTimeStamp = ts;
168 
169  // Call non-const base class method.
170 
171  result = const_cast<DetPedestalRetrievalAlg*>(this)->UpdateFolder(ts);
172  if(result) {
173 
174  //DBFolder was updated, so now update the Snapshot
175  fData.Clear();
176  fData.SetIoV(this->Begin(), this->End());
177 
178  std::vector<DBChannelID_t> channels;
179  fFolder->GetChannelList(channels);
180  for (auto it = channels.begin(); it != channels.end(); ++it) {
181 
182  double mean, mean_err, rms, rms_err;
183  fFolder->GetNamedChannelData(*it, "mean", mean);
184  fFolder->GetNamedChannelData(*it, "mean_err", mean_err);
185  fFolder->GetNamedChannelData(*it, "rms", rms);
186  fFolder->GetNamedChannelData(*it, "rms_err", rms_err);
187 
188  DetPedestal pd(*it);
189  pd.SetPedMean( (float)mean );
190  pd.SetPedMeanErr( (float)mean_err );
191  pd.SetPedRms( (float)rms );
192  pd.SetPedRmsErr( (float)rms_err );
193 
194  fData.AddOrReplaceRow(pd);
195  }
196  }
197  }
198 
199  return result;
200 
201  }
std::unique_ptr< DBFolder > fFolder
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
DetPedestalRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.
const IOVTimeStamp & End() const
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:15
const IOVTimeStamp & Begin() const
Get Timestamp information.
const IOVTimeStamp& lariov::DatabaseRetrievalAlg::End ( ) const
inlineinherited
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
const DetPedestal & lariov::DetPedestalRetrievalAlg::Pedestal ( DBChannelID_t  ch) const

Retrieve pedestal information.

Definition at line 203 of file DetPedestalRetrievalAlg.cxx.

References DBUpdate(), and fData.

Referenced by PedMean(), PedMeanErr(), PedRms(), and PedRmsErr().

203  {
204  DBUpdate();
205  return fData.GetRow(ch);
206  }
bool DBUpdate() const
Do actual database updates.
float lariov::DetPedestalRetrievalAlg::PedMean ( DBChannelID_t  ch) const
override

Definition at line 208 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

208  {
209  return this->Pedestal(ch).PedMean();
210  }
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
float lariov::DetPedestalRetrievalAlg::PedMeanErr ( DBChannelID_t  ch) const
override

Definition at line 216 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

216  {
217  return this->Pedestal(ch).PedMeanErr();
218  }
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
float lariov::DetPedestalRetrievalAlg::PedRms ( DBChannelID_t  ch) const
override

Definition at line 212 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

212  {
213  return this->Pedestal(ch).PedRms();
214  }
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
float lariov::DetPedestalRetrievalAlg::PedRmsErr ( DBChannelID_t  ch) const
override

Definition at line 220 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

220  {
221  return this->Pedestal(ch).PedRmsErr();
222  }
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
void lariov::DetPedestalRetrievalAlg::Reconfigure ( fhicl::ParameterSet const &  p)
overridevirtual

Reconfigure function called by fhicl constructor.

Reimplemented from lariov::DatabaseRetrievalAlg.

Definition at line 41 of file DetPedestalRetrievalAlg.cxx.

References geo::GeometryCore::begin_wire_id(), geo::GeometryCore::end_wire_id(), fData, fDataSource, file, fhicl::ParameterSet::get(), geo::kCollection, geo::kInduction, geo::GeometryCore::PlaneWireToChannel(), lariov::DatabaseRetrievalAlg::Reconfigure(), geo::GeometryCore::SignalType(), and tmp.

Referenced by DetPedestalRetrievalAlg().

41  {
42 
43  this->DatabaseRetrievalAlg::Reconfigure(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg"));
44  fData.Clear();
45  IOVTimeStamp tmp = IOVTimeStamp::MaxTimeStamp();
46  tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
47  fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
48 
49  bool UseDB = p.get<bool>("UseDB", false);
50  bool UseFile = p.get<bool>("UseFile", false);
51  std::string fileName = p.get<std::string>("FileName", "");
52 
53  //priority: (1) use db, (2) use table, (3) use defaults
54  //If none are specified, use defaults
55  if ( UseDB ) fDataSource = DataSource::Database;
56  else if (UseFile) fDataSource = DataSource::File;
57  else fDataSource = DataSource::Default;
58 
59  if (fDataSource == DataSource::Default) {
60  std::cout << "Using default pedestal values\n";
61  float default_collmean = p.get<float>("DefaultCollMean", 400.0);
62  float default_collrms = p.get<float>("DefaultCollRms", 0.3);
63  float default_mean_err = p.get<float>("DefaultMeanErr", 0.0);
64  float default_rms_err = p.get<float>("DefaultRmsErr", 0.0);
65  float default_indmean = p.get<float>("DefaultIndMean", 2048.0);
66  float default_indrms = p.get<float>("DefaultIndRms", 0.3);
67 
68  DetPedestal DefaultColl(0);
69  DetPedestal DefaultInd(0);
70 
71  DefaultColl.SetPedMean(default_collmean);
72  DefaultColl.SetPedMeanErr(default_mean_err);
73  DefaultColl.SetPedRms(default_collrms);
74  DefaultColl.SetPedRmsErr(default_rms_err);
75 
76  DefaultInd.SetPedMean(default_indmean);
77  DefaultInd.SetPedMeanErr(default_mean_err);
78  DefaultInd.SetPedRms(default_indrms);
79  DefaultInd.SetPedRmsErr(default_rms_err);
80 
83  for ( ; itW != geo->end_wire_id(); ++itW) {
84  DBChannelID_t ch = geo->PlaneWireToChannel(*itW);
85 
86  if (geo->SignalType(ch) == geo::kCollection) {
87  DefaultColl.SetChannel(ch);
88  fData.AddOrReplaceRow(DefaultColl);
89  }
90  else if (geo->SignalType(ch) == geo::kInduction) {
91  DefaultInd.SetChannel(ch);
92  fData.AddOrReplaceRow(DefaultInd);
93  }
94  else throw IOVDataError("Wire type is not collection or induction!");
95  }
96  }
97  else if (fDataSource == DataSource::File) {
98  cet::search_path sp("FW_SEARCH_PATH");
99  std::string abs_fp = sp.find_file(fileName);
100  std::cout << "Using pedestals from local file: "<<abs_fp<<"\n";
101  std::ifstream file(abs_fp);
102  if (!file) {
103  throw cet::exception("DetPedestalRetrievalAlg")
104  << "File "<<abs_fp<<" is not found.";
105  }
106 
107  std::string line;
108  DetPedestal dp(0);
109  while (std::getline(file, line)) {
110  size_t current_comma = line.find(',');
111  DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
112  float ped = std::stof( line.substr(current_comma+1, line.find(',',current_comma+1)-(current_comma+1)) );
113 
114  current_comma = line.find(',',current_comma+1);
115  float rms = std::stof( line.substr(current_comma+1, line.find(',',current_comma+1)-(current_comma+1)) );
116 
117  current_comma = line.find(',',current_comma+1);
118  float ped_err = std::stof( line.substr(current_comma+1, line.find(',',current_comma+1)-(current_comma+1)) );
119 
120  current_comma = line.find(',',current_comma+1);
121  float rms_err = std::stof( line.substr(current_comma+1) );
122 
123  dp.SetChannel(ch);
124  dp.SetPedMean(ped);
125  dp.SetPedMeanErr(ped_err);
126  dp.SetPedRms(rms);
127  dp.SetPedRmsErr(rms_err);
128  fData.AddOrReplaceRow(dp);
129  }
130  } // if source from file
131  else {
132  std::cout << "Using pedestals from conditions database\n";
133  }
134  }
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
Base forward iterator browsing all wire IDs in the detector.
Definition: GeometryCore.h:567
Float_t tmp
Definition: plot.C:37
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Signal from induction planes.
Definition: geo_types.h:92
wire_id_iterator end_wire_id() const
Returns an iterator pointing after the last wire ID in the detector.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
TFile * file
wire_id_iterator begin_wire_id() const
Returns an iterator pointing to the first wire ID in the detector.
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Signal from collection planes.
Definition: geo_types.h:93
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::DetPedestalRetrievalAlg::Update ( DBTimeStamp_t  ts)

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

Definition at line 146 of file DetPedestalRetrievalAlg.cxx.

References DBUpdate(), and fEventTimeStamp.

146  {
147 
148  fEventTimeStamp = ts;
149  return DBUpdate(ts);
150  }
bool DBUpdate() const
Do actual database updates.
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 lariov::SIOVPmtGainProvider::DBUpdate(), lariov::SIOVElectronicsCalibProvider::DBUpdate(), DBUpdate(), and lariov::SIOVChannelStatusProvider::DBUpdate().

49  {
50  return fFolder->UpdateData(ts);
51  }
std::unique_ptr< DBFolder > fFolder
void lariov::DetPedestalRetrievalAlg::UpdateTimeStamp ( DBTimeStamp_t  ts)

Update event time stamp.

Definition at line 139 of file DetPedestalRetrievalAlg.cxx.

References fEventTimeStamp.

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

139  {
140  mf::LogInfo("DetPedestalRetrievalAlg") << "DetPedestalRetrievalAlg::UpdateTimeStamp called.";
141  fEventTimeStamp = ts;
142  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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

DBTimeStamp_t lariov::DetPedestalRetrievalAlg::fCurrentTimeStamp
mutableprivate

Definition at line 98 of file DetPedestalRetrievalAlg.h.

Referenced by DBUpdate().

Snapshot<DetPedestal> lariov::DetPedestalRetrievalAlg::fData
mutableprivate
DataSource::ds lariov::DetPedestalRetrievalAlg::fDataSource
private

Definition at line 100 of file DetPedestalRetrievalAlg.h.

Referenced by DBUpdate(), and Reconfigure().

DBTimeStamp_t lariov::DetPedestalRetrievalAlg::fEventTimeStamp
private

Definition at line 97 of file DetPedestalRetrievalAlg.h.

Referenced by DBUpdate(), Update(), and UpdateTimeStamp().

constexpr const char* lariov::DetPedestalRetrievalAlg::FIELD_NAMES[NCOLUMNS] = {"channel", "mean", "mean_err", "rms", "rms_err"}
static

Definition at line 84 of file DetPedestalRetrievalAlg.h.

constexpr const char* lariov::DetPedestalRetrievalAlg::FIELD_TYPES[NCOLUMNS] = {"unsigned int", "float", "float", "float", "float"}
static

Definition at line 86 of file DetPedestalRetrievalAlg.h.

constexpr unsigned int lariov::DetPedestalRetrievalAlg::NCOLUMNS = 5
static

Definition at line 82 of file DetPedestalRetrievalAlg.h.


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