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