5 #include "art/Framework/Services/Registry/ServiceHandle.h"
6 #include "cetlib_except/exception.h"
7 #include "fhiclcpp/ParameterSet.h"
14 #include "messagefacility/MessageLogger/MessageLogger.h"
23 const std::string& url,
24 const std::string& tag ) :
51 bool UseDB = p.get<
bool>(
"UseDB",
false);
52 bool UseFile = p.get<
bool>(
"UseFile",
false);
53 std::string
fileName = p.get<std::string>(
"FileName",
"");
62 std::cout <<
"Using default pedestal values\n";
63 float default_collmean = p.get<
float>(
"DefaultCollMean", 400.0);
64 float default_collrms = p.get<
float>(
"DefaultCollRms", 0.3);
65 float default_mean_err = p.get<
float>(
"DefaultMeanErr", 0.0);
66 float default_rms_err = p.get<
float>(
"DefaultRmsErr", 0.0);
67 float default_indmean = p.get<
float>(
"DefaultIndMean", 2048.0);
68 float default_indrms = p.get<
float>(
"DefaultIndRms", 0.3);
83 art::ServiceHandle<geo::Geometry const> geo;
85 for ( ; itW != geo->end_wire_id(); ++itW) {
90 fData.AddOrReplaceRow(DefaultColl);
94 fData.AddOrReplaceRow(DefaultInd);
96 else throw IOVDataError(
"Wire type is not collection or induction!");
100 cet::search_path sp(
"FW_SEARCH_PATH");
101 std::string abs_fp = sp.find_file(fileName);
102 std::cout <<
"Using pedestals from local file: "<<abs_fp<<
"\n";
103 std::ifstream
file(abs_fp);
105 throw cet::exception(
"DetPedestalRetrievalAlg")
106 <<
"File "<<abs_fp<<
" is not found.";
111 while (std::getline(file, line)) {
112 size_t current_comma = line.find(
',');
114 float ped = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
116 current_comma = line.find(
',',current_comma+1);
117 float rms = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
119 current_comma = line.find(
',',current_comma+1);
120 float ped_err = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
122 current_comma = line.find(
',',current_comma+1);
123 float rms_err = std::stof( line.substr(current_comma+1) );
130 fData.AddOrReplaceRow(dp);
134 std::cout <<
"Using pedestals from conditions database\n";
142 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::UpdateTimeStamp called.";
168 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::DBUpdate called with new timestamp.";
180 std::vector<DBChannelID_t> channels;
181 fFolder->GetChannelList(channels);
182 for (
auto it = channels.begin(); it != channels.end(); ++it) {
184 double mean, mean_err, rms, rms_err;
185 fFolder->GetNamedChannelData(*it,
"mean", mean);
186 fFolder->GetNamedChannelData(*it,
"mean_err", mean_err);
187 fFolder->GetNamedChannelData(*it,
"rms", rms);
188 fFolder->GetNamedChannelData(*it,
"rms_err", rms_err);
196 fData.AddOrReplaceRow(pd);
207 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)
Base forward iterator browsing all wire IDs in the detector.
std::uint32_t DBChannelID_t
float PedMeanErr(DBChannelID_t ch) const override
std::uint64_t DBTimeStamp_t
Class def header for a class DetPedestalRetrievalAlg.
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
Is this data-file representing beam spills or cosmic spills?
DataSource::ds fDataSource
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.
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
unsigned long Stamp() const
void SetPedMean(float pedMean)
services TFileService fileName
Collection of exception classes for IOVData.
const IOVTimeStamp & Begin() const
Get Timestamp information.
float PedRmsErr(DBChannelID_t ch) const override
float PedMean(DBChannelID_t ch) const override
float PedRms(DBChannelID_t ch) const override
static IOVTimeStamp MaxTimeStamp()
void UpdateTimeStamp(DBTimeStamp_t ts)
Update event time stamp.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
void Reconfigure(fhicl::ParameterSet const &p) override
Reconfigure function called by fhicl constructor.
Signal from collection planes.