6 #include "cetlib_except/exception.h" 23 const std::string& url,
24 const std::string& tag )
27 , fCurrentTimeStamp(0)
50 bool UseDB = p.
get<
bool>(
"UseDB",
false);
51 bool UseFile = p.
get<
bool>(
"UseFile",
false);
52 std::string fileName = p.
get<std::string>(
"FileName",
"");
64 std::cout <<
"Using default pedestal values\n";
65 float default_collmean = p.
get<
float>(
"DefaultCollMean", 400.0);
66 float default_collrms = p.
get<
float>(
"DefaultCollRms", 0.3);
67 float default_mean_err = p.
get<
float>(
"DefaultMeanErr", 0.0);
68 float default_rms_err = p.
get<
float>(
"DefaultRmsErr", 0.0);
69 float default_indmean = p.
get<
float>(
"DefaultIndMean", 2048.0);
70 float default_indrms = p.
get<
float>(
"DefaultIndRms", 0.3);
86 for (
auto const& wid : wireReadoutGeom.Iterate<
geo::WireID>()) {
87 DBChannelID_t ch = wireReadoutGeom.PlaneWireToChannel(wid);
91 fData.AddOrReplaceRow(DefaultColl);
95 fData.AddOrReplaceRow(DefaultInd);
98 throw IOVDataError(
"Wire type is not collection or induction!");
102 cet::search_path sp(
"FW_SEARCH_PATH");
103 std::string abs_fp = sp.find_file(fileName);
104 std::cout <<
"Using pedestals from local file: " << abs_fp <<
"\n";
105 std::ifstream
file(abs_fp);
107 throw cet::exception(
"DetPedestalRetrievalAlg") <<
"File " << abs_fp <<
" is not found.";
112 while (std::getline(file, line)) {
113 size_t current_comma = line.find(
',');
114 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
115 float ped = std::stof(
116 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
118 current_comma = line.find(
',', current_comma + 1);
119 float rms = std::stof(
120 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
122 current_comma = line.find(
',', current_comma + 1);
123 float ped_err = std::stof(
124 line.substr(current_comma + 1, line.find(
',', current_comma + 1) - (current_comma + 1)));
126 current_comma = line.find(
',', current_comma + 1);
127 float rms_err = std::stof(line.substr(current_comma + 1));
134 fData.AddOrReplaceRow(dp);
138 std::cout <<
"Using pedestals from conditions database\n";
146 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::UpdateTimeStamp called.";
171 static std::mutex mutex;
172 std::lock_guard<std::mutex> lock(mutex);
178 <<
"DetPedestalRetrievalAlg::DBUpdate called with new timestamp.";
190 std::vector<DBChannelID_t> channels;
191 fFolder->GetChannelList(channels);
192 for (
auto it = channels.begin(); it != channels.end(); ++it) {
194 double mean, mean_err, rms, rms_err;
195 fFolder->GetNamedChannelData(*it,
"mean", mean);
196 fFolder->GetNamedChannelData(*it,
"mean_err", mean_err);
197 fFolder->GetNamedChannelData(*it,
"rms", rms);
198 fFolder->GetNamedChannelData(*it,
"rms_err", rms_err);
206 fData.AddOrReplaceRow(pd);
217 return fData.GetRow(ch);
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
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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)
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)
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()
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
Interface to geometry for wire readouts .
cet::coded_exception< error, detail::translate > exception
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
Signal from collection planes.