LArSoft  v06_85_00
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...
 
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 Attributes

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 19 of file DetPedestalRetrievalAlg.cxx.

References fData, and tmp.

21  :
22  DatabaseRetrievalAlg(foldername, url, tag),
23  fDataSource(DataSource::Database) {
24 
25  fData.Clear();
26  IOVTimeStamp tmp = IOVTimeStamp::MaxTimeStamp();
27  tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
28  fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
29  }
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 32 of file DetPedestalRetrievalAlg.cxx.

References Reconfigure().

32  :
33  DatabaseRetrievalAlg(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg")) {
34 
35  this->Reconfigure(p);
36  }
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
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 167 of file DetPedestalRetrievalAlg.cxx.

References fData.

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

167  {
168  return fData.GetRow(ch);
169  }
float lariov::DetPedestalRetrievalAlg::PedMean ( DBChannelID_t  ch) const
override

Definition at line 171 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

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

Definition at line 179 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

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

Definition at line 175 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

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

Definition at line 183 of file DetPedestalRetrievalAlg.cxx.

References Pedestal().

183  {
184  return this->Pedestal(ch).PedRmsErr();
185  }
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 38 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().

38  {
39 
40  this->DatabaseRetrievalAlg::Reconfigure(p.get<fhicl::ParameterSet>("DatabaseRetrievalAlg"));
41  fData.Clear();
42  IOVTimeStamp tmp = IOVTimeStamp::MaxTimeStamp();
43  tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
44  fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
45 
46  bool UseDB = p.get<bool>("UseDB", false);
47  bool UseFile = p.get<bool>("UseFile", false);
48  std::string fileName = p.get<std::string>("FileName", "");
49 
50  //priority: (1) use db, (2) use table, (3) use defaults
51  //If none are specified, use defaults
52  if ( UseDB ) fDataSource = DataSource::Database;
53  else if (UseFile) fDataSource = DataSource::File;
54  else fDataSource = DataSource::Default;
55 
56  if (fDataSource == DataSource::Default) {
57  std::cout << "Using default pedestal values\n";
58  float default_collmean = p.get<float>("DefaultCollMean", 400.0);
59  float default_collrms = p.get<float>("DefaultCollRms", 0.3);
60  float default_mean_err = p.get<float>("DefaultMeanErr", 0.0);
61  float default_rms_err = p.get<float>("DefaultRmsErr", 0.0);
62  float default_indmean = p.get<float>("DefaultIndMean", 2048.0);
63  float default_indrms = p.get<float>("DefaultIndRms", 0.3);
64 
65  DetPedestal DefaultColl(0);
66  DetPedestal DefaultInd(0);
67 
68  DefaultColl.SetPedMean(default_collmean);
69  DefaultColl.SetPedMeanErr(default_mean_err);
70  DefaultColl.SetPedRms(default_collrms);
71  DefaultColl.SetPedRmsErr(default_rms_err);
72 
73  DefaultInd.SetPedMean(default_indmean);
74  DefaultInd.SetPedMeanErr(default_mean_err);
75  DefaultInd.SetPedRms(default_indrms);
76  DefaultInd.SetPedRmsErr(default_rms_err);
77 
80  for ( ; itW != geo->end_wire_id(); ++itW) {
81  DBChannelID_t ch = geo->PlaneWireToChannel(*itW);
82 
83  if (geo->SignalType(ch) == geo::kCollection) {
84  DefaultColl.SetChannel(ch);
85  fData.AddOrReplaceRow(DefaultColl);
86  }
87  else if (geo->SignalType(ch) == geo::kInduction) {
88  DefaultInd.SetChannel(ch);
89  fData.AddOrReplaceRow(DefaultInd);
90  }
91  else throw IOVDataError("Wire type is not collection or induction!");
92  }
93  }
94  else if (fDataSource == DataSource::File) {
95  cet::search_path sp("FW_SEARCH_PATH");
96  std::string abs_fp = sp.find_file(fileName);
97  std::cout << "Using pedestals from local file: "<<abs_fp<<"\n";
98  std::ifstream file(abs_fp);
99  if (!file) {
100  throw cet::exception("DetPedestalRetrievalAlg")
101  << "File "<<abs_fp<<" is not found.";
102  }
103 
104  std::string line;
105  DetPedestal dp(0);
106  while (std::getline(file, line)) {
107  size_t current_comma = line.find(',');
108  DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
109  float ped = std::stof( line.substr(current_comma+1, line.find(',',current_comma+1)-(current_comma+1)) );
110 
111  current_comma = line.find(',',current_comma+1);
112  float rms = 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 ped_err = 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 rms_err = std::stof( line.substr(current_comma+1) );
119 
120  dp.SetChannel(ch);
121  dp.SetPedMean(ped);
122  dp.SetPedMeanErr(ped_err);
123  dp.SetPedRms(rms);
124  dp.SetPedRmsErr(rms_err);
125  fData.AddOrReplaceRow(dp);
126  }
127  } // if source from file
128  else {
129  std::cout << "Using pedestals from conditions database\n";
130  }
131  }
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 134 of file DetPedestalRetrievalAlg.cxx.

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

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

134  {
135 
136  if (fDataSource != DataSource::Database) return false;
137 
138  if (!this->UpdateFolder(ts)) return false;
139 
140  //DBFolder was updated, so now update the Snapshot
141  fData.Clear();
142  fData.SetIoV(this->Begin(), this->End());
143 
144  std::vector<DBChannelID_t> channels;
145  fFolder->GetChannelList(channels);
146  for (auto it = channels.begin(); it != channels.end(); ++it) {
147 
148  double mean, mean_err, rms, rms_err;
149  fFolder->GetNamedChannelData(*it, "mean", mean);
150  fFolder->GetNamedChannelData(*it, "mean_err", mean_err);
151  fFolder->GetNamedChannelData(*it, "rms", rms);
152  fFolder->GetNamedChannelData(*it, "rms_err", rms_err);
153 
154  DetPedestal pd(*it);
155  pd.SetPedMean( (float)mean );
156  pd.SetPedMeanErr( (float)mean_err );
157  pd.SetPedRms( (float)rms );
158  pd.SetPedRmsErr( (float)rms_err );
159 
160  fData.AddOrReplaceRow(pd);
161  }
162 
163  return true;
164 
165  }
std::unique_ptr< DBFolder > fFolder
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
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.
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::Update(), lariov::SIOVElectronicsCalibProvider::Update(), 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<DetPedestal> lariov::DetPedestalRetrievalAlg::fData
private

Definition at line 89 of file DetPedestalRetrievalAlg.h.

Referenced by DetPedestalRetrievalAlg(), Pedestal(), Reconfigure(), and Update().

DataSource::ds lariov::DetPedestalRetrievalAlg::fDataSource
private

Definition at line 87 of file DetPedestalRetrievalAlg.h.

Referenced by Reconfigure(), and Update().

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

Definition at line 81 of file DetPedestalRetrievalAlg.h.

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

Definition at line 83 of file DetPedestalRetrievalAlg.h.

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

Definition at line 79 of file DetPedestalRetrievalAlg.h.


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