1 #ifndef SIOVPMTGAINPROVIDER_CXX 2 #define SIOVPMTGAINPROVIDER_CXX 8 #include "cetlib_except/exception.h" 27 IOVTimeStamp
tmp = IOVTimeStamp::MaxTimeStamp();
28 tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
29 fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
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",
"");
42 float default_gain = p.
get<
float>(
"DefaultGain");
43 float default_gain_err = p.
get<
float>(
"DefaultGainErr");
45 PmtGain defaultGain(0);
47 defaultGain.SetGain(default_gain);
48 defaultGain.SetGainErr(default_gain_err);
49 defaultGain.SetExtraInfo(CalibrationExtraInfo(
"PmtGain"));
52 for (
unsigned int od=0; od!=geo->
NOpDets(); ++od) {
54 defaultGain.SetChannel(od);
55 fData.AddOrReplaceRow(defaultGain);
61 cet::search_path sp(
"FW_SEARCH_PATH");
62 std::string abs_fp = sp.find_file(fileName);
63 std::cout <<
"Using pmt gains from local file: "<<abs_fp<<
"\n";
64 std::ifstream
file(abs_fp);
67 <<
"File "<<abs_fp<<
" is not found.";
72 while (std::getline(file, line)) {
73 if (line[0] ==
'#')
continue;
74 size_t current_comma = line.find(
',');
75 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
76 float gain = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
78 current_comma = line.find(
',',current_comma+1);
79 float gain_err = std::stof( line.substr(current_comma+1) );
81 CalibrationExtraInfo info(
"PmtGain");
85 dp.SetGainErr(gain_err);
86 dp.SetExtraInfo(info);
88 fData.AddOrReplaceRow(dp);
92 std::cout <<
"Using pmt gains from conditions database"<<std::endl;
98 if (
fDataSource != DataSource::Database)
return false;
106 std::vector<DBChannelID_t> channels;
107 fFolder->GetChannelList(channels);
108 for (
auto it = channels.begin(); it != channels.end(); ++it) {
110 double gain, gain_err;
111 fFolder->GetNamedChannelData(*it,
"gain", gain);
112 fFolder->GetNamedChannelData(*it,
"gain_sigma", gain_err);
115 pg.SetGain( (
float)gain );
116 pg.SetGainErr( (
float)gain_err );
117 pg.SetExtraInfo(CalibrationExtraInfo(
"PmtGain"));
119 fData.AddOrReplaceRow(pg);
126 return fData.GetRow(ch);
std::unique_ptr< DBFolder > fFolder
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.
Snapshot< PmtGain > fData
SIOVPmtGainProvider(fhicl::ParameterSet const &p)
Constructors.
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
T get(std::string const &key) const
DataSource::ds fDataSource
const IOVTimeStamp & End() const
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Filters for channels, events, etc.
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
Namespace collecting geometry-related classes utilities.
Collection of exception classes for WebDBI.
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