5 #include "cetlib_except/exception.h" 17 , fCurrentTimeStamp(0)
32 bool UseDB = p.
get<
bool>(
"UseDB",
false);
33 bool UseFile = p.
get<
bool>(
"UseFile",
false);
34 std::string fileName = p.
get<std::string>(
"FileName",
"");
46 float default_gain = p.
get<
float>(
"DefaultGain");
47 float default_gain_err = p.
get<
float>(
"DefaultGainErr");
48 float default_st = p.
get<
float>(
"DefaultShapingTime");
49 float default_st_err = p.
get<
float>(
"DefaultShapingTimeErr");
53 defaultCalib.SetGain(default_gain);
54 defaultCalib.SetGainErr(default_gain_err);
55 defaultCalib.SetShapingTime(default_st);
56 defaultCalib.SetShapingTimeErr(default_st_err);
62 defaultCalib.SetChannel(ch);
63 fData.AddOrReplaceRow(defaultCalib);
67 cet::search_path sp(
"FW_SEARCH_PATH");
68 std::string abs_fp = sp.find_file(fileName);
69 std::cout <<
"Using electronics calibrations from local file: " << abs_fp <<
"\n";
70 std::ifstream
file(abs_fp);
73 <<
"File " << abs_fp <<
" is not found.";
78 while (std::getline(file, line)) {
79 size_t current_comma = line.find(
',');
80 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
81 float gain = std::stof(
82 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
84 current_comma = line.find(
',', current_comma + 1);
85 float gain_err = std::stof(
86 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
88 current_comma = line.find(
',', current_comma + 1);
89 float shaping_time = std::stof(
90 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
92 current_comma = line.find(
',', current_comma + 1);
93 float shaping_time_err = std::stof(line.substr(current_comma + 1));
104 fData.AddOrReplaceRow(dp);
108 std::cout <<
"Using electronics calibrations from conditions database" << std::endl;
117 <<
"SIOVElectronicsCalibProvider::UpdateTimeStamp called.";
147 <<
"SIOVElectronicsCalibProvider::DBUpdate called with new timestamp.";
159 std::vector<DBChannelID_t> channels;
160 fFolder->GetChannelList(channels);
161 for (
auto it = channels.begin(); it != channels.end(); ++it) {
163 double gain, gain_err, shaping_time, shaping_time_err;
164 fFolder->GetNamedChannelData(*it,
"gain", gain);
165 fFolder->GetNamedChannelData(*it,
"gain_err", gain_err);
166 fFolder->GetNamedChannelData(*it,
"shaping_time", shaping_time);
167 fFolder->GetNamedChannelData(*it,
"shaping_time_err", shaping_time_err);
176 fData.AddOrReplaceRow(pg);
185 DBChannelID_t ch)
const 188 return fData.GetRow(ch);
float ShapingTimeErr(DBChannelID_t ch) const override
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
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)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
DBTimeStamp_t fCurrentTimeStamp
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
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)
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.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
unsigned long Stamp() const
float Gain(DBChannelID_t ch) const override
float ShapingTime() const
bool Update(DBTimeStamp_t ts)
Update Snapshot and inherited DBFolder if using database. Return true if updated. ...
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.
void SetShapingTimeErr(float v)
static IOVTimeStamp MaxTimeStamp()
void SetExtraInfo(CalibrationExtraInfo const &info)
Snapshot< ElectronicsCalib > fData
Namespace collecting geometry-related classes utilities.
bool DBUpdate() const
Do actual database updates.
CalibrationExtraInfo const & ExtraInfo() const
float ShapingTimeErr() const
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception