4 #include "cetlib_except/exception.h" 16 fCurrentTimeStamp(0) {
29 bool UseDB = p.
get<
bool>(
"UseDB",
false);
30 bool UseFile = p.
get<
bool>(
"UseFile",
false);
40 float default_gain = p.
get<
float>(
"DefaultGain");
41 float default_gain_err = p.
get<
float>(
"DefaultGainErr");
42 float default_st = p.
get<
float>(
"DefaultShapingTime");
43 float default_st_err = p.
get<
float>(
"DefaultShapingTimeErr");
47 defaultCalib.SetGain(default_gain);
48 defaultCalib.SetGainErr(default_gain_err);
49 defaultCalib.SetShapingTime(default_st);
50 defaultCalib.SetShapingTimeErr(default_st_err);
57 defaultCalib.SetChannel(ch);
58 fData.AddOrReplaceRow(defaultCalib);
65 std::cout <<
"Using electronics calibrations from local file: "<<abs_fp<<
"\n";
66 std::ifstream
file(abs_fp);
69 <<
"File "<<abs_fp<<
" is not found.";
74 while (std::getline(file, line)) {
75 size_t current_comma = line.find(
',');
77 float gain = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
79 current_comma = line.find(
',',current_comma+1);
80 float gain_err = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
82 current_comma = line.find(
',',current_comma+1);
83 float shaping_time = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
85 current_comma = line.find(
',',current_comma+1);
86 float shaping_time_err = std::stof( line.substr(current_comma+1) );
97 fData.AddOrReplaceRow(dp);
101 std::cout <<
"Using electronics calibrations from conditions database"<<
std::endl;
108 mf::LogInfo(
"SIOVElectronicsCalibProvider") <<
"SIOVElectronicsCalibProvider::UpdateTimeStamp called.";
134 mf::LogInfo(
"SIOVElectronicsCalibProvider") <<
"SIOVElectronicsCalibProvider::DBUpdate called with new timestamp.";
146 std::vector<DBChannelID_t>
channels;
147 fFolder->GetChannelList(channels);
148 for (
auto it = channels.begin(); it != channels.end(); ++it) {
150 double gain, gain_err, shaping_time, shaping_time_err;
151 fFolder->GetNamedChannelData(*it,
"gain", gain);
152 fFolder->GetNamedChannelData(*it,
"gain_err", gain_err);
153 fFolder->GetNamedChannelData(*it,
"shaping_time", shaping_time);
154 fFolder->GetNamedChannelData(*it,
"shaping_time_err", shaping_time_err);
164 fData.AddOrReplaceRow(pg);
174 return fData.GetRow(ch);
float ShapingTimeErr(DBChannelID_t ch) const override
Class def header for a class SIOVElectronicsCalibProvider.
std::unique_ptr< DBFolder > fFolder
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
void SetStamp(unsigned long stamp, unsigned int substamp=0)
Base forward iterator browsing all wire IDs in the detector.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::uint32_t DBChannelID_t
DBTimeStamp_t fCurrentTimeStamp
std::uint64_t DBTimeStamp_t
Retrieves information: electronics calibrations, specifically gain and shaping time.
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
DataSource::ds fDataSource
float GainErr(DBChannelID_t ch) const override
art framework interface to geometry description
unsigned long SubStamp() const
void SetShapingTime(float v)
const ElectronicsCalib & ElectronicsCalibObject(DBChannelID_t ch) const
Retrieve electronics calibration information.
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
T get(std::string const &key) const
float ShapingTime(DBChannelID_t ch) const override
DBTimeStamp_t fEventTimeStamp
void SetChannel(unsigned int ch)
wire_id_iterator end_wire_id() const
Returns an iterator pointing after the last wire ID in the detector.
const IOVTimeStamp & End() const
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
Filters for channels, events, etc.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
unsigned long Stamp() const
float Gain(DBChannelID_t ch) const override
float ShapingTime() const
void line(double t, double *p, double &x, double &y, double &z)
bool Update(DBTimeStamp_t ts)
Update Snapshot and inherited DBFolder if using database. Return true if updated. ...
std::string find_file(std::string const &filename) const
SIOVElectronicsCalibProvider(fhicl::ParameterSet const &p)
Constructors.
const IOVTimeStamp & Begin() const
Get Timestamp information.
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
wire_id_iterator begin_wire_id() const
Returns an iterator pointing to the first wire ID in the detector.
void SetShapingTimeErr(float v)
static IOVTimeStamp MaxTimeStamp()
void SetExtraInfo(CalibrationExtraInfo const &info)
auto const & get(AssnsNode< L, R, D > const &r)
Snapshot< ElectronicsCalib > fData
LArSoft geometry interface.
bool DBUpdate() const
Do actual database updates.
CalibrationExtraInfo const & ExtraInfo() const
float ShapingTimeErr() const
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)