5 #include "cetlib_except/exception.h" 17 , fCurrentTimeStamp(0)
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",
"");
45 float default_gain = p.
get<
float>(
"DefaultGain");
46 float default_gain_err = p.
get<
float>(
"DefaultGainErr");
47 float default_st = p.
get<
float>(
"DefaultShapingTime");
48 float default_st_err = p.
get<
float>(
"DefaultShapingTimeErr");
52 defaultCalib.SetGain(default_gain);
53 defaultCalib.SetGainErr(default_gain_err);
54 defaultCalib.SetShapingTime(default_st);
55 defaultCalib.SetShapingTimeErr(default_st_err);
59 for (
auto const& wid : wireReadoutGeom.Iterate<
geo::WireID>()) {
60 DBChannelID_t ch = wireReadoutGeom.PlaneWireToChannel(wid);
61 defaultCalib.SetChannel(ch);
62 fData.AddOrReplaceRow(defaultCalib);
66 cet::search_path sp(
"FW_SEARCH_PATH");
67 std::string abs_fp = sp.find_file(fileName);
68 std::cout <<
"Using electronics calibrations from local file: " << abs_fp <<
"\n";
69 std::ifstream
file(abs_fp);
72 <<
"File " << abs_fp <<
" is not found.";
77 while (std::getline(file, line)) {
78 size_t current_comma = line.find(
',');
79 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
80 float gain = std::stof(
81 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
83 current_comma = line.find(
',', current_comma + 1);
84 float gain_err = std::stof(
85 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
87 current_comma = line.find(
',', current_comma + 1);
88 float shaping_time = std::stof(
89 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
91 current_comma = line.find(
',', current_comma + 1);
92 float shaping_time_err = std::stof(line.substr(current_comma + 1));
103 fData.AddOrReplaceRow(dp);
107 std::cout <<
"Using electronics calibrations from conditions database" << std::endl;
116 <<
"SIOVElectronicsCalibProvider::UpdateTimeStamp called.";
146 <<
"SIOVElectronicsCalibProvider::DBUpdate called with new timestamp.";
158 std::vector<DBChannelID_t> channels;
159 fFolder->GetChannelList(channels);
160 for (
auto it = channels.begin(); it != channels.end(); ++it) {
162 double gain, gain_err, shaping_time, shaping_time_err;
163 fFolder->GetNamedChannelData(*it,
"gain", gain);
164 fFolder->GetNamedChannelData(*it,
"gain_err", gain_err);
165 fFolder->GetNamedChannelData(*it,
"shaping_time", shaping_time);
166 fFolder->GetNamedChannelData(*it,
"shaping_time_err", shaping_time_err);
175 fData.AddOrReplaceRow(pg);
184 DBChannelID_t ch)
const 187 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)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
DBTimeStamp_t fCurrentTimeStamp
Retrieves information: electronics calibrations, specifically gain and shaping time.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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.
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
bool DBUpdate() const
Do actual database updates.
CalibrationExtraInfo const & ExtraInfo() const
float ShapingTimeErr() const
cet::coded_exception< error, detail::translate > exception