14 #include "art/Framework/Core/EDAnalyzer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 #include "art_root_io/TFileService.h"
20 #include "canvas/Persistency/Common/Ptr.h"
21 #include "fhiclcpp/ParameterSet.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
37 #include "nug4/MagneticFieldServices/MagneticFieldService.h"
45 explicit MagDriftAna(fhicl::ParameterSet
const& pset);
90 , fFFTHitFinderModuleLabel{pset.get<std::string>(
"HitsModuleLabel")}
101 art::ServiceHandle<art::TFileService const>
tfs;
105 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
108 art::ServiceHandle<mag::MagneticFieldService const> MagFieldHandle;
109 auto const* MagField = MagFieldHandle->provider();
111 double Temperature =
detProp.Temperature();
112 double DriftVelocity =
detProp.DriftVelocity(Efield, Temperature) / 1000.;
117 fDirCosY = -DriftVelocity * MagField->FieldAtPoint().z() /
Efield;
118 fDirCosZ = +DriftVelocity * MagField->FieldAtPoint().y() /
Efield;
119 MF_LOG_VERBATIM(
"MagDriftAna") <<
"Drift ratios: "
124 art::ServiceHandle<geo::Geometry const> geom;
126 double width = 2 * geom->TPC(0).HalfWidth();
127 double halfHeight = geom->TPC(0).HalfHeight();
128 double length = geom->TPC(0).Length();
130 double zScale = std::max(fDirCosZ / 2.0, 4
e-4);
134 tfs->make<TH1D>(
"hChargeXpos",
"MC X charge depositions; X (cm); Events", 101, 0.0, width);
136 "hChargeYpos",
"MC Y charge depositions; Y (cm); Events", 101, -halfHeight, halfHeight);
138 tfs->make<TH1D>(
"hChargeZpos",
"MC Z charge depositions; Z (cm); Events", 101, 0.0, length);
139 fHitZpos = tfs->make<TH1D>(
"hHitZpos",
"Z charge collection; Z (cm); Events", 101, 0.0, length);
142 "Z drift of charge; delta Z (cm); Events",
147 "hDeltaZoverX",
"Z drift of charge; delta Z/X; Events", 51, -10 * zScale, 10 * zScale);
149 "delta Z vs X; X (cm); delta Z (cm), Events",
159 "Z drift of charge (long drift); delta Z (cm); Events",
164 "Z drift of charge (long drift); delta Z/X; Events",
177 l->SetLineColor(kRed);
178 l->SetLineStyle(kDotted);
186 l->SetLineColor(kRed);
187 l->SetLineStyle(kDotted);
195 if (evt.isRealData()) {
196 throw cet::exception(
"MagDriftAna: ") <<
"Not for use on Data yet...\n";
199 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
203 art::Handle<std::vector<recob::Hit>> hitHandle;
206 art::ServiceHandle<geo::Geometry const> geom;
211 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
213 std::vector<art::Ptr<recob::Hit>> hits;
214 art::fill_ptr_vector(hits, hitHandle);
221 for (
auto itr : hits) {
223 hitWireID = itr->
WireID();
226 if (hitWireID.
Plane != (geom->Nplanes() - 1))
continue;
231 double w0pos[3] = {0.};
232 geom->TPC(hitWireID.
TPC).Plane(hitWireID.
Plane).Wire(0).GetCenter(w0pos);
233 double HitZpos = w0pos[2] + hitWireID.
Wire * geom->TPC(hitWireID.
TPC).WirePitch();
234 double Charge = itr->Integral();
238 std::vector<double> xyz = bt_serv->HitToXYZ(clockData, itr);
241 double ChargeZpos = xyz[2];
248 double DeltaZ = HitZpos - ChargeZpos;
255 if (xyz[0] > (
fChargeYpos->GetXaxis()->GetXmax() * 0.80)) {
void analyze(const art::Event &evt) override
Declaration of signal hit object.
std::string fLArG4ModuleLabel
std::string fFFTHitFinderModuleLabel
WireID_t Wire
Index of the wire within its plane.
Base class for creation of raw signals on wires.
PlaneID_t Plane
Index of the plane within its TPC.
MagDriftAna(fhicl::ParameterSet const &pset)
Encapsulate the geometry of a wire.
void ensureHists(art::Event const &evt, detinfo::DetectorClocksData const &clockData)
Encapsulate the construction of a single detector plane.
Contains all timing reference information for the detector.
constexpr WireID()=default
Default constructor: an invalid TPC ID.
art::ServiceHandle< art::TFileService > tfs
TPCID_t TPC
Index of the TPC within its cryostat.
art framework interface to geometry description
Encapsulate the construction of a single detector plane.