55#include " art/Framework/Services/Registry/ServiceHandle.h"
66#include " art/Persistency/Common/PtrMaker.h"
77#include " art/Utilities/ToolMacros.h"
8+ #include " cetlib_except/exception.h"
89#include " cetlib/cpu_timer.h"
910#include " fhiclcpp/ParameterSet.h"
1011#include " messagefacility/MessageLogger/MessageLogger.h"
@@ -110,7 +111,10 @@ sbnd::calo::NormalizeDriftSQLite::RunInfo sbnd::calo::NormalizeDriftSQLite::GetR
110111double sbnd::calo::NormalizeDriftSQLite::Normalize (double dQdx, const art::Event &e,
111112 const recob::Hit &hit, const geo::Point_t &location, const geo::Vector_t &direction, double t0) {
112113
113- assert (fClockData );
114+ if (!fClockData ) {
115+ std::cout << " Error: fClockData is not valid" << std::endl;
116+ throw cet::exception (" fClockData is not valid" );
117+ }
114118
115119 // Get the info
116120 RunInfo runelifetime = GetRunInfo (e.id ().runID ().run ());
@@ -127,16 +131,20 @@ double sbnd::calo::NormalizeDriftSQLite::Normalize(double dQdx, const art::Event
127131 if (cryo == 0 && tpc == 1 ) thiselifetime = runelifetime.tau_W ;
128132
129133 // Get the hit time
130- double thit = hit.PeakTime ()/2000 . - 0.2 - t0;
134+ double thit = fClockData ->TPCTick2TrigTime (hit.PeakTime ()) - t0;
135+ thit = thit * 1 .e -3 ;
131136
132137 if (fVerbose ) std::cout << " NormalizeDriftSQLite Tool -- Norm factor: " << exp (thit / thiselifetime) << " at TPC: " << tpc << " Cryo: " << cryo << " Time: " << thit << " Track T0: " << t0 << " , x: " << location.X () << std::endl;
133138
134139 // Scale
135140 if (thiselifetime > 0 ) {
136141 dQdx = dQdx*exp (thit / thiselifetime);
137142 }
138- // TODO: what to do if no lifetime is found? throw an exception??
139- else {}
143+ // Throw exception if thiselifetime is not updated to non-zero value
144+ else {
145+ std::cout << " sbnd::calo::NormalizeDriftSQLite::Normalize electron lifetime is not found for run " << e.id ().runID ().run () << std::endl;
146+ throw cet::exception (" Electron lifetime is not found" );
147+ }
140148
141149 return dQdx;
142150}
0 commit comments