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;
52 std::string
URL(uint32_t run);
69 fURL = pset.get<std::string>(
"URL");
70 fTimeout = pset.get<
unsigned>(
"Timeout");
71 fVerbose = pset.get<
bool>(
"Verbose",
false);
80 if (fRunInfos.count(run)) {
81 return fRunInfos.at(run);
86 std::string url = URL(run);
88 if (fVerbose)
std::cout <<
"NormalizeDrift Tool -- New Run info, requesting data from url:\n" << url << std::endl;
90 Dataset d = getDataWithTimeout(url.c_str(),
"", fTimeout, &
error);
93 throw cet::exception(
"NormalizeDrift") <<
"Calibration Database access failed. URL: (" << url <<
") Error Code: " <<
error;
96 if (fVerbose)
std::cout <<
"NormalizeDrift Tool -- Received HTTP response:\n" << getHTTPmessage(d) << std::endl;
98 if (getHTTPstatus(d) != 200) {
99 throw cet::exception(
"NormalizeDrift")
100 <<
"Calibration Database access failed. URL: (" << url
101 <<
"). HTTP error status: " << getHTTPstatus(d) <<
". HTTP error message: " << getHTTPmessage(d);
106 std::vector<bool> tpc_set(4,
false);
117 int ch = getLongValue(tup, 0, &err);
119 throw cet::exception(
"NormalizeDrift") <<
"Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 0. Error Code: " <<
error;
123 double tau = getDoubleValue(tup, 1, &err);
125 throw cet::exception(
"NormalizeDrift") <<
"Calibration Database access failed. URL: (" << url <<
") Failed on tuple access, row: " <<
row <<
", col 1. Error Code: " <<
error;
129 if (ch < 0 || ch > 3) {
130 throw cet::exception(
"NormalizeDrift") <<
"Calibration Database access failed. URL: (" << url <<
") Bad channel number: " << ch;
133 tpc_set.at(ch) =
true;
136 if (ch == 0) thisrun.
tau_EE = tau;
137 if (ch == 1) thisrun.
tau_EW = tau;
138 if (ch == 2) thisrun.
tau_WE = tau;
139 if (ch == 3) thisrun.
tau_WW = tau;
142 if (fVerbose)
std::cout <<
"NormalizeDrift Tool -- Lifetime Data:" <<
"\nTPC EE: " << thisrun.
tau_EE <<
"\nTPC EW: " << thisrun.
tau_EW <<
"\nTPC WE: " << thisrun.
tau_WE <<
"\nTPC WW: " << thisrun.
tau_WW << std::endl;
145 for (
unsigned tpc = 0; tpc < 4; tpc++) {
147 throw cet::exception(
"NormalizeDrift") <<
"Calibration Database access failed. URL: (" << url <<
") TPC not set: " << tpc;
152 fRunInfos[run] = thisrun;
160 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
163 RunInfo runelifetime = GetRunInfo(e.id().runID().run());
166 double thiselifetime = -1;
171 if (cryo == 0 && (tpc == 0 || tpc == 1)) thiselifetime = runelifetime.
tau_EE;
173 if (cryo == 0 && (tpc == 2 || tpc == 3)) thiselifetime = runelifetime.
tau_EW;
175 if (cryo == 1 && (tpc == 0 || tpc == 1)) thiselifetime = runelifetime.
tau_WE;
177 if (cryo == 1 && (tpc == 2 || tpc == 3)) thiselifetime = runelifetime.
tau_WW;
180 double thit = clock_data.TPCTick2TrigTime(hit.
PeakTime()) - t0;
182 if (fVerbose)
std::cout <<
"NormalizeDrift Tool -- Norm factor: " <<
exp(thit / thiselifetime) <<
" at TPC: " << tpc <<
" Cryo: " << cryo <<
" Time: " << thit <<
" Track T0: " << t0 << std::endl;
185 if (thiselifetime > 0) {
186 dQdx = dQdx*
exp(thit / thiselifetime);
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
geo::WireID WireID() const
EResult err(const char *call)
RunInfo GetRunInfo(uint32_t run)
CryostatID_t Cryostat
Index of cryostat.
INormalizeCharge interface class definiton.
process_name can override from command line with o or output calo
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
std::string URL(uint32_t run)
std::map< uint32_t, RunInfo > fRunInfos
float PeakTime() const
Time of the signal peak, in tick units.
std::string to_string(WindowPattern const &pattern)
void configure(const fhicl::ParameterSet &pset) override
2D representation of charge deposited in the TDC/wire plane
TPCID_t TPC
Index of the TPC within its cryostat.
NormalizeDrift(fhicl::ParameterSet const &pset)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
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...