FairRoot/PandaRoot
PndSdsSimplePixelClusterFinder.cxx
Go to the documentation of this file.
1 // A basic clusterfinder for pixel detectors
3 #include "TMath.h"
4 #include "FairLogger.h"
5 
6 std::vector< std::vector<Int_t> > PndSdsSimplePixelClusterFinder::GetClusters(std::vector<PndSdsDigiPixel> hits)
7 {
8  fHits = hits;
9 // if (fVerbose > 1) Print();
10  std::vector<Int_t> posHits;
11  for (UInt_t i = 0; i < fHits.size(); i++) posHits.push_back(i);
12  std::vector< std::vector< Int_t> > result;
13  Int_t sizeTempHits = posHits.size();
14  //Int_t actHit = 0;
15  while (sizeTempHits != 0){
16  std::vector<Int_t> tempInt;
17  if (fChargeConverter->DigiValueToCharge(fHits[posHits[0]]) == 0){
18  MoveHit(&posHits,0);
19  sizeTempHits = posHits.size();
20  }
21  else {
22  tempInt.push_back(MoveHit(&posHits,0));
23  result.push_back(tempInt);
24  Int_t sizeResultI = (result.end()-1)->size(); // size of last vector in array
25  for (Int_t i = 0; i < sizeResultI; i++){
26  sizeTempHits = posHits.size();
27  for (Int_t j = 0; j < sizeTempHits; j++){
28  if (fChargeConverter->DigiValueToCharge(fHits[posHits[j]]) == 0){
29  MoveHit(&posHits,j);
30  if (fVerbose > 1)
31  std::cout << "Charge too low!" << std::endl;
32  j--;
33  }
34  else{
35  if (fHits[(*(result.end()-1))[i]].GetSensorID() == fHits[posHits[j]].GetSensorID()){
36  if (IsInRange(fHits[(*(result.end()-1))[i]], fHits[posHits[j]])) {
37  (result.end()-1)->push_back(MoveHit(&posHits,j));
38  j--;
39  if (fVerbose > 1)
40  std::cout << "Hit added to cluster: " << result.size()-1 << std::endl;
41  }
42  }
43 
44  }
45  sizeTempHits = posHits.size();
46  }
47  sizeResultI = (result.end()-1)->size();
48  }
49  }
50  }
51  if (fVerbose > 1) PrintResult(result);
52  return result;
53 }
54 
55 Int_t PndSdsSimplePixelClusterFinder::MoveHit(std::vector<Int_t>* hitVector, Int_t index) const
56 {
57  Int_t result = -1;
58  if (index < (Int_t)hitVector->size()){
59  result = (*hitVector)[index];
60  hitVector->erase(hitVector->begin()+index);
61  }
62  return result;
63 }
64 
66 {
67  Double_t result1, result2;
68  Int_t col1 = hit1.GetPixelColumn() + (Int_t)((hit1.GetFE()%10) * fcols);
69  Int_t col2 = hit2.GetPixelColumn() + (Int_t)((hit2.GetFE()%10) * fcols);
70  Int_t row1 = hit1.GetPixelRow() + (Int_t)((hit1.GetFE()/10) * frows);
71  Int_t row2 = hit2.GetPixelRow() + (Int_t)((hit2.GetFE()/10) * frows);
72  if (fVerbose > 2){
73  std::cout <<" -I- PndSdsSimplePixelClusterFinder::IsInRange():"<<std::endl;
74  std::cout << "Hit1: ";
75  hit1.Print();
76  std::cout << "Hit2: ";
77  hit2.Print();
78  std::cout << "col1: " << col1 << " col2: " << col2 << " row1: " << row1 << " row2: " << row2 << std::endl;
79  std::cout << "col1 - col2: " << (col1-col2) << " row1 - row2 " << (row1-row2) << std::endl;
80  }
81  result1 = (col1-col2);
82  result1 *= result1;
83  result2 = (row1-row2);
84  result2 *= result2;
85  result1 += result2;
86  if (fVerbose > 2)
87  std::cout << "IsInRange result: " << TMath::Sqrt(result1) << " Radius " << fradius << std::endl;
88  return (TMath::Sqrt(result1) < fradius);
89 }
Int_t GetPixelRow() const
void PrintResult(std::vector< std::vector< Int_t > > clusters)
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 GetFE() const
Definition: PndSdsDigi.h:57
bool IsInRange(PndSdsDigiPixel hit1, PndSdsDigiPixel hit2) const
virtual Double_t DigiValueToCharge(Double_t digi)=0
Converts a given digitized charge into charge in electrons.
PndSdsChargeConversion * fChargeConverter
std::vector< std::vector< Int_t > > GetClusters(std::vector< PndSdsDigiPixel > hits)
Double_t
std::vector< PndSdsDigiPixel > fHits
Int_t MoveHit(std::vector< Int_t > *hitVector, Int_t index) const
Data class to store the digi output of a pixel module.
CbmHit * hits[nHits]
Definition: RiemannTest.C:19