FairRoot/PandaRoot
PndMvdTopixClusterFinder.cxx
Go to the documentation of this file.
1 // A basic clusterfinder for pixel detectors
3 #include "TMath.h"
4 
5 #include <iostream>
6 
7 #include "FairMQLogger.h"
8 
9 std::vector<std::vector<Int_t> > PndMvdTopixClusterFinder::GetClusters(std::vector<PndSdsDigiTopix4>& hits) {
10 // fHits = hits;
11 
12 // LOG(INFO) << "HitsIn Cluster Finder!" << std::endl;
13  std::vector<Int_t> posHits;
14  for (UInt_t i = 0; i < hits.size(); i++){
15 // LOG(INFO) << i << " : " << hits[i];
16 // LOG(INFO) << i << " : " << hits[i].GetTimeStamp();
17  posHits.push_back(i);
18  }
19  std::vector<std::vector<Int_t> > result;
20  Int_t sizeTempHits = posHits.size();
21  //Int_t actHit = 0;
22  while (sizeTempHits != 0) {
23  std::vector<Int_t> tempInt;
24  tempInt.push_back(MoveHit(&posHits, 0));
25  result.push_back(tempInt);
26  Int_t sizeResultI = (result.end() - 1)->size(); // size of last vector in array
27  for (Int_t i = 0; i < sizeResultI; i++) {
28  sizeTempHits = posHits.size();
29  for (Int_t j = 0; j < sizeTempHits; j++) {
30  if (hits[(*(result.end() - 1))[i]].GetSensorID() == hits[posHits[j]].GetSensorID()) {
31  if (IsInRange(&hits[(*(result.end() - 1))[i]], &hits[posHits[j]])) {
32  (result.end() - 1)->push_back(MoveHit(&posHits, j));
33  j--;
34  }
35  }
36  sizeTempHits = posHits.size();
37  }
38  sizeResultI = (result.end() - 1)->size();
39  }
40  }
41  return result;
42 }
43 
44 Int_t PndMvdTopixClusterFinder::MoveHit(std::vector<Int_t>* hitVector, Int_t index) const
45 {
46  Int_t result = -1;
47  if (index < (Int_t)hitVector->size()){
48  result = (*hitVector)[index];
49  hitVector->erase(hitVector->begin()+index);
50  }
51  return result;
52 }
53 
55 {
56  Double_t result1, result2;
57  Int_t col1 = hit1->GetPixelColumn() + (Int_t)((hit1->GetFE()%10) * fcols);
58  Int_t col2 = hit2->GetPixelColumn() + (Int_t)((hit2->GetFE()%10) * fcols);
59  Int_t row1 = hit1->GetPixelRow() + (Int_t)((hit1->GetFE()/10) * frows);
60  Int_t row2 = hit2->GetPixelRow() + (Int_t)((hit2->GetFE()/10) * frows);
61 
62  result1 = (col1-col2);
63  result1 *= result1;
64  result2 = (row1-row2);
65  result2 *= result2;
66  result1 += result2;
67 
68  return (TMath::Sqrt(result1) < fradius);
69 }
Int_t GetPixelRow() const
Int_t i
Definition: run_full.C:25
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Int_t GetPixelColumn() const
labels push_back("electron")
Int_t MoveHit(std::vector< Int_t > *hitVector, Int_t index) const
Int_t GetFE() const
Definition: PndSdsDigi.h:57
Double_t
std::vector< std::vector< Int_t > > GetClusters(std::vector< PndSdsDigiTopix4 > &hits)
bool IsInRange(PndSdsDigiPixel *hit1, PndSdsDigiPixel *hit2) const
Data class to store the digi output of a pixel module.
CbmHit * hits[nHits]
Definition: RiemannTest.C:19