Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_pandora::PFParticleHitDumper Class Reference

PFParticleHitDumper class. More...

Inheritance diagram for lar_pandora::PFParticleHitDumper:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 PFParticleHitDumper (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~PFParticleHitDumper ()
 Destructor. More...
 
void beginJob ()
 
void endJob ()
 
void analyze (const art::Event &evt)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void FillRecoTracks (const PFParticlesToTracks &particlesToTracks)
 Store 3D track hits. More...
 
void FillReco3D (const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits)
 Store 3D hits. More...
 
void FillReco2D (const art::Event &event, const HitVector &hitVector, const HitsToPFParticles &hitsToParticles)
 Store 2D hits. More...
 
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. More...
 
void FillRecoWires (const art::Event &event, const WireVector &wireVector)
 Store raw data. More...
 
double GetUVW (const geo::WireID &wireID) const
 Conversion from wire ID to U/V/W coordinate. More...
 
double YZtoU (const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
 Convert from (Y,Z) to U coordinate. More...
 
double YZtoV (const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
 Convert from (Y,Z) to V coordinate. More...
 

Private Attributes

TTree * m_pRecoTracks
 
TTree * m_pReco3D
 
TTree * m_pReco2D
 
TTree * m_pRecoComparison
 
TTree * m_pRecoWire
 
int m_run
 
int m_event
 
int m_particle
 
int m_primary
 
int m_pdgcode
 
int m_cstat
 
int m_tpc
 
int m_plane
 
int m_wire
 
double m_u
 
double m_v
 
double m_w
 
double m_x
 
double m_y
 
double m_z
 
double m_q
 
int m_hitsFromSpacePoints
 
int m_hitsFromClusters
 
int m_hitsFromTrackOrShower
 
std::string m_calwireLabel
 
std::string m_hitfinderLabel
 
std::string m_clusterLabel
 
std::string m_spacepointLabel
 
std::string m_particleLabel
 
std::string m_trackLabel
 
std::string m_showerLabel
 
bool m_storeWires
 
bool m_printDebug
 switch for print statements (TODO: use message service!) More...
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

PFParticleHitDumper class.

Definition at line 26 of file PFParticleHitDumper_module.cc.

Constructor & Destructor Documentation

lar_pandora::PFParticleHitDumper::PFParticleHitDumper ( fhicl::ParameterSet const &  pset)

Constructor.

Parameters
pset

Definition at line 209 of file PFParticleHitDumper_module.cc.

209  : art::EDAnalyzer(pset)
210  {
211  this->reconfigure(pset);
212  }
void reconfigure(fhicl::ParameterSet const &pset)
lar_pandora::PFParticleHitDumper::~PFParticleHitDumper ( )
virtual

Destructor.

Definition at line 216 of file PFParticleHitDumper_module.cc.

216 {}

Member Function Documentation

void lar_pandora::PFParticleHitDumper::analyze ( const art::Event evt)

Definition at line 312 of file PFParticleHitDumper_module.cc.

313  {
314  if (m_printDebug) std::cout << " *** PFParticleHitDumper::analyze(...) *** " << std::endl;
315 
316  m_run = evt.run();
317  m_event = evt.id().event();
318 
319  m_particle = -1;
320  m_primary = 0;
321  m_pdgcode = 0;
322 
323  m_cstat = 0;
324  m_tpc = 0;
325  m_plane = 0;
326  m_wire = 0;
327 
328  m_x = 0.0;
329  m_y = 0.0;
330  m_u = 0.0;
331  m_v = 0.0;
332  m_z = 0.0;
333  m_w = 0.0;
334  m_q = 0.0;
335 
336  if (m_printDebug) {
337  std::cout << " Run: " << m_run << std::endl;
338  std::cout << " Event: " << m_event << std::endl;
339  }
340 
341  // Need geometry service to convert channel to wire ID
343 
344  // Get particles, tracks, space points, hits (and wires)
345  // ====================================================
346  TrackVector trackVector, trackVectorExtra;
347  ShowerVector showerVector, showerVectorExtra;
348  PFParticleVector particleVector;
349  SpacePointVector spacePointVector;
350  HitVector hitVector;
351  WireVector wireVector;
352 
353  PFParticlesToTracks particlesToTracks;
354  PFParticlesToShowers particlesToShowers;
355  PFParticlesToSpacePoints particlesToSpacePoints;
356  PFParticlesToHits particlesToHits, particlesToHitsClusters;
357  TracksToHits tracksToHits;
358  ShowersToHits showersToHits;
359  HitsToPFParticles hitsToParticles, hitsToParticlesClusters;
360  SpacePointsToHits spacePointsToHits;
361 
364  evt, m_spacepointLabel, spacePointVector, spacePointsToHits);
365  LArPandoraHelper::CollectTracks(evt, m_trackLabel, trackVector, particlesToTracks);
366  LArPandoraHelper::CollectTracks(evt, m_trackLabel, trackVectorExtra, tracksToHits);
367  LArPandoraHelper::CollectShowers(evt, m_showerLabel, showerVector, particlesToShowers);
368  LArPandoraHelper::CollectShowers(evt, m_showerLabel, showerVectorExtra, showersToHits);
370  evt, m_particleLabel, particleVector, particlesToSpacePoints);
374  particlesToHits,
375  hitsToParticles,
376  LArPandoraHelper::DaughterMode::kUseDaughters,
377  false);
379  evt, m_particleLabel, m_clusterLabel, particlesToHitsClusters, hitsToParticlesClusters);
380 
382 
383  if (m_printDebug) std::cout << " PFParticles: " << particleVector.size() << std::endl;
384 
385  // Loop over Tracks (Fill 3D Track Tree)
386  // =====================================
387  if (m_printDebug) std::cout << " PFParticleHitDumper::FillRecoTracks(...) " << std::endl;
388  this->FillRecoTracks(particlesToTracks);
389 
390  // Loop over PFParticles (Fill 3D Reco Tree)
391  // =========================================
392  if (m_printDebug) std::cout << " PFParticleHitDumper::FillReco3D(...) " << std::endl;
393  this->FillReco3D(particleVector, particlesToSpacePoints, spacePointsToHits);
394 
395  // Loop over Hits (Fill 2D Reco Tree)
396  // ==================================
397  if (m_printDebug) std::cout << " PFParticleHitDumper::FillReco2D(...) " << std::endl;
398  this->FillReco2D(evt, hitVector, hitsToParticles);
399 
400  // Loop over Hits (Fill Associated 2D Hits Tree)
401  // =============================================
402  if (m_printDebug)
403  std::cout << " PFParticleHitDumper::FillAssociated2DHits(...) " << std::endl;
404  this->FillAssociated2DHits(evt,
405  particleVector,
406  particlesToHits,
407  particlesToHitsClusters,
408  particlesToTracks,
409  tracksToHits,
410  particlesToShowers,
411  showersToHits);
412 
413  // Loop over Wires (Fill Reco Wire Tree)
414  // =====================================
415  if (m_printDebug) std::cout << " PFParticleHitDumper::FillRecoWires(...) " << std::endl;
416  this->FillRecoWires(evt, wireVector);
417  }
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.
static void CollectWires(const art::Event &evt, const std::string &label, WireVector &wireVector)
Collect the reconstructed wires from the ART event record.
std::vector< art::Ptr< recob::Shower > > ShowerVector
void FillRecoWires(const art::Event &event, const WireVector &wireVector)
Store raw data.
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
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.
bool m_printDebug
switch for print statements (TODO: use message service!)
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
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.
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.
std::vector< art::Ptr< recob::Track > > TrackVector
RunNumber_t run() const
Definition: DataViewImpl.cc:71
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
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.
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.
void FillRecoTracks(const PFParticlesToTracks &particlesToTracks)
Store 3D track hits.
std::vector< art::Ptr< recob::Hit > > HitVector
std::vector< art::Ptr< recob::Wire > > WireVector
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
EventNumber_t event() const
Definition: EventID.h:116
EventID id() const
Definition: Event.cc:34
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleHitDumper::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 237 of file PFParticleHitDumper_module.cc.

238  {
239  mf::LogDebug("LArPandora") << " *** PFParticleHitDumper::beginJob() *** " << std::endl;
240 
241  //
243 
244  m_pRecoTracks = tfs->make<TTree>("pandoraTracks", "LAr Reco Tracks");
245  m_pRecoTracks->Branch("run", &m_run, "run/I");
246  m_pRecoTracks->Branch("event", &m_event, "event/I");
247  m_pRecoTracks->Branch("particle", &m_particle, "particle/I");
248  m_pRecoTracks->Branch("x", &m_x, "x/D");
249  m_pRecoTracks->Branch("y", &m_y, "y/D");
250  m_pRecoTracks->Branch("z", &m_z, "z/D");
251 
252  m_pReco3D = tfs->make<TTree>("pandora3D", "LAr Reco 3D");
253  m_pReco3D->Branch("run", &m_run, "run/I");
254  m_pReco3D->Branch("event", &m_event, "event/I");
255  m_pReco3D->Branch("particle", &m_particle, "particle/I");
256  m_pReco3D->Branch("primary", &m_primary, "primary/I");
257  m_pReco3D->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
258  m_pReco3D->Branch("cstat", &m_cstat, "cstat/I");
259  m_pReco3D->Branch("tpc", &m_tpc, "tpc/I");
260  m_pReco3D->Branch("plane", &m_plane, "plane/I");
261  m_pReco3D->Branch("x", &m_x, "x/D");
262  m_pReco3D->Branch("y", &m_y, "y/D");
263  m_pReco3D->Branch("u", &m_u, "u/D");
264  m_pReco3D->Branch("v", &m_v, "v/D");
265  m_pReco3D->Branch("z", &m_z, "z/D");
266 
267  m_pReco2D = tfs->make<TTree>("pandora2D", "LAr Reco 2D");
268  m_pReco2D->Branch("run", &m_run, "run/I");
269  m_pReco2D->Branch("event", &m_event, "event/I");
270  m_pReco2D->Branch("particle", &m_particle, "particle/I");
271  m_pReco2D->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
272  m_pReco2D->Branch("cstat", &m_cstat, "cstat/I");
273  m_pReco2D->Branch("tpc", &m_tpc, "tpc/I");
274  m_pReco2D->Branch("plane", &m_plane, "plane/I");
275  m_pReco2D->Branch("wire", &m_wire, "wire/I");
276  m_pReco2D->Branch("x", &m_x, "x/D");
277  m_pReco2D->Branch("w", &m_w, "w/D");
278  m_pReco2D->Branch("q", &m_q, "q/D");
279 
280  m_pRecoComparison = tfs->make<TTree>("pandora2Dcomparison", "LAr Reco 2D (comparison)");
281  m_pRecoComparison->Branch("run", &m_run, "run/I");
282  m_pRecoComparison->Branch("event", &m_event, "event/I");
283  m_pRecoComparison->Branch("particle", &m_particle, "particle/I");
284  m_pRecoComparison->Branch("pdgcode", &m_pdgcode, "pdgcode/I");
285  m_pRecoComparison->Branch(
286  "hitsFromSpacePoints", &m_hitsFromSpacePoints, "hitsFromSpacePoints/I");
287  m_pRecoComparison->Branch("hitsFromClusters", &m_hitsFromClusters, "hitsFromClusters/I");
288  m_pRecoComparison->Branch(
289  "hitsFromTrackOrShower", &m_hitsFromTrackOrShower, "hitsFromTrackOrShower/I");
290 
291  m_pRecoWire = tfs->make<TTree>("rawdata", "LAr Reco Wires");
292  m_pRecoWire->Branch("run", &m_run, "run/I");
293  m_pRecoWire->Branch("event", &m_event, "event/I");
294  m_pRecoWire->Branch("cstat", &m_cstat, "cstat/I");
295  m_pRecoWire->Branch("tpc", &m_tpc, "tpc/I");
296  m_pRecoWire->Branch("plane", &m_plane, "plane/I");
297  m_pRecoWire->Branch("wire", &m_wire, "wire/I");
298  m_pRecoWire->Branch("x", &m_x, "x/D");
299  m_pRecoWire->Branch("w", &m_w, "w/D");
300  m_pRecoWire->Branch("q", &m_q, "q/D");
301  }
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleHitDumper::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 306 of file PFParticleHitDumper_module.cc.

307  {}
void lar_pandora::PFParticleHitDumper::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 
)
private

Store number of 2D hits associated to PFParticle in different ways.

Parameters
particleVectorthe input vector of PFParticles
particlesToHitsmapping between PFParticles and 2D hits through space points
particlesToHitsClustersmapping between PFParticles and 2D hits through clusters
particlesToTracksmapping between PFParticles and tracks
particlesToShowersmapping between PFParticles and showers

Definition at line 554 of file PFParticleHitDumper_module.cc.

562  {
563  // Create dummy entry if there are no 2D hits
564  if (particleVector.empty()) { m_pRecoComparison->Fill(); }
565 
566  for (unsigned int i = 0; i < particleVector.size(); ++i) {
567  //initialise variables
568  m_particle = -1;
569  m_pdgcode = 0;
571  m_hitsFromClusters = 0;
573 
574  const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
575  m_particle = particle->Self();
576  m_pdgcode = particle->PdgCode();
577 
578  PFParticlesToHits::const_iterator pIter = particlesToHits.find(particle);
579  PFParticlesToHits::const_iterator pIter2 = particlesToHitsClusters.find(particle);
580  if (particlesToHits.end() != pIter) m_hitsFromSpacePoints = pIter->second.size();
581  if (particlesToHitsClusters.end() != pIter2) m_hitsFromClusters = pIter2->second.size();
582 
583  if (m_pdgcode == 13) {
584  PFParticlesToTracks::const_iterator iter = particlesToTracks.find(particle);
585  const art::Ptr<recob::Track> track = *(iter->second.begin());
586 
587  TracksToHits::const_iterator iter2 = tracksToHits.find(track);
588  if (tracksToHits.end() != iter2) {
589  const HitVector& hitVector = iter2->second;
590  m_hitsFromTrackOrShower = hitVector.size();
591  }
592  }
593  else if (m_pdgcode == 11) {
594  PFParticlesToShowers::const_iterator iter = particlesToShowers.find(particle);
595  const art::Ptr<recob::Shower> shower = *(iter->second.begin());
596 
597  ShowersToHits::const_iterator iter2 = showersToHits.find(shower);
598  if (showersToHits.end() != iter2) {
599  const HitVector& hitVector = iter2->second;
600  m_hitsFromTrackOrShower = hitVector.size();
601  }
602  }
603 
604  if (m_printDebug)
605  std::cout << " PFParticle " << m_particle << " (PDG " << m_pdgcode << ") has "
606  << m_hitsFromSpacePoints << " hits from space points and " << m_hitsFromClusters
607  << " hits from clusters, and its recob::Track/Shower has "
608  << m_hitsFromTrackOrShower << " associated hits " << std::endl;
609 
610  m_pRecoComparison->Fill();
611  }
612  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
intermediate_table::const_iterator const_iterator
bool m_printDebug
switch for print statements (TODO: use message service!)
std::vector< art::Ptr< recob::Hit > > HitVector
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleHitDumper::FillReco2D ( const art::Event event,
const HitVector hitVector,
const HitsToPFParticles hitsToParticles 
)
private

Store 2D hits.

Parameters
hitVectorthe input vector of 2D hits
hitsToParticlesmapping between 2D hits and PFParticles

Definition at line 617 of file PFParticleHitDumper_module.cc.

620  {
621  // Initialise variables
622  m_particle = -1;
623  m_pdgcode = 0;
624  m_cstat = 0;
625  m_tpc = 0;
626  m_plane = 0;
627  m_wire = 0;
628  m_x = 0.0;
629  m_w = 0.0;
630  m_q = 0.0;
631 
632  // Create dummy entry if there are no 2D hits
633  if (hitVector.empty()) { m_pReco2D->Fill(); }
634 
635  // Need DetectorProperties service to convert from ticks to X
636  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
637 
638  // Loop over 2D hits
639  for (unsigned int i = 0; i < hitVector.size(); ++i) {
640  const art::Ptr<recob::Hit> hit = hitVector.at(i);
641 
642  m_particle = -1;
643  m_pdgcode = 0;
644 
645  HitsToPFParticles::const_iterator pIter = hitsToParticles.find(hit);
646  if (hitsToParticles.end() != pIter) {
647  const art::Ptr<recob::PFParticle> particle = pIter->second;
648  m_particle = particle->Self();
649  m_pdgcode = particle->PdgCode();
650  }
651 
652  const geo::WireID& wireID(hit->WireID());
653  m_cstat = wireID.Cryostat;
654  m_tpc = wireID.TPC;
655  m_plane = wireID.Plane;
656  m_wire = wireID.Wire;
657 
658  m_q = hit->Integral();
659  m_x = detProp.ConvertTicksToX(hit->PeakTime(), wireID.Plane, wireID.TPC, wireID.Cryostat);
660  m_w = this->GetUVW(wireID);
661 
662  m_pReco2D->Fill();
663  }
664  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
geo::WireID WireID() const
Definition: Hit.h:233
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
intermediate_table::const_iterator const_iterator
double GetUVW(const geo::WireID &wireID) const
Conversion from wire ID to U/V/W coordinate.
const double e
Detector simulation of raw signals on wires.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
void lar_pandora::PFParticleHitDumper::FillReco3D ( const PFParticleVector particleVector,
const PFParticlesToSpacePoints particlesToSpacePoints,
const SpacePointsToHits spacePointsToHits 
)
private

Store 3D hits.

Parameters
particleVectorthe input vector of PFParticles
particlesToSpacePointsmapping between 3D hits and PFParticles
spacePointsToHitsmapping between 3D hits and 2D hits

Definition at line 468 of file PFParticleHitDumper_module.cc.

471  {
472  // Initialise variables
473  m_particle = -1;
474  m_primary = 0;
475  m_pdgcode = 0;
476  m_cstat = 0;
477  m_tpc = 0;
478  m_plane = 0;
479  m_x = 0.0;
480  m_u = 0.0;
481  m_v = 0.0;
482  m_y = 0.0;
483  m_z = 0.0;
484 
485  // Create dummy entry if there are no particles
486  if (particleVector.empty()) { m_pReco3D->Fill(); }
487 
488  // Store associations between particle and particle ID
489  PFParticleMap theParticleMap;
490 
491  for (unsigned int i = 0; i < particleVector.size(); ++i) {
492  const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
493  theParticleMap[particle->Self()] = particle;
494  }
495 
496  // Loop over particles
497  for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(),
498  iterEnd1 = particlesToSpacePoints.end();
499  iter1 != iterEnd1;
500  ++iter1) {
501  const art::Ptr<recob::PFParticle> particle = iter1->first;
502  const SpacePointVector& spacepoints = iter1->second;
503 
504  m_particle = particle->Self();
505  m_pdgcode = particle->PdgCode();
506  m_primary = 0;
507 
508  if (particle->IsPrimary()) { m_primary = 1; }
509  else {
510  const size_t parentID(particle->Parent());
511  PFParticleMap::const_iterator pIter = theParticleMap.find(parentID);
512  if (theParticleMap.end() == pIter)
513  throw cet::exception("LArPandora")
514  << " PFParticleHitDumper::analyze --- Found particle with ID code";
515 
516  const art::Ptr<recob::PFParticle> particleParent = pIter->second;
517  if (LArPandoraHelper::IsNeutrino(particleParent)) m_primary = 1;
518  }
519 
520  if (m_printDebug)
521  std::cout << " PFPARTICLE [" << m_particle << "] [Primary=" << m_primary << "] ("
522  << spacepoints.size() << " Space Points)" << std::endl;
523 
524  for (unsigned int j = 0; j < spacepoints.size(); ++j) {
525  const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
526 
527  m_x = spacepoint->XYZ()[0];
528  m_y = spacepoint->XYZ()[1];
529  m_z = spacepoint->XYZ()[2];
530 
531  SpacePointsToHits::const_iterator iter2 = spacePointsToHits.find(spacepoint);
532  if (spacePointsToHits.end() == iter2)
533  throw cet::exception("LArPandora")
534  << " PFParticleHitDumper::analyze --- Found space point without associated hit";
535 
536  const art::Ptr<recob::Hit> hit = iter2->second;
537  const geo::WireID& wireID(hit->WireID());
538 
539  m_cstat = wireID.Cryostat;
540  m_tpc = wireID.TPC;
541  m_plane = wireID.Plane;
542 
543  m_u = this->YZtoU(m_cstat, m_tpc, m_y, m_z);
544  m_v = this->YZtoV(m_cstat, m_tpc, m_y, m_z);
545 
546  m_pReco3D->Fill();
547  }
548  }
549  }
double YZtoU(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to U coordinate.
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
geo::WireID WireID() const
Definition: Hit.h:233
double YZtoV(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to V coordinate.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
intermediate_table::const_iterator const_iterator
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
bool m_printDebug
switch for print statements (TODO: use message service!)
size_t Parent() const
Definition: PFParticle.h:96
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
Detector simulation of raw signals on wires.
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleHitDumper::FillRecoTracks ( const PFParticlesToTracks particlesToTracks)
private

Store 3D track hits.

Parameters
particlesToTracksmapping between 3D track hits and PFParticles

Definition at line 422 of file PFParticleHitDumper_module.cc.

423  {
424  // Initialise variables
425  m_particle = -1;
426  m_x = 0.0;
427  m_y = 0.0;
428  m_z = 0.0;
429 
430  // Create dummy entry if there are no particles
431  if (particlesToTracks.empty()) { m_pRecoTracks->Fill(); }
432 
433  // Loop over tracks
434  for (PFParticlesToTracks::const_iterator iter = particlesToTracks.begin(),
435  iterEnd = particlesToTracks.end();
436  iter != iterEnd;
437  ++iter) {
438  const art::Ptr<recob::PFParticle> particle = iter->first;
439  const TrackVector& trackVector = iter->second;
440 
441  m_particle = particle->Self();
442 
443  if (!trackVector.empty()) {
444  if (trackVector.size() != 1 && m_printDebug)
445  std::cout << " Warning: Found particle with more than one associated track " << std::endl;
446 
447  const art::Ptr<recob::Track> track = *(trackVector.begin());
448 
449  if (m_printDebug)
450  std::cout << " PFPARTICLE [" << m_particle << "] (" << track->NumberTrajectoryPoints()
451  << " Trajectory Points)" << std::endl;
452 
453  for (unsigned int p = 0; p < track->NumberTrajectoryPoints(); ++p) {
454  const auto position(track->LocationAtPoint(p));
455  m_x = position.x();
456  m_y = position.y();
457  m_z = position.z();
458 
459  m_pRecoTracks->Fill();
460  }
461  }
462  }
463  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
Point_t const & LocationAtPoint(size_t i) const
Definition: Track.h:126
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102
intermediate_table::const_iterator const_iterator
bool m_printDebug
switch for print statements (TODO: use message service!)
p
Definition: test.py:223
std::vector< art::Ptr< recob::Track > > TrackVector
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleHitDumper::FillRecoWires ( const art::Event event,
const WireVector wireVector 
)
private

Store raw data.

Parameters
wireVectorthe input vector of reconstructed wires

Definition at line 669 of file PFParticleHitDumper_module.cc.

670  {
671 
672  // Create dummy entry if there are no wires
673  if (wireVector.empty()) { m_pRecoWire->Fill(); }
674 
675  // Need geometry service to convert channel to wire ID
677 
678  // Need DetectorProperties service to convert from ticks to X
679  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
680 
681  // Loop over wires
682  int signalCounter(0);
683 
684  for (unsigned int i = 0; i < wireVector.size(); ++i) {
685  const art::Ptr<recob::Wire> wire = wireVector.at(i);
686 
687  const std::vector<float>& signals(wire->Signal());
688  const std::vector<geo::WireID> wireIds = theGeometry->ChannelToWire(wire->Channel());
689 
690  if ((signalCounter++) < 10 && m_printDebug)
691  std::cout << " numWires=" << wireVector.size() << " numSignals=" << signals.size()
692  << std::endl;
693 
694  double time(0.0);
695 
696  m_q = 0.0;
697 
698  for (std::vector<float>::const_iterator tIter = signals.begin(), tIterEnd = signals.end();
699  tIter != tIterEnd;
700  ++tIter) {
701  time += 1.0;
702  m_q = *tIter;
703 
704  if (m_q < 2.0) // seems to remove most noise
705  continue;
706 
707  for (std::vector<geo::WireID>::const_iterator wIter = wireIds.begin(),
708  wIterEnd = wireIds.end();
709  wIter != wIterEnd;
710  ++wIter) {
711  const geo::WireID& wireID = *wIter;
712  m_cstat = wireID.Cryostat;
713  m_tpc = wireID.TPC;
714  m_plane = wireID.Plane;
715  m_wire = wireID.Wire;
716 
717  m_x = detProp.ConvertTicksToX(time, wireID.Plane, wireID.TPC, wireID.Cryostat);
718  m_w = this->GetUVW(wireID);
719 
720  m_pRecoWire->Fill();
721  }
722  }
723  }
724  }
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
intermediate_table::const_iterator const_iterator
double GetUVW(const geo::WireID &wireID) const
Conversion from wire ID to U/V/W coordinate.
bool m_printDebug
switch for print statements (TODO: use message service!)
const double e
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:231
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
std::vector< float > Signal() const
Return a zero-padded full length vector filled with RoI signal.
Definition: Wire.cxx:47
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
QTextStream & endl(QTextStream &s)
double lar_pandora::PFParticleHitDumper::GetUVW ( const geo::WireID wireID) const
private

Conversion from wire ID to U/V/W coordinate.

Parameters
wireIDthe input wire ID

Definition at line 729 of file PFParticleHitDumper_module.cc.

730  {
731  // define UVW as closest distance from (0,0) to wire axis
733 
734  double xyzStart[3];
735  theGeometry->Cryostat(wireID.Cryostat)
736  .TPC(wireID.TPC)
737  .Plane(wireID.Plane)
738  .Wire(wireID.Wire)
739  .GetStart(xyzStart);
740  const double ay(xyzStart[1]);
741  const double az(xyzStart[2]);
742 
743  double xyzEnd[3];
744  theGeometry->Cryostat(wireID.Cryostat)
745  .TPC(wireID.TPC)
746  .Plane(wireID.Plane)
747  .Wire(wireID.Wire)
748  .GetEnd(xyzEnd);
749  const double by(xyzEnd[1]);
750  const double bz(xyzEnd[2]);
751 
752  const double ny(by - ay);
753  const double nz(bz - az);
754  const double N2(ny * ny + nz * nz);
755 
756  const double ry(ay - (ay * ny + az * nz) * ny / N2);
757  const double rz(az - (ay * ny + az * nz) * nz / N2);
758  const double sign((rz > 0.0) ? +1.0 : -1.0);
759 
760  return sign * std::sqrt(ry * ry + rz * rz);
761  }
void GetStart(double *xyz) const
Definition: WireGeo.h:157
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:506
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
int sign(double val)
Definition: UtilFunc.cxx:104
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
void GetEnd(double *xyz) const
Definition: WireGeo.h:163
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
void lar_pandora::PFParticleHitDumper::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 221 of file PFParticleHitDumper_module.cc.

222  {
223  m_storeWires = pset.get<bool>("StoreWires", false);
224  m_trackLabel = pset.get<std::string>("TrackModule", "pandoraTrack");
225  m_showerLabel = pset.get<std::string>("ShowerModule", "pandoraShower");
226  m_particleLabel = pset.get<std::string>("PFParticleModule", "pandora");
227  m_spacepointLabel = pset.get<std::string>("SpacePointModule", "pandora");
228  m_clusterLabel = pset.get<std::string>("ClusterModule", "pandora");
229  m_hitfinderLabel = pset.get<std::string>("HitFinderModule", "gaushit");
230  m_calwireLabel = pset.get<std::string>("CalWireModule", "caldata");
231  m_printDebug = pset.get<bool>("PrintDebug", false);
232  }
std::string string
Definition: nybbler.cc:12
bool m_printDebug
switch for print statements (TODO: use message service!)
double lar_pandora::PFParticleHitDumper::YZtoU ( const unsigned int  cstat,
const unsigned int  tpc,
const double  y,
const double  z 
) const
private

Convert from (Y,Z) to U coordinate.

Parameters
cstatthe cryostat
tpcthe tpc
ythe y coordinate
zthe z coordinate

Definition at line 766 of file PFParticleHitDumper_module.cc.

770  {
771  // TODO: Check that this stills works in DUNE
773  const double m_theta(theGeometry->WireAngleToVertical(geo::kU, tpc, cstat));
774  return z * std::sin(m_theta) - y * std::cos(m_theta);
775  }
Planes which measure U.
Definition: geo_types.h:129
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
double lar_pandora::PFParticleHitDumper::YZtoV ( const unsigned int  cstat,
const unsigned int  tpc,
const double  y,
const double  z 
) const
private

Convert from (Y,Z) to V coordinate.

Parameters
cstatthe crystat
tpcthe tpc
ythe y coordinate
zthe z coordinate

Definition at line 780 of file PFParticleHitDumper_module.cc.

784  {
785  // TODO; Check that this still works in DUNE
787  const double m_theta(theGeometry->WireAngleToVertical(geo::kV, tpc, cstat));
788  return z * std::sin(m_theta) - y * std::cos(m_theta);
789  }
Planes which measure V.
Definition: geo_types.h:130
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.

Member Data Documentation

std::string lar_pandora::PFParticleHitDumper::m_calwireLabel
private

Definition at line 161 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_clusterLabel
private

Definition at line 163 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_cstat
private

Definition at line 144 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_event
private

Definition at line 139 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_hitfinderLabel
private

Definition at line 162 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_hitsFromClusters
private

Definition at line 158 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_hitsFromSpacePoints
private

Definition at line 157 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_hitsFromTrackOrShower
private

Definition at line 159 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_particle
private

Definition at line 140 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_particleLabel
private

Definition at line 165 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_pdgcode
private

Definition at line 142 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_plane
private

Definition at line 146 of file PFParticleHitDumper_module.cc.

TTree* lar_pandora::PFParticleHitDumper::m_pReco2D
private

Definition at line 134 of file PFParticleHitDumper_module.cc.

TTree* lar_pandora::PFParticleHitDumper::m_pReco3D
private

Definition at line 133 of file PFParticleHitDumper_module.cc.

TTree* lar_pandora::PFParticleHitDumper::m_pRecoComparison
private

Definition at line 135 of file PFParticleHitDumper_module.cc.

TTree* lar_pandora::PFParticleHitDumper::m_pRecoTracks
private

Definition at line 132 of file PFParticleHitDumper_module.cc.

TTree* lar_pandora::PFParticleHitDumper::m_pRecoWire
private

Definition at line 136 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_primary
private

Definition at line 141 of file PFParticleHitDumper_module.cc.

bool lar_pandora::PFParticleHitDumper::m_printDebug
private

switch for print statements (TODO: use message service!)

Definition at line 170 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_q
private

Definition at line 155 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_run
private

Definition at line 138 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_showerLabel
private

Definition at line 167 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_spacepointLabel
private

Definition at line 164 of file PFParticleHitDumper_module.cc.

bool lar_pandora::PFParticleHitDumper::m_storeWires
private

Definition at line 169 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_tpc
private

Definition at line 145 of file PFParticleHitDumper_module.cc.

std::string lar_pandora::PFParticleHitDumper::m_trackLabel
private

Definition at line 166 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_u
private

Definition at line 149 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_v
private

Definition at line 150 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_w
private

Definition at line 151 of file PFParticleHitDumper_module.cc.

int lar_pandora::PFParticleHitDumper::m_wire
private

Definition at line 147 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_x
private

Definition at line 152 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_y
private

Definition at line 153 of file PFParticleHitDumper_module.cc.

double lar_pandora::PFParticleHitDumper::m_z
private

Definition at line 154 of file PFParticleHitDumper_module.cc.


The documentation for this class was generated from the following file: