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