PandaRoot
PndFtsHoughSpacePeak.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
26 #ifndef PndFtsHoughSpacePeak_H
27 #define PndFtsHoughSpacePeak_H
28 
29 #include "PndFtsHoughTrackerTask.h"
30 
31 // Root Class Headers ----------------
32 #include "PndTrackCand.h"
33 #include "Rtypes.h" // for Double_t, Int_t, etc
34 #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
35 #include <set>
36 
37 class PndFtsHoughSpacePeak : public TObject {
38  public:
39  static const Int_t noVal = -1;
40 
41  // Constructors / Destructors ---------
42  PndFtsHoughSpacePeak(Int_t height = noVal, Int_t firstBin = noVal, Int_t firstHitIdx = noVal);
44 
45  inline void resetBins();
46  inline void replaceBins(Int_t height, Int_t firstBin, Int_t firstHitIdx);
47  inline void addBin(Int_t binNumber, Int_t hitIdx);
48 
49  void setFinished(Bool_t newVal) { fFinished = newVal; };
50 
51  Bool_t isFinished() const { return fFinished; };
52  Int_t getHeight() const { return fHeight; };
53 
54  const std::set<Int_t> &getBins() const { return fBins; };
55  const std::set<Int_t> &getHitIds() const { return fHitIds; };
56 
57  inline Bool_t binsOverlapWith(const PndFtsHoughSpacePeak &toCheck);
58  inline void mergeWith(const PndFtsHoughSpacePeak &toAdd);
59 
60  private:
61  std::set<Int_t> fBins; // globalbins belonging to the peak
62  std::set<Int_t> fHitIds; // hit indices belonging to the peak
63  Int_t fHeight; // height of peak
64  Bool_t fFinished;
65 
66  ClassDef(PndFtsHoughSpacePeak, 1);
67 };
68 
69 void PndFtsHoughSpacePeak::addBin(Int_t binNumber, Int_t hitIdx)
70 {
71  fBins.insert(binNumber);
72  fHitIds.insert(hitIdx);
73 }
74 
75 void PndFtsHoughSpacePeak::replaceBins(Int_t height, Int_t firstBin, Int_t firstHitIdx)
76 {
77  resetBins();
78  addBin(firstBin, firstHitIdx);
79  fHeight = height;
80 }
81 
83 {
84  fBins.clear();
85  fHitIds.clear();
86  fFinished = kFALSE;
87  fHeight = noVal;
88 }
89 
91 {
92  // return kTRUE iif toAdd has bins in common with this
93  const std::set<Int_t> binsToSearch = toCheck.getBins();
94  // try to find elements from toAdd in this
95  for (std::set<Int_t>::iterator it = binsToSearch.begin(); it != binsToSearch.end(); ++it) {
96  std::set<Int_t>::iterator itFind = fBins.find(*it);
97  if (itFind != fBins.end())
98  return kTRUE; // element from binsToSearch was found in this
99  }
100  return kFALSE; // none of the elements from binsToSearch was found in this
101 }
102 
104 {
105  // merge bins
106  const std::set<Int_t> binsToMerge = toAdd.getBins();
107  fBins.insert(binsToMerge.begin(), binsToMerge.end());
108  // merge hit indices
109  const std::set<Int_t> hitsToMerge = toAdd.getHitIds();
110  fHitIds.insert(hitsToMerge.begin(), hitsToMerge.end());
111 }
112 
113 #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