1 #ifndef SIOVELECTRONICSCALIBPROVIDER_CXX 2 #define SIOVELECTRONICSCALIBPROVIDER_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");
44 float default_st = p.
get<
float>(
"DefaultShapingTime");
45 float default_st_err = p.
get<
float>(
"DefaultShapingTimeErr");
47 ElectronicsCalib defaultCalib(0);
49 defaultCalib.SetGain(default_gain);
50 defaultCalib.SetGainErr(default_gain_err);
51 defaultCalib.SetShapingTime(default_st);
52 defaultCalib.SetShapingTimeErr(default_st_err);
53 defaultCalib.SetExtraInfo(CalibrationExtraInfo(
"ElectronicsCalib"));
59 defaultCalib.SetChannel(ch);
60 fData.AddOrReplaceRow(defaultCalib);
65 cet::search_path sp(
"FW_SEARCH_PATH");
66 std::string abs_fp = sp.find_file(fileName);
67 std::cout <<
"Using electronics calibrations from local file: "<<abs_fp<<
"\n";
68 std::ifstream
file(abs_fp);
71 <<
"File "<<abs_fp<<
" is not found.";
75 ElectronicsCalib dp(0);
76 while (std::getline(file, line)) {
77 size_t current_comma = line.find(
',');
78 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
79 float gain = std::stof( 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, line.find(
',',current_comma+1)-(current_comma+1)) );
84 current_comma = line.find(
',',current_comma+1);
85 float shaping_time = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
87 current_comma = line.find(
',',current_comma+1);
88 float shaping_time_err = std::stof( line.substr(current_comma+1) );
90 CalibrationExtraInfo info(
"ElectronicsCalib");
94 dp.SetGainErr(gain_err);
95 dp.SetShapingTime(shaping_time);
96 dp.SetShapingTimeErr(shaping_time_err);
97 dp.SetExtraInfo(info);
99 fData.AddOrReplaceRow(dp);
103 std::cout <<
"Using electronics calibrations from conditions database"<<std::endl;
109 if (
fDataSource != DataSource::Database)
return false;
117 std::vector<DBChannelID_t> channels;
118 fFolder->GetChannelList(channels);
119 for (
auto it = channels.begin(); it != channels.end(); ++it) {
121 double gain, gain_err, shaping_time, shaping_time_err;
122 fFolder->GetNamedChannelData(*it,
"gain", gain);
123 fFolder->GetNamedChannelData(*it,
"gain_err", gain_err);
124 fFolder->GetNamedChannelData(*it,
"shaping_time", shaping_time);
125 fFolder->GetNamedChannelData(*it,
"shaping_time_err", shaping_time_err);
128 ElectronicsCalib pg(*it);
129 pg.SetGain( (
float)gain );
130 pg.SetGainErr( (
float)gain_err );
131 pg.SetShapingTime( (
float)shaping_time );
132 pg.SetShapingTimeErr( (
float)shaping_time_err );
133 pg.SetExtraInfo(CalibrationExtraInfo(
"ElectronicsCalib"));
135 fData.AddOrReplaceRow(pg);
142 return fData.GetRow(ch);
float ShapingTimeErr(DBChannelID_t ch) const override
Class def header for a class SIOVElectronicsCalibProvider.
std::unique_ptr< DBFolder > fFolder
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
Base forward iterator browsing all wire IDs in the detector.
CalibrationExtraInfo const & ExtraInfo(DBChannelID_t ch) const override
DataSource::ds fDataSource
float GainErr(DBChannelID_t ch) const override
const ElectronicsCalib & ElectronicsCalibObject(DBChannelID_t ch) const
Retrieve electronics calibration information.
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
T get(std::string const &key) const
float ShapingTime(DBChannelID_t ch) const override
wire_id_iterator end_wire_id() const
Returns an iterator pointing after the last wire ID in the detector.
const IOVTimeStamp & End() const
Filters for channels, events, etc.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
float Gain(DBChannelID_t ch) const override
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.
wire_id_iterator begin_wire_id() const
Returns an iterator pointing to the first wire ID in the detector.
Snapshot< ElectronicsCalib > fData
Namespace collecting geometry-related classes utilities.
Collection of exception classes for WebDBI.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception