FairRoot/PandaRoot
PndSdsIdealPixelClusterFinder.cxx
Go to the documentation of this file.
2 #include "TMath.h"
3 
4 std::vector< std::vector<Int_t> > PndSdsIdealPixelClusterFinder::GetClusters(std::vector<PndSdsDigiPixel>)// hits //[R.K.03/2017] unused variable(s)
5 {
6  if (fVerbose > 1)
7  Print();
8  std::vector<Int_t> posHits; // stores the position of the hits in the TClonesArray (only this information is stored)
9  for (UInt_t i = 0; i < fHits.size(); i++) posHits.push_back(i);
10  std::vector< std::vector< Int_t> > result;
11  Int_t sizeTempHits = posHits.size();
12  // Int_t actHit = 0;
13 
14  while (sizeTempHits != 0){
15  std::vector<Int_t> tempInt;
16  if (fHits[posHits[0]].GetCharge() == 0){ //if the hit has no charge it is deleted out of posHits
17  if (fVerbose > 2){
18  std::cout << "Charge too low for pixel: " << std::endl;
19  fHits[posHits[0]].Print();
20  }
21  MoveHit(&posHits,0);
22  }
23  else {
24  tempInt.push_back(MoveHit(&posHits,0)); //Move the first hit of the remaining hits into the new cluster
25  result.push_back(tempInt);
26 
27  sizeTempHits = posHits.size();
28  for (Int_t j = 0; j < sizeTempHits; j++){
29  if (fHits[posHits[j]].GetCharge() == 0){
30  MoveHit(&posHits,j);
31  if (fVerbose > 2){
32  std::cout << "Charge too low for pixel: " << std::endl;
33  fHits[posHits[0]].Print();
34  }
35  j--;
36  }
37  else{
38  if (fHits[(*(result.end()-1))[0]].GetSensorID() == fHits[posHits[j]].GetSensorID()){
39  if (IsInRange(fHits[(*(result.end()-1))[0] ], fHits[posHits[j]])) {
40  (result.end()-1)->push_back(MoveHit(&posHits,j)); // the hit position is added to the current cluster
41  j--;
42  if (fVerbose > 2)
43  std::cout << "Hit added to cluster: " << result.size()-1 << std::endl;
44  }
45  }
46 
47  }
48  sizeTempHits = posHits.size();
49  }
50  }
51  }
52  if (fVerbose > 1)
53  PrintResult(result);
54  return result;
55 }
56 
57 Int_t PndSdsIdealPixelClusterFinder::MoveHit(std::vector<Int_t>* hitVector, Int_t index) const
58 {
59  Int_t result = -1;
60  if (index < (Int_t)hitVector->size()){
61  result = (*hitVector)[index];
62  hitVector->erase(hitVector->begin()+index);
63  }
64  return result;
65 }
66 
68 {
69  return (hit1.GetIndex(0) == hit2.GetIndex(0)); // two hits are in range if they come from the same MC hit
70 }
void PrintResult(std::vector< std::vector< Int_t > > clusters)
bool IsInRange(PndSdsDigiPixel hit1, PndSdsDigiPixel hit2) const
Int_t i
Definition: run_full.C:25
Int_t GetIndex(int i=0) const
Definition: PndSdsDigi.h:63
labels push_back("electron")
Int_t MoveHit(std::vector< Int_t > *hitVector, Int_t index) const
std::vector< std::vector< Int_t > > GetClusters(std::vector< PndSdsDigiPixel > hits)
std::vector< PndSdsDigiPixel > fHits
Data class to store the digi output of a pixel module.