128 nutools::dbi::Table LifetimePurMonTable;
129 LifetimePurMonTable.SetDetector(
"pdunesp");
130 LifetimePurMonTable.SetTableName(
"lifetime_purmon");
131 LifetimePurMonTable.SetTableType(nutools::dbi::kConditionsTable);
132 LifetimePurMonTable.SetDataTypeMask(nutools::dbi::kDataOnly);
133 if (
fIsMC) LifetimePurMonTable.SetDataTypeMask(nutools::dbi::kMCOnly);
135 int centerIdx = LifetimePurMonTable.AddCol(
"center",
"double");
136 int lowIdx = LifetimePurMonTable.AddCol(
"low",
"double");
137 int highIdx = LifetimePurMonTable.AddCol(
"high",
"double");
145 LifetimePurMonTable.SetMinTSVld(
fCurrentTS-1*86400.);
146 LifetimePurMonTable.SetMaxTSVld(
fCurrentTS+1*86400.);
150 LifetimePurMonTable.SetVerbosity(100);
156 readOk = LifetimePurMonTable.Load();
159 mf::LogError(
"LifetimeCalibProtoDUNE") <<
"Load from lifetime calib database table failed.";
160 throw cet::exception(
"LifetimeCalibProtoDUNE") <<
"Failed to query lifetime database. Please check URL: https://dbdata0vm.fnal.gov:9443/dune_con_prod/app" <<
"\n";
165 if (LifetimePurMonTable.NRow() == 0) {
166 mf::LogError(
"LifetimeCalibProtoDUNE") <<
"Number of rows in lifetime calib table is 0. This should never be the case!";
170 std::vector<double> loaded_tv;
171 std::vector<double> loaded_center;
172 std::vector<double> loaded_low;
173 std::vector<double> loaded_high;
175 loaded_center.clear();
179 if (LifetimePurMonTable.NRow() == 1)
fInterpolate =
false;
181 nutools::dbi::Row*
row;
184 for (
int i=0; i<LifetimePurMonTable.NRow(); ++i) {
186 LifetimePurMon_t lifetime;
187 row = LifetimePurMonTable.GetRow(i);
188 chan = row->Channel();
191 mf::LogError(
"LifetimeCalibProtoDUNE") <<
"Channel numuber in lifetime calib table is not 1. This should never be the case!";
195 row->Col(centerIdx).Get(lifetime.center);
196 row->Col(lowIdx).Get(lifetime.low);
197 row->Col(highIdx).Get(lifetime.high);
199 loaded_tv.push_back(row->VldTime());
200 loaded_center.push_back(lifetime.center);
201 loaded_low.push_back(lifetime.low);
202 loaded_high.push_back(lifetime.high);
209 LifetimePurMon_t interpolate_lifetime;
214 double temp_0 = 1e10;
215 double temp_1 = 1e10;
216 for (
size_t j=0; j<loaded_tv.size(); j++) {
230 interpolate_lifetime.center = loaded_center[t1_idx];
231 interpolate_lifetime.low = loaded_low[t1_idx];
232 interpolate_lifetime.high = loaded_high[t1_idx];
236 interpolate_lifetime.center = loaded_center[t0_idx];
237 interpolate_lifetime.low = loaded_low[t0_idx];
238 interpolate_lifetime.high = loaded_high[t0_idx];
240 if (t0_idx != -1 && t1_idx != -1) {
241 if (t0_idx == t1_idx) {
242 interpolate_lifetime.center = loaded_center[t0_idx];
243 interpolate_lifetime.low = loaded_low[t0_idx];
244 interpolate_lifetime.high = loaded_high[t0_idx];
249 interpolate_lifetime.center = ( loaded_center[t0_idx]*(loaded_tv[t1_idx]-
fCurrentTS) + loaded_center[t1_idx]*(
fCurrentTS-loaded_tv[t0_idx]) ) / (loaded_tv[t1_idx]-loaded_tv[t0_idx]);
250 interpolate_lifetime.low = ( loaded_low[t0_idx]*(loaded_tv[t1_idx]-
fCurrentTS) + loaded_low[t1_idx]*(
fCurrentTS-loaded_tv[t0_idx]) ) / (loaded_tv[t1_idx]-loaded_tv[t0_idx]);
251 interpolate_lifetime.high = ( loaded_high[t0_idx]*(loaded_tv[t1_idx]-
fCurrentTS) + loaded_high[t1_idx]*(
fCurrentTS-loaded_tv[t0_idx]) ) / (loaded_tv[t1_idx]-loaded_tv[t0_idx]);
std::map< int, LifetimePurMon_t > fLifetimePurMon
std::string fLifetimeFileName
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::string fLifetimeDBTag
cet::coded_exception< error, detail::translate > exception