LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
FeatureVertexFinderAna_module.cc
Go to the documentation of this file.
1 #ifndef FEATUREVERTEXFINDERANA_H
2 #define FEATUREVERTEXFINDERANA_H
3 //
5 // FeatureVertexFinder designed to analyze 2d & 3d verticies found in the TPC
6 //
7 // jaasaadi@syr.edu
8 //
9 // Note: This ana module will utilize MC truth information for verticies and is not (yet)
10 // intended as a unit test for data...though many of the same methods will likely be used
11 // for real data (when the time comes)
13 
14 // ########################
15 // ### LArSoft Includes ###
16 // ########################
31 
32 // ##########################
33 // ### Basic C++ Includes ###
34 // ##########################
35 #include <vector>
36 #include <string>
37 #include <iostream>
38 #include <iomanip>
39 #include <ios>
40 #include <sstream>
41 #include <fstream>
42 #include <math.h>
43 #include <algorithm>
44 #include <vector>
45 
46 // ##########################
47 // ### Framework Includes ###
48 // ##########################
52 #include "fhiclcpp/ParameterSet.h"
60 
61 // #####################
62 // ### ROOT Includes ###
63 // #####################
64 #include "TMath.h"
65 #include "TH1D.h"
66 #include "TH2D.h"
67 #include "TVectorD.h"
68 #include "TGeoManager.h"
69 #include "TMath.h"
70 #include "TGraph.h"
71 #include "TF1.h"
72 #include "TVector3.h"
73 
74 // ====================================================================================
75 // ====================================================================================
76 
77 namespace vertex{
78 
79 // Base class for creation of verticies
81 
82 
83 public:
84  explicit FeatureVertexFinderAna(fhicl::ParameterSet const& pset);
85  virtual ~FeatureVertexFinderAna();
86 
87  // providing read write access to the event
88  void analyze (const art::Event& evt);
89  void beginJob();
90  void reconfigure(fhicl::ParameterSet const& p);
91 
92 private:
93  std::string fLArG4ModuleLabel; //<---LArG4 Module Label
94  std::string fGenieModuleLabel; //<---Genie Module Label
95  std::string fVertexModuleLabel; //<---Vertex Module Label
96  std::string fEndPoint2dModuleLabel; //<---2d Vertex Module Label (EndPoint2d)
97 
98 
99  // Outputting histograms for analysis
100 
101  TH1F* fRun;
102  TH1F* fEvt;
118 
122 
135 
139 
144 
149 
154 
155  TH1F* fRecoVtxN3d;
159 
163 
167 
168 }; // End class VertexFinderAna
169 // ====================================================================================
170 // ====================================================================================
171 
172 
173 //------------------------------------------------------------------
175  : EDAnalyzer(pset)
176 {
177  this->reconfigure(pset);
178 }
179 
180 //------------------------------------------------------------------
182 {
183 }
184 
185 
186 //------------------------------------------------------------------
188 {
189  fLArG4ModuleLabel = p.get< std::string >("LArGeantModuleLabel");
190  fGenieModuleLabel = p.get< std::string >("GenieModuleLabel");
191  fVertexModuleLabel = p.get< std::string >("VertexModuleLabel");
192  fEndPoint2dModuleLabel = p.get< std::string >("EndPoint2dModuleLabel");
193  return;
194 }
195 
196 //-------------------------------------------------
198 {
199  // get access to the TFile service
201  // ====================================
202  // ==== Outputting TH1F Histograms ====
203  // ====================================
204  fRun = tfs->make<TH1F>("fRun", "Run Number", 1000, 0, 1000);
205  fEvt = tfs->make<TH1F>("fEvt", "Event Number", 1000, 0, 1000);
206  fTruthVtxXPos = tfs->make<TH1F>("fTruthVtxXPos", "Truth Vertex X Position", 400, 0, 200);
207  fTruthVtxYPos = tfs->make<TH1F>("fTruthVtxYPos", "Truth Vertex Y Position", 400, -100, 100);
208  fTruthVtxZPos = tfs->make<TH1F>("fTruthVtxZPos", "Truth Vertex Z Position", 2000, 0, 1000);
209  fTruthWireNumberPlane0 = tfs->make<TH1F>("fTruthWireNumberPlane0", "Truth Wire Number Plane 0", 3000, 0, 3000);
210  fTruthTimeTickPlane0 = tfs->make<TH1F>("fTruthTimeTickPlane0", "Truth Time Tick Plane 0", 3200, 0, 3200);
211  fTruthWireNumberPlane1 = tfs->make<TH1F>("fTruthWireNumberPlane1", "Truth Wire Number Plane 1", 3000, 0, 3000);
212  fTruthTimeTickPlane1 = tfs->make<TH1F>("fTruthTimeTickPlane1", "Truth Time Tick Plane 1", 3200, 0, 3200);
213  fTruthWireNumberPlane2 = tfs->make<TH1F>("fTruthWireNumberPlane2", "Truth Wire Number Plane 2", 3000, 0, 3000);
214  fTruthTimeTickPlane2 = tfs->make<TH1F>("fTruthTimeTickPlane2", "Truth Time Tick Plane 2", 3200, 0, 3200);
215  fTruthWireInCmPlane0 = tfs->make<TH1F>("fTruthWireInCmPlane0", "Truth Wire In CM Plane 0", 2000, 0, 1000);
216  fTruthTimeInCmPlane0 = tfs->make<TH1F>("fTruthTimeInCmPlane0", "Truth Time In Cm Plane 0", 2000, 0, 1000);
217  fTruthWireInCmPlane1 = tfs->make<TH1F>("fTruthWireInCmPlane1", "Truth Wire In CM Plane 1", 2000, 0, 1000);
218  fTruthTimeInCmPlane1 = tfs->make<TH1F>("fTruthTimeInCmPlane1", "Truth Time In Cm Plane 1", 2000, 0, 1000);
219  fTruthWireInCmPlane2 = tfs->make<TH1F>("fTruthWireInCmPlane2", "Truth Wire In CM Plane 2", 2000, 0, 1000);
220  fTruthTimeInCmPlane2 = tfs->make<TH1F>("fTruthTimeInCmPlane2", "Truth Time In Cm Plane 2", 2000, 0, 1000);
221 
222  fTwoDNVtxPlane0 = tfs->make<TH1F>("fTwoDNVtxPlane0", "TwoD Number of Verticies Found in Plane 0", 400, 0, 200);
223  fTwoDNVtxPlane1 = tfs->make<TH1F>("fTwoDNVtxPlane1", "TwoD Number of Verticies Found in Plane 1", 400, 0, 200);
224  fTwoDNVtxPlane2 = tfs->make<TH1F>("fTwoDNVtxPlane2", "TwoD Number of Verticies Found in Plane 2", 400, 0, 200);
225 
226  fTwoDWireNumberPlane0 = tfs->make<TH1F>("fTwoDWireNumberPlane0", "TwoD Wire Number Plane 0", 3000, 0, 3000);
227  fTwoDTimeTickPlane0 = tfs->make<TH1F>("fTwoDTimeTickPlane0", "TwoD Time Tick Plane 0", 3200, 0, 3200);
228  fTwoDWireNumberPlane1 = tfs->make<TH1F>("fTwoDWireNumberPlane1", "TwoD Wire Number Plane 1", 3000, 0, 3000);
229  fTwoDTimeTickPlane1 = tfs->make<TH1F>("fTwoDTimeTickPlane1", "TwoD Time Tick Plane 1", 3200, 0, 3200);
230  fTwoDWireNumberPlane2 = tfs->make<TH1F>("fTwoDWireNumberPlane2", "TwoD Wire Number Plane 2", 3000, 0, 3000);
231  fTwoDTimeTickPlane2 = tfs->make<TH1F>("fTwoDTimeTickPlane2", "TwoD Time Tick Plane 2", 3200, 0, 3200);
232  fTwoDWireInCmPlane0 = tfs->make<TH1F>("fTwoDWireInCmPlane0", "TwoD Wire In CM Plane 0", 2000, 0, 1000);
233  fTwoDTimeInCmPlane0 = tfs->make<TH1F>("fTwoDTimeInCmPlane0", "TwoD Time In Cm Plane 0", 2000, 0, 1000);
234  fTwoDWireInCmPlane1 = tfs->make<TH1F>("fTwoDWireInCmPlane1", "TwoD Wire In CM Plane 1", 2000, 0, 1000);
235  fTwoDTimeInCmPlane1 = tfs->make<TH1F>("fTwoDTimeInCmPlane1", "TwoD Time In Cm Plane 1", 2000, 0, 1000);
236  fTwoDWireInCmPlane2 = tfs->make<TH1F>("fTwoDWireInCmPlane2", "TwoD Wire In CM Plane 2", 2000, 0, 1000);
237  fTwoDTimeInCmPlane2 = tfs->make<TH1F>("fTwoDTimeInCmPlane2", "TwoD Time In Cm Plane 2", 2000, 0, 1000);
238 
239  fTwoDStrengthPlane0 = tfs->make<TH1F>("fTwoDStrengthPlane0", "TwoD Strength Plane 0", 1000, 0, 500);
240  fTwoDStrengthPlane1 = tfs->make<TH1F>("fTwoDStrengthPlane1", "TwoD Strength Plane 1", 1000, 0, 500);
241  fTwoDStrengthPlane2 = tfs->make<TH1F>("fTwoDStrengthPlane2", "TwoD Strength Plane 2", 1000, 0, 500);
242 
243  fRecoCheck2dWireNumPlane0 = tfs->make<TH1F>("fRecoCheck2dWireNumPlane0", "Reco Wire Number - True Wire Number Plane 0", 400, -200, 200);
244  fRecoCheck2dTimeTickPlane0 = tfs->make<TH1F>("fRecoCheck2dTimeTickPlane0", "Reco Time Tick - True Time Tick Plane 0", 1000, -500, 500);
245  fRecoCheck2dWireInCmPlane0 = tfs->make<TH1F>("fRecoCheck2dWireInCmPlane0", "Reco Wire in CM - True Wire in CM Plane 0", 200, -50, 50);
246  fRecoCheck2dTimeInCmPlane0 = tfs->make<TH1F>("fRecoCheck2dTimeInCmPlane0", "Reco Time in CM - True Time in CM Plane 0", 200, -50, 50);
247 
248  fRecoCheck2dWireNumPlane1 = tfs->make<TH1F>("fRecoCheck2dWireNumPlane1", "Reco Wire Number - True Wire Number Plane 1", 400, -200, 200);
249  fRecoCheck2dTimeTickPlane1 = tfs->make<TH1F>("fRecoCheck2dTimeTickPlane1", "Reco Time Tick - True Time Tick Plane 1", 1000, -500, 500);
250  fRecoCheck2dWireInCmPlane1 = tfs->make<TH1F>("fRecoCheck2dWireInCmPlane1", "Reco Wire in CM - True Wire in CM Plane 1", 200, -50, 50);
251  fRecoCheck2dTimeInCmPlane1 = tfs->make<TH1F>("fRecoCheck2dTimeInCmPlane1", "Reco Time in CM - True Time in CM Plane 1", 200, -50, 50);
252 
253  fRecoCheck2dWireNumPlane2 = tfs->make<TH1F>("fRecoCheck2dWireNumPlane2", "Reco Wire Number - True Wire Number Plane 2", 400, -200, 200);
254  fRecoCheck2dTimeTickPlane2 = tfs->make<TH1F>("fRecoCheck2dTimeTickPlane2", "Reco Time Tick - True Time Tick Plane 2", 1000, -500, 500);
255  fRecoCheck2dWireInCmPlane2 = tfs->make<TH1F>("fRecoCheck2dWireInCmPlane2", "Reco Wire in CM - True Wire in CM Plane 2", 200, -50, 50);
256  fRecoCheck2dTimeInCmPlane2 = tfs->make<TH1F>("fRecoCheck2dTimeInCmPlane2", "Reco Time in CM - True Time in CM Plane 2", 200, -50, 50);
257 
258  fRecoVtxN3d = tfs->make<TH1F>("fRecoVtxN3d", "Number of 3d-Reco Verticies", 400, 0, 200);
259  fRecoVtxXPos = tfs->make<TH1F>("fRecoVtxXPos", "Reco Vertex X Position", 400, -10, 200);
260  fRecoVtxYPos = tfs->make<TH1F>("fRecoVtxYPos", "Reco Vertex Y Position", 400, -100, 100);
261  fRecoVtxZPos = tfs->make<TH1F>("fRecoVtxZPos", "Reco Vertex Z Position", 2000, -10, 1000);
262 
263  fRecoCheck3dVtxX = tfs->make<TH1F>("fRecoCheck3dVtxX", "Reco X Position - True X Postion", 800, -100, 100);
264  fRecoCheck3dVtxY = tfs->make<TH1F>("fRecoCheck3dVtxY", "Reco Y Position - True Y Postion", 800, -100, 100);
265  fRecoCheck3dVtxZ = tfs->make<TH1F>("fRecoCheck3dVtxZ", "Reco Z Position - True Z Postion", 800, -100, 100);
266 
267  fRecoCheck3dVtxXvsX = tfs->make <TH2D>("fRecoCheck3dVtxXvsX", "(Reco X - True X)/True X vs True X", 400, -10, 200, 120, -20, 20);
268  fRecoCheck3dVtxYvsY = tfs->make <TH2D>("fRecoCheck3dVtxYvsY", "(Reco Y - True Y)/True Y vs True Y", 400, -100, 100, 120, -20, 20);
269  fRecoCheck3dVtxZvsZ = tfs->make <TH2D>("fRecoCheck3dVtxZvsZ", "(Reco Z - True Z)/True Z vs True Z", 1000, -10, 1000, 120, -20, 20);
270 
271 
272  return;
273 }
274 
275 // ====================================================================================
276 // ============================== Access the event ====================================
277 // ====================================================================================
279 {
280 
281  // ###############################
282  // ### Filling Run/Event Histo ###
283  // ###############################
284  fRun->Fill( evt.run() );
285  fEvt->Fill( evt.id().event() );
286 
287  // ##############################################
288  // ### Getting the Geant Information Directly ###
289  // ##############################################
291  evt.getByLabel(fLArG4ModuleLabel, mcParticleHandle);
292 
293  // #######################################
294  // ### Getting MC Truth Info from simb ###
295  // #######################################
296  art::Handle< std::vector<simb::MCTruth> > mctruthListHandle;
297  evt.getByLabel(fGenieModuleLabel,mctruthListHandle);
298 
299  // ############################################
300  // ### Getting information from BackTrackerService ###
301  // ############################################
303 
304  // ####################################
305  // ### Getting Geometry Information ###
306  // ####################################
308 
309  // ###################################
310  // ### Getting Detector Properties ###
311  // ###################################
312  const detinfo::DetectorProperties* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
313 
314  // ######################################################
315  // ### Getting 2d Vertex information (vertex2dHandle) ###
316  // ######################################################
318  evt.getByLabel(fEndPoint2dModuleLabel,vertex2dHandle);
319 
320  // ##################################################
321  // ### Getting the 3d Vertex (vertex3dListHandle) ###
322  // ##################################################
323  art::Handle< std::vector<recob::Vertex> > vertex3dListHandle;
324  evt.getByLabel(fVertexModuleLabel,vertex3dListHandle);
325 
326 
327 
328  // ==========================================================
329  // === Detector numbers that are useful (to be set later) ===
330  // ==========================================================
331  //size_t nplanes = 0;
332  std::vector<double> WirePitch_CurrentPlane(geom->Views().size(), 0.); //<---Setting the Wire pitch for each plane
333  // Right now assuming only 3 planes
334  // ##############################
335  // ### get the wire pitch for each view ###
336  // ##############################
337  size_t vn = 0;
338  for(auto v : geom->Views() ){
339  WirePitch_CurrentPlane[vn] = geom->WirePitch(v);
340  ++vn;
341  }
342 
343  // ##################################################
344  // ### Calculating the Timetick to CM conversion ###
345  // ##################################################
346  float TimeTick = detp->SamplingRate()/1000.; //<---To get units of microsecond...not nanosec
347  float DriftVelocity = detp->DriftVelocity(detp->Efield(),detp->Temperature());
348 
349  float TimetoCm = TimeTick*DriftVelocity;
350 
351 
352 
353 
354 // ===========================================================================================================
355 // ==================================== Looping over MC information ==========================================
356 // ===========================================================================================================
357 
358 
359  // ##################################
360  // ### Getting MC Truth simb Info ###
361  // ##################################
363  for (unsigned int ii = 0; ii < mctruthListHandle->size(); ++ii)
364  {
365  art::Ptr<simb::MCTruth> mctparticle(mctruthListHandle,ii);
366  mclist.push_back(mctparticle);
367  }
368 
369  // ##############################################
370  // ### Variables for truth vertex information ###
371  // ##############################################
372  float truth_vertex[5] = {0.}; //<---Truth x,y,z information
373 
374  uint32_t VtxWireNum[3] = {0}; //<---Wire number in each plane ( WireNum[plane#] )
375  double VtxTimeTick[3] = {0.}; //<---Time tick in each plane ( TimeTick[plane#] )
376 
377  double VtxWireNum_InCM[3] = {0.}; //<---Wire number in each plane in CM ( WireNum[plane#] )
378  double VtxTimeTick_InCM[3] = {0.}; //<---Time tick in each plane in CM ( TimeTick[plane#] )
379 
380 
381  // ###################################
382  // ### Finding the MC truth vertex ###
383  // ###################################
384  for( unsigned int i = 0; i < mclist.size(); ++i )
385  {
386  art::Ptr<simb::MCTruth> mc(mclist[i]);
387  simb::MCParticle neut(mc->GetParticle(i));
388 
389  // ############################################
390  // ### Filling the vertex x,y,z information ###
391  // ############################################
392  truth_vertex[0] =neut.Vx();
393  truth_vertex[1] =neut.Vy();
394  truth_vertex[2] =neut.Vz();
395 
396  }// end i loop
397 
398  // ### Filling Histograms ###
399  fTruthVtxXPos->Fill( truth_vertex[0] );
400  fTruthVtxYPos->Fill( truth_vertex[1] );
401  fTruthVtxZPos->Fill( truth_vertex[2] );
402 
403  // ##############################
404  // ### Looping over geo::PlaneIDs ###
405  // ##############################
406  for(auto const& pid : geom->IteratePlaneIDs()){
407  // ############################################################################
408  // ### Calculating the nearest wire the vertex corresponds to in each plane ###
409  // ############################################################################
410 
411  try{
412  // geom->NearestWire(worldLoc[3], Plane#, TPC#, Cyrostat#)
413  VtxWireNum[pid.Plane] = geom->NearestWire(truth_vertex,pid.Plane,pid.TPC,pid.Cryostat);
414  }
415  catch(...){
416  mf::LogWarning("FeatureVertexFinderAna") << "Can't find nearest wire";
417  continue;
418  }
419  // detp->ConvertXToTicks(xpos, plane#, TPC#, Cyrostat#)
420  VtxTimeTick[pid.Plane] = (detp->ConvertXToTicks(truth_vertex[0],pid.Plane, pid.TPC, pid.Cryostat)
421  + detp->GetXTicksOffset(pid.Plane, pid.TPC, pid.Cryostat));
422 
423  // ======================== Translating each of these in cm =====================
424  VtxWireNum_InCM[pid.Plane] = VtxWireNum[pid.Plane] * WirePitch_CurrentPlane[pid.Plane];
425  VtxTimeTick_InCM[pid.Plane] = VtxTimeTick[pid.Plane] * TimetoCm;
426  }//<---End pid loop
427 
428  // ### Filling Histograms ###
429  fTruthWireNumberPlane0->Fill( VtxWireNum[0] );
430  fTruthTimeTickPlane0->Fill( VtxTimeTick[0] );
431  fTruthWireNumberPlane1->Fill( VtxWireNum[1] );
432  fTruthTimeTickPlane1->Fill( VtxTimeTick[1] );
433  fTruthWireNumberPlane2->Fill( VtxWireNum[2] );
434  fTruthTimeTickPlane2->Fill( VtxTimeTick[2] );
435 
436  fTruthWireInCmPlane0->Fill( VtxWireNum_InCM[0] );
437  fTruthTimeInCmPlane0->Fill( VtxTimeTick_InCM[0] );
438  fTruthWireInCmPlane1->Fill( VtxWireNum_InCM[1] );
439  fTruthTimeInCmPlane1->Fill( VtxTimeTick_InCM[1] );
440  fTruthWireInCmPlane2->Fill( VtxWireNum_InCM[2] );
441  fTruthTimeInCmPlane2->Fill( VtxTimeTick_InCM[2] );
442 
443 
444 // ===================================================================================================================
445 // ==================================== Looping over EndPoint2d information ==========================================
446 // ===================================================================================================================
447 
449 
450  // Variables for Vertex2d
451 
452  double Vertex2d_TimeTick[10000] = {0.}; //<---Vertex2d Time Tick for the current plane ( TimeTick[#2d] )
453  double Vertex2d_Wire[10000] = {0.}; //<---Veretx2d Wire # ( Wire[#2d] )
454 
455  double Vertex2d_TimeTick_InCM[10000] = {0.}; //<---Vertex 2d Time tick in CM ( TimeTick[#2d] )
456  double Vertex2d_Wire_InCM[10000] = {0.}; //<---Veretx2d Wire in CM ( Wire[#2d] )
457  int n2dVtx = 0;
458 
459  int n2dVtxPlane0 = 0, n2dVtxPlane1 = 0, n2dVtxPlane2 = 0;
460 
461  bool vertexWstrengthplane0 = false , vertexWstrengthplane1 = false;//, vertexWstrengthplane2 = false; //commented out, Wes, 12.4.13
462 
463  // ######################################
464  // ### Loop over the EndPoint2d List ###
465  // ######################################
466  for(size_t ii = 0; ii < vertex2dHandle->size(); ++ii){
467  art::Ptr<recob::EndPoint2D> vertex(vertex2dHandle, ii);
468  vert2d.push_back(vertex);
469  }
470 
471  // ############################################
472  // ### If we have 2d vertex, loop over them ###
473  // ############################################
474  if(vert2d.size() > 0)
475  {
476 
477  // ##############################
478  // ### Looping over geo::PlaneIDs ###
479  // ##############################
480  for(auto const& pid : geom->IteratePlaneIDs() ){
481  for(size_t ww = 0; ww<vert2d.size(); ++ww){
482  //std::cout<<"plane = "<<plane<<std::endl;
483  //std::cout<<"vert2d[ww]->WireID().Plane = "<<vert2d[ww]->WireID().Plane<<std::endl;
484  // Only look at this 2d vertex if it is in the current plane
485  if (vert2d[ww]->WireID().planeID() != pid){continue;}
486 
487  Vertex2d_TimeTick[n2dVtx] = vert2d[ww]->DriftTime();
488  Vertex2d_Wire[n2dVtx] = vert2d[ww]->WireID().Wire;
489 
490  // ======================== Translating each of these in cm =====================
491  Vertex2d_Wire_InCM[n2dVtx] = Vertex2d_Wire[n2dVtx] * WirePitch_CurrentPlane[pid.Plane];
492  //std::cout<<"Vertex2d_Wire[n2dVtx] = "<<Vertex2d_Wire[n2dVtx]<<" , WirePitch_CurrentPlane[plane] = "<<WirePitch_CurrentPlane[plane]<<std::endl;
493  //std::cout<<"Vertex2d_Wire_InCM[n2dVtx] = "<<Vertex2d_Wire_InCM[n2dVtx]<<std::endl;
494  Vertex2d_TimeTick_InCM[n2dVtx] = Vertex2d_TimeTick[n2dVtx] * TimetoCm;
495 
496  // ###########################################################################
497  // ### Checking how well we did in reconstructing the vertex (Reco - True) ###
498  // ###########################################################################
499 
500  float RecoCheck_TimeTick = Vertex2d_TimeTick[n2dVtx] - VtxTimeTick[pid.Plane];
501  float RecoCheck_WireNum = Vertex2d_Wire[n2dVtx] - VtxWireNum[pid.Plane];
502 
503  float RecoCheck_TimeInCm = Vertex2d_TimeTick_InCM[n2dVtx] - VtxTimeTick_InCM[pid.Plane];
504  float RecoCheck_WireInCm = Vertex2d_Wire_InCM[n2dVtx] - VtxWireNum_InCM[pid.Plane];
505 
506 
507 
508  if( vert2d[ww]->Strength() > -1)
509  {
510  if(pid.Plane == 0)
511  {
512  vertexWstrengthplane0 = true;
513  //std::cout<<"Filling Plane 0 "<<std::endl;
514  //std::cout<<"Vertex2d_Wire[n2dVtx] = "<<Vertex2d_Wire[n2dVtx]<<std::endl;
515 
516  fTwoDWireNumberPlane0->Fill( Vertex2d_Wire[n2dVtx] );
517  fTwoDTimeTickPlane0->Fill( Vertex2d_TimeTick[n2dVtx] );
518  fTwoDWireInCmPlane0->Fill( Vertex2d_Wire_InCM[n2dVtx] );
519  fTwoDTimeInCmPlane0->Fill( Vertex2d_TimeTick_InCM[n2dVtx] );
520 
521  fTwoDStrengthPlane0->Fill( vert2d[ww]->Strength() );
522 
523  fRecoCheck2dWireNumPlane0->Fill( RecoCheck_WireNum );
524  fRecoCheck2dTimeTickPlane0->Fill( RecoCheck_TimeTick );
525  fRecoCheck2dWireInCmPlane0->Fill( RecoCheck_WireInCm );
526  fRecoCheck2dTimeInCmPlane0->Fill( RecoCheck_TimeInCm );
527 
528  n2dVtxPlane0++;
529 
530  }//<---End Plane 0
531 
532  if(pid.Plane == 1)
533  {
534  vertexWstrengthplane1 = true;
535  fTwoDWireNumberPlane1->Fill( Vertex2d_Wire[n2dVtx] );
536  fTwoDTimeTickPlane1->Fill( Vertex2d_TimeTick[n2dVtx] );
537  fTwoDWireInCmPlane1->Fill( Vertex2d_Wire_InCM[n2dVtx] );
538  fTwoDTimeInCmPlane1->Fill( Vertex2d_TimeTick_InCM[n2dVtx] );
539 
540  fTwoDStrengthPlane1->Fill( vert2d[ww]->Strength() );
541 
542  fRecoCheck2dWireNumPlane1->Fill( RecoCheck_WireNum );
543  fRecoCheck2dTimeTickPlane1->Fill( RecoCheck_TimeTick );
544  fRecoCheck2dWireInCmPlane1->Fill( RecoCheck_WireInCm );
545  fRecoCheck2dTimeInCmPlane1->Fill( RecoCheck_TimeInCm );
546 
547  n2dVtxPlane1++;
548 
549  }//<---End Plane 1
550 
551  if(pid.Plane == 2)
552  {
553  //vertexWstrengthplane2 = true;
554  fTwoDWireNumberPlane2->Fill( Vertex2d_Wire[n2dVtx] );
555  fTwoDTimeTickPlane2->Fill( Vertex2d_TimeTick[n2dVtx] );
556  fTwoDWireInCmPlane2->Fill( Vertex2d_Wire_InCM[n2dVtx] );
557  fTwoDTimeInCmPlane2->Fill( Vertex2d_TimeTick_InCM[n2dVtx] );
558 
559  fTwoDStrengthPlane2->Fill( vert2d[ww]->Strength() );
560 
561  fRecoCheck2dWireNumPlane2->Fill( RecoCheck_WireNum );
562  fRecoCheck2dTimeTickPlane2->Fill( RecoCheck_TimeTick );
563  fRecoCheck2dWireInCmPlane2->Fill( RecoCheck_WireInCm );
564  fRecoCheck2dTimeInCmPlane2->Fill( RecoCheck_TimeInCm );
565 
566  n2dVtxPlane2++;
567 
568 
569  }//<---End Plane 2
570  }
571 
572 
573  ++n2dVtx;
574  }//<--end ww loop
575 
576 
577  }//<---End plane ID
578 
579  }//<--End checking if we have 2d end points
580 
581  fTwoDNVtxPlane0->Fill( n2dVtxPlane0 );
582  fTwoDNVtxPlane1->Fill( n2dVtxPlane1 );
583  fTwoDNVtxPlane2->Fill( n2dVtxPlane2 );
584 
585  // =================================================================================================================
586 // ==================================== Looping over 3dVertex information ==========================================
587 // =================================================================================================================
589 
590  double xyz[3] = {0.};
591 
592  for(unsigned int ii = 0; ii < vertex3dListHandle->size(); ++ii)
593  {
594  art::Ptr<recob::Vertex> vertex3d(vertex3dListHandle, ii);
595  Vertexlist.push_back(vertex3d); // class member
596 
597  }//<---End ii loop
598 
599  if(Vertexlist.size() > 0 && vertexWstrengthplane0 && vertexWstrengthplane1)
600  {
601 
602  fRecoVtxN3d->Fill(Vertexlist.size());
603  for(unsigned int ww = 0; ww<Vertexlist.size(); ww++)
604  {
605  Vertexlist[ww]->XYZ(xyz);
606 
607  // ###########################################################################
608  // ### Checking how well we did in reconstructing the vertex (Reco - True) ###
609  // ###########################################################################
610 
611  // === Finding the Delta X, Y, Z between Reco vtx and truth ===
612 
613  double DeltaX = xyz[0] - truth_vertex[0] ;
614  double DeltaY = xyz[1] - truth_vertex[1] ;
615  double DeltaZ = xyz[2] - truth_vertex[2] ;
616 
617  double DeltaXoverTrueX = DeltaX / truth_vertex[0];
618  double DeltaYoverTrueY = DeltaY / truth_vertex[0];
619  double DeltaZoverTrueZ = DeltaZ / truth_vertex[0];
620 
621  fRecoVtxXPos->Fill( xyz[0] );
622  fRecoVtxYPos->Fill( xyz[1] );
623  fRecoVtxZPos->Fill( xyz[2] );
624 
625  fRecoCheck3dVtxX->Fill( DeltaX );
626  fRecoCheck3dVtxY->Fill( DeltaY );
627  fRecoCheck3dVtxZ->Fill( DeltaZ );
628 
629  fRecoCheck3dVtxXvsX->Fill( xyz[0], DeltaXoverTrueX );
630  fRecoCheck3dVtxYvsY->Fill( xyz[1], DeltaYoverTrueY );
631  fRecoCheck3dVtxZvsZ->Fill( xyz[2], DeltaZoverTrueZ );
632 
633 
634 
635 
636  }
637  }
638 
639 return;
640 }//<---End access the event
641 
642 
644 
645 }// end of vertex namespace
646 
647 #endif // FEATUREVERTEXFINDERANA_H
Encapsulate the construction of a single cyostat.
Declaration of signal hit object.
std::set< geo::View_t > const & Views() const
Returns a list of possible views in the detector.
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
FeatureVertexFinderAna(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
void reconfigure(fhicl::ParameterSet const &p)
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
virtual double Temperature() const =0
T get(std::string const &key) const
Definition: ParameterSet.h:231
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Declaration of cluster object.
size_type size() const
Definition: PtrVector.h:308
Encapsulate the geometry of a wire.
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:73
double Vx(const int i=0) const
Definition: MCParticle.h:225
T * make(ARGS...args) const
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
EventNumber_t event() const
Definition: EventID.h:117
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
TCEvent evt
Definition: DataStructs.cxx:5
RunNumber_t run() const
Definition: Event.h:77
Tools and modules for checking out the basics of the Monte Carlo.
EventID id() const
Definition: Event.h:56
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
virtual double GetXTicksOffset(int p, int t, int c) const =0
vertex reconstruction