Public Member Functions | Protected Attributes | List of all members
rb::HitMap Class Reference

Provides efficient lookup of CellHits by plane and cell number. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-09-26/RecoBase/HitMap.h"

Public Member Functions

 HitMap ()
 
 HitMap (const art::PtrVector< rb::CellHit > &chits)
 
 HitMap (const rb::Cluster *clust)
 
 ~HitMap ()
 
void Add (const art::Ptr< rb::CellHit > &chit)
 
void Add (const art::PtrVector< rb::CellHit > &chits)
 
void Add (const rb::Cluster *clust)
 Add all the hits in a cluster, or derived class. More...
 
void Remove (unsigned int planeIdx, unsigned int cellIdx)
 
void Clear ()
 
bool CellExists (unsigned int planeIdx, unsigned int cellIdx) const
 Does the map contain any cell at this position? More...
 
art::Ptr< rb::CellHitCell (unsigned int planeIdx, unsigned int cellIdx) const
 Return the cell at this position. Empty pointer if no match. More...
 
art::Ptr< rb::CellHitoperator() (unsigned int planeIdx, unsigned int cellIdx) const
 Syntactic sugar for Cell. More...
 

Protected Attributes

std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
 

Detailed Description

Provides efficient lookup of CellHits by plane and cell number.

Definition at line 22 of file HitMap.h.

Constructor & Destructor Documentation

rb::HitMap::HitMap ( )

Definition at line 15 of file HitMap.cxx.

16  {
17  }
rb::HitMap::HitMap ( const art::PtrVector< rb::CellHit > &  chits)

Definition at line 20 of file HitMap.cxx.

References Add().

21  {
22  Add(chits);
23  }
void Add(const art::Ptr< rb::CellHit > &chit)
Definition: HitMap.cxx:37
rb::HitMap::HitMap ( const rb::Cluster clust)

Definition at line 26 of file HitMap.cxx.

References Add().

27  {
28  Add(clust);
29  }
void Add(const art::Ptr< rb::CellHit > &chit)
Definition: HitMap.cxx:37
rb::HitMap::~HitMap ( )

Definition at line 32 of file HitMap.cxx.

33  {
34  }

Member Function Documentation

void rb::HitMap::Add ( const art::Ptr< rb::CellHit > &  chit)

Definition at line 37 of file HitMap.cxx.

References rb::CellHit::Cell(), febshutoff_auto::chan, fMap, it, make_pair(), rb::CellHit::PE(), and rb::CellHit::Plane().

Referenced by Add(), dt::Chain::AllHits(), align::Alignment::analyze(), HitMap(), and dt::ViewMerger::MaybeExtendToVertex().

38  {
39  const geo::OfflineChan chan(chit->Plane(), chit->Cell());
40 
41  typedef std::map<geo::OfflineChan, art::Ptr<rb::CellHit> >::iterator it_t;
42  it_t it = fMap.find(chan);
43 
44  if(it == fMap.end()){
45  // If there's no hit on this channel, store this one there
46  fMap.insert(std::make_pair(chan, chit));
47  }
48  else{
49  // If there already was a hit, highest energy wins
50  if(chit->PE() > it->second->PE()){
51  it->second = chit;
52  }
53  else{
54  // Discard this hit
55  }
56  }
57  }
std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
Definition: HitMap.h:52
set< int >::iterator it
unsigned short Plane() const
Definition: CellHit.h:39
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
unsigned short Cell() const
Definition: CellHit.h:40
float PE() const
Definition: CellHit.h:42
A (plane, cell) pair.
Definition: OfflineChan.h:17
void rb::HitMap::Add ( const art::PtrVector< rb::CellHit > &  chits)

Definition at line 60 of file HitMap.cxx.

References Add(), getGoodRuns4SAM::n, and art::PtrVector< T >::size().

61  {
62  const unsigned int N = chits.size();
63  for(unsigned int n = 0; n < N; ++n) Add(chits[n]);
64  }
size_type size() const
Definition: PtrVector.h:308
void Add(const art::Ptr< rb::CellHit > &chit)
Definition: HitMap.cxx:37
void rb::HitMap::Add ( const rb::Cluster clust)

Add all the hits in a cluster, or derived class.

Definition at line 67 of file HitMap.cxx.

References Add(), rb::Cluster::Cell(), compare_h5_caf::idx, and rb::Cluster::NCell().

68  {
69  const int maxIdx = clust->NCell();
70  for(int idx = 0; idx < maxIdx; ++idx)
71  Add(clust->Cell(idx));
72  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
void Add(const art::Ptr< rb::CellHit > &chit)
Definition: HitMap.cxx:37
art::Ptr< rb::CellHit > rb::HitMap::Cell ( unsigned int  planeIdx,
unsigned int  cellIdx 
) const

Return the cell at this position. Empty pointer if no match.

Definition at line 88 of file HitMap.cxx.

References fMap, and it.

Referenced by Clear(), and operator()().

90  {
91  std::map<geo::OfflineChan, art::Ptr<rb::CellHit> >::const_iterator it =
93 
94  if(it == fMap.end()) return art::Ptr<rb::CellHit>();
95 
96  return it->second;
97  }
std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
Definition: HitMap.h:52
set< int >::iterator it
A (plane, cell) pair.
Definition: OfflineChan.h:17
bool rb::HitMap::CellExists ( unsigned int  planeIdx,
unsigned int  cellIdx 
) const

Does the map contain any cell at this position?

Definition at line 81 of file HitMap.cxx.

References fMap.

Referenced by dt::Chain::AllHits(), align::Alignment::analyze(), Clear(), dt::ViewMerger::CountUnexplainedOnLine(), chaninfo::FindSwappedChannels::fill_hist_and_tree(), and dt::DiscreteTracker::MergeParasiteTracks().

83  {
84  return fMap.find(geo::OfflineChan(plane, cell)) != fMap.end();
85  }
std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
Definition: HitMap.h:52
A (plane, cell) pair.
Definition: OfflineChan.h:17
void rb::HitMap::Clear ( )
inline

Definition at line 37 of file HitMap.h.

References Cell(), CellExists(), fMap, and operator()().

37 {fMap.clear();}
std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
Definition: HitMap.h:52
art::Ptr< rb::CellHit > rb::HitMap::operator() ( unsigned int  planeIdx,
unsigned int  cellIdx 
) const

Syntactic sugar for Cell.

Definition at line 100 of file HitMap.cxx.

References Cell().

Referenced by Clear().

102  {
103  return Cell(planeIdx, cellIdx);
104  }
art::Ptr< rb::CellHit > Cell(unsigned int planeIdx, unsigned int cellIdx) const
Return the cell at this position. Empty pointer if no match.
Definition: HitMap.cxx:88
void rb::HitMap::Remove ( unsigned int  planeIdx,
unsigned int  cellIdx 
)

Definition at line 75 of file HitMap.cxx.

References fMap.

76  {
78  }
std::map< geo::OfflineChan, art::Ptr< rb::CellHit > > fMap
Definition: HitMap.h:52
A (plane, cell) pair.
Definition: OfflineChan.h:17

Member Data Documentation

std::map<geo::OfflineChan, art::Ptr<rb::CellHit> > rb::HitMap::fMap
protected

Definition at line 52 of file HitMap.h.

Referenced by Add(), Cell(), CellExists(), Clear(), and Remove().


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