CbmRoot
Loading...
Searching...
No Matches
CbmClusteringWard.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2019 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Grigory Kozlov, Andrey Lebedev [committer] */
4
5/*
6 * CbmClusteringWard.cxx
7 *
8 * Created on: Apr 10, 2012
9 * Author: kozlov
10 */
11
12#include "CbmClusteringWard.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
35 : clustersInMethod()
36 , padsInClusters()
37 , fS()
38 , fClustersInBlock()
39 , clustersInMethod_2(0)
40 , wardActivePads()
41 , fClusters()
42 , firstBlockElement()
43 , fModuleGeo()
44 , BLOCK_SIZE()
45 , fNumbersOfPads()
46 , MAX_NEIGHBORS()
47 , listValue()
48{
49 fNofPads = 0;
51 fNofClusters = 0;
52}
53
54CbmClusteringWard::CbmClusteringWard(CbmClusteringGeometry* moduleGeo, Int_t blockSize) : fModuleGeo()
55{
56 MAX_NEIGHBORS = 50;
57 BLOCK_SIZE = blockSize;
58
59 fClusters = new Cluster[5000]; //1000 - temporary value
60
62 for (Int_t iCl = 0; iCl < BLOCK_SIZE; iCl++) {
65 fClustersInBlock[iCl].xc = 0;
66 fClustersInBlock[iCl].yc = 0;
70 for (Int_t iPad = 0; iPad < MAX_NEIGHBORS; iPad++) {
71 fClustersInBlock[iCl].neighbors[iPad] = 0;
72 fClustersInBlock[iCl].wardDistances[iPad] = 0;
73 fClustersInBlock[iCl].S[iPad] = 0;
74 //---!!!---<>
75 //fClustersInBlock[iCl].numbersOfPadsInCluster[j] = 0;
76 }
77 }
78
81 firstBlockElement = 0; //Novii blok na4inaets9 so sleduushego elementa
82 listValue = 0;
83
84 fNofPads = moduleGeo->GetNPads();
85 fNofActivePads = moduleGeo->GetAPadsNom();
87 fS = new Bool_t[fNofPads];
88 fNumbersOfPads = new Int_t[fNofPads]; //---|
89 Int_t nom = 0;
90 padsInClusters = new Int_t[fNofPads]; //---|
91 wardActivePads = new Bool_t[fNofPads];
92
93 for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
94 padsInClusters[iPad] = iPad; //g_ClustersArray[iPad] - ???
95 if (moduleGeo->GetPadCharge(iPad) > 0) {
96 wardActivePads[iPad] = true;
97 }
98 else {
99 wardActivePads[iPad] = false;
100 }
101 }
102
103 for (Int_t iPad = 0; iPad < fNofPads; iPad++) {
104 fS[iPad] = 0;
105 fNumbersOfPads[iPad] = 0;
106 if (moduleGeo->GetPadCharge(iPad) > 0) {
107 fS[iPad] = 1;
108 nom++;
109 fNumbersOfPads[iPad] = nom;
110 }
111 }
112
113 //-----------------------------------
114 /*for(Int_t iPad = 0; iPad < BLOCK_SIZE; iPad++)
115 {
116 if(fClustersInBlock[iPad].clCharge != 0){
117 std::cout<<"Cl: "<<fClustersInBlock[iPad].nofCluster<<"; Charge: "<<fClustersInBlock[iPad].clCharge<<"\n";
118 std::cout<<"activePads: "<<wardActivePads[iPad]<<"; fS: "<<fS[iPad]<<"\n";}
119 }*/
120}
121
123{
124 /*delete fS;
125 delete fNumbersOfPads;
126 delete fClustersInBlock;
127 delete fClusters;*/
128}
129
130Float_t CbmClusteringWard::WardDistance(Int_t iPad1, Int_t iPad2)
131{
132 return (((fClustersInBlock[iPad1].clCharge * fClustersInBlock[iPad2].clCharge)
133 * ((fClustersInBlock[iPad1].xc - fClustersInBlock[iPad2].xc)
134 * (fClustersInBlock[iPad1].xc - fClustersInBlock[iPad2].xc)
135 + (fClustersInBlock[iPad1].yc - fClustersInBlock[iPad2].yc)
136 * (fClustersInBlock[iPad1].yc - fClustersInBlock[iPad2].yc)))
137 / (fClustersInBlock[iPad1].clCharge + fClustersInBlock[iPad2].clCharge));
138}
139
141{
142 Int_t clusterNumber = 0;
143 for (Int_t iPad = 0; iPad < fNofPads; iPad++) //0 <> 1 -???
144 {
145 //Initsiatsi9 aktivnih 94eek
146 if (moduleGeo->GetPadCharge(iPad) > 0) {
147 fClustersInBlock[clusterNumber].nofNeighbors = moduleGeo->GetGoodNeighborsNum(iPad);
148 fClustersInBlock[clusterNumber].nofPads = 1;
149 fClustersInBlock[clusterNumber].padsInCluster[0] = iPad;
150 //---!!!---<
151 //fClustersInBlock[clusterNumber].numbersOfPadsInCluster[1] = iPad;
152 fClustersInBlock[clusterNumber].nofCluster = iPad;
153 fClustersInBlock[clusterNumber].clCharge = moduleGeo->GetPadCharge(iPad);
154 fClustersInBlock[clusterNumber].xc = moduleGeo->GetX0(iPad);
155 fClustersInBlock[clusterNumber].yc = moduleGeo->GetY0(iPad);
156 clusterNumber++; //Moved from the beginning of FOR loop - check
157 }
158 }
159 clustersInMethod = clusterNumber;
160 //clustersInMethod_2 = clustersInMethod; //- !!! CHECK, probably it is not needed
161 //Opredelenie sosedei dl9 vseh 94eek-klasterov
162 //Vipoln9ets9 posle opredeleni9 vseh nomerov klasterov v klasse
163 Int_t neighbor = 0;
164 for (Int_t iPad = 0; iPad < clustersInMethod; iPad++) //0 <> 1 - ???
165 {
166 neighbor = 0;
167 for (Int_t jPad = 0; jPad < clustersInMethod; jPad++) //0 <> 1 - ???
168 {
169 for (Int_t kPad = 0; kPad < fClustersInBlock[iPad].nofNeighbors; kPad++) //0 <> 1 - ???
170 {
171 if (moduleGeo->GetNeighbor(fClustersInBlock[iPad].nofCluster, kPad) == fClustersInBlock[jPad].nofCluster) {
172 fClustersInBlock[iPad].neighbors[neighbor] = jPad;
173 neighbor++;
174 }
175 }
176 }
177 fClustersInBlock[iPad].nofNeighbors = neighbor; //Added
178 }
179 //Vi4islenie rassto9nii mejdu sosed9mi
180 for (Int_t iCl = 0; iCl < clustersInMethod; iCl++) //0 <> 1 - ???
181 {
182 for (Int_t jCl = 0; jCl < fClustersInBlock[iCl].nofNeighbors; jCl++) //0 <> 1 - ???
183 {
184 fClustersInBlock[iCl].wardDistances[jCl] = WardDistance(iCl, fClustersInBlock[iCl].neighbors[jCl]);
185 //Aktivizatsi9 rassto9niz mejdu sosed9mi
186 fClustersInBlock[iCl].S[jCl] = 1;
187 }
188 }
189}
190
191//The block loading methods are not ready. There is a problem with nofNeighbors
192void CbmClusteringWard::AddClusterInBlock(CbmClusteringGeometry* moduleGeo, Int_t newCluster, Int_t addedCluster)
193{
194 fClustersInBlock[newCluster].nofNeighbors = moduleGeo->GetGoodNeighborsNum(addedCluster);
195 fClustersInBlock[newCluster].nofPads = 1;
196 fClustersInBlock[newCluster].nofCluster = addedCluster;
197 fClustersInBlock[newCluster].linkToDesignation = padsInClusters[addedCluster];
198 fClustersInBlock[newCluster].clCharge = moduleGeo->GetPadCharge(addedCluster);
199 fClustersInBlock[newCluster].xc = moduleGeo->GetX0(addedCluster);
200 fClustersInBlock[newCluster].yc = moduleGeo->GetY0(addedCluster);
201 fClustersInBlock[newCluster].nofNeighbors = 0;
202 fClustersInBlock[newCluster].padsInCluster[0] = moduleGeo->GetDigiNum(addedCluster);
203 //std::cout<<"AddClusterInBlock: "<<addedCluster<<" -> "<<newCluster<<"\n";
204 //std::cout<<"nofCluster: "<<fClustersInBlock[newCluster].nofCluster<<"; ";
205 //std::cout<<"clCharge: "<<fClustersInBlock[newCluster].clCharge<<"; ";
206 //std::cout<<"linkToDesignation: "<<fClustersInBlock[newCluster].linkToDesignation<<"\n";
207 //std::cout<<"xc = "<<fClustersInBlock[newCluster].xc<<"; yc = "<<fClustersInBlock[newCluster].yc<<"\n";
208 //std::cout<<"nofPads: "<<fClustersInBlock[newCluster].nofPads<<"; ";
209 //std::cout<<"nofNeighbors: "<<fClustersInBlock[newCluster].nofNeighbors<<"\n";
210}
211
212Bool_t CbmClusteringWard::WardBlockCreateStep(CbmClusteringGeometry* moduleGeo, Int_t wardStep, Bool_t wardStepRec,
213 Int_t addedPad)
214{
215 //std::cout<<"BlockCreateStep started!\n";
216 Int_t tempPad = addedPad;
217 //wardActivePads[tempPad] = false;
218 //Proverka previsheni9 limita obrabotki za 1 shag
219 if (wardStep >= BLOCK_SIZE) {
220 //Aktivasti9 94eiki esli dobavlenie v spisok obrabotki nevozmojno
221 wardActivePads[tempPad] = true;
222 return false;
223 }
224 if (wardStepRec == false) {
225 //Aktivasti9 94eiki esli dobavlenie v spisok obrabotki nevozmojno
226 wardActivePads[tempPad] = true;
227 return false;
228 }
229 if (tempPad > fNofPads) {
230 std::cout << "Error with tempPad in WardBlockCreateStep\n";
231 return false;
232 }
233 Int_t lastPadInRecursion = tempPad;
234 //Deaktivatsi9 94eiki
235 wardActivePads[tempPad] = false;
236 wardStep++;
237 if (moduleGeo->GetGoodNeighborsNum(addedPad) > 0) {
238 for (Int_t iPad = 0; iPad < moduleGeo->GetGoodNeighborsNum(addedPad); iPad++) //0 <> 1 -???
239 {
240 if (wardActivePads[moduleGeo->GetNeighbor(addedPad, iPad)] == true) {
241 //std::cout<<"\nEst' sosed!\n";
242 wardStepRec = WardBlockCreateStep(moduleGeo, wardStep, wardStepRec, moduleGeo->GetNeighbor(addedPad, iPad));
243 if (wardStepRec == 0) {
244 //Aktivasti9 94eiki esli dobavlenie v spisok obrabotki nevozmojno
245 wardActivePads[tempPad] = true;
246 return false;
247 }
248 /*listValue++;
249 clustersInMethod = listValue;
250 std::cout<<"ADD CLUSTER - 1\n"; //--------------------
251 AddClusterInBlock(moduleGeo, wardStep, tempPad);
252 //-???- moved
253 wardActivePads[tempPad] = false;
254 lastPadInRecursion = 0;*/
255 }
256 }
257 }
258 if (lastPadInRecursion != 0) {
259 listValue++;
261 //std::cout<<"ADD CLUSTER - 2\n"; //--------------------
262 AddClusterInBlock(moduleGeo, wardStep, lastPadInRecursion);
263 std::cout << "Add cluster " << lastPadInRecursion << " in cluster " << wardStep << "\n";
264 //std::cout<<"Cluster added!\n"; //--------------------
265 //wardActivePads[lastPadInRecursion] = false; //---???---
266 }
267 //Yda4noe zavershenie rekursivnoi funktsii
268 return wardStepRec;
269}
270
272{
273 //Koeffitsient dostato4nosti razmera spiska obrabotki
274 Float_t listLimit = 0.9;
275 //Flag zaversheni9 postroeni9 spiska obrabotki
276 Bool_t workListFinished = false;
277 //Poslednii element spiska 94eek, vnesennii v spisok obrabotki ---!!!---
278 //int wardStepFinish = 0;
279 //Nomer dobavl9emoi 94eiki
280 Int_t nomActivePad = 0;
281 //Nomer poslednei dobavlennoi v spisok obrabotki 94eiki
282 Int_t lastActivePad = firstBlockElement - 1;
283 //Koli4estvo ob'ektov v spiske obrabotki
284 Int_t wardStep = 0;
285 Bool_t wardStepRec = true;
286 //Int_t AAA = 0;
287 do {
288 do {
289 lastActivePad++;
290 if (wardActivePads[lastActivePad] == true) {
291 nomActivePad = lastActivePad;
292 }
293 } while ((nomActivePad == 0) && (lastActivePad < fNofPads));
294 wardStep = listValue;
295 if ((nomActivePad != 0) && (lastActivePad < fNofPads)) {
296 //std::cout<<"---nomActivePad: "<<nomActivePad<<"\n";
297 AddClusterInBlock(moduleGeo, wardStep, nomActivePad); //??? - dobavil 21.12.12 - ???
298 wardStepRec = WardBlockCreateStep(moduleGeo, wardStep, wardStepRec, nomActivePad);
299 //std::cout<<"BlockCreateStep finished!\n"; //---------------
300 }
301 nomActivePad = 0;
302 //---!!!---!!!---!!!---
303 if ((lastActivePad >= fNofPads) || (wardStep >= (int) (listLimit * BLOCK_SIZE))) //???
304 {
305 workListFinished = true;
306 }
307 //std::cout<<AAA<<"\n";
308 //AAA++;
309 } while ((!workListFinished) /*&&(AAA < 35)*/);
310 //Sostavlenie spiska sosedei
311 //std::cout<<"clustersInMethod: "<<clustersInMethod<<"\n";
312 Int_t neighbor = 0;
313 for (Int_t iCl = 0; iCl < clustersInMethod; iCl++) //0 <> 1 - ???
314 {
315 neighbor = 0;
316 //std::cout<<"Neighbors: "<<moduleGeo->GetGoodNeighborsNum(fClustersInBlock[iCl].nofCluster)<<"\n";
317 for (Int_t jCl = 0; jCl < clustersInMethod; jCl++) //0 <> 1 - ???
318 {
319 for (Int_t kCl = 0; kCl < moduleGeo->GetGoodNeighborsNum(
320 fClustersInBlock[iCl].nofCluster) /*fClustersInBlock[iCl].nofNeighbors*/;
321 kCl++) //0 <> 1 - ???
322 {
323 //std::cout<<"Cl1: "<<moduleGeo->GetNeighbor(fClustersInBlock[iCl].nofCluster, kCl);
324 //std::cout<<"; Cl2: "<<fClustersInBlock[jCl].nofCluster<<"\n";
325 if (moduleGeo->GetNeighbor(fClustersInBlock[iCl].nofCluster, kCl) == fClustersInBlock[jCl].nofCluster) {
326 fClustersInBlock[iCl].neighbors[neighbor] = jCl;
327 //std::cout<<"Get Neighbor "<<jCl<<" to Pad "<<iCl<<"\n";
328 neighbor++;
329 }
330 }
331 }
332 fClustersInBlock[iCl].nofNeighbors = neighbor;
333 }
334 //Vi4islenie rassto9nii mejdu sosed9mi
335 for (Int_t iCl = 0; iCl < clustersInMethod; iCl++) //0 <> 1 - ???
336 {
337 for (Int_t jCl = 0; jCl < fClustersInBlock[iCl].nofNeighbors; jCl++) //0 <> 1 - ???
338 {
339 fClustersInBlock[iCl].wardDistances[jCl] = WardDistance(iCl, fClustersInBlock[iCl].neighbors[jCl]);
340 //Aktivizatsi9 rassto9ni9 mejdu sosed9mi
341 fClustersInBlock[iCl].S[jCl] = 1;
342 }
343 }
344 Int_t TEMP = firstBlockElement + listValue;
345 for (Int_t iPad = firstBlockElement; iPad < TEMP; iPad++) //0 <> 1 - ???
346 {
347 if (padsInClusters[iPad] == 0) {
348 listValue++;
349 }
350 }
352 for (Int_t i = 0; i < fNofPads + 1; i++) {
353 std::cout << "->Pad " << i << "; Cl: " << fClustersInBlock[i].nofCluster
354 << "; sPads: " << fClustersInBlock[i].nofPads << "; nofNeighbors: " << fClustersInBlock[i].nofNeighbors
355 << "\n";
356 }
357 //std::cout<<"! listValue: "<<listValue<<"\n";
358}
359
360void CbmClusteringWard::DeleteCluaster(Int_t clusterNumber)
361{
362 //Ydalenie klastera iz spiskov sosedei
363 Bool_t clusterWasDeleted = false;
364 for (Int_t iCl = 0; iCl < fClustersInBlock[clusterNumber].nofNeighbors; iCl++) //0 <> 1 - ???
365 {
366 clusterWasDeleted = false;
367 for (Int_t jCl = 0; jCl < fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].nofNeighbors;
368 jCl++) //0 <> 1 - ???
369 {
370 //Sjatie spiskov sosedei klastera s zamesheniem ydal9emogo klastera
371 if (clusterWasDeleted == true) {
372 //Podn9t' nomer soseda v spiske
373 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].neighbors[jCl - 1] =
374 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].neighbors[jCl];
375 //Opustit' NULL v spiske
376 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].neighbors[jCl] = 0;
377 //Podn9t' rassto9nie v spiske
378 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].wardDistances[jCl - 1] =
380 //Opustit' NULL v spiske
381 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].wardDistances[jCl] = 0;
382 //Podn9t' flag aktivnosti rassto9ni9 v spiske
383 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].S[jCl - 1] =
384 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].S[jCl];
385 //Opustit' NULL v spiske
386 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].S[jCl] = 0;
387 }
388 //Dostignut udal9emii klaster v spiske sosedei
389 if (fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].neighbors[jCl] == clusterNumber) {
390 clusterWasDeleted = true;
391 }
392 }
393 //Ymen'shenie koli4estva sosedei dlz sosedei ydal9emogo klastera -???-
395 }
396 //O4istka spiska sosedei ydal9emogo klastera
397 for (Int_t iCl = 0; iCl < fClustersInBlock[clusterNumber].nofNeighbors; iCl++) //0 <> 1 - ???
398 {
399 fClustersInBlock[clusterNumber].neighbors[iCl] = 0;
400 fClustersInBlock[clusterNumber].wardDistances[iCl] = 0;
401 fClustersInBlock[clusterNumber].S[iCl] = 0;
402 }
403 //Ydalenie klastera
404 fClustersInBlock[clusterNumber].nofPads = 0;
405 fClustersInBlock[clusterNumber].nofNeighbors = 0;
406 fClustersInBlock[clusterNumber].nofCluster = 0;
407 fClustersInBlock[clusterNumber].linkToDesignation = 0;
408 fClustersInBlock[clusterNumber].clCharge = 0;
409 fClustersInBlock[clusterNumber].xc = 0;
410 fClustersInBlock[clusterNumber].yc = 0;
411 fNofClusters--;
412 /*for(Int_t iCl = clusterNumber; iCl < (fNofClusters - 1); iCl++)
413 {
414 fClustersInBlock[iCl].nofPads = fClustersInBlock[iCl + 1].nofPads;
415 fClustersInBlock[iCl].nofNeighbors = fClustersInBlock[iCl + 1].nofNeighbors;
416 fClustersInBlock[iCl].nofCluster = fClustersInBlock[iCl+1].nofCluster;
417 }*/
418}
419
421{
422 Float_t newDistance;
423 //Ydalenie klastera iz sobstvennogo spiska sosedei
424 for (Int_t iCl = 0; iCl < fClustersInBlock[clusterNumber].nofNeighbors; iCl++) //0 <> 1 - ???
425 {
426 if (fClustersInBlock[clusterNumber].neighbors[iCl] == clusterNumber) {
427 for (Int_t jCl = iCl; jCl < fClustersInBlock[clusterNumber].nofNeighbors; jCl++) //???
428 {
429 fClustersInBlock[clusterNumber].neighbors[jCl] = fClustersInBlock[clusterNumber].neighbors[jCl + 1];
430 fClustersInBlock[clusterNumber].S[jCl] = fClustersInBlock[clusterNumber].S[jCl + 1];
431 }
432 //Yni4tojenie poslednego soseda posle sdviga massiva
433 fClustersInBlock[clusterNumber].neighbors[fClustersInBlock[clusterNumber].nofNeighbors - 1] = 0; // - 1 -???
434 fClustersInBlock[clusterNumber].S[fClustersInBlock[clusterNumber].nofNeighbors - 1] = 0;
435 fClustersInBlock[clusterNumber].nofNeighbors--;
436 }
437 }
438 //Ras4et novih rassto9nii dl9 vseh sosedei
439 for (Int_t iCl = 0; iCl < fClustersInBlock[clusterNumber].nofNeighbors; iCl++) //0 <> 1 - ???
440 {
441 newDistance = WardDistance(clusterNumber, fClustersInBlock[clusterNumber].neighbors[iCl]);
442 fClustersInBlock[clusterNumber].wardDistances[iCl] = newDistance;
443 //Ystanovka rassto9nii sosed9m
444 for (Int_t jCl = 0; jCl < fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].nofNeighbors;
445 jCl++) //0 <> 1 - ???
446 {
447 if (fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].neighbors[jCl] == clusterNumber) {
448 fClustersInBlock[fClustersInBlock[clusterNumber].neighbors[iCl]].wardDistances[jCl] = newDistance;
449 }
450 }
451 }
452}
453
454
455Float_t CbmClusteringWard::XCenterRecalculation(Int_t cl1, Int_t cl2)
456{
457 return (fClustersInBlock[cl1].xc * fClustersInBlock[cl1].clCharge
458 + fClustersInBlock[cl2].xc * fClustersInBlock[cl2].clCharge)
460}
461
462Float_t CbmClusteringWard::YCenterRecalculation(Int_t cl1, Int_t cl2)
463{
464 return (fClustersInBlock[cl1].yc * fClustersInBlock[cl1].clCharge
465 + fClustersInBlock[cl2].yc * fClustersInBlock[cl2].clCharge)
467}
468
470{
471 Float_t minimalDistance = maxDistance;
472 Int_t cluster1 = 0, cluster2 = 0;
473 do {
474 minimalDistance = maxDistance + 0.0001;
475 //Proverka nali4i9 ob'edin9emih klasterov
476 if (clustersInMethod == 1) {
477 break;
478 }
479 //Nahojdenie minimal'nogo Wardovskogo rassto9ni9
480 cluster1 = -1;
481 for (Int_t iCl = 0; iCl < fNofActivePads; iCl++) //0 <> 1 - ???
482 {
483 //std::cout<<iCl<<" - Neighbours: "<<fClustersInBlock[iCl].nofNeighbors<<"\n";
484 for (Int_t jCl = 0; jCl < fClustersInBlock[iCl].nofNeighbors; jCl++) //0 <> 1 - ???
485 {
486 /* Inogda popadauts9 W == 0
487 * Nedo4et v rabote metodov udaleni9 i peres4eta
488 * Ne vli9et na itogovii rezultat
489 */
490 if ((fClustersInBlock[iCl].wardDistances[jCl] < minimalDistance)
491 && (fClustersInBlock[iCl].wardDistances[jCl] > 0)) {
492 minimalDistance = fClustersInBlock[iCl].wardDistances[jCl];
493 cluster1 = iCl;
494 cluster2 = fClustersInBlock[iCl].neighbors[jCl];
495 }
496 }
497 //std::cout<<" - c1: "<<cluster1<<"; c2: "<<cluster2<<"\n";
498 }
499 if (cluster1 == -1) break; //If there is no cluster for removing. Strange line
500 //Prekreshenie raboti po predel'nomu rassto9niu
501 if (minimalDistance >= maxDistance) break;
502 //Vibor glavnogo klastera pri ob'edinenii
503 if (cluster1 > cluster2) {
504 Int_t k = cluster1;
505 cluster1 = cluster2;
506 cluster2 = k;
507 }
508 // std::cout<<">>>Connect Cl "<<cluster2<<" to Cl "<<cluster1<<"\n";
509 //Sbros aktivnosti prisoedin9emogo klastera,
510 //Esli oni dubliryut sv9zi glavnogo klastera
511 for (Int_t iCl = 0; iCl < fClustersInBlock[cluster1].nofNeighbors; iCl++) //0 <> 1 - ???
512 {
513 for (Int_t jCl = 0; jCl < fClustersInBlock[cluster2].nofNeighbors; jCl++) //0 <> 1 - ???
514 {
515 if (fClustersInBlock[cluster1].neighbors[iCl] == fClustersInBlock[cluster2].neighbors[jCl]) {
516 fClustersInBlock[cluster2].S[jCl] = 0;
517 }
518 }
519 }
520 //Pereda4a sosedei s aktivnimi sv9z9mi glavnomy klasteru
521 for (Int_t iCl = 0; iCl < fClustersInBlock[cluster2].nofNeighbors; iCl++) //0 <> 1 - ???
522 {
523 if (fClustersInBlock[cluster2].S[iCl] == 1) {
525 fClustersInBlock[cluster2].neighbors[iCl];
526 fClustersInBlock[cluster1].S[fClustersInBlock[cluster1].nofNeighbors] = 1;
527 fClustersInBlock[cluster1].nofNeighbors++;
528 }
529 }
530 //Pereda4a 94eek glavnomu klasteru
531 for (Int_t iCl = 0; iCl < fClustersInBlock[cluster2].nofPads; iCl++) //0 <> 1 - ???
532 {
534 fClustersInBlock[cluster2].padsInCluster[iCl];
535 fClustersInBlock[cluster1].nofPads++;
536 //---!!!---<>
537 //fClustersInBlock[cluster1].numbersOfPadsInCluster[fClustersInBlock[cluster1].nofPads] = ClustersInBlock[cluster2].numbersOfPadsInCluster[i];
538 }
539 for (Int_t iPad = 0; iPad < fNofPads; iPad++) //0 <> 1 - ??? //g_max_pads <> fNofPads - ???
540 {
541 if (padsInClusters[iPad] == fClustersInBlock[cluster2].linkToDesignation)
542 {
544 }
545 }
546 //Vi4islenie stentra novogo klastera
547 fClustersInBlock[cluster1].xc = XCenterRecalculation(cluster1, cluster2);
548 fClustersInBlock[cluster1].yc = YCenterRecalculation(cluster1, cluster2);
549 //Zamena prisoedin9emogo klastera na novii v spiskah sosedei drugih klasterov
550 //Bool_t thereIsNewCluaster;
551 for (Int_t iCl = 0; iCl < fClustersInBlock[cluster2].nofNeighbors; iCl++) //0 <> 1 - ???
552 {
553 Bool_t thereIsNewCluaster = false;
554 for (Int_t j = 0; j < fClustersInBlock[fClustersInBlock[cluster2].neighbors[iCl]].nofNeighbors;
555 j++) //0 <> 1 - ???
556 {
557 //Esli v spiskah sosedei yje est' novii klaster
558 if (fClustersInBlock[fClustersInBlock[cluster2].neighbors[iCl]].neighbors[j] == cluster1) {
559 thereIsNewCluaster = true;
560 }
561 }
562 //Dobavlenie novogo klastera v spiski sosedei sosedei prisoedin9emogo klastera
563 if (thereIsNewCluaster == false) {
567 }
568 }
569 //Vi4islenie amplitudi novogo klastera
571 //Ydalenie prisoedinennogo klastera
572 DeleteCluaster(cluster2);
573 //Peres4et rassto9nii dl9 novogo klastera
576 } while (minimalDistance < maxDistance);
577 //Yplotnenie massiva klasterov
578 //Int_t clustersInMethodTEMP = clustersInMethod;
579 Int_t d = 0;
580 for (Int_t iCl = 0; iCl < fNofActivePads; iCl++) //0 <> 1 - ??? - = ne ydal9l
581 {
582 d = 0;
583 if (fClustersInBlock[iCl].clCharge == 0) {
584 for (Int_t i = iCl; i < fNofActivePads; i++) {
585 if (fClustersInBlock[i].clCharge == 0) {
586 d++;
587 }
588 else
589 break;
590 }
591 for (Int_t jCl = iCl; jCl < fNofActivePads; jCl++) {
596 fClustersInBlock[jCl].xc = fClustersInBlock[jCl + d].xc;
597 fClustersInBlock[jCl].yc = fClustersInBlock[jCl + d].yc;
598 //Perenos nomerov sosedei
599 for (Int_t kCl = 0; kCl < fClustersInBlock[jCl + d].nofNeighbors; kCl++) //0 <> 1 - ???
600 {
601 fClustersInBlock[jCl].neighbors[kCl] = fClustersInBlock[jCl + d].neighbors[kCl];
603 }
604 //Perenos nomerov 94eek v klastere
605 for (Int_t iPad = 0; iPad < fClustersInBlock[jCl].nofPads; iPad++) {
607 }
608 //---!!!---
609 /*for(int k = 1; k <= ClustersInBlock[j + 1].padsInCluster; k++)
610 {
611 ClustersInBlock[j].numbersOfPadsInCluster[k] = ClustersInBlock[j+1].numbersOfPadsInCluster[k];
612 }*/
613 }
614 }
615 }
616 //clustersInMethod_2 += clustersInMethod;
617 /* Dopolnitel'noe obnulenie udalennih elementov
618 * massiva klasterov ne vipoln9los', poskol'ky
619 * oni doljni bit' obnuleni pri udalenii
620 * prisoedin9emih klasterov
621 */
622}
623
625{
626 // std::cout<<"-===-clInMethod: "<<clustersInMethod<<"\n";
627 Int_t nc = fNofClusters;
628 for (Int_t iCl = 0; iCl < /*clustersInMethod*/ fNofClusters; iCl++) //0 <> 1 - ???
629 {
630 if (fClustersInBlock[iCl].nofPads == 0) {
631 nc--;
632 continue;
633 }
635 //fClusters[clustersInMethod_2 + iCl].linkToDesignation = fClustersInBlock[iCl].linkToDesignation; //linkToDesignation - ???
637 // std::cout<<"-=-nofPads: "<<fClustersInBlock[iCl].nofPads<<"\n";
641 for (Int_t i = 0; i < fClusters[clustersInMethod_2 + iCl].nofPads; i++) {
643 }
644 //WARNING net zapolneni9 massiva sosedei - ?!
645 }
646 fNofClusters = nc;
648 // std::cout<<"-===-clInMethod_2: "<<clustersInMethod_2<<"\n";
649 //std::cout<<"clustersInMethod: "<<clustersInMethod<<"\n";
650}
651
653{
654 WardCreate(moduleGeo);
655 std::cout << "---Ward block created\n";
656 //WardBlockCreate(moduleGeo);
657 WardProcessingData(maxDistance);
658 std::cout << "---Ward data processed\n";
660 std::cout << "---Ward clustering finished\n";
661 /*do{
662 Int_t TEMP = firstBlockElement;
663 WardBlockCreate(moduleGeo);
664 if(TEMP == firstBlockElement)
665 {
666 cout<<"Error!";
667 break;
668 }
669 WardProcessingData(maxDistance);
670 GetClustersFromBlock();
671 }while(firstBlockElement < fNofPads);*/
672}
673
674Int_t CbmClusteringWard::GetCluster(Int_t iCluster) { return fClusters[iCluster].nofCluster; }
675Float_t CbmClusteringWard::GetX0(Int_t iCluster) { return fClusters[iCluster].xc; }
676Float_t CbmClusteringWard::GetY0(Int_t iCluster) { return fClusters[iCluster].yc; }
677UInt_t CbmClusteringWard::GetClCharge(Int_t iCluster) { return fClusters[iCluster].sumClCharge; }
678Int_t CbmClusteringWard::GetNofPads(Int_t iCluster) { return fClusters[iCluster].nofPads; }
679Int_t CbmClusteringWard::GetPadInCluster(Int_t iCluster, Int_t iPad)
680{
681 //std::cout<<"Cl: "<<iCluster;
682 //std::cout<<"\nPad: "<<iPad;
683 //std::cout<<"\nnPad: "<<fClusters[iCluster].padsInCluster[iPad]<<"\n";
684 if (fClusters[iCluster].padsInCluster[iPad] > 10000) return 0;
685 if (fClusters[iCluster].padsInCluster[iPad] < 0) return 0;
686 return fClusters[iCluster].padsInCluster[iPad];
687}
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)
void WardMainFunction(CbmClusteringGeometry *moduleGeo, Float_t maxDistance)
Float_t GetX0(Int_t iCluster)
void WardCreate(CbmClusteringGeometry *moduleGeo)
CbmClusteringWard()
Constructor.
Float_t XCenterRecalculation(Int_t cl1, Int_t cl2)
void AddClusterInBlock(CbmClusteringGeometry *moduleGeo, Int_t newCluster, Int_t addedCluster)
Int_t GetCluster(Int_t iCluster)
void WardBlockCreate(CbmClusteringGeometry *moduleGeo)
UInt_t GetClCharge(Int_t iCluster)
Bool_t WardBlockCreateStep(CbmClusteringGeometry *moduleGeo, Int_t wardStep, Bool_t wardStepRec, Int_t addedPad)
void WardDistanceRecalculation(Int_t clusterNumber)
ClusterBlock * fClustersInBlock
Int_t GetPadInCluster(Int_t iCluster, Int_t iPad)
Float_t GetY0(Int_t iCluster)
Float_t YCenterRecalculation(Int_t cl1, Int_t cl2)
void DeleteCluaster(Int_t clusterNumber)
void WardProcessingData(Float_t maxDistance)
Float_t WardDistance(Int_t iPad1, Int_t iPad2)
Int_t GetNofPads() const
virtual ~CbmClusteringWard()
Destructor.