LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
PFParticleHitDumper_module.cc
Go to the documentation of this file.
1 
10 
11 #include "TTree.h"
12 
17 
18 #include <string>
19 
20 //------------------------------------------------------------------------------------------------------------------------------------------
21 
22 namespace lar_pandora {
23 
28  public:
35 
39  virtual ~PFParticleHitDumper();
40 
41  void beginJob();
42  void endJob();
43  void analyze(const art::Event& evt);
44  void reconfigure(fhicl::ParameterSet const& pset);
45 
46  private:
52  void FillRecoTracks(const PFParticlesToTracks& particlesToTracks);
53 
61  void FillReco3D(const PFParticleVector& particleVector,
62  const PFParticlesToSpacePoints& particlesToSpacePoints,
63  const SpacePointsToHits& spacePointsToHits);
64 
71  void FillReco2D(const art::Event& event,
72  const HitVector& hitVector,
73  const HitsToPFParticles& hitsToParticles);
74 
84  void FillAssociated2DHits(const art::Event& evt,
85  const PFParticleVector& particleVector,
86  const PFParticlesToHits& particlesToHits,
87  const PFParticlesToHits& particlesToHitsClusters,
88  const PFParticlesToTracks& particlesToTracks,
89  const TracksToHits& tracksToHits,
90  const PFParticlesToShowers& particlesToShowers,
91  const ShowersToHits& showersToHits);
92 
98  void FillRecoWires(const art::Event& event, const WireVector& wireVector);
99 
105  double GetUVW(const geo::WireID& wireID) const;
106 
115  double YZtoU(const unsigned int cstat,
116  const unsigned int tpc,
117  const double y,
118  const double z) const;
119 
128  double YZtoV(const unsigned int cstat,
129  const unsigned int tpc,
130  const double y,
131  const double z) const;
132 
133  TTree* m_pRecoTracks;
134  TTree* m_pReco3D;
135  TTree* m_pReco2D;
137  TTree* m_pRecoWire;
138 
139  int m_run;
140  int m_event;
142  int m_primary;
143  int m_pdgcode;
144 
145  int m_cstat;
146  int m_tpc;
147  int m_plane;
148  int m_wire;
149 
150  double m_u;
151  double m_v;
152  double m_w;
153  double m_x;
154  double m_y;
155  double m_z;
156  double m_q;
157 
161 
162  std::string m_calwireLabel;
163  std::string m_hitfinderLabel;
164  std::string m_clusterLabel;
165  std::string m_spacepointLabel;
166  std::string m_particleLabel;
167  std::string m_trackLabel;
168  std::string m_showerLabel;
169 
172  };
173 
175 
176 } // namespace lar_pandora
177 
178 //------------------------------------------------------------------------------------------------------------------------------------------
179 // implementation follows
180 
184 #include "art_root_io/TFileDirectory.h"
185 #include "art_root_io/TFileService.h"
186 #include "fhiclcpp/ParameterSet.h"
188 
196 #include "lardataobj/RecoBase/Hit.h"
204 
205 #include <iostream>
206 
207 namespace lar_pandora {
208 
210  {
211  this->reconfigure(pset);
212  }
213 
214  //------------------------------------------------------------------------------------------------------------------------------------------
215 
217 
218  //------------------------------------------------------------------------------------------------------------------------------------------
219 
221  {
222  m_storeWires = pset.get<bool>("StoreWires", false);
223  m_trackLabel = pset.get<std::string>("TrackModule", "pandoraTrack");
224  m_showerLabel = pset.get<std::string>("ShowerModule", "pandoraShower");
225  m_particleLabel = pset.get<std::string>("PFParticleModule", "pandora");
226  m_spacepointLabel = pset.get<std::string>("SpacePointModule", "pandora");
227  m_clusterLabel = pset.get<std::string>("ClusterModule", "pandora");
228  m_hitfinderLabel = pset.get<std::string>("HitFinderModule", "gaushit");
229  m_calwireLabel = pset.get<std::string>("CalWireModule", "caldata");
230  m_printDebug = pset.get<bool>("PrintDebug", false);
231  }
232 
233  //------------------------------------------------------------------------------------------------------------------------------------------
234 
236  {
237  mf::LogDebug("LArPandora") << " *** PFParticleHitDumper::beginJob() *** " << std::endl;
238 
239  //
241 
242  m_pRecoTracks = tfs->make<TTree>("pandoraTracks", "LAr Reco Tracks");
243  m_pRecoTracks->Branch("run", &m_run, "run/I");
244  m_pRecoTracks->Branch("event", &m_event, "event/I");
245  m_pRecoTracks->Branch("particle", &m_particle, "particle/I");
246  m_pRecoTracks->Branch("x", &m_x, "x/D");
247  m_pRecoTracks->Branch("y", &m_y, "y/D");
248  m_pRecoTracks->Branch("z", &m_z, "z/D");
249 
250  m_pReco3D = tfs->make<TTree>("pandora3D", "LAr Reco 3D");
251  m_pReco3D->Branch("run", &m_run, "run/I");
252  m_pReco3D->Branch("event", &m_event, "event/I");
253  m_pReco3D->Branch("particle", &m_particle, "particle/I");
254  m_pReco3D->Branch("primary", &m_primary, "primary/I");
255  m_pReco3D->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
256  m_pReco3D->Branch("cstat", &m_cstat, "cstat/I");
257  m_pReco3D->Branch("tpc", &m_tpc, "tpc/I");
258  m_pReco3D->Branch("plane", &m_plane, "plane/I");
259  m_pReco3D->Branch("x", &m_x, "x/D");
260  m_pReco3D->Branch("y", &m_y, "y/D");
261  m_pReco3D->Branch("u", &m_u, "u/D");
262  m_pReco3D->Branch("v", &m_v, "v/D");
263  m_pReco3D->Branch("z", &m_z, "z/D");
264 
265  m_pReco2D = tfs->make<TTree>("pandora2D", "LAr Reco 2D");
266  m_pReco2D->Branch("run", &m_run, "run/I");
267  m_pReco2D->Branch("event", &m_event, "event/I");
268  m_pReco2D->Branch("particle", &m_particle, "particle/I");
269  m_pReco2D->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
270  m_pReco2D->Branch("cstat", &m_cstat, "cstat/I");
271  m_pReco2D->Branch("tpc", &m_tpc, "tpc/I");
272  m_pReco2D->Branch("plane", &m_plane, "plane/I");
273  m_pReco2D->Branch("wire", &m_wire, "wire/I");
274  m_pReco2D->Branch("x", &m_x, "x/D");
275  m_pReco2D->Branch("w", &m_w, "w/D");
276  m_pReco2D->Branch("q", &m_q, "q/D");
277 
278  m_pRecoComparison = tfs->make<TTree>("pandora2Dcomparison", "LAr Reco 2D (comparison)");
279  m_pRecoComparison->Branch("run", &m_run, "run/I");
280  m_pRecoComparison->Branch("event", &m_event, "event/I");
281  m_pRecoComparison->Branch("particle", &m_particle, "particle/I");
282  m_pRecoComparison->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
283  m_pRecoComparison->Branch(
284  "hitsFromSpacePoints", &m_hitsFromSpacePoints, "hitsFromSpacePoints/I");
285  m_pRecoComparison->Branch("hitsFromClusters", &m_hitsFromClusters, "hitsFromClusters/I");
286  m_pRecoComparison->Branch(
287  "hitsFromTrackOrShower", &m_hitsFromTrackOrShower, "hitsFromTrackOrShower/I");
288 
289  m_pRecoWire = tfs->make<TTree>("rawdata", "LAr Reco Wires");
290  m_pRecoWire->Branch("run", &m_run, "run/I");
291  m_pRecoWire->Branch("event", &m_event, "event/I");
292  m_pRecoWire->Branch("cstat", &m_cstat, "cstat/I");
293  m_pRecoWire->Branch("tpc", &m_tpc, "tpc/I");
294  m_pRecoWire->Branch("plane", &m_plane, "plane/I");
295  m_pRecoWire->Branch("wire", &m_wire, "wire/I");
296  m_pRecoWire->Branch("x", &m_x, "x/D");
297  m_pRecoWire->Branch("w", &m_w, "w/D");
298  m_pRecoWire->Branch("q", &m_q, "q/D");
299  }
300 
301  //------------------------------------------------------------------------------------------------------------------------------------------
302 
304 
305  //------------------------------------------------------------------------------------------------------------------------------------------
306 
308  {
309  if (m_printDebug) std::cout << " *** PFParticleHitDumper::analyze(...) *** " << std::endl;
310 
311  m_run = evt.run();
312  m_event = evt.id().event();
313 
314  m_particle = -1;
315  m_primary = 0;
316  m_pdgcode = 0;
317 
318  m_cstat = 0;
319  m_tpc = 0;
320  m_plane = 0;
321  m_wire = 0;
322 
323  m_x = 0.0;
324  m_y = 0.0;
325  m_u = 0.0;
326  m_v = 0.0;
327  m_z = 0.0;
328  m_w = 0.0;
329  m_q = 0.0;
330 
331  if (m_printDebug) {
332  std::cout << " Run: " << m_run << std::endl;
333  std::cout << " Event: " << m_event << std::endl;
334  }
335 
336  // Get particles, tracks, space points, hits (and wires)
337  // ====================================================
338  TrackVector trackVector, trackVectorExtra;
339  ShowerVector showerVector, showerVectorExtra;
340  PFParticleVector particleVector;
341  SpacePointVector spacePointVector;
342  HitVector hitVector;
343  WireVector wireVector;
344 
345  PFParticlesToTracks particlesToTracks;
346  PFParticlesToShowers particlesToShowers;
347  PFParticlesToSpacePoints particlesToSpacePoints;
348  PFParticlesToHits particlesToHits, particlesToHitsClusters;
349  TracksToHits tracksToHits;
350  ShowersToHits showersToHits;
351  HitsToPFParticles hitsToParticles, hitsToParticlesClusters;
352  SpacePointsToHits spacePointsToHits;
353 
356  evt, m_spacepointLabel, spacePointVector, spacePointsToHits);
357  LArPandoraHelper::CollectTracks(evt, m_trackLabel, trackVector, particlesToTracks);
358  LArPandoraHelper::CollectTracks(evt, m_trackLabel, trackVectorExtra, tracksToHits);
359  LArPandoraHelper::CollectShowers(evt, m_showerLabel, showerVector, particlesToShowers);
360  LArPandoraHelper::CollectShowers(evt, m_showerLabel, showerVectorExtra, showersToHits);
362  evt, m_particleLabel, particleVector, particlesToSpacePoints);
366  particlesToHits,
367  hitsToParticles,
368  LArPandoraHelper::DaughterMode::kUseDaughters,
369  false);
371  evt, m_particleLabel, m_clusterLabel, particlesToHitsClusters, hitsToParticlesClusters);
372 
374 
375  if (m_printDebug) std::cout << " PFParticles: " << particleVector.size() << std::endl;
376 
377  // Loop over Tracks (Fill 3D Track Tree)
378  // =====================================
379  if (m_printDebug) std::cout << " PFParticleHitDumper::FillRecoTracks(...) " << std::endl;
380  this->FillRecoTracks(particlesToTracks);
381 
382  // Loop over PFParticles (Fill 3D Reco Tree)
383  // =========================================
384  if (m_printDebug) std::cout << " PFParticleHitDumper::FillReco3D(...) " << std::endl;
385  this->FillReco3D(particleVector, particlesToSpacePoints, spacePointsToHits);
386 
387  // Loop over Hits (Fill 2D Reco Tree)
388  // ==================================
389  if (m_printDebug) std::cout << " PFParticleHitDumper::FillReco2D(...) " << std::endl;
390  this->FillReco2D(evt, hitVector, hitsToParticles);
391 
392  // Loop over Hits (Fill Associated 2D Hits Tree)
393  // =============================================
394  if (m_printDebug)
395  std::cout << " PFParticleHitDumper::FillAssociated2DHits(...) " << std::endl;
396  this->FillAssociated2DHits(evt,
397  particleVector,
398  particlesToHits,
399  particlesToHitsClusters,
400  particlesToTracks,
401  tracksToHits,
402  particlesToShowers,
403  showersToHits);
404 
405  // Loop over Wires (Fill Reco Wire Tree)
406  // =====================================
407  if (m_printDebug) std::cout << " PFParticleHitDumper::FillRecoWires(...) " << std::endl;
408  this->FillRecoWires(evt, wireVector);
409  }
410 
411  //------------------------------------------------------------------------------------------------------------------------------------------
412 
414  {
415  // Initialise variables
416  m_particle = -1;
417  m_x = 0.0;
418  m_y = 0.0;
419  m_z = 0.0;
420 
421  // Create dummy entry if there are no particles
422  if (particlesToTracks.empty()) { m_pRecoTracks->Fill(); }
423 
424  // Loop over tracks
425  for (PFParticlesToTracks::const_iterator iter = particlesToTracks.begin(),
426  iterEnd = particlesToTracks.end();
427  iter != iterEnd;
428  ++iter) {
429  const art::Ptr<recob::PFParticle> particle = iter->first;
430  const TrackVector& trackVector = iter->second;
431 
432  m_particle = particle->Self();
433 
434  if (!trackVector.empty()) {
435  if (trackVector.size() != 1 && m_printDebug)
436  std::cout << " Warning: Found particle with more than one associated track " << std::endl;
437 
438  const art::Ptr<recob::Track> track = *(trackVector.begin());
439 
440  if (m_printDebug)
441  std::cout << " PFPARTICLE [" << m_particle << "] (" << track->NumberTrajectoryPoints()
442  << " Trajectory Points)" << std::endl;
443 
444  for (unsigned int p = 0; p < track->NumberTrajectoryPoints(); ++p) {
445  const auto position(track->LocationAtPoint(p));
446  m_x = position.x();
447  m_y = position.y();
448  m_z = position.z();
449 
450  m_pRecoTracks->Fill();
451  }
452  }
453  }
454  }
455 
456  //------------------------------------------------------------------------------------------------------------------------------------------
457 
459  const PFParticlesToSpacePoints& particlesToSpacePoints,
460  const SpacePointsToHits& spacePointsToHits)
461  {
462  // Initialise variables
463  m_particle = -1;
464  m_primary = 0;
465  m_pdgcode = 0;
466  m_cstat = 0;
467  m_tpc = 0;
468  m_plane = 0;
469  m_x = 0.0;
470  m_u = 0.0;
471  m_v = 0.0;
472  m_y = 0.0;
473  m_z = 0.0;
474 
475  // Create dummy entry if there are no particles
476  if (particleVector.empty()) { m_pReco3D->Fill(); }
477 
478  // Store associations between particle and particle ID
479  PFParticleMap theParticleMap;
480 
481  for (unsigned int i = 0; i < particleVector.size(); ++i) {
482  const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
483  theParticleMap[particle->Self()] = particle;
484  }
485 
486  // Loop over particles
487  for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(),
488  iterEnd1 = particlesToSpacePoints.end();
489  iter1 != iterEnd1;
490  ++iter1) {
491  const art::Ptr<recob::PFParticle> particle = iter1->first;
492  const SpacePointVector& spacepoints = iter1->second;
493 
494  m_particle = particle->Self();
495  m_pdgcode = particle->PdgCode();
496  m_primary = 0;
497 
498  if (particle->IsPrimary()) { m_primary = 1; }
499  else {
500  const size_t parentID(particle->Parent());
501  PFParticleMap::const_iterator pIter = theParticleMap.find(parentID);
502  if (theParticleMap.end() == pIter)
503  throw cet::exception("LArPandora")
504  << " PFParticleHitDumper::analyze --- Found particle with ID code";
505 
506  const art::Ptr<recob::PFParticle> particleParent = pIter->second;
507  if (LArPandoraHelper::IsNeutrino(particleParent)) m_primary = 1;
508  }
509 
510  if (m_printDebug)
511  std::cout << " PFPARTICLE [" << m_particle << "] [Primary=" << m_primary << "] ("
512  << spacepoints.size() << " Space Points)" << std::endl;
513 
514  for (unsigned int j = 0; j < spacepoints.size(); ++j) {
515  const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
516 
517  m_x = spacepoint->XYZ()[0];
518  m_y = spacepoint->XYZ()[1];
519  m_z = spacepoint->XYZ()[2];
520 
521  SpacePointsToHits::const_iterator iter2 = spacePointsToHits.find(spacepoint);
522  if (spacePointsToHits.end() == iter2)
523  throw cet::exception("LArPandora")
524  << " PFParticleHitDumper::analyze --- Found space point without associated hit";
525 
526  const art::Ptr<recob::Hit> hit = iter2->second;
527  const geo::WireID& wireID(hit->WireID());
528 
529  m_cstat = wireID.Cryostat;
530  m_tpc = wireID.TPC;
531  m_plane = wireID.Plane;
532 
533  m_u = this->YZtoU(m_cstat, m_tpc, m_y, m_z);
534  m_v = this->YZtoV(m_cstat, m_tpc, m_y, m_z);
535 
536  m_pReco3D->Fill();
537  }
538  }
539  }
540 
541  //------------------------------------------------------------------------------------------------------------------------------------------
542 
544  const PFParticleVector& particleVector,
545  const PFParticlesToHits& particlesToHits,
546  const PFParticlesToHits& particlesToHitsClusters,
547  const PFParticlesToTracks& particlesToTracks,
548  const TracksToHits& tracksToHits,
549  const PFParticlesToShowers& particlesToShowers,
550  const ShowersToHits& showersToHits)
551  {
552  // Create dummy entry if there are no 2D hits
553  if (particleVector.empty()) { m_pRecoComparison->Fill(); }
554 
555  for (unsigned int i = 0; i < particleVector.size(); ++i) {
556  //initialise variables
557  m_particle = -1;
558  m_pdgcode = 0;
560  m_hitsFromClusters = 0;
562 
563  const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
564  m_particle = particle->Self();
565  m_pdgcode = particle->PdgCode();
566 
567  PFParticlesToHits::const_iterator pIter = particlesToHits.find(particle);
568  PFParticlesToHits::const_iterator pIter2 = particlesToHitsClusters.find(particle);
569  if (particlesToHits.end() != pIter) m_hitsFromSpacePoints = pIter->second.size();
570  if (particlesToHitsClusters.end() != pIter2) m_hitsFromClusters = pIter2->second.size();
571 
572  if (m_pdgcode == 13) {
573  PFParticlesToTracks::const_iterator iter = particlesToTracks.find(particle);
574  const art::Ptr<recob::Track> track = *(iter->second.begin());
575 
576  TracksToHits::const_iterator iter2 = tracksToHits.find(track);
577  if (tracksToHits.end() != iter2) {
578  const HitVector& hitVector = iter2->second;
579  m_hitsFromTrackOrShower = hitVector.size();
580  }
581  }
582  else if (m_pdgcode == 11) {
583  PFParticlesToShowers::const_iterator iter = particlesToShowers.find(particle);
584  const art::Ptr<recob::Shower> shower = *(iter->second.begin());
585 
586  ShowersToHits::const_iterator iter2 = showersToHits.find(shower);
587  if (showersToHits.end() != iter2) {
588  const HitVector& hitVector = iter2->second;
589  m_hitsFromTrackOrShower = hitVector.size();
590  }
591  }
592 
593  if (m_printDebug)
594  std::cout << " PFParticle " << m_particle << " (PDG " << m_pdgcode << ") has "
595  << m_hitsFromSpacePoints << " hits from space points and " << m_hitsFromClusters
596  << " hits from clusters, and its recob::Track/Shower has "
597  << m_hitsFromTrackOrShower << " associated hits " << std::endl;
598 
599  m_pRecoComparison->Fill();
600  }
601  }
602 
603  //------------------------------------------------------------------------------------------------------------------------------------------
604 
606  const HitVector& hitVector,
607  const HitsToPFParticles& hitsToParticles)
608  {
609  // Initialise variables
610  m_particle = -1;
611  m_pdgcode = 0;
612  m_cstat = 0;
613  m_tpc = 0;
614  m_plane = 0;
615  m_wire = 0;
616  m_x = 0.0;
617  m_w = 0.0;
618  m_q = 0.0;
619 
620  // Create dummy entry if there are no 2D hits
621  if (hitVector.empty()) { m_pReco2D->Fill(); }
622 
623  // Need DetectorProperties service to convert from ticks to X
624  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
625 
626  // Loop over 2D hits
627  for (unsigned int i = 0; i < hitVector.size(); ++i) {
628  const art::Ptr<recob::Hit> hit = hitVector.at(i);
629 
630  m_particle = -1;
631  m_pdgcode = 0;
632 
633  HitsToPFParticles::const_iterator pIter = hitsToParticles.find(hit);
634  if (hitsToParticles.end() != pIter) {
635  const art::Ptr<recob::PFParticle> particle = pIter->second;
636  m_particle = particle->Self();
637  m_pdgcode = particle->PdgCode();
638  }
639 
640  const geo::WireID& wireID(hit->WireID());
641  m_cstat = wireID.Cryostat;
642  m_tpc = wireID.TPC;
643  m_plane = wireID.Plane;
644  m_wire = wireID.Wire;
645 
646  m_q = hit->Integral();
647  m_x = detProp.ConvertTicksToX(hit->PeakTime(), wireID.Plane, wireID.TPC, wireID.Cryostat);
648  m_w = this->GetUVW(wireID);
649 
650  m_pReco2D->Fill();
651  }
652  }
653 
654  //------------------------------------------------------------------------------------------------------------------------------------------
655 
657  {
658 
659  // Create dummy entry if there are no wires
660  if (wireVector.empty()) { m_pRecoWire->Fill(); }
661 
662  // Need DetectorProperties service to convert from ticks to X
663  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
664 
665  // Loop over wires
666  int signalCounter(0);
667 
668  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
669  for (unsigned int i = 0; i < wireVector.size(); ++i) {
670  const art::Ptr<recob::Wire> wire = wireVector.at(i);
671 
672  const std::vector<float>& signals(wire->Signal());
673  const std::vector<geo::WireID> wireIds = wireReadoutGeom.ChannelToWire(wire->Channel());
674 
675  if ((signalCounter++) < 10 && m_printDebug)
676  std::cout << " numWires=" << wireVector.size() << " numSignals=" << signals.size()
677  << std::endl;
678 
679  double time(0.0);
680 
681  m_q = 0.0;
682 
683  for (std::vector<float>::const_iterator tIter = signals.begin(), tIterEnd = signals.end();
684  tIter != tIterEnd;
685  ++tIter) {
686  time += 1.0;
687  m_q = *tIter;
688 
689  if (m_q < 2.0) // seems to remove most noise
690  continue;
691 
692  for (std::vector<geo::WireID>::const_iterator wIter = wireIds.begin(),
693  wIterEnd = wireIds.end();
694  wIter != wIterEnd;
695  ++wIter) {
696  const geo::WireID& wireID = *wIter;
697  m_cstat = wireID.Cryostat;
698  m_tpc = wireID.TPC;
699  m_plane = wireID.Plane;
700  m_wire = wireID.Wire;
701 
702  m_x = detProp.ConvertTicksToX(time, wireID.Plane, wireID.TPC, wireID.Cryostat);
703  m_w = this->GetUVW(wireID);
704 
705  m_pRecoWire->Fill();
706  }
707  }
708  }
709  }
710 
711  //------------------------------------------------------------------------------------------------------------------------------------------
712 
713  double PFParticleHitDumper::GetUVW(const geo::WireID& wireID) const
714  {
715  // define UVW as closest distance from (0,0) to wire axis
716  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
717 
718  auto const xyzStart = wireReadoutGeom.Wire(wireID).GetStart();
719  const double ay(xyzStart.Y());
720  const double az(xyzStart.Z());
721 
722  auto const xyzEnd = wireReadoutGeom.Wire(wireID).GetEnd();
723  const double by(xyzEnd.Y());
724  const double bz(xyzEnd.Z());
725 
726  const double ny(by - ay);
727  const double nz(bz - az);
728  const double N2(ny * ny + nz * nz);
729 
730  const double ry(ay - (ay * ny + az * nz) * ny / N2);
731  const double rz(az - (ay * ny + az * nz) * nz / N2);
732  const double sign((rz > 0.0) ? +1.0 : -1.0);
733 
734  return sign * std::sqrt(ry * ry + rz * rz);
735  }
736 
737  //------------------------------------------------------------------------------------------------------------------------------------------
738 
739  double PFParticleHitDumper::YZtoU(const unsigned int cstat,
740  const unsigned int tpc,
741  const double y,
742  const double z) const
743  {
744  // TODO: Check that this stills works in DUNE
745  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
746  const double m_theta(wireReadoutGeom.WireAngleToVertical(geo::kU, geo::TPCID{cstat, tpc}));
747  return z * std::sin(m_theta) - y * std::cos(m_theta);
748  }
749 
750  //------------------------------------------------------------------------------------------------------------------------------------------
751 
752  double PFParticleHitDumper::YZtoV(const unsigned int cstat,
753  const unsigned int tpc,
754  const double y,
755  const double z) const
756  {
757  // TODO; Check that this still works in DUNE
758  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
759  const double m_theta(wireReadoutGeom.WireAngleToVertical(geo::kV, geo::TPCID{cstat, tpc}));
760  return z * std::sin(m_theta) - y * std::cos(m_theta);
761  }
762 
763  //------------------------------------------------------------------------------------------------------------------------------------------
764 
765 } //namespace lar_pandora
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
void FillReco2D(const art::Event &event, const HitVector &hitVector, const HitsToPFParticles &hitsToParticles)
Store 2D hits.
double YZtoU(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to U coordinate.
Encapsulate the construction of a single cyostat .
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
Planes which measure V.
Definition: geo_types.h:132
Declaration of signal hit object.
double YZtoV(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to V coordinate.
Float_t y
Definition: compare.C:6
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
Definition: Track.h:160
Double_t z
Definition: plot.C:276
static void CollectWires(const art::Event &evt, const std::string &label, WireVector &wireVector)
Collect the reconstructed wires from the ART event record.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:195
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:79
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:254
std::vector< art::Ptr< recob::Shower > > ShowerVector
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
intermediate_table::const_iterator const_iterator
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:290
void FillRecoWires(const art::Event &event, const WireVector &wireVector)
Store raw data.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
Particle class.
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
double GetUVW(const geo::WireID &wireID) const
Conversion from wire ID to U/V/W coordinate.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
void FillAssociated2DHits(const art::Event &evt, const PFParticleVector &particleVector, const PFParticlesToHits &particlesToHits, const PFParticlesToHits &particlesToHitsClusters, const PFParticlesToTracks &particlesToTracks, const TracksToHits &tracksToHits, const PFParticlesToShowers &particlesToShowers, const ShowersToHits &showersToHits)
Store number of 2D hits associated to PFParticle in different ways.
Planes which measure U.
Definition: geo_types.h:131
bool m_printDebug
switch for print statements (TODO: use message service!)
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:223
void reconfigure(fhicl::ParameterSet const &pset)
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
size_t Parent() const
Definition: PFParticle.h:92
PFParticleHitDumper(fhicl::ParameterSet const &pset)
Constructor.
std::map< art::Ptr< recob::Shower >, HitVector > ShowersToHits
static void CollectShowers(const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
Collect the reconstructed PFParticles and associated Showers from the ART event record.
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
void FillReco3D(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits)
Store 3D hits.
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
const Double32_t * XYZ() const
Definition: SpacePoint.h:78
std::vector< art::Ptr< recob::Track > > TrackVector
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:373
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
Declaration of cluster object.
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
Definition of data types for geometry description.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
Detector simulation of raw signals on wires.
std::vector< float > Signal() const
Return a zero-padded full length vector filled with RoI signal.
Definition: Wire.cxx:30
void FillRecoTracks(const PFParticlesToTracks &particlesToTracks)
Store 3D track hits.
int sign(double val)
Definition: UtilFunc.cxx:104
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:226
std::vector< art::Ptr< recob::Hit > > HitVector
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane .
Provides recob::Track data product.
std::vector< art::Ptr< recob::Wire > > WireVector
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: MVAAlg.h:12
EventNumber_t event() const
Definition: EventID.h:116
Declaration of basic channel signal object.
TCEvent evt
Definition: DataStructs.cxx:8
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:315
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.cc:29
Float_t track
Definition: plot.C:35
helper function for LArPandoraInterface producer module
EventID id() const
Definition: Event.cc:23
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.
Encapsulate the construction of a single detector plane .