24 #include "art/Framework/Core/EDAnalyzer.h"
25 #include "art/Framework/Core/ModuleMacros.h"
26 #include "art/Framework/Principal/Event.h"
27 #include "art/Framework/Principal/Handle.h"
28 #include "art/Framework/Services/Registry/ServiceHandle.h"
29 #include "art_root_io/TFileService.h"
30 #include "canvas/Persistency/Common/Ptr.h"
31 #include "canvas/Persistency/Common/PtrVector.h"
32 #include "fhiclcpp/ParameterSet.h"
33 #include "messagefacility/MessageLogger/MessageLogger.h"
137 art::ServiceHandle<art::TFileService const>
tfs;
140 fRun = tfs->make<TH1F>(
"fRun",
"Run Number", 1000, 0, 1000);
141 fEvt = tfs->make<TH1F>(
"fEvt",
"Event Number", 1000, 0, 1000);
142 fTruthVtxXPos = tfs->make<TH1F>(
"fTruthVtxXPos",
"Truth Vertex X Position", 400, 0, 200);
143 fTruthVtxYPos = tfs->make<TH1F>(
"fTruthVtxYPos",
"Truth Vertex Y Position", 400, -100, 100);
144 fTruthVtxZPos = tfs->make<TH1F>(
"fTruthVtxZPos",
"Truth Vertex Z Position", 2000, 0, 1000);
146 tfs->make<TH1F>(
"fTruthWireNumberPlane0",
"Truth Wire Number Plane 0", 3000, 0, 3000);
148 tfs->make<TH1F>(
"fTruthTimeTickPlane0",
"Truth Time Tick Plane 0", 3200, 0, 3200);
150 tfs->make<TH1F>(
"fTruthWireNumberPlane1",
"Truth Wire Number Plane 1", 3000, 0, 3000);
152 tfs->make<TH1F>(
"fTruthTimeTickPlane1",
"Truth Time Tick Plane 1", 3200, 0, 3200);
154 tfs->make<TH1F>(
"fTruthWireNumberPlane2",
"Truth Wire Number Plane 2", 3000, 0, 3000);
156 tfs->make<TH1F>(
"fTruthTimeTickPlane2",
"Truth Time Tick Plane 2", 3200, 0, 3200);
158 tfs->make<TH1F>(
"fTruthWireInCmPlane0",
"Truth Wire In CM Plane 0", 2000, 0, 1000);
160 tfs->make<TH1F>(
"fTruthTimeInCmPlane0",
"Truth Time In Cm Plane 0", 2000, 0, 1000);
162 tfs->make<TH1F>(
"fTruthWireInCmPlane1",
"Truth Wire In CM Plane 1", 2000, 0, 1000);
164 tfs->make<TH1F>(
"fTruthTimeInCmPlane1",
"Truth Time In Cm Plane 1", 2000, 0, 1000);
166 tfs->make<TH1F>(
"fTruthWireInCmPlane2",
"Truth Wire In CM Plane 2", 2000, 0, 1000);
168 tfs->make<TH1F>(
"fTruthTimeInCmPlane2",
"Truth Time In Cm Plane 2", 2000, 0, 1000);
171 tfs->make<TH1F>(
"fTwoDNVtxPlane0",
"TwoD Number of Verticies Found in Plane 0", 400, 0, 200);
173 tfs->make<TH1F>(
"fTwoDNVtxPlane1",
"TwoD Number of Verticies Found in Plane 1", 400, 0, 200);
175 tfs->make<TH1F>(
"fTwoDNVtxPlane2",
"TwoD Number of Verticies Found in Plane 2", 400, 0, 200);
178 tfs->make<TH1F>(
"fTwoDWireNumberPlane0",
"TwoD Wire Number Plane 0", 3000, 0, 3000);
180 tfs->make<TH1F>(
"fTwoDTimeTickPlane0",
"TwoD Time Tick Plane 0", 3200, 0, 3200);
182 tfs->make<TH1F>(
"fTwoDWireNumberPlane1",
"TwoD Wire Number Plane 1", 3000, 0, 3000);
184 tfs->make<TH1F>(
"fTwoDTimeTickPlane1",
"TwoD Time Tick Plane 1", 3200, 0, 3200);
186 tfs->make<TH1F>(
"fTwoDWireNumberPlane2",
"TwoD Wire Number Plane 2", 3000, 0, 3000);
188 tfs->make<TH1F>(
"fTwoDTimeTickPlane2",
"TwoD Time Tick Plane 2", 3200, 0, 3200);
190 tfs->make<TH1F>(
"fTwoDWireInCmPlane0",
"TwoD Wire In CM Plane 0", 2000, 0, 1000);
192 tfs->make<TH1F>(
"fTwoDTimeInCmPlane0",
"TwoD Time In Cm Plane 0", 2000, 0, 1000);
194 tfs->make<TH1F>(
"fTwoDWireInCmPlane1",
"TwoD Wire In CM Plane 1", 2000, 0, 1000);
196 tfs->make<TH1F>(
"fTwoDTimeInCmPlane1",
"TwoD Time In Cm Plane 1", 2000, 0, 1000);
198 tfs->make<TH1F>(
"fTwoDWireInCmPlane2",
"TwoD Wire In CM Plane 2", 2000, 0, 1000);
200 tfs->make<TH1F>(
"fTwoDTimeInCmPlane2",
"TwoD Time In Cm Plane 2", 2000, 0, 1000);
203 tfs->make<TH1F>(
"fTwoDStrengthPlane0",
"TwoD Strength Plane 0", 1000, 0, 500);
205 tfs->make<TH1F>(
"fTwoDStrengthPlane1",
"TwoD Strength Plane 1", 1000, 0, 500);
207 tfs->make<TH1F>(
"fTwoDStrengthPlane2",
"TwoD Strength Plane 2", 1000, 0, 500);
210 "fRecoCheck2dWireNumPlane0",
"Reco Wire Number - True Wire Number Plane 0", 400, -200, 200);
212 "fRecoCheck2dTimeTickPlane0",
"Reco Time Tick - True Time Tick Plane 0", 1000, -500, 500);
214 "fRecoCheck2dWireInCmPlane0",
"Reco Wire in CM - True Wire in CM Plane 0", 200, -50, 50);
216 "fRecoCheck2dTimeInCmPlane0",
"Reco Time in CM - True Time in CM Plane 0", 200, -50, 50);
219 "fRecoCheck2dWireNumPlane1",
"Reco Wire Number - True Wire Number Plane 1", 400, -200, 200);
221 "fRecoCheck2dTimeTickPlane1",
"Reco Time Tick - True Time Tick Plane 1", 1000, -500, 500);
223 "fRecoCheck2dWireInCmPlane1",
"Reco Wire in CM - True Wire in CM Plane 1", 200, -50, 50);
225 "fRecoCheck2dTimeInCmPlane1",
"Reco Time in CM - True Time in CM Plane 1", 200, -50, 50);
228 "fRecoCheck2dWireNumPlane2",
"Reco Wire Number - True Wire Number Plane 2", 400, -200, 200);
230 "fRecoCheck2dTimeTickPlane2",
"Reco Time Tick - True Time Tick Plane 2", 1000, -500, 500);
232 "fRecoCheck2dWireInCmPlane2",
"Reco Wire in CM - True Wire in CM Plane 2", 200, -50, 50);
234 "fRecoCheck2dTimeInCmPlane2",
"Reco Time in CM - True Time in CM Plane 2", 200, -50, 50);
236 fRecoVtxN3d = tfs->make<TH1F>(
"fRecoVtxN3d",
"Number of 3d-Reco Verticies", 400, 0, 200);
237 fRecoVtxXPos = tfs->make<TH1F>(
"fRecoVtxXPos",
"Reco Vertex X Position", 400, -10, 200);
238 fRecoVtxYPos = tfs->make<TH1F>(
"fRecoVtxYPos",
"Reco Vertex Y Position", 400, -100, 100);
239 fRecoVtxZPos = tfs->make<TH1F>(
"fRecoVtxZPos",
"Reco Vertex Z Position", 2000, -10, 1000);
242 tfs->make<TH1F>(
"fRecoCheck3dVtxX",
"Reco X Position - True X Postion", 800, -100, 100);
244 tfs->make<TH1F>(
"fRecoCheck3dVtxY",
"Reco Y Position - True Y Postion", 800, -100, 100);
246 tfs->make<TH1F>(
"fRecoCheck3dVtxZ",
"Reco Z Position - True Z Postion", 800, -100, 100);
249 "fRecoCheck3dVtxXvsX",
"(Reco X - True X)/True X vs True X", 400, -10, 200, 120, -20, 20);
251 "fRecoCheck3dVtxYvsY",
"(Reco Y - True Y)/True Y vs True Y", 400, -100, 100, 120, -20, 20);
253 "fRecoCheck3dVtxZvsZ",
"(Reco Z - True Z)/True Z vs True Z", 1000, -10, 1000, 120, -20, 20);
260 fRun->Fill(evt.run());
261 fEvt->Fill(evt.id().event());
264 art::Handle<std::vector<simb::MCParticle>> mcParticleHandle;
268 art::Handle<std::vector<simb::MCTruth>> mctruthListHandle;
272 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
274 art::ServiceHandle<geo::Geometry const> geom;
275 auto const clock_data =
276 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
277 auto const det_prop =
278 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
281 art::Handle<std::vector<recob::EndPoint2D>> vertex2dHandle;
285 art::Handle<std::vector<recob::Vertex>> vertex3dListHandle;
289 std::vector<double> WirePitch_CurrentPlane(geom->Views().size(),
294 for (
auto v : geom->Views()) {
295 WirePitch_CurrentPlane[vn] = geom->WirePitch(v);
302 float DriftVelocity = det_prop.DriftVelocity(det_prop.Efield(), det_prop.Temperature());
303 float TimetoCm = TimeTick * DriftVelocity;
308 art::PtrVector<simb::MCTruth> mclist;
309 for (
unsigned int ii = 0; ii < mctruthListHandle->size(); ++ii) {
310 art::Ptr<simb::MCTruth> mctparticle(mctruthListHandle, ii);
311 mclist.push_back(mctparticle);
315 float truth_vertex[5] = {0.};
317 uint32_t VtxWireNum[3] = {0};
318 double VtxTimeTick[3] = {0.};
320 double VtxWireNum_InCM[3] = {0.};
321 double VtxTimeTick_InCM[3] = {0.};
324 for (
unsigned int i = 0; i < mclist.size(); ++i) {
325 art::Ptr<simb::MCTruth> mc(mclist[i]);
326 simb::MCParticle neut(mc->GetParticle(i));
329 truth_vertex[0] = neut.Vx();
330 truth_vertex[1] = neut.Vy();
331 truth_vertex[2] = neut.Vz();
341 for (
auto const& pid : geom->IteratePlaneIDs()) {
344 VtxWireNum[pid.Plane] = geom->NearestWire(truth_vertex, pid.Plane, pid.TPC, pid.Cryostat);
347 mf::LogWarning(
"FeatureVertexFinderAna") <<
"Can't find nearest wire";
350 VtxTimeTick[pid.Plane] =
351 det_prop.ConvertXToTicks(truth_vertex[0], pid.Plane, pid.TPC, pid.Cryostat) +
352 det_prop.GetXTicksOffset(pid.Plane, pid.TPC, pid.Cryostat);
355 VtxWireNum_InCM[pid.Plane] = VtxWireNum[pid.Plane] * WirePitch_CurrentPlane[pid.Plane];
356 VtxTimeTick_InCM[pid.Plane] = VtxTimeTick[pid.Plane] * TimetoCm;
376 art::PtrVector<recob::EndPoint2D> vert2d;
379 double Vertex2d_TimeTick[10000] = {
381 double Vertex2d_Wire[10000] = {0.};
383 double Vertex2d_TimeTick_InCM[10000] = {0.};
384 double Vertex2d_Wire_InCM[10000] = {0.};
387 int n2dVtxPlane0 = 0, n2dVtxPlane1 = 0, n2dVtxPlane2 = 0;
389 bool vertexWstrengthplane0 =
false,
390 vertexWstrengthplane1 =
394 for (
size_t ii = 0; ii < vertex2dHandle->size(); ++ii) {
395 art::Ptr<recob::EndPoint2D>
vertex(vertex2dHandle, ii);
396 vert2d.push_back(vertex);
400 if (vert2d.size() > 0) {
403 for (
auto const& pid : geom->IteratePlaneIDs()) {
404 for (
size_t ww = 0; ww < vert2d.size(); ++ww) {
406 if (vert2d[ww]->
WireID().planeID() != pid) {
continue; }
408 Vertex2d_TimeTick[n2dVtx] = vert2d[ww]->DriftTime();
409 Vertex2d_Wire[n2dVtx] = vert2d[ww]->WireID().Wire;
412 Vertex2d_Wire_InCM[n2dVtx] = Vertex2d_Wire[n2dVtx] * WirePitch_CurrentPlane[pid.Plane];
413 Vertex2d_TimeTick_InCM[n2dVtx] = Vertex2d_TimeTick[n2dVtx] * TimetoCm;
417 float RecoCheck_TimeTick = Vertex2d_TimeTick[n2dVtx] - VtxTimeTick[pid.Plane];
418 float RecoCheck_WireNum = Vertex2d_Wire[n2dVtx] - VtxWireNum[pid.Plane];
420 float RecoCheck_TimeInCm = Vertex2d_TimeTick_InCM[n2dVtx] - VtxTimeTick_InCM[pid.Plane];
421 float RecoCheck_WireInCm = Vertex2d_Wire_InCM[n2dVtx] - VtxWireNum_InCM[pid.Plane];
423 if (vert2d[ww]->Strength() > -1) {
424 if (pid.Plane == 0) {
425 vertexWstrengthplane0 =
true;
443 if (pid.Plane == 1) {
444 vertexWstrengthplane1 =
true;
461 if (pid.Plane == 2) {
491 art::PtrVector<recob::Vertex> Vertexlist;
493 double xyz[3] = {0.};
495 for (
unsigned int ii = 0; ii < vertex3dListHandle->size(); ++ii) {
496 art::Ptr<recob::Vertex> vertex3d(vertex3dListHandle, ii);
497 Vertexlist.push_back(vertex3d);
501 if (Vertexlist.size() > 0 && vertexWstrengthplane0 && vertexWstrengthplane1) {
504 for (
unsigned int ww = 0; ww < Vertexlist.size(); ww++) {
505 Vertexlist[ww]->XYZ(xyz);
510 double DeltaX = xyz[0] - truth_vertex[0];
511 double DeltaY = xyz[1] - truth_vertex[1];
512 double DeltaZ = xyz[2] - truth_vertex[2];
514 double DeltaXoverTrueX = DeltaX / truth_vertex[0];
515 double DeltaYoverTrueY = DeltaY / truth_vertex[0];
516 double DeltaZoverTrueZ = DeltaZ / truth_vertex[0];
TH1F * fTwoDTimeInCmPlane2
TH2D * fRecoCheck3dVtxXvsX
TH1F * fTwoDTimeTickPlane2
std::string fEndPoint2dModuleLabel
TH1F * fTwoDTimeInCmPlane0
TH1F * fTwoDTimeInCmPlane1
TH1F * fTruthTimeInCmPlane0
TH1F * fTwoDWireNumberPlane1
TH1F * fTruthWireNumberPlane0
TH1F * fTruthTimeTickPlane2
std::string fVertexModuleLabel
TH1F * fTwoDWireNumberPlane2
TH1F * fRecoCheck2dWireNumPlane1
TH1F * fTruthWireInCmPlane2
void analyze(const art::Event &evt) override
TH1F * fTruthWireInCmPlane1
TH1F * fRecoCheck2dTimeInCmPlane2
TH1F * fTwoDStrengthPlane2
TH1F * fTruthTimeInCmPlane1
TH1F * fRecoCheck2dTimeInCmPlane1
TH1F * fRecoCheck2dTimeTickPlane2
std::string fGenieModuleLabel
TH1F * fRecoCheck2dTimeTickPlane0
std::string fLArG4ModuleLabel
TH2D * fRecoCheck3dVtxZvsZ
FeatureVertexFinderAna(fhicl::ParameterSet const &pset)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
TH1F * fRecoCheck2dWireInCmPlane2
TH1F * fTwoDStrengthPlane0
TH1F * fTwoDStrengthPlane1
TH1F * fTwoDTimeTickPlane0
TH1F * fTwoDTimeTickPlane1
TH1F * fTruthTimeTickPlane0
TH1F * fRecoCheck2dWireNumPlane2
TH1F * fTruthWireNumberPlane2
TH1F * fRecoCheck2dTimeInCmPlane0
TH1F * fRecoCheck2dWireNumPlane0
TH1F * fTruthTimeTickPlane1
TH1F * fRecoCheck2dWireInCmPlane1
TH1F * fRecoCheck2dTimeTickPlane1
TH1F * fTwoDWireInCmPlane1
TH2D * fRecoCheck3dVtxYvsY
TH1F * fRecoCheck2dWireInCmPlane0
TH1F * fTwoDWireInCmPlane0
art::ServiceHandle< art::TFileService > tfs
TH1F * fTruthWireInCmPlane0
TH1F * fTruthWireNumberPlane1
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
TH1F * fTwoDWireInCmPlane2
art framework interface to geometry description
TH1F * fTruthTimeInCmPlane2
TH1F * fTwoDWireNumberPlane0