1 #ifndef WEBDB_DETPEDESTALRETRIEVALALG_CXX 2 #define WEBDB_DETPEDESTALRETRIEVALALG_CXX 6 #include "larevt/CalibrationDBI/IOVData/IOVDataConstants.h" 11 #include "cetlib_except/exception.h" 20 const std::string& url,
21 const std::string& tag ) :
26 IOVTimeStamp
tmp = IOVTimeStamp::MaxTimeStamp();
27 tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
28 fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
42 IOVTimeStamp
tmp = IOVTimeStamp::MaxTimeStamp();
43 tmp.SetStamp(tmp.Stamp()-1, tmp.SubStamp());
44 fData.SetIoV(tmp, IOVTimeStamp::MaxTimeStamp());
46 bool UseDB = p.
get<
bool>(
"UseDB",
false);
47 bool UseFile = p.
get<
bool>(
"UseFile",
false);
48 std::string fileName = p.
get<std::string>(
"FileName",
"");
57 std::cout <<
"Using default pedestal values\n";
58 float default_collmean = p.
get<
float>(
"DefaultCollMean", 400.0);
59 float default_collrms = p.
get<
float>(
"DefaultCollRms", 0.3);
60 float default_mean_err = p.
get<
float>(
"DefaultMeanErr", 0.0);
61 float default_rms_err = p.
get<
float>(
"DefaultRmsErr", 0.0);
62 float default_indmean = p.
get<
float>(
"DefaultIndMean", 2048.0);
63 float default_indrms = p.
get<
float>(
"DefaultIndRms", 0.3);
65 DetPedestal DefaultColl(0);
66 DetPedestal DefaultInd(0);
68 DefaultColl.SetPedMean(default_collmean);
69 DefaultColl.SetPedMeanErr(default_mean_err);
70 DefaultColl.SetPedRms(default_collrms);
71 DefaultColl.SetPedRmsErr(default_rms_err);
73 DefaultInd.SetPedMean(default_indmean);
74 DefaultInd.SetPedMeanErr(default_mean_err);
75 DefaultInd.SetPedRms(default_indrms);
76 DefaultInd.SetPedRmsErr(default_rms_err);
84 DefaultColl.SetChannel(ch);
85 fData.AddOrReplaceRow(DefaultColl);
88 DefaultInd.SetChannel(ch);
89 fData.AddOrReplaceRow(DefaultInd);
91 else throw IOVDataError(
"Wire type is not collection or induction!");
95 cet::search_path sp(
"FW_SEARCH_PATH");
96 std::string abs_fp = sp.find_file(fileName);
97 std::cout <<
"Using pedestals from local file: "<<abs_fp<<
"\n";
98 std::ifstream
file(abs_fp);
101 <<
"File "<<abs_fp<<
" is not found.";
106 while (std::getline(file, line)) {
107 size_t current_comma = line.find(
',');
108 DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, current_comma));
109 float ped = std::stof( line.substr(current_comma+1, line.find(
',',current_comma+1)-(current_comma+1)) );
111 current_comma = line.find(
',',current_comma+1);
112 float rms = 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 ped_err = 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 rms_err = std::stof( line.substr(current_comma+1) );
122 dp.SetPedMeanErr(ped_err);
124 dp.SetPedRmsErr(rms_err);
125 fData.AddOrReplaceRow(dp);
129 std::cout <<
"Using pedestals from conditions database\n";
136 if (
fDataSource != DataSource::Database)
return false;
144 std::vector<DBChannelID_t> channels;
145 fFolder->GetChannelList(channels);
146 for (
auto it = channels.begin(); it != channels.end(); ++it) {
148 double mean, mean_err, rms, rms_err;
149 fFolder->GetNamedChannelData(*it,
"mean", mean);
150 fFolder->GetNamedChannelData(*it,
"mean_err", mean_err);
151 fFolder->GetNamedChannelData(*it,
"rms", rms);
152 fFolder->GetNamedChannelData(*it,
"rms_err", rms_err);
155 pd.SetPedMean( (
float)mean );
156 pd.SetPedMeanErr( (
float)mean_err );
157 pd.SetPedRms( (
float)rms );
158 pd.SetPedRmsErr( (
float)rms_err );
160 fData.AddOrReplaceRow(pd);
168 return fData.GetRow(ch);
172 return this->
Pedestal(ch).PedMean();
180 return this->
Pedestal(ch).PedMeanErr();
184 return this->
Pedestal(ch).PedRmsErr();
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.
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.
DataSource::ds fDataSource
T get(std::string const &key) const
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
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.
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.