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");
45 defaultGain.SetGain(default_gain);
46 defaultGain.SetGainErr(default_gain_err);
50 for (
unsigned int od=0; od!=geo->
NOpDets(); ++od) {
52 defaultGain.SetChannel(od);
53 fData.AddOrReplaceRow(defaultGain);
61 std::cout <<
"Using pmt gains from local file: "<<abs_fp<<
"\n";
62 std::ifstream
file(abs_fp);
65 <<
"File "<<abs_fp<<
" is not found.";
70 while (std::getline(file, line)) {
71 if (line[0] ==
'#')
continue;
72 size_t current_comma = line.find(
',');
74 float gain = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
76 current_comma = line.find(
',',current_comma+1);
77 float gain_err = std::stof( line.substr(current_comma+1) );
86 fData.AddOrReplaceRow(dp);
90 std::cout <<
"Using pmt gains from conditions database"<<
std::endl;
97 mf::LogInfo(
"SIOVPmtGainProvider") <<
"SIOVPmtGainProvider::UpdateTimeStamp called.";
123 mf::LogInfo(
"SIOVPmtGainProvider") <<
"SIOVPmtGainProvider::DBUpdate called with new timestamp.";
135 std::vector<DBChannelID_t>
channels;
136 fFolder->GetChannelList(channels);
137 for (
auto it = channels.begin(); it != channels.end(); ++it) {
139 double gain, gain_err;
140 fFolder->GetNamedChannelData(*it,
"gain", gain);
141 fFolder->GetNamedChannelData(*it,
"gain_sigma", gain_err);
148 fData.AddOrReplaceRow(pg);
158 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)
std::uint32_t DBChannelID_t
std::uint64_t DBTimeStamp_t
SIOVPmtGainProvider(fhicl::ParameterSet const &p)
Constructors.
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
art framework interface to geometry description
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
unsigned long Stamp() const
CalibrationExtraInfo const & ExtraInfo() const
void line(double t, double *p, double &x, double &y, double &z)
Class def header for a class SIOVPmtGainProvider.
std::string find_file(std::string const &filename) const
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()
auto const & get(AssnsNode< L, R, D > const &r)
LArSoft geometry interface.
float GainErr(DBChannelID_t ch) const override
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)