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