FairRoot/PandaRoot
PndFtsHoughSpacePeak.h
Go to the documentation of this file.
1 
15 #ifndef PndFtsHoughSpacePeak_H
16 #define PndFtsHoughSpacePeak_H
17 
18 #include "PndFtsHoughTrackerTask.h"
19 
20 // Root Class Headers ----------------
21 #include "PndTrackCand.h"
22 #include "Rtypes.h" // for Double_t, Int_t, etc
23 #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
24 #include <set>
25 
26 
27 
28 
29 
30 class PndFtsHoughSpacePeak : public TObject {
31 public:
32  static const Int_t noVal = -1;
33 
34  // Constructors / Destructors ---------
35  PndFtsHoughSpacePeak( Int_t height = noVal, Int_t firstBin = noVal, Int_t firstHitIdx = noVal );
37 
38  inline void resetBins();
39  inline void replaceBins( Int_t height, Int_t firstBin, Int_t firstHitIdx );
40  inline void addBin(Int_t binNumber, Int_t hitIdx);
41 
42  void setFinished(Bool_t newVal){ fFinished = newVal; };
43 
44  Bool_t isFinished() const{ return fFinished; };
45  Int_t getHeight() const{ return fHeight; };
46 
47  const std::set<Int_t>& getBins() const { return fBins; };
48  const std::set<Int_t>& getHitIds() const { return fHitIds; };
49 
50  inline Bool_t binsOverlapWith(const PndFtsHoughSpacePeak& toCheck);
51  inline void mergeWith(const PndFtsHoughSpacePeak& toAdd);
52 
53 
54 private:
55  std::set< Int_t > fBins; // globalbins belonging to the peak
56  std::set< Int_t > fHitIds; // hit indices belonging to the peak
57  Int_t fHeight; // height of peak
59 
61 
62 };
63 
64 void PndFtsHoughSpacePeak::addBin(Int_t binNumber, Int_t hitIdx){
65  fBins.insert(binNumber);
66  fHitIds.insert(hitIdx);
67 }
68 
69 void PndFtsHoughSpacePeak::replaceBins( Int_t height, Int_t firstBin, Int_t firstHitIdx ){
70  resetBins();
71  addBin(firstBin, firstHitIdx);
72  fHeight = height;
73 }
74 
75 
77  fBins.clear();
78  fHitIds.clear();
79  fFinished = kFALSE;
80  fHeight = noVal;
81 }
82 
84  // return kTRUE iif toAdd has bins in common with this
85  const std::set< Int_t > binsToSearch = toCheck.getBins();
86  // try to find elements from toAdd in this
87  for (std::set< Int_t >::iterator it = binsToSearch.begin(); it != binsToSearch.end(); ++it){
88  std::set< Int_t >::iterator itFind = fBins.find( *it );
89  if ( itFind != fBins.end() ) return kTRUE; // element from binsToSearch was found in this
90  }
91  return kFALSE; // none of the elements from binsToSearch was found in this
92 }
93 
95  // merge bins
96  const std::set< Int_t > binsToMerge = toAdd.getBins();
97  fBins.insert( binsToMerge.begin(), binsToMerge.end() );
98  // merge hit indices
99  const std::set< Int_t > hitsToMerge = toAdd.getHitIds();
100  fHitIds.insert( hitsToMerge.begin(), hitsToMerge.end() );
101 }
102 
103 #endif
Bool_t isFinished() const
Bool_t binsOverlapWith(const PndFtsHoughSpacePeak &toCheck)
void setFinished(Bool_t newVal)
Class for saving peaks of a Hough space.
PndFtsHoughSpacePeak(Int_t height=noVal, Int_t firstBin=noVal, Int_t firstHitIdx=noVal)
void replaceBins(Int_t height, Int_t firstBin, Int_t firstHitIdx)
void mergeWith(const PndFtsHoughSpacePeak &toAdd)
const std::set< Int_t > & getHitIds() const
std::set< Int_t > fHitIds
static const Int_t noVal
std::set< Int_t > fBins
void addBin(Int_t binNumber, Int_t hitIdx)
ClassDef(PndFtsHoughSpacePeak, 1)
const std::set< Int_t > & getBins() const