EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingFinderHough.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingFinderHough.cxx
1 // --------------------------------------------------------------------------------------
2 // CbmRichRingFinderHough source file
3 // Base class for ring finders based on on HT method
4 // Implementation: Semen Lebedev (s.lebedev@gsi.de)
5 
7 
8 #include "tbb/task_scheduler_init.h"
9 #include "tbb/task.h"
10 #include "tbb/tick_count.h"
11 #include "tbb/parallel_invoke.h"
12 
13 
14 #include <iostream>
15 #include <cmath>
16 #include <set>
17 #include <algorithm>
18 #include <fstream>
19 
20 using std::cout;
21 using std::endl;
22 using std::vector;
23 
24 class FinderTask{
26 public:
28  fHTImpl = HTImpl;
29  }
30  void operator()() const {
31  fHTImpl->DoFind();
32  }
33 };
34 
35 // ----- Standard constructor ------------------------------------------
37 {
38  fRingCount = 0;
39  fNEvent = 0;
40 
42  fHTImpl1->Init();
43 
45  fHTImpl2->Init();
46 
47  tbb::task_scheduler_init init;
48 }
49 
51 {
52  delete fHTImpl1;
53  delete fHTImpl2;
54 }
55 
56 int CbmRichRingFinderHough::DoFind(const vector<CbmRichHoughHit>& data)
57 {
58  fNEvent++;
59  std::vector<CbmRichHoughHit> UpH;
60  std::vector<CbmRichHoughHit> DownH;
61  fRingCount = 0;
62 
63  UpH.reserve(data.size()/2);
64  DownH.reserve(data.size()/2);
65 
66  for(int iHit = 0; iHit < data.size(); iHit++) {
67  CbmRichHoughHit hit = data[iHit];
68  if (hit.fHit.fY >= 0)
69  UpH.push_back(hit);
70  else
71  DownH.push_back(hit);
72  }
73 
74  fHTImpl1->SetData(UpH);
75  fHTImpl1->DoFind();
76  int nofFoundRings = fHTImpl1->GetFoundRings().size();
77  UpH.clear();
78 
79  fHTImpl1->SetData(DownH);
80  fHTImpl1->DoFind();
81  nofFoundRings += fHTImpl1->GetFoundRings().size();
82  DownH.clear();
83 
84  cout << "NofFoundRings = " << nofFoundRings << endl;
85 }
86 
87 int CbmRichRingFinderHough::DoFindParallel(const vector<CbmRichHoughHit>& data)
88 {
89  fNEvent++;
90  std::vector<CbmRichHoughHit> UpH;
91  std::vector<CbmRichHoughHit> DownH;
92  fRingCount = 0;
93 
94  UpH.reserve(data.size()/2);
95  DownH.reserve(data.size()/2);
96 
97  for(int iHit = 0; iHit < data.size(); iHit++) {
98  CbmRichHoughHit hit = data[iHit];
99  if (hit.fHit.fY >= 0)
100  UpH.push_back(hit);
101  else
102  DownH.push_back(hit);
103  }
104 
105  fHTImpl1->SetData(UpH);
106  fHTImpl2->SetData(DownH);
107 
108  //fHTImpl1->DoFind();
109  //fHTImpl2->DoFind();
110 
111  FinderTask a(fHTImpl1);
112  FinderTask b(fHTImpl2);
113  tbb::parallel_invoke(a, b);
114 
115  int nofFoundRings = fHTImpl1->GetFoundRings().size();
116  nofFoundRings += fHTImpl2->GetFoundRings().size();
117 
118  UpH.clear();
119  DownH.clear();
120 
121  cout << "NofFoundRings = " << nofFoundRings << endl;
122 }