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");
46 defaultGain.SetGain(default_gain);
47 defaultGain.SetGainErr(default_gain_err);
50 art::ServiceHandle<geo::Geometry const> geo;
51 for (
unsigned int od=0; od!=geo->NOpDets(); ++od) {
52 if (geo->IsValidOpChannel(od)) {
53 defaultGain.SetChannel(od);
54 fData.AddOrReplaceRow(defaultGain);
60 cet::search_path sp(
"FW_SEARCH_PATH");
61 std::string abs_fp = sp.find_file(fileName);
62 std::cout <<
"Using pmt gains from local file: "<<abs_fp<<
"\n";
63 std::ifstream
file(abs_fp);
65 throw cet::exception(
"SIOVPmtGainProvider")
66 <<
"File "<<abs_fp<<
" is not found.";
71 while (std::getline(file, line)) {
72 if (line[0] ==
'#')
continue;
73 size_t current_comma = line.find(
',');
75 float gain = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
77 current_comma = line.find(
',',current_comma+1);
78 float gain_err = std::stof( line.substr(current_comma+1) );
87 fData.AddOrReplaceRow(dp);
91 std::cout <<
"Using pmt gains from conditions database"<<std::endl;
98 mf::LogInfo(
"SIOVPmtGainProvider") <<
"SIOVPmtGainProvider::UpdateTimeStamp called.";
124 mf::LogInfo(
"SIOVPmtGainProvider") <<
"SIOVPmtGainProvider::DBUpdate called with new timestamp.";
136 std::vector<DBChannelID_t> channels;
137 fFolder->GetChannelList(channels);
138 for (
auto it = channels.begin(); it != channels.end(); ++it) {
140 double gain, gain_err;
141 fFolder->GetNamedChannelData(*it,
"gain", gain);
142 fFolder->GetNamedChannelData(*it,
"gain_sigma", gain_err);
149 fData.AddOrReplaceRow(pg);
159 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)
Snapshot< PmtGain > fData
void SetExtraInfo(CalibrationExtraInfo const &info)
std::uint32_t DBChannelID_t
std::uint64_t DBTimeStamp_t
SIOVPmtGainProvider(fhicl::ParameterSet const &p)
Constructors.
unsigned long SubStamp() const
float Gain(DBChannelID_t ch) const override
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
Retrieves information: pmt gain.
void SetChannel(unsigned int ch)
DataSource::ds fDataSource
const IOVTimeStamp & End() const
DBTimeStamp_t fCurrentTimeStamp
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
DBTimeStamp_t fEventTimeStamp
unsigned long Stamp() const
CalibrationExtraInfo const & ExtraInfo() const
services TFileService fileName
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.
static IOVTimeStamp MaxTimeStamp()
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
float GainErr(DBChannelID_t ch) const override
art framework interface to geometry description
BEGIN_PROLOG could also be cout