CbmRoot
CbmClusteringSL.cxx
Go to the documentation of this file.
1 /*
2  * CbmClusteringSL.cxx
3  *
4  * Created on: Apr 10, 2012
5  * Author: kozlov
6  */
7 
8 #include "CbmClusteringSL.h"
10 #include "CbmMCTrack.h"
11 #include "CbmMuchDigi.h"
12 #include "CbmMuchGeoScheme.h"
13 #include "CbmMuchLayerSide.h"
14 #include "CbmMuchModuleGem.h"
15 #include "CbmMuchPad.h"
16 #include "CbmMuchPixelHit.h"
17 #include "CbmMuchPoint.h"
18 #include "CbmStsHit.h"
19 #include "CbmStsPoint.h"
20 
21 #include "FairRootManager.h"
22 
23 #include "TClonesArray.h"
24 
25 #include <cassert>
26 #include <iostream>
27 
28 using std::cout;
29 using std::endl;
30 
32  : fS(NULL), fNumbersOfPads(NULL), fA1(NULL), fClusters(NULL) {
33  fNofPads = 0;
34  fNofActivePads = 0;
35  fNofClusters = 0;
36 }
37 
39  : fS(NULL), fNumbersOfPads(NULL), fA1(NULL), fClusters(NULL) {
40  //Initialization
41  fNofPads = moduleGeo->GetNPads();
42  fNofActivePads = moduleGeo->GetAPadsNom();
44  fA1 = new UInt_t[fNofPads];
45  fS = new Bool_t[fNofPads];
47  fNumbersOfPads = new Int_t[fNofPads];
48  Int_t nom = 0;
49  for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
50  fA1[iPad] =
51  moduleGeo->GetPadCharge(iPad); //Filling primary array of charges
52  fS[iPad] = 0;
53  fNumbersOfPads[iPad] = 0;
54  if (fA1[iPad] > 0) {
55  fS[iPad] = 1; //Filling array of states
56  nom++;
57  fNumbersOfPads[iPad] = nom; //Filling array of relations Pad/Cluster
58  }
59  }
60 }
61 
63  delete[] fA1;
64  delete[] fS;
65  delete[] fNumbersOfPads;
66  delete[] fClusters;
67 }
68 
70  Int_t activePad) {
71  for (Int_t iPad = 0; iPad < moduleGeo->GetNeighborsNum(activePad); iPad++) {
72  if (fS[moduleGeo->GetNeighbor(activePad, iPad)] == 1) {
73  fNumbersOfPads[moduleGeo->GetNeighbor(activePad, iPad)] =
74  fNumbersOfPads[activePad];
75  fS[moduleGeo->GetNeighbor(activePad, iPad)] = 0;
76  SLRec1(moduleGeo, moduleGeo->GetNeighbor(activePad, iPad));
77  }
78  }
79 }
80 
82  Int_t activePad) {
83  for (Int_t iPad = 0; iPad < moduleGeo->GetGoodNeighborsNum(activePad);
84  iPad++) {
85  if (fS[moduleGeo->GetNeighbor(activePad, iPad)] == 1) {
86  fNumbersOfPads[moduleGeo->GetNeighbor(activePad, iPad)] =
87  fNumbersOfPads[activePad];
88  fS[moduleGeo->GetNeighbor(activePad, iPad)] = 0;
89  SLRec2(moduleGeo, moduleGeo->GetNeighbor(activePad, iPad));
90  }
91  }
92 }
93 
95  Int_t algVersion) {
96  //algVersion == 1 -> all neighbors
97  //algVersion == 2 -> only good neighbors
98  //First step of clustering algorithm: Creating relationships between objects
99  for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
100  if ((fA1[iPad] > 0) && (fS[iPad] == 1)) {
101  if (algVersion == 1) { SLRec1(moduleGeo, iPad); }
102  if (algVersion == 2) { SLRec2(moduleGeo, iPad); }
103  if ((algVersion != 1) && (algVersion != 2)) {
104  std::cout << " - CbmClusteringSL: Error! Unsupported version of the "
105  "algorithm.\n";
106  }
107  }
108  }
109  for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
110  if (fA1[iPad] > 0) { fS[iPad] = 1; }
111  }
112  for (Int_t iPad = 0; iPad < fNofActivePads; iPad++) //All clusters are empty
113  {
114  //fClusters[iPad].nofCluster = 0;
115  fClusters[iPad].fNofPads = 0;
116  fClusters[iPad].fCharge = 0;
117  fClusters[iPad].fX = 0;
118  fClusters[iPad].fY = 0;
119  }
120 
121  //Second step of clustering algorithm: Creating clusters by relationships
122  Int_t nomCl = 0;
123  Int_t Replase = 0;
124  for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
125  if ((fA1[iPad] != 0) && (fS[iPad] == 1))
126  //if(activePad1[iPad] != 0)
127  {
128  Replase = fNumbersOfPads[iPad];
129  nomCl++;
130  Int_t padInCluster = 0;
131  for (Int_t nPad = 0; nPad < fNofPads; nPad++) {
132 
133  if ((fNumbersOfPads[nPad] == Replase)
134  && (moduleGeo->GetPadCharge(nPad) > 0) && (fS[nPad] == 1)) {
135  fNumbersOfPads[nPad] = nomCl;
136  fS[nPad] = 0;
137  //Filling clusters
138  fClusters[nomCl - 1].fX +=
139  (moduleGeo->GetX0(nPad) * moduleGeo->GetPadCharge(nPad));
140  fClusters[nomCl - 1].fY +=
141  (moduleGeo->GetY0(nPad) * moduleGeo->GetPadCharge(nPad));
142  fClusters[nomCl - 1].fCharge += moduleGeo->GetPadCharge(nPad);
143  fClusters[nomCl - 1].fPadsInCluster.push_back(
144  moduleGeo->GetDigiNum(nPad));
145  padInCluster++;
146  fClusters[nomCl - 1].fNofPads = padInCluster;
147  }
148  }
149  }
150  }
151  //Hits calculation
152  for (Int_t iCl = 0; iCl < nomCl; iCl++) {
153  if (fClusters[iCl].fCharge == 0) {
154  cout << " - MainClusteringA1: Warning! DIVISION ON ZERO!";
155  break;
156  }
157  fClusters[iCl].fX = fClusters[iCl].fX / fClusters[iCl].fCharge;
158  fClusters[iCl].fY = fClusters[iCl].fY / fClusters[iCl].fCharge;
159  }
160  fNofClusters = nomCl;
161 }
162 
163 /*Int_t CbmClusteringSL::GetCluster(Int_t iCluster)
164 {
165  return fClusters[iCluster].nofCluster;
166 }*/
167 Float_t CbmClusteringSL::GetX0(Int_t iCluster) {
168  return fClusters[iCluster].fX;
169 }
170 Float_t CbmClusteringSL::GetY0(Int_t iCluster) {
171  return fClusters[iCluster].fY;
172 }
173 UInt_t CbmClusteringSL::GetClCharge(Int_t iCluster) {
174  return fClusters[iCluster].fCharge;
175 }
176 Int_t CbmClusteringSL::GetNofPads(Int_t iCluster) {
177  return fClusters[iCluster].fNofPads;
178 }
179 Int_t CbmClusteringSL::GetPadInCluster(Int_t iCluster, Int_t iPad) {
180  return fClusters[iCluster].fPadsInCluster[iPad];
181 }
CbmMuchLayerSide.h
CbmClusteringSL::GetClCharge
UInt_t GetClCharge(Int_t iCluster)
Definition: CbmClusteringSL.cxx:173
CbmClusteringSL::Cluster
Definition: CbmClusteringSL.h:51
CbmMuchDigi.h
CbmClusteringSL::GetX0
Float_t GetX0(Int_t iCluster)
Definition: CbmClusteringSL.cxx:167
CbmClusteringSL::fNumbersOfPads
Int_t * fNumbersOfPads
Definition: CbmClusteringSL.h:48
CbmClusteringSL::SLRec1
void SLRec1(CbmClusteringGeometry *moduleGeo, Int_t activePad)
Definition: CbmClusteringSL.cxx:69
CbmClusteringGeometry.h
CbmClusteringGeometry::GetX0
Float_t GetX0(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:365
CbmClusteringSL::GetY0
Float_t GetY0(Int_t iCluster)
Definition: CbmClusteringSL.cxx:170
CbmClusteringGeometry::GetGoodNeighborsNum
Int_t GetGoodNeighborsNum(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:385
CbmClusteringGeometry::GetNeighbor
Int_t GetNeighbor(Int_t iPad, Int_t iNeighbor)
Definition: CbmClusteringGeometry.cxx:389
CbmClusteringSL::fNofActivePads
Int_t fNofActivePads
Definition: CbmClusteringSL.h:44
CbmClusteringSL::fA1
UInt_t * fA1
Definition: CbmClusteringSL.h:46
CbmClusteringSL::fNofClusters
Int_t fNofClusters
Definition: CbmClusteringSL.h:50
CbmClusteringSL.h
CbmClusteringSL::GetPadInCluster
Int_t GetPadInCluster(Int_t iCluster, Int_t iPad)
Definition: CbmClusteringSL.cxx:179
CbmClusteringSL::MainClusteringSL
void MainClusteringSL(CbmClusteringGeometry *moduleGeo, Int_t algVersion)
Definition: CbmClusteringSL.cxx:94
CbmClusteringGeometry::GetNeighborsNum
Int_t GetNeighborsNum(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:381
CbmMuchPoint.h
CbmClusteringSL::Cluster::fY
Float_t fY
Definition: CbmClusteringSL.h:54
CbmClusteringGeometry::GetPadCharge
UInt_t GetPadCharge(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:397
CbmClusteringSL::Cluster::fX
Float_t fX
Definition: CbmClusteringSL.h:53
CbmClusteringSL::fClusters
Cluster * fClusters
Definition: CbmClusteringSL.h:59
CbmMuchPad.h
CbmClusteringSL::Cluster::fCharge
UInt_t fCharge
Definition: CbmClusteringSL.h:55
CbmStsPoint.h
CbmMCTrack.h
CbmClusteringGeometry::GetNPads
Int_t GetNPads() const
Definition: CbmClusteringGeometry.h:52
CbmClusteringSL::Cluster::fPadsInCluster
std::vector< Int_t > fPadsInCluster
Definition: CbmClusteringSL.h:57
CbmClusteringGeometry::GetY0
Float_t GetY0(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:371
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
CbmClusteringGeometry::GetDigiNum
Int_t GetDigiNum(Int_t iPad)
Definition: CbmClusteringGeometry.cxx:373
CbmClusteringSL::CbmClusteringSL
CbmClusteringSL()
Definition: CbmClusteringSL.cxx:31
CbmClusteringSL::SLRec2
void SLRec2(CbmClusteringGeometry *moduleGeo, Int_t activePad)
Definition: CbmClusteringSL.cxx:81
CbmClusteringGeometry
Definition: CbmClusteringGeometry.h:17
CbmMuchGeoScheme.h
CbmClusteringSL::fNofPads
Int_t fNofPads
Definition: CbmClusteringSL.h:43
CbmClusteringSL::fS
Bool_t * fS
Definition: CbmClusteringSL.h:47
CbmClusteringGeometry::GetAPadsNom
Int_t GetAPadsNom() const
Definition: CbmClusteringGeometry.h:53
CbmClusteringSL::GetNofPads
Int_t GetNofPads() const
Definition: CbmClusteringSL.h:32
CbmMuchModuleGem.h
CbmClusteringSL::Cluster::fNofPads
Int_t fNofPads
Definition: CbmClusteringSL.h:56
CbmClusteringSL::~CbmClusteringSL
virtual ~CbmClusteringSL()
Definition: CbmClusteringSL.cxx:62
CbmStsHit.h
Data class for a reconstructed hit in the STS.