95 std::string url =
URL(timestamp);
97 if (
fVerbose)
std::cout <<
"NormalizeYZ Tool -- New Scale info, requesting data from url:\n" << url << std::endl;
101 throw cet::exception(
"NormalizeYZ") <<
"Calibration Database access failed. URL: (" << url <<
") Error Code: " <<
error;
104 if (
fVerbose)
std::cout <<
"NormalizeYZ Tool -- Received HTTP response:\n" << getHTTPmessage(d) << std::endl;
106 if (getHTTPstatus(d) != 200) {
107 throw cet::exception(
"NormalizeYZ")
108 <<
"Calibration Database access failed. URL: (" << url
109 <<
"). HTTP error status: " << getHTTPstatus(d) <<
". HTTP error message: " << getHTTPmessage(d);
117 Tuple tup = getTuple(d, 0);
118 float tzero = getDoubleValue(tup, 0, &error);
120 throw cet::exception(
"NormalizeYZ")
121 <<
"Calibration Database access failed. URL: (" << url
122 <<
"). Failed on tuple access, row 0, col 0. Error Code: " <<
error;
125 if (
fVerbose)
std::cout <<
"NormalizeYZ Tool -- Obtained T0: " << tzero << std::endl;
128 bool found_scale_t0 =
false;
130 const ScaleInfo &scale = scale_pair.second;
131 if (scale.tzero == tzero) {
133 found_scale_t0 =
true;
135 if (
fVerbose)
std::cout <<
"NormalizeYZ Tool -- Found prior matching T0 from timestamp: " << scale_pair.first << std::endl;
141 if (found_scale_t0) {
142 fScaleInfos[timestamp] = thisscale;
143 return fScaleInfos.at(timestamp);
149 thisscale.tzero = tzero;
152 int n_tuple = getNtuples(d);
154 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Bad Tuple Number: " << n_tuple;
159 for (
unsigned row = 4;
row < (unsigned)n_tuple;
row++) {
165 int strl = getStringValue(tup, 1, tpcbuf, 10, &err);
168 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 1. Error Code: " <<
err;
171 std::string tpcname(tpcbuf);
172 if (tpcname ==
"EE") itpc = 0;
173 else if (tpcname ==
"EW") itpc = 1;
174 else if (tpcname ==
"WE") itpc = 2;
175 else if (tpcname ==
"WW") itpc = 3;
177 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Bad TPC name (" << tpcname <<
").";
181 double ylo = getDoubleValue(tup, 8, &err);
183 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 8. Error Code: " <<
err;
185 double yhi = getDoubleValue(tup, 9, &err);
187 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 9. Error Code: " <<
err;
189 double zlo = getDoubleValue(tup, 10, &err);
191 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 10. Error Code: " <<
err;
193 double zhi = getDoubleValue(tup, 11, &err);
195 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 11. Error Code: " <<
err;
199 double scale = getDoubleValue(tup, 4, &err);
201 throw cet::exception(
"NormalizeYZ") <<
"NormalizeYZ Tool -- Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 4. Error Code: " <<
err;
204 ScaleInfo::ScaleBin
bin;
212 thisscale.bins.push_back(bin);
216 fScaleInfos[timestamp] = thisscale;
217 return fScaleInfos.at(timestamp);
EResult err(const char *call)
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
std::map< uint64_t, ScaleInfo > fScaleInfos
std::string URL(uint64_t timestamp)
BEGIN_PROLOG could also be cout