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");
51 defaultGain.SetGain(default_gain);
52 defaultGain.SetGainErr(default_gain_err);
56 for (
unsigned int od = 0; od != geo->
NOpDets(); ++od) {
58 defaultGain.SetChannel(od);
59 fData.AddOrReplaceRow(defaultGain);
64 cet::search_path sp(
"FW_SEARCH_PATH");
65 std::string abs_fp = sp.find_file(fileName);
66 std::cout <<
"Using pmt gains from local file: " << abs_fp <<
"\n";
67 std::ifstream
file(abs_fp);
69 throw cet::exception(
"SIOVPmtGainProvider") <<
"File " << abs_fp <<
" is not found.";
74 while (std::getline(file, line)) {
75 if (line[0] ==
'#')
continue;
76 size_t current_comma = line.find(
',');
77 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
78 float gain = std::stof(
79 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
81 current_comma = line.find(
',', current_comma + 1);
82 float gain_err = std::stof(line.substr(current_comma + 1));
91 fData.AddOrReplaceRow(dp);
95 std::cout <<
"Using pmt gains from conditions database" << std::endl;
103 mf::LogInfo(
"SIOVPmtGainProvider") <<
"SIOVPmtGainProvider::UpdateTimeStamp called.";
133 <<
"SIOVPmtGainProvider::DBUpdate called with new timestamp.";
145 std::vector<DBChannelID_t> channels;
146 fFolder->GetChannelList(channels);
147 for (
auto it = channels.begin(); it != channels.end(); ++it) {
149 double gain, gain_err;
150 fFolder->GetNamedChannelData(*it,
"gain", gain);
151 fFolder->GetNamedChannelData(*it,
"gain_sigma", gain_err);
158 fData.AddOrReplaceRow(pg);
169 return fData.GetRow(ch);
std::unique_ptr< DBFolder > fFolder
bool DBUpdate() const
Do actual database updates.
const PmtGain & PmtGainObject(DBChannelID_t ch) const
Retrieve gain information.
bool Update(DBTimeStamp_t ts)
Update Snapshot and inherited DBFolder if using database. Return true if updated. ...
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
Snapshot< PmtGain > fData
void SetExtraInfo(CalibrationExtraInfo const &info)
SIOVPmtGainProvider(fhicl::ParameterSet const &p)
Constructors.
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
unsigned long SubStamp() const
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
T get(std::string const &key) const
Retrieves information: pmt gain.
void SetChannel(unsigned int ch)
DataSource::ds fDataSource
const IOVTimeStamp & End() const
DBTimeStamp_t fCurrentTimeStamp
unsigned int NOpDets() const
Number of OpDets in the whole detector.
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
Filters for channels, events, etc.
DBTimeStamp_t fEventTimeStamp
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
unsigned long Stamp() const
CalibrationExtraInfo const & ExtraInfo() const
Class def header for a class SIOVPmtGainProvider.
const IOVTimeStamp & Begin() const
Get Timestamp information.
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
float Gain(DBChannelID_t ch) const override
static IOVTimeStamp MaxTimeStamp()
Namespace collecting geometry-related classes utilities.
float GainErr(DBChannelID_t ch) const override
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception