4 #include "art/Framework/Services/Registry/ServiceHandle.h"
5 #include "cetlib_except/exception.h"
7 #include "messagefacility/MessageLogger/MessageLogger.h"
17 fCurrentTimeStamp(0) {
30 bool UseDB = p.get<
bool>(
"UseDB",
false);
31 bool UseFile = p.get<
bool>(
"UseFile",
false);
32 std::string
fileName = p.get<std::string>(
"FileName",
"");
41 float default_gain = p.get<
float>(
"DefaultGain");
42 float default_gain_err = p.get<
float>(
"DefaultGainErr");
43 float default_st = p.get<
float>(
"DefaultShapingTime");
44 float default_st_err = p.get<
float>(
"DefaultShapingTimeErr");
48 defaultCalib.SetGain(default_gain);
49 defaultCalib.SetGainErr(default_gain_err);
50 defaultCalib.SetShapingTime(default_st);
51 defaultCalib.SetShapingTimeErr(default_st_err);
54 art::ServiceHandle<geo::Geometry const> geo;
56 for (; itW != geo->end_wire_id(); ++itW) {
58 defaultCalib.SetChannel(ch);
59 fData.AddOrReplaceRow(defaultCalib);
64 cet::search_path sp(
"FW_SEARCH_PATH");
65 std::string abs_fp = sp.find_file(fileName);
66 std::cout <<
"Using electronics calibrations from local file: "<<abs_fp<<
"\n";
67 std::ifstream
file(abs_fp);
69 throw cet::exception(
"SIOVElectronicsCalibProvider")
70 <<
"File "<<abs_fp<<
" is not found.";
75 while (std::getline(file, line)) {
76 size_t current_comma = line.find(
',');
78 float gain = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
80 current_comma = line.find(
',',current_comma+1);
81 float gain_err = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
83 current_comma = line.find(
',',current_comma+1);
84 float shaping_time = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
86 current_comma = line.find(
',',current_comma+1);
87 float shaping_time_err = std::stof( line.substr(current_comma+1) );
98 fData.AddOrReplaceRow(dp);
102 std::cout <<
"Using electronics calibrations from conditions database"<<std::endl;
109 mf::LogInfo(
"SIOVElectronicsCalibProvider") <<
"SIOVElectronicsCalibProvider::UpdateTimeStamp called.";
135 mf::LogInfo(
"SIOVElectronicsCalibProvider") <<
"SIOVElectronicsCalibProvider::DBUpdate called with new timestamp.";
147 std::vector<DBChannelID_t> channels;
148 fFolder->GetChannelList(channels);
149 for (
auto it = channels.begin(); it != channels.end(); ++it) {
151 double gain, gain_err, shaping_time, shaping_time_err;
152 fFolder->GetNamedChannelData(*it,
"gain", gain);
153 fFolder->GetNamedChannelData(*it,
"gain_err", gain_err);
154 fFolder->GetNamedChannelData(*it,
"shaping_time", shaping_time);
155 fFolder->GetNamedChannelData(*it,
"shaping_time_err", shaping_time_err);
165 fData.AddOrReplaceRow(pg);
175 return fData.GetRow(ch);
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.
std::uint32_t DBChannelID_t
DBTimeStamp_t fCurrentTimeStamp
float ShapingTimeErr(DBChannelID_t ch) const override
std::uint64_t DBTimeStamp_t
Retrieves information: electronics calibrations, specifically gain and shaping time.
DataSource::ds fDataSource
CalibrationExtraInfo const & ExtraInfo(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.
DBTimeStamp_t fEventTimeStamp
void SetChannel(unsigned int ch)
const IOVTimeStamp & End() const
float GainErr(DBChannelID_t ch) const override
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
float ShapingTime(DBChannelID_t ch) const override
unsigned long Stamp() const
services TFileService fileName
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)
float Gain(DBChannelID_t ch) const override
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
art framework interface to geometry description
BEGIN_PROLOG could also be cout