1 #ifndef WEBDB_DETPEDESTALRETRIEVALALG_CXX 2 #define WEBDB_DETPEDESTALRETRIEVALALG_CXX 6 #include "larevt/CalibrationDBI/IOVData/IOVDataConstants.h" 11 #include "cetlib_except/exception.h" 21 const std::string& url,
22 const std::string& tag ) :
29 IOVTimeStamp
tmp = IOVTimeStamp::MaxTimeStamp();
30 tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
31 fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
45 IOVTimeStamp
tmp = IOVTimeStamp::MaxTimeStamp();
46 tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
47 fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
49 bool UseDB = p.
get<
bool>(
"UseDB",
false);
50 bool UseFile = p.
get<
bool>(
"UseFile",
false);
51 std::string fileName = p.
get<std::string>(
"FileName",
"");
60 std::cout <<
"Using default pedestal values\n";
61 float default_collmean = p.
get<
float>(
"DefaultCollMean", 400.0);
62 float default_collrms = p.
get<
float>(
"DefaultCollRms", 0.3);
63 float default_mean_err = p.
get<
float>(
"DefaultMeanErr", 0.0);
64 float default_rms_err = p.
get<
float>(
"DefaultRmsErr", 0.0);
65 float default_indmean = p.
get<
float>(
"DefaultIndMean", 2048.0);
66 float default_indrms = p.
get<
float>(
"DefaultIndRms", 0.3);
68 DetPedestal DefaultColl(0);
69 DetPedestal DefaultInd(0);
71 DefaultColl.SetPedMean(default_collmean);
72 DefaultColl.SetPedMeanErr(default_mean_err);
73 DefaultColl.SetPedRms(default_collrms);
74 DefaultColl.SetPedRmsErr(default_rms_err);
76 DefaultInd.SetPedMean(default_indmean);
77 DefaultInd.SetPedMeanErr(default_mean_err);
78 DefaultInd.SetPedRms(default_indrms);
79 DefaultInd.SetPedRmsErr(default_rms_err);
87 DefaultColl.SetChannel(ch);
88 fData.AddOrReplaceRow(DefaultColl);
91 DefaultInd.SetChannel(ch);
92 fData.AddOrReplaceRow(DefaultInd);
94 else throw IOVDataError(
"Wire type is not collection or induction!");
98 cet::search_path sp(
"FW_SEARCH_PATH");
99 std::string abs_fp = sp.find_file(fileName);
100 std::cout <<
"Using pedestals from local file: "<<abs_fp<<
"\n";
101 std::ifstream
file(abs_fp);
104 <<
"File "<<abs_fp<<
" is not found.";
109 while (std::getline(file, line)) {
110 size_t current_comma = line.find(
',');
111 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
112 float ped = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
114 current_comma = line.find(
',',current_comma+1);
115 float rms = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
117 current_comma = line.find(
',',current_comma+1);
118 float ped_err = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
120 current_comma = line.find(
',',current_comma+1);
121 float rms_err = std::stof( line.substr(current_comma+1) );
125 dp.SetPedMeanErr(ped_err);
127 dp.SetPedRmsErr(rms_err);
128 fData.AddOrReplaceRow(dp);
132 std::cout <<
"Using pedestals from conditions database\n";
140 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::UpdateTimeStamp called.";
166 mf::LogInfo(
"DetPedestalRetrievalAlg") <<
"DetPedestalRetrievalAlg::DBUpdate called with new timestamp.";
178 std::vector<DBChannelID_t> channels;
179 fFolder->GetChannelList(channels);
180 for (
auto it = channels.begin(); it != channels.end(); ++it) {
182 double mean, mean_err, rms, rms_err;
183 fFolder->GetNamedChannelData(*it,
"mean", mean);
184 fFolder->GetNamedChannelData(*it,
"mean_err", mean_err);
185 fFolder->GetNamedChannelData(*it,
"rms", rms);
186 fFolder->GetNamedChannelData(*it,
"rms_err", rms_err);
189 pd.SetPedMean( (
float)mean );
190 pd.SetPedMeanErr( (
float)mean_err );
191 pd.SetPedRms( (
float)rms );
192 pd.SetPedRmsErr( (
float)rms_err );
194 fData.AddOrReplaceRow(pd);
205 return fData.GetRow(ch);
209 return this->
Pedestal(ch).PedMean();
217 return this->
Pedestal(ch).PedMeanErr();
221 return this->
Pedestal(ch).PedRmsErr();
DBTimeStamp_t fEventTimeStamp
std::unique_ptr< DBFolder > fFolder
virtual void Reconfigure(fhicl::ParameterSet const &p)
Configure using fhicl::ParameterSet.
float PedRmsErr(DBChannelID_t ch) const override
Base forward iterator browsing all wire IDs in the detector.
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
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
bool Update(DBTimeStamp_t ts)
Update Snapshot and inherited DBFolder if using database. Return true if updated. ...
const DetPedestal & Pedestal(DBChannelID_t ch) const
Retrieve pedestal information.
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
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
wire_id_iterator end_wire_id() const
Returns an iterator pointing after the last wire ID in the detector.
const IOVTimeStamp & End() const
DBTimeStamp_t fCurrentTimeStamp
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.
const IOVTimeStamp & Begin() const
Get Timestamp information.
wire_id_iterator begin_wire_id() const
Returns an iterator pointing to the first wire ID in the detector.
float PedMean(DBChannelID_t ch) const override
Namespace collecting geometry-related classes utilities.
Collection of exception classes for WebDBI.
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.