2 #include "art/Framework/Core/EDProducer.h"
3 #include "art/Framework/Principal/Event.h"
4 #include "art/Framework/Principal/Handle.h"
5 #include "art/Framework/Services/Registry/ServiceHandle.h"
6 #include "art/Persistency/Common/PtrMaker.h"
7 #include "art/Utilities/ToolMacros.h"
8 #include "cetlib/cpu_timer.h"
9 #include "fhiclcpp/ParameterSet.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
32 void configure(
const fhicl::ParameterSet& pset)
override;
44 std::map<unsigned, double>
scale;
49 std::string
URL(uint64_t timestamp);
66 fURL = pset.get<std::string>(
"URL");
67 fTimeout = pset.get<
unsigned>(
"Timeout");
68 fVerbose = pset.get<
bool>(
"Verbose",
false);
77 if (fScaleInfos.count(timestamp)) {
78 return fScaleInfos.at(timestamp);
83 std::string url = URL(timestamp);
85 if (fVerbose)
std::cout <<
"NormalizeTPC Tool -- New Scale info, requesting data from url:\n" << url << std::endl;
87 Dataset d = getDataWithTimeout(url.c_str(),
"", fTimeout, &
error);
89 throw cet::exception(
"NormalizeTPC") <<
"Calibration Database access failed. URL: (" << url <<
") Error Code: " <<
error;
92 if (fVerbose)
std::cout <<
"NormalizeTPC Tool -- Received HTTP response:\n" << getHTTPmessage(d) << std::endl;
94 if (getHTTPstatus(d) != 200) {
95 throw cet::exception(
"NormalizeTPC")
96 <<
"Calibration Database access failed. URL: (" << url
97 <<
"). HTTP error status: " << getHTTPstatus(d) <<
". HTTP error message: " << getHTTPmessage(d);
104 int n_tuple = getNtuples(d);
106 throw cet::exception(
"NormalizeTPC") <<
"Calibration Database access failed. URL: (" << url <<
") Bad Tuple Number: " << n_tuple;
111 for (
unsigned row = 4;
row < (unsigned)n_tuple;
row++) {
116 int ch = getLongValue(tup, 0, &err);
118 throw cet::exception(
"NormalizeTPC") <<
"Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 0. Error Code: " <<
error;
122 double scale = getDoubleValue(tup, 2, &err);
124 throw cet::exception(
"NormalizeTPC") <<
"Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 1. Error Code: " <<
error;
127 thisscale.
scale[ch] = scale;
131 fScaleInfos[timestamp] = thisscale;
139 ScaleInfo i = GetScaleInfo(e.time().timeHigh());
145 unsigned itpc = 2*cryo + tpc/2;
150 if (i.
scale.count(itpc)) scale = i.
scale.at(itpc);
152 if (fVerbose)
std::cout <<
"NormalizeTPC Tool -- Data at itpc: " << itpc <<
" scale: " << scale << std::endl;
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::map< uint64_t, ScaleInfo > fScaleInfos
geo::WireID WireID() const
EResult err(const char *call)
double Normalize(double dQdx, const art::Event &e, const recob::Hit &h, const geo::Point_t &location, const geo::Vector_t &direction, double t0) override
NormalizeTPC(fhicl::ParameterSet const &pset)
CryostatID_t Cryostat
Index of cryostat.
INormalizeCharge interface class definiton.
process_name can override from command line with o or output calo
ScaleInfo GetScaleInfo(uint64_t timestamp)
std::string to_string(WindowPattern const &pattern)
2D representation of charge deposited in the TDC/wire plane
void configure(const fhicl::ParameterSet &pset) override
TPCID_t TPC
Index of the TPC within its cryostat.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::string URL(uint64_t timestamp)
std::map< unsigned, double > scale
BEGIN_PROLOG could also be cout
This is an interface for an art Tool which scales charge by some factor given information about its a...