6 #include "cetlib_except/exception.h" 23 const std::string& url,
24 const std::string& tag )
27 , fCurrentTimeStamp(0)
53 bool UseDB = p.
get<
bool>(
"UseDB",
false);
54 bool UseFile = p.
get<
bool>(
"UseFile",
false);
55 std::string fileName = p.
get<std::string>(
"FileName",
"");
67 std::cout <<
"Using default pedestal values\n";
68 float default_collmean = p.
get<
float>(
"DefaultCollMean", 400.0);
69 float default_collrms = p.
get<
float>(
"DefaultCollRms", 0.3);
70 float default_mean_err = p.
get<
float>(
"DefaultMeanErr", 0.0);
71 float default_rms_err = p.
get<
float>(
"DefaultRmsErr", 0.0);
72 float default_indmean = p.
get<
float>(
"DefaultIndMean", 2048.0);
73 float default_indrms = p.
get<
float>(
"DefaultIndRms", 0.3);
94 fData.AddOrReplaceRow(DefaultColl);
98 fData.AddOrReplaceRow(DefaultInd);
101 throw IOVDataError(
"Wire type is not collection or induction!");
105 cet::search_path sp(
"FW_SEARCH_PATH");
106 std::string abs_fp = sp.find_file(fileName);
107 std::cout <<
"Using pedestals from local file: " << abs_fp <<
"\n";
108 std::ifstream
file(abs_fp);
110 throw cet::exception(
"DetPedestalRetrievalAlg") <<
"File " << abs_fp <<
" is not found.";
115 while (std::getline(file, line)) {
116 size_t current_comma = line.find(
',');
117 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
118 float ped = std::stof(
119 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
121 current_comma = line.find(
',', current_comma + 1);
122 float rms = std::stof(
123 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
125 current_comma = line.find(
',', current_comma + 1);
126 float ped_err = std::stof(
127 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
129 current_comma = line.find(
',', current_comma + 1);
130 float rms_err = std::stof(line.substr(current_comma + 1));
137 fData.AddOrReplaceRow(dp);
141 std::cout <<
"Using pedestals from conditions database\n";
149 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::UpdateTimeStamp called.";
176 static std::mutex mutex;
177 std::lock_guard<std::mutex> lock(mutex);
183 <<
"DetPedestalRetrievalAlg::DBUpdate called with new timestamp.";
195 std::vector<DBChannelID_t> channels;
196 fFolder->GetChannelList(channels);
197 for (
auto it = channels.begin(); it != channels.end(); ++it) {
199 double mean, mean_err, rms, rms_err;
200 fFolder->GetNamedChannelData(*it,
"mean", mean);
201 fFolder->GetNamedChannelData(*it,
"mean_err", mean_err);
202 fFolder->GetNamedChannelData(*it,
"rms", rms);
203 fFolder->GetNamedChannelData(*it,
"rms_err", rms_err);
211 fData.AddOrReplaceRow(pd);
222 return fData.GetRow(ch);
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
DBTimeStamp_t fEventTimeStamp
std::unique_ptr< DBFolder > fFolder
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
void SetStamp(unsigned long stamp, unsigned int substamp=0)
float PedRmsErr(DBChannelID_t ch) const override
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Class def header for a class DetPedestalRetrievalAlg.
float PedRms(DBChannelID_t ch) const override
float PedMeanErr(DBChannelID_t ch) const override
void SetPedRms(float pedRms)
bool Update(DBTimeStamp_t ts)
Update Snapshot and inherited DBFolder if using database. Return true if updated. ...
Class def header for a class IOVTimeStamp.
unsigned long SubStamp() const
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
void SetPedRmsErr(float pedRmsErr)
Access the description of detector geometry.
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
void SetPedMeanErr(float pedMeanErr)
Signal from induction planes.
bool DBUpdate() const
Do actual database updates.
DataSource::ds fDataSource
T get(std::string const &key) const
Retrieves channel information: pedestal and RMS.
DetPedestalRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.
Snapshot< DetPedestal > fData
void SetChannel(unsigned int ch)
const IOVTimeStamp & End() const
DBTimeStamp_t fCurrentTimeStamp
Definition of data types for geometry description.
Filters for channels, events, etc.
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
unsigned long Stamp() const
void SetPedMean(float pedMean)
Collection of exception classes for IOVData.
const IOVTimeStamp & Begin() const
Get Timestamp information.
float PedMean(DBChannelID_t ch) const override
static IOVTimeStamp MaxTimeStamp()
Namespace collecting geometry-related classes utilities.
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
Signal from collection planes.