31 #include "art/Framework/Core/EDAnalyzer.h"
32 #include "art/Framework/Core/ModuleMacros.h"
33 #include "art/Framework/Principal/Event.h"
34 #include "art/Framework/Principal/Handle.h"
35 #include "art/Framework/Services/Registry/ServiceHandle.h"
36 #include "art_root_io/TFileService.h"
37 #include "canvas/Persistency/Common/Ptr.h"
38 #include "fhiclcpp/ParameterSet.h"
39 #include "messagefacility/MessageLogger/MessageLogger.h"
105 art::ServiceHandle<art::TFileService const>
tfs;
106 fHitResidualAll = tfs->make<TH1F>(
"fHitResidualAll",
"Hit Residual All", 1600, -400, 400);
107 fHitResidualAllAlt = tfs->make<TH1F>(
"fHitResidualAllAlt",
"Hit Residual All", 1600, -400, 400);
109 tfs->make<TH1F>(
"fNumberOfHitsPerEvent",
"Number of Hits in Each Event", 10000, 0, 10000);
111 tfs->make<TH2F>(
"fPeakTimeVsWire",
"Peak Time vs Wire Number", 3200, 0, 3200, 9500, 0, 9500);
113 fHTree = tfs->make<TTree>(
"HTree",
"HTree");
114 fHTree->Branch(
"Evt", &
fEvt,
"Evt/I");
115 fHTree->Branch(
"Run", &
fRun,
"Run/I");
119 fHTree->Branch(
"nHits", &
fnHits,
"nHits/I");
120 fHTree->Branch(
"Wire", &
fWire,
"Wire[nHits]/I");
121 fHTree->Branch(
"StartTime", &
fStartTime,
"fStartTime[nHits]/F");
122 fHTree->Branch(
"EndTime", &
fEndTime,
"fEndTime[nHits]/F");
123 fHTree->Branch(
"PeakTime", &
fPeakTime,
"fPeakTime[nHits]/F");
124 fHTree->Branch(
"PeakTimeUncert", &
fPeakTimeUncert,
"fPeakTimeUncert[nHits]/F");
125 fHTree->Branch(
"Charge", &
fCharge,
"fCharge[nHits]/F");
126 fHTree->Branch(
"ChargeUncert", &
fChargeUncert,
"fChargeUncert[nHits]/F");
127 fHTree->Branch(
"Multiplicity", &
fMultiplicity,
"fMultiplicity[nHits]/I");
128 fHTree->Branch(
"GOF", &
fGOF,
"fGOF[nHits]/F");
134 fHTree->Branch(
"TruePeakPos", &
fTruePeakPos,
"fTruePeakPos[nHits]/F");
142 fEvt = evt.id().event();
145 art::ServiceHandle<geo::Geometry const> geom;
146 auto const clock_data =
147 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
148 auto const det_prop =
149 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
151 art::Handle<std::vector<recob::Wire>> wireVecHandle;
155 float TotWireCharge = 0;
157 for (
size_t wireIter = 0; wireIter < wireVecHandle->size(); wireIter++) {
158 art::Ptr<recob::Wire> wire(wireVecHandle, wireIter);
159 std::vector<float> signal(wire->Signal());
161 for (
auto timeIter = signal.begin(); timeIter + 2 < signal.end(); timeIter++) {
163 if (*timeIter < 2) {
continue; }
165 TotWireCharge += *timeIter;
172 art::Handle<std::vector<recob::Hit>> hitHandle;
175 std::vector<art::Ptr<recob::Hit>> hits;
176 art::fill_ptr_vector(hits, hitHandle);
180 fnHits = hitHandle->size();
183 for (
size_t numHit = 0; numHit < hitHandle->size(); ++numHit) {
185 art::Ptr<recob::Hit>
hit(hitHandle, numHit);
187 fWire[hitCount] = hit->WireID().Wire;
188 fStartTime[hitCount] = hit->PeakTimeMinusRMS();
189 fEndTime[hitCount] = hit->PeakTimePlusRMS();
192 fCharge[hitCount] = hit->Integral();
195 fGOF[hitCount] = hit->GoodnessOfFit();
198 TotCharge += hit->Integral();
206 unsigned int plane = 0;
207 Float_t TruthHitTime = 0, TruthHitCalculated = 0;
211 double drift_velocity = det_prop.DriftVelocity(det_prop.Efield(), det_prop.Temperature());
213 for (
size_t nh = 0; nh < hitHandle->size(); nh++) {
215 art::Ptr<recob::Hit> hitPoint(hitHandle, nh);
216 plane = hitPoint->WireID().Plane;
221 std::vector<sim::TrackIDE> trackides;
222 std::vector<double> xyz;
224 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
225 trackides = bt_serv->HitToTrackIDEs(clock_data, hitPoint);
226 xyz = bt_serv->HitToXYZ(clock_data, hitPoint);
228 catch (cet::exception
const&) {
229 mf::LogWarning(
"GausHitFinderAna") <<
"BackTrackerService Failed";
240 TruthHitTime = det_prop.ConvertXToTicks(
241 xyz[0], plane, hitPoint->WireID().TPC, hitPoint->WireID().Cryostat);
247 const double origin[3] = {0.};
249 geom->Plane(plane).LocalToWorld(origin, pos);
250 double planePos_timeCorr = (pos[0] / drift_velocity) * (1. / time_tick) + 60;
253 TruthHitCalculated = ((xyz[0]) / (drift_velocity * time_tick)) + planePos_timeCorr;
257 double hitresid = ((TruthHitTime - hitPoint->PeakTime()) / hitPoint->SigmaPeakTime());
261 ((TruthHitCalculated - hitPoint->PeakTime()) / hitPoint->SigmaPeakTime());
Float_t fPeakTime[kMaxHits]
Declaration of signal hit object.
std::string fLArG4ModuleLabel
Int_t fMultiplicity[kMaxHits]
Float_t fPeakTimeUncert[kMaxHits]
TH1F * fHitResidualAllAlt
std::string fCalDataModuleLabel
Float_t fCharge[kMaxHits]
GausHitFinderAna(fhicl::ParameterSet const &pset)
TH1F * fNumberOfHitsPerEvent
Float_t fTotalHitChargePerEvent
Float_t fEndTime[kMaxHits]
Encapsulate the construction of a single detector plane.
Declaration of basic channel signal object.
Base class for creation of raw signals on wires.
std::string fHitFinderModuleLabel
art::ServiceHandle< art::TFileService > tfs
Float_t fTruePeakPos[kMaxHits]
std::size_t count(Cont const &cont)
Float_t fStartTime[kMaxHits]
Float_t fChargeUncert[kMaxHits]
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
void analyze(const art::Event &evt) override
art framework interface to geometry description
constexpr Point origin()
Returns a origin position with a point of the specified type.