HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hmdccluster.cc
Go to the documentation of this file.
1 using namespace std;
2 #include "hmdccluster.h"
3 #include "TMath.h"
4 #include "hmdcclussim.h"
5 #include "hmdcgeanttrack.h"
6 #include "hmdclistcells.h"
7 
8 //*-- AUTHOR : Pechenov Vladimir
9 //*-- Modified : 15/02/2007 by V. Pechenov
10 
11 //_HADES_CLASS_DESCRIPTION
12 ////////////////////////////////////////////////////////////////
13 // HMdcCluster
14 //
15 // Temporary cluster information for cluster finder
16 //
17 ////////////////////////////////////////////////////////////////
18 
21 
22 void HMdcCluster::init(Char_t sec,Char_t seg,Float_t x,Float_t y,Float_t sx,Float_t sy) {
23  sector = sec;
24  segment = seg;
25  status = kTRUE;
26  nMergedClus = 1;
27  clusMerg = 0;
28  lCells1.clear();
29  lCells2.clear();
30  clearBinStat();
31  x0 = x;
32  y0 = y;
33  xSt = sx;
34  ySt = sy;
35  errX = 0.5*xSt;
36  errY = 0.5*ySt;
37  sigma1 = 0.;
38  sigma2 = 0.;
39  alpha = 0.;
40  fakeFlag = 0;
41  realFlag = 0;
42 }
43 
45  nBins = 0;
46  sumWt = 0;
47  meanX = 0;
48  meanY = 0;
49  meanXX = 0;
50  meanYY = 0;
51  meanYX = 0;
52  meanXWt = 0;
53  meanYWt = 0;
54  meanXXWt = 0;
55  meanYYWt = 0;
56  minWt = 1000;
57 
58  clusMod1 = 0;
59  clusMod2 = 0;
60  flag = 0;
61  numCells1 = -1;
62  numCells2 = -1;
63 }
64 
66  if(im==0) clusMod1 = cl;
67  else if(im==1) clusMod2 = cl;
68  cl->flag++;
69 }
70 
72  // seg!=0 and seg!=1 - inner and outer segments
73  if(segment != 1) {
74  lCells1.add(&(clst2.lCells1));
75  numCells1 = -1;
76  }
77  if(segment != 0) {
78  lCells2.add(&(clst2.lCells2));
79  numCells2 = -1;
80  }
81  clst2.status = kFALSE;
82  clst2.clusMerg = this;
83 
84  clst2.correctContent(iXFirst,iYFirst);
85  sumWt += clst2.sumWt;
86  nBins += clst2.nBins;
87  meanX += clst2.meanX;
88  meanY += clst2.meanY;
89  meanXX += clst2.meanXX;
90  meanYY += clst2.meanYY;
91  meanYX += clst2.meanYX;
92  meanXWt += clst2.meanXWt;
93  meanYWt += clst2.meanYWt;
94  meanXXWt += clst2.meanXXWt;
95  meanYYWt += clst2.meanYYWt;
96  nMergedClus += clst2.nMergedClus;
97  if(minWt > clst2.minWt) minWt = clst2.minWt;
98 
99  calcXY();
100 }
101 
102 void HMdcCluster::correctContent(Int_t iXf,Int_t iYf) {
103  Int_t shX = iXf - iXFirst;
104  Int_t shY = iYf - iYFirst;
105  if(shX != 0) {
106  Int_t vl1 = shX*nBins;
107  Int_t vl2 = shX*sumWt;
108  meanX -= vl1;
109  meanXX -= shX*(2*meanX + vl1);
110  meanXWt -= vl2;
111  meanXXWt -= shX*(2*meanXWt + vl2);
112  }
113  if(shY != 0) {
114  Int_t vl1 = shY*nBins;
115  Int_t vl2 = shY*sumWt;
116  meanY -= vl1;
117  meanYY -= shY*(2*meanY + vl1);
118  meanYWt -= vl2;
119  meanYYWt -= shY*(2*meanYWt + vl2);
120  }
121  meanYX -= meanX*shY + meanY*shX + shX*shY*nBins;
122  iXFirst = iXf;
123  iYFirst = iYf;
124 }
125 
127  if(nBins<2) {
128  x = x0 + iXFirst*xSt;
129  y = y0 + iYFirst*ySt;
130  } else if(minWt > 1) {
131  Int_t norm = minWt-1;
132  Float_t rSumWt = 1/Float_t(sumWt-nBins*norm);
133 
134  x = Float_t(meanXWt-meanX*norm)*rSumWt;
135  errX = (meanXXWt-meanXX*norm)*rSumWt - x*x;
136  x = (x + iXFirst)*xSt + x0;
137 
138  y = Float_t(meanYWt-meanY*norm)*rSumWt;
139  errY = (meanYYWt-meanYY*norm)*rSumWt - y*y;
140  y = (y + iYFirst)*ySt + y0;
141  } else {
142  Float_t rSumWt = 1/Float_t(sumWt);
143 
144  x = meanXWt*rSumWt;
145  errX = meanXXWt*rSumWt - x*x;
146  x = (x + iXFirst)*xSt + x0;
147 
148  y = meanYWt*rSumWt;
149  errY = meanYYWt*rSumWt - y*y;
150  y = (y + iYFirst)*ySt + y0;
151  }
152 }
153 
155  lCells1=clst1.lCells1;
156  lCells1.add(&(clst2.lCells1));
157  if(segment != 0) {
158  lCells2=clst1.lCells2;
159  lCells2.add(&(clst2.lCells2));
160  }
161  clst1.flag = 1;
162  clst2.flag = 1;
163 // clst2.status=kFALSE; ?
164 // clst2.clusMerg=this; ?
165  clst2.correctContent(clst1.iXFirst,clst1.iYFirst);
166  sumWt = clst1.sumWt+clst2.sumWt;
167  nBins = clst1.nBins+clst2.nBins;
168  meanX = clst1.meanX+clst2.meanX;
169  meanY = clst1.meanY+clst2.meanY;
170  meanXX = clst1.meanXX+clst2.meanXX;
171  meanYY = clst1.meanYY+clst2.meanYY;
172  meanYX = clst1.meanYX+clst2.meanYX;
173  meanXWt = clst1.meanXWt+clst2.meanXWt;
174  meanYWt = clst1.meanYWt+clst2.meanYWt;
175  meanXXWt = clst1.meanXXWt+clst2.meanXXWt;
176  meanYYWt = clst1.meanYYWt+clst2.meanYYWt;
177  minWt = clst1.minWt <= clst2.minWt ? clst1.minWt : clst2.minWt; //???
178  nMergedClus += clst2.nMergedClus; //??????????????
179 
180  calcXY();
181 }
182 
184  if(nBins<2) return;
185  errX = TMath::Sqrt(errX + 0.25)*xSt; // 0.25 = 0.5*0.5 (half of bin)
186  errY = TMath::Sqrt(errY + 0.25)*ySt;
187  // Cluster shape:-------------------------------------------------
188  // eXX,eYY,eXY=eYX - covariance matrix componets
189  //
190  // | eXX-sigma aXY | | E1 |
191  // A= | | B=| |
192  // | eYX eYY-sigma | | E2 |
193  //
194  // A^2=0; ==> sigma1 & sigma2 - (sigma1 > sigma2)
195  //
196  // | 0 | | E1 |
197  // AB=| |; ==> | | - direction of main axis
198  // | 0 | | E2 |
199  Float_t eXX = (meanXX*nBins - meanX*meanX)*xSt*xSt;
200  Float_t eYX = (meanYX*nBins - meanY*meanX)*xSt*ySt;
201  Float_t eYY = (meanYY*nBins - meanY*meanY)*ySt*ySt;
202  Float_t v1 = (eXX+eYY)*0.5;
203  Float_t eYX2 = eYX*eYX;
204  Float_t v2 = TMath::Sqrt(v1*v1 - eXX*eYY + eYX2);
205  Float_t sigma1D = v1 + v2;
206  Float_t sigma2D = v1 - v2;
207  Float_t e1 = sigma1D - eXX;
208  Float_t e2 = sigma1D - eYY;
209  sigma1 = TMath::Sqrt(sigma1D)/nBins;
210  sigma2 = (sigma2D<10e-5) ? 0. : TMath::Sqrt(sigma2D)/nBins;
211  alpha = TMath::ATan2(TMath::Sqrt(eYX2+e1*e1),TMath::Sqrt(eYX2+e2*e2))*TMath::RadToDeg();
212  if(eYX<0.) alpha=180.-alpha;
213 }
214 
215 void HMdcCluster::fillClus(HMdcClus* fClus, Int_t nLst, Bool_t fillTrList) {
216  fClus->setSumWt(sumWt);
217  fClus->setNBins(nBins);
218  fClus->setXY(x,errX,y,errY);
219  fClus->setNMergClust(nMergedClus);
220  fClus->setRealLevel(minWt);
221  fClus->setFakeFlag(fakeFlag);
222  HMdcList12GroupCells& list=(nLst==0) ? lCells1:lCells2;
223  HMdcTrackInfSim* clusSimInf = 0;
224  if(fillTrList && fClus->isGeant()) clusSimInf = HMdcGeantEvent::getMdcTrackInfSim();
225  if(clusSimInf) clusSimInf->fillClusTrackInf((HMdcClusSim*)fClus);
226  if(clusMod1==0) {
227  Int_t nDrTm=list.getNDrTimes(0,5);
228  if(nDrTm>0 && fClus->getMinCl(0)>0) {
229  fClus->setClFnLevelM1(fClus->getMinCl(0));
230  fClus->setClusSizeM1(nBins);
231  fClus->setNMergClustM1(nMergedClus);
232  fClus->setShapeM1(sigma1,sigma2,alpha);
233  if(clusSimInf) clusSimInf->fillClusModTrackInf((HMdcClusSim*)fClus, &list,0);
234  } else fClus->clearMod1Par();
235  fClus->setNDrTimesM1(nDrTm);
236  } else {
237  fClus->setClFnLevelM1((UChar_t)(clusMod1->minWt+0.1));
238  fClus->setClusSizeM1(clusMod1->nBins);
239  fClus->setNDrTimesM1(clusMod1->lCells1.getNDrTimes(0,5));
240  fClus->setNMergClustM1(clusMod1->nMergedClus);
241  fClus->setShapeM1(clusMod1->sigma1,clusMod1->sigma2,clusMod1->alpha);
242  if(clusSimInf) clusSimInf->fillClusModTrackInf((HMdcClusSim*)fClus, &(clusMod1->lCells1),0);
243  }
244  if(clusMod2==0) {
245  Int_t nDrTm=list.getNDrTimes(6,11);
246  if(nDrTm>0 && fClus->getMinCl(1)>0) {
247  fClus->setClFnLevelM2(fClus->getMinCl(1));
248  fClus->setClusSizeM2(nBins);
249  fClus->setNMergClustM2(nMergedClus);
250  fClus->setShapeM2(sigma1,sigma2,alpha);
251  if(clusSimInf) clusSimInf->fillClusModTrackInf((HMdcClusSim*)fClus,
252  &list,1);
253  } else fClus->clearMod2Par();
254  fClus->setNDrTimesM2(nDrTm);
255  } else {
256  fClus->setClFnLevelM2((UChar_t)(clusMod2->minWt+0.1));
257  fClus->setClusSizeM2(clusMod2->nBins);
258  fClus->setNDrTimesM2(clusMod2->lCells1.getNDrTimes(6,11));
259  fClus->setNMergClustM2(clusMod2->nMergedClus);
260  fClus->setShapeM2(clusMod2->sigma1,clusMod2->sigma2,clusMod2->alpha);
261  if(clusSimInf) clusSimInf->fillClusModTrackInf((HMdcClusSim*)fClus, &(clusMod2->lCells1),1);
262  }
263 }
264 
265 void HMdcCluster::print(void) {
266  // Debug print:
267  printf("Sector %i Cluster: status=%s, flag=%i,nMergedClus=%i x=%.1f y=%.1f\n",
268  sector+1,status ? "kTRUE" : "kFALSE",flag,nMergedClus,x,y);
270  for(Int_t seg=0;seg<2;seg++) {
271  HMdcList12GroupCells &lCells = seg==0 ? lCells1 : lCells2;
272  if(lCells.getNCells()==0) continue;
273  if(listCells == NULL) {
274  printf(" - - - - - - - lCells%i:\n",seg+1);
275  lCells.print();
276  } else for(Int_t lay=0; lay<12; lay++) {
277  Int_t mod = seg*2 + lay/6;
278  Int_t layer = lay%6;
279  printf("M.%i L.%i %2i cells:",mod+1,layer+1,lCells.getNCells(lay));
280  HMdcLayListCells &listCellsLay = (*listCells)[sector][mod][layer];
281  Int_t cell=-1;
282  while((cell=lCells.next(lay,cell)) >= 0) listCellsLay.printCellInfo(cell);
283  printf("\n");
284  }
285  }
286 }
287 
289  // For HMdcLookUpTb !
290  // Function test are wires from one cluster fully included in another cluster.
291  // Index of "this" obj. in array must be < index cl2 !!!
292  // ??? return kTRUE 0,1,2, or 3if "cl2" is included to "this" (STOP LOOP)
293  // ??? return kFALSE cl2 is not included to "this" or "this" is included to "cl2"
294  if(numCells1<0) {
295  numCells1 = lCells1.getNCells();
296  nLayers1 = lCells1.getNLayers();
297  }
298  if(numCells2<0) {
299  numCells2 = lCells2.getNCells();
300  nLayers2 = lCells2.getNLayers();
301  }
302  if(cl2.numCells1<0) {
303  cl2.numCells1 = cl2.lCells1.getNCells();
304  cl2.nLayers1 = cl2.lCells1.getNLayers();
305  }
306  if(cl2.numCells2<0) {
307  cl2.numCells2 = cl2.lCells2.getNCells();
308  cl2.nLayers2 = cl2.lCells2.getNLayers();
309  }
310 
311  // dCells - Number of not identical cells (for smaller cluster)
312  // nIdentDrTimes return num.cells!
313  Int_t dCells;
314  Int_t dNCells;
315  Int_t dLayers;
316  Int_t nIdCells;
317  if (segment == 0) {
318  nIdCells = lCells1.nIdentDrTimes(&(cl2.lCells1));
319  dCells = numCells1 <= cl2.numCells1 ? numCells1-nIdCells :
320  cl2.numCells1-nIdCells;
321  // !!!!!!!!!! 6 ??? 2 ??? It is not fine tuning!
322  if(nIdCells < 6 || dCells+2 > nIdCells) return 0;
323  dNCells = numCells1 - cl2.numCells1;
324  dLayers = nLayers1 - cl2.nLayers1;
325  } else if(segment == 1) {
326  nIdCells = lCells2.nIdentDrTimes(&(cl2.lCells2));
327  dCells = numCells2 <= cl2.numCells2 ? numCells2-nIdCells :
328  cl2.numCells2-nIdCells;
329  //!!!!!!!!!!!!!! ????????? 6 !!!!!! One need to tune next line:
330  if(nIdCells < 6 || dCells+2 > nIdCells) return 0;
331  dNCells = numCells2 - cl2.numCells2;
332  dLayers = nLayers2 - cl2.nLayers2;
333  } else {
334  Int_t nCells1 = numCells1 + numCells2;
335  Int_t nCells2 = cl2.numCells1 + cl2.numCells2;
336  nIdCells = lCells1.nIdentDrTimes(&(cl2.lCells1)) +
337  lCells2.nIdentDrTimes(&(cl2.lCells2));
338  dCells = nCells1 <= nCells2 ? nCells1-nIdCells : nCells2-nIdCells;
339  //!!!!!!!!!!!!!! ????????? 6 !!!!!! One need to tune next line:
340  if(nIdCells < 6 || dCells+2 > nIdCells) return 0;
341  dNCells = nCells1 - nCells2;
342  dLayers = (nLayers1+nLayers2) - (cl2.nLayers1+cl2.nLayers2);
343  }
344 
345 
346  Int_t nDBins = nBins - cl2.nBins;
347  Int_t dRLevel = (Int_t)(minWt+0.1) - (Int_t)(cl2.minWt+0.1);
348  Int_t inclFlag = 0; // inclFlag==0 continue loop!
349 
350  // Don't change order without testing efficiency!:
351 
352  if(dCells==0) { //== dCells==0 ============================:
353  if (nDBins>0 && dNCells>0) inclFlag = 3; // delete cl2
354  else if(nDBins<0 && dNCells<0) inclFlag = 2; // replace "this"
355  else if(dRLevel > 0) inclFlag = 3; // delete cl2
356  else if(dRLevel < 0) inclFlag = 2; // replace "this"
357  else if(nDBins > 0) inclFlag = 3; // delete cl2
358  else if(nDBins < 0) inclFlag = 2; // replace "this"
359  else if(dNCells > 0) inclFlag = 3; // delete cl2
360  else if(dNCells < 0) inclFlag = 2; // replace "this"
361  else inclFlag = 1; // add "this" to cl2
362  } else if(dCells==1) { //== dCells==1 ============================:
363 //???? 2 and 4 are parameters. ???
364  if (nDBins> 2 && dNCells> 4) inclFlag = 3; // delete cl2
365  else if(nDBins<-2 && dNCells<-4) inclFlag = 2; // replace "this"
366  else if(dRLevel > 0) inclFlag = 3; // delete cl2
367  else if(dRLevel < 0) inclFlag = 2; // replace "this"
368  else if(dLayers > 0) inclFlag = 3; // delete cl2
369  else if(dLayers < 0) inclFlag = 2; // replace "this"
370  else if(nDBins > 0) inclFlag = 3; // delete cl2
371  else if(nDBins < 0) inclFlag = 2; // replace "this"
372  else if(dNCells > 0) inclFlag = 3; // delete cl2
373  else if(dNCells < 0) inclFlag = 2; // replace "this"
374  else inclFlag = 1; // add "this" to cl2
375  } else if(dCells==2) { //== dCells==2 ============================:
376 //???? 2 and 6 are parameters. ???
377  if (nDBins> 2 && dNCells> 6) inclFlag = 3; // delete cl2
378  else if(nDBins<-2 && dNCells<-6) inclFlag = 2; // replace "this"
379  else if(dRLevel > 0) inclFlag = 3; // delete cl2
380  else if(dRLevel < 0) inclFlag = 2; // replace "this"
381  else if(dLayers > 0) inclFlag = 3; // delete cl2
382  else if(dLayers < 0) inclFlag = 2; // replace "this"
383  else if(nDBins > 0) inclFlag = 3; // delete cl2
384  else if(nDBins < 0) inclFlag = 2; // replace "this"
385  else if(dNCells > 0) inclFlag = 3; // delete cl2
386  else if(dNCells < 0) inclFlag = 2; // replace "this"
387  else inclFlag = 1; // add "this" to cl2
388  } else if(dCells==3) { //== dCells==3 ============================:
389 //???? 2 and 7 are parameters. ???
390  if (nDBins> 2 && dNCells> 7) inclFlag = 3; // delete cl2
391  else if(nDBins<-2 && dNCells<-7) inclFlag = 2; // replace "this"
392  else if(dRLevel > 0) inclFlag = 3; // delete cl2
393  else if(dRLevel < 0) inclFlag = 2; // replace "this"
394  else if(dLayers > 0) inclFlag = 3; // delete cl2
395  else if(dLayers < 0) inclFlag = 2; // replace "this"
396  else if(nDBins > 0) inclFlag = 3; // delete cl2
397  else if(nDBins < 0) inclFlag = 2; // replace "this"
398  else if(dNCells > 0) inclFlag = 3; // delete cl2
399  else if(dNCells < 0) inclFlag = 2; // replace "this"
400  else inclFlag = 1; // add "this" to cl2
401  } else if(dCells==4) { //== dCells==4 ============================:
402 //???? 2 and 8 are parameters. ???
403  if (nDBins> 2 && dNCells> 8) inclFlag = 3; // delete cl2
404  else if(nDBins<-2 && dNCells<-8) inclFlag = 2; // replace "this"
405  else if(dRLevel > 0) inclFlag = 3; // delete cl2
406  else if(dRLevel < 0) inclFlag = 2; // replace "this"
407  else if(dLayers > 0) inclFlag = 3; // delete cl2
408  else if(dLayers < 0) inclFlag = 2; // replace "this"
409  else if(nDBins > 0) inclFlag = 3; // delete cl2
410  else if(nDBins < 0) inclFlag = 2; // replace "this"
411  else if(dNCells > 0) inclFlag = 3; // delete cl2
412  else if(dNCells < 0) inclFlag = 2; // replace "this"
413  else inclFlag = 1; // add "this" to cl2
414  }
415 
416  if(inclFlag == 3) { // "cl2" cluster will not used. Stop loop!
417  cl2.clusMerg = this;
418  cl2.setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
419  } else if(inclFlag == 2) { // "this" cluster will not used. Continue loop!
420  clusMerg = &cl2;
421  setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
422  } else if(inclFlag == 1) { // add "this" to "cl2" and repeat loop!
423  cl2.addClus(*this);
424  clusMerg = &cl2;
425  setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
426  }
427  return inclFlag;
428 }
429 
431  // For HMdc34ClFinder !
432  // Function test are wires from one cluster fully included in another cluster.
433  // Index of "this" obj. in array must be < index cl2 !!!
434  // return kTRUE if "cl2" is included to "this" (STOP LOOP)
435  // return kFALSE cl2 is not included to "this" or "this" is included to "cl2"
436 
437  if(segment != 1) return 0; //?????
438 
439  if(numCells2<0) {
440  numCells2 = lCells2.getNCells();
441  nLayers2 = lCells2.getNLayers();
442  }
443  if(cl2.numCells2<0) {
444  cl2.numCells2 = cl2.lCells2.getNCells();
445  cl2.nLayers2 = cl2.lCells2.getNLayers();
446  }
447 
448  // dCells - Number of not identical cells (for smaller cluster)
449  // nIdentDrTimes return num.cells!
450  Int_t nIdCells = lCells2.nIdentDrTimes(&(cl2.lCells2));
451  Int_t dCells = numCells2 <= cl2.numCells2 ? numCells2-nIdCells : cl2.numCells2-nIdCells;
452  //!!!!!!!!!!!!!! ????????? 6 !!!!!! One need to tune next line:
453  if(nIdCells < 6 || dCells+2 > nIdCells) return 0;
454  Int_t dNCells = numCells2 - cl2.numCells2;
455  Int_t dLayers = nLayers2 - cl2.nLayers2;
456 
457  Int_t nDBins = nBins - cl2.nBins;
458  Int_t dRLevel = (Int_t)(minWt+0.1) - (Int_t)(cl2.minWt+0.1);
459  Int_t inclFlag = 0;
460 
461  // Don't change order without testing efficiency!:
462 
463  if(dCells==0) { //== dCells==0 ============================:
464  if (nDBins>0 && dNCells>0) inclFlag = 3; // delete cl2
465  else if(nDBins<0 && dNCells<0) inclFlag = 2; // replace "this"
466  else if(dRLevel > 0) inclFlag = 3; // delete cl2
467  else if(dRLevel < 0) inclFlag = 2; // replace "this"
468  else if(nDBins > 0) inclFlag = 3; // delete cl2
469  else if(nDBins < 0) inclFlag = 2; // replace "this"
470  else if(dNCells > 0) inclFlag = 3; // delete cl2
471  else if(dNCells < 0) inclFlag = 2; // replace "this"
472  else inclFlag = 1; // add "this" to cl2
473  } else if(dCells==1) { //== dCells==1 ============================:
474 //???? 2 and 4 are parameters. ???
475  if (nDBins> 2 && dNCells> 4) inclFlag = 3; // delete cl2
476  else if(nDBins<-2 && dNCells<-4) inclFlag = 2; // replace "this"
477  else if(dRLevel > 0) inclFlag = 3; // delete cl2
478  else if(dRLevel < 0) inclFlag = 2; // replace "this"
479  else if(dLayers > 0) inclFlag = 3; // delete cl2
480  else if(dLayers < 0) inclFlag = 2; // replace "this"
481  else if(nDBins > 0) inclFlag = 3; // delete cl2
482  else if(nDBins < 0) inclFlag = 2; // replace "this"
483  else if(dNCells > 0) inclFlag = 3; // delete cl2
484  else if(dNCells < 0) inclFlag = 2; // replace "this"
485  else inclFlag = 1; // add "this" to cl2
486  } else if(dCells==2) { //== dCells==2 ============================:
487 //???? 2 and 6 are parameters. ???
488  if (nDBins> 2 && dNCells> 6) inclFlag = 3; // delete cl2
489  else if(nDBins<-2 && dNCells<-6) inclFlag = 2; // replace "this"
490  else if(dRLevel > 0) inclFlag = 3; // delete cl2
491  else if(dRLevel < 0) inclFlag = 2; // replace "this"
492  else if(dLayers > 0) inclFlag = 3; // delete cl2
493  else if(dLayers < 0) inclFlag = 2; // replace "this"
494  else if(nDBins > 0) inclFlag = 3; // delete cl2
495  else if(nDBins < 0) inclFlag = 2; // replace "this"
496  else if(dNCells > 0) inclFlag = 3; // delete cl2
497  else if(dNCells < 0) inclFlag = 2; // replace "this"
498  // -no for sim.data else inclFlag = 1; // add "this" to cl2 ---------------?
499  } else if(dCells==3) { //== dCells==3 ============================:
500 //???? 2 and 6 are parameters. ???
501  if (nDBins> 2 && dNCells> 7) inclFlag = 3; // delete cl2
502  else if(nDBins<-2 && dNCells<-7) inclFlag = 2; // replace "this"
503  else if(dRLevel > 0) inclFlag = 3; // delete cl2
504  else if(dRLevel < 0) inclFlag = 2; // replace "this"
505  else if(dLayers > 0) inclFlag = 3; // delete cl2
506  else if(dLayers < 0) inclFlag = 2; // replace "this"
507  else if(nDBins > 0) inclFlag = 3; // delete cl2
508  else if(nDBins < 0) inclFlag = 2; // replace "this"
509  else if(dNCells > 0) inclFlag = 3; // delete cl2
510  else if(dNCells < 0) inclFlag = 2; // replace "this"
511  // -no for sim.data else inclFlag = 1; // add "this" to cl2 ---------------?
512  } else if(dCells==4) { //== dCells==4 ============================:
513 //???? 2 and 6 are parameters. ???
514  if (nDBins> 2 && dNCells> 8) inclFlag = 3; // delete cl2
515  else if(nDBins<-2 && dNCells<-8) inclFlag = 2; // replace "this"
516  else if(dRLevel > 0) inclFlag = 3; // delete cl2
517  else if(dRLevel < 0) inclFlag = 2; // replace "this"
518  else if(dLayers > 0) inclFlag = 3; // delete cl2
519  else if(dLayers < 0) inclFlag = 2; // replace "this"
520  else if(nDBins > 0) inclFlag = 3; // delete cl2
521  else if(nDBins < 0) inclFlag = 2; // replace "this"
522  else if(dNCells > 0) inclFlag = 3; // delete cl2
523  else if(dNCells < 0) inclFlag = 2; // replace "this"
524  // -no for sim.data else inclFlag = 1; // add "this" to cl2
525  }
526 
527  if(inclFlag == 3) { // "cl2" cluster will not used. Stop loop!
528  cl2.clusMerg = this;
529  cl2.setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
530  } else if(inclFlag == 2) { // "this" cluster will not used. Continue loop!
531  clusMerg = &cl2;
532  setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
533  } else if(inclFlag == 1) { // add "this" to "cl2" and repeat loop!
534  cl2.addClus(*this);
535  clusMerg = &cl2;
536  setFakeFlagAndStatus(dCells+1); // dCells+1 for tuning of fake suppr.cuts
537  }
538  return inclFlag;
539 }
540 
542  clusMod1 = clusM1;
543  // Skip merged clusters:
544  while(clusMod1->clusMerg != 0) clusMod1 = clusMod1->clusMerg;
545  clusMod1->flag++;
546 }
547 
549  clusMod2 = clusM2;
550  // Skip merged clusters:
551  while(clusMod2->clusMerg != 0) clusMod2 = clusMod2->clusMerg;
552  clusMod2->flag++;
553 }
554 
556  if(clusMod1!=0 && cls2.clusMod1!=0 && clusMod1!=cls2.clusMod1) return kTRUE;
557  if(clusMod2!=0 && cls2.clusMod2!=0 && clusMod2!=cls2.clusMod2) return kTRUE;
558  return kFALSE;
559 }
560 
562  return minWt <= lCells1.getNLayers() + 1;
563 }
564 
566  return minWt <= lCells2.getNLayers() + 1;
567 }
568 
570  if(fakeFlag==0) return pListCells->getNUniqueWires(0,lCells1);
571  else return pListCells->getNUniqueWires2(0,lCells1);
572 }
573 
574 Int_t HMdcCluster::getNUniqueAndRWiresSeg1(HMdcSecListCells* pListCells,Int_t& nRWires) {
575  if(fakeFlag==0) return pListCells->getNUniqueAndRWires(0,lCells1,nRWires);
576  else return pListCells->getNUniqueAndRWires2(0,lCells1,nRWires);
577 }
578 
579 void HMdcCluster::resetFakeFlagSeg1(Bool_t fake,HMdcSecListCells* pListCells) {
580  if(fake && fakeFlag == 0) {
581  fakeFlag = 11;
582  pListCells->subFrClusCounters(0,lCells1);
583  if(realFlag > 0) {
584  realFlag = 0;
585  pListCells->subFrRClusCounters(0,lCells1);
586  }
587  } else if(!fake && fakeFlag > 0) {
588  fakeFlag = 0;
589  pListCells->addToClusCounters(0,lCells1);
590  }
591 }
592 
593 void HMdcCluster::resetRealFlagSeg1(Bool_t real,HMdcSecListCells* pListCells) {
594  if(real && realFlag == 0) {
595  if(fakeFlag > 0) {
596  fakeFlag = 0;
597  pListCells->addToClusCounters(0,lCells1);
598  }
599  realFlag = 1;
600  pListCells->addToRClusCounters(0,lCells1);
601  }
602  else if(!real && realFlag > 0) {
603  realFlag = 0;
604  pListCells->subFrRClusCounters(0,lCells1);
605  }
606 }
607 
608 //===HMdcClustersArrs===========================================================
609 
611 
613  if(!pMdcClustersArrs) pMdcClustersArrs = new HMdcClustersArrs();
614  return pMdcClustersArrs;
615 }
616 
618  if(pMdcClustersArrs != 0) delete pMdcClustersArrs;
619 }
620 
622  for(Int_t i=0;i<3;i++) {
623  clusArr[i] = 0;
624  arrSize[i] = 0;
625  }
626  dXWind1 = 40.; // ??? 40. ???
627  dYWind1 = 10.;
628  dXWind2 = 120.; // ??? 40. ???
629  dYWind2 = 40.;
630 }
631 
633  if(this == pMdcClustersArrs) pMdcClustersArrs = 0;
634  for(Int_t i=0;i<3;i++) if(clusArr[i]) {
635  delete [] clusArr[i];
636  clusArr[i] = 0;
637  }
638 }
639 
641  if(createArray(0,size) == 0) return 0;
642  size = arrSize[0];
643  if(createArray(1,size) == 0) return 0;
644  size = arrSize[1];
645  if(createArray(2,size) == 0) return 0;
646  return size;
647 }
648 
650  // return pointer to the array of HMdcCluster objects
651  // if array is not created it will be created
652  if(clusArr[ind] != 0) size = arrSize[ind];
653  else if(size>0) {
654  clusArr[ind] = new HMdcCluster [size];
655  arrSize[ind] = size;
656  }
657  return clusArr[ind];
658 }
659 
660 HMdcCluster* HMdcClustersArrs::getCluster(Int_t indarr,Int_t indClus) {
661  if(clusArr[indarr]==0 || indClus>=arrSize[indarr] || indClus<0) return 0;
662  return &(clusArr[indarr][indClus]);
663 }
664 
665 void HMdcClustersArrs::testCluster(Int_t indArr,Int_t indClus) {
666  HMdcCluster* clArr = clusArr[indArr];
667  for(Int_t iCl=0;iCl<indClus;iCl++) if(clArr[iCl].getStatus()) {
668  // Optimization:
669  if(TMath::Abs(clArr[iCl].getY()-clArr[indClus].getY()) > dYWind1) continue;
670  if(TMath::Abs(clArr[iCl].getX()-clArr[indClus].getX()) > dXWind1) continue;
671  Int_t inclFlag = clArr[iCl].testForInclude(clArr[indClus]);
672  if( inclFlag == 0 || inclFlag == 2 ) continue;
673  if( inclFlag == 1 ) testCluster(indArr,indClus);
674  return;
675  }
676 }
677 
678 Bool_t HMdcClustersArrs::testMdc34Cluster(Int_t indArr,Int_t indClus,Int_t firstClst) {
679  // return kTRUE if cluster "indClus" is removed
680  HMdcCluster* clArr = clusArr[indArr];
681  for(Int_t iCl=firstClst;iCl<indClus;iCl++) if(clArr[iCl].getStatus()) {
682  // Optimization:
683  if(TMath::Abs(clArr[iCl].getY()-clArr[indClus].getY()) > dYWind2) continue;
684  if(TMath::Abs(clArr[iCl].getX()-clArr[indClus].getX()) > dXWind2) continue;
685  Int_t inclFlag = clArr[iCl].testForInc34CFnd(clArr[indClus]);
686  if( inclFlag == 0 || inclFlag == 2 ) continue;
687  if( inclFlag == 1 ) return testMdc34Cluster(indArr,indClus,firstClst);
688  return kTRUE; // inclFlag == 3 - remove cluster "indcClus"
689  }
690  return kFALSE;
691 }
static HMdcEvntListCells * getExObject(void)
Int_t next(Int_t lay, Int_t prCell) const
Int_t nBins
Definition: hmdccluster.h:25
Bool_t subFrRClusCounters(Int_t seg, HMdcList12GroupCells &listCells)
Int_t getNCells(Int_t lay, Int_t layEnd=-1) const
void correctContent(Int_t iXf, Int_t iYf)
Definition: hmdccluster.cc:102
void setMod2ClusSkipMerg(HMdcCluster *clusM2)
Definition: hmdccluster.cc:548
void setXY(Float_t xl, Float_t errx, Float_t yl, Float_t erry)
Definition: hmdcclus.h:96
Int_t getNLayers(void) const
Int_t meanYX
Definition: hmdccluster.h:31
void clearMod1Par(void)
Definition: hmdcclus.h:74
Int_t testForInclude(HMdcCluster &cl2)
Definition: hmdccluster.cc:288
void setClusSizeM1(Short_t clSz)
Definition: hmdcclus.h:117
void setModCluster(Int_t im, HMdcCluster *cl)
Definition: hmdccluster.cc:65
Int_t numCells2
Definition: hmdccluster.h:17
void setFakeFlag(UChar_t fl)
Definition: hmdcclus.h:131
HMdcCluster * clusMod1
Definition: hmdccluster.h:55
Int_t getNUniqueAndRWires(Int_t seg, HMdcList12GroupCells &listCells, Int_t &nWInReal) const
Int_t meanXWt
Definition: hmdccluster.h:32
void setClFnLevelM2(UChar_t lv)
Definition: hmdcclus.h:123
Bool_t subFrClusCounters(Int_t seg, HMdcList12GroupCells &listCells)
void setNDrTimesM1(Short_t nDrTm)
Definition: hmdcclus.h:118
void setClFnLevelM1(UChar_t lv)
Definition: hmdcclus.h:116
Int_t getMinCl(void) const
Definition: hmdcclus.h:138
void resetFakeFlagSeg1(Bool_t fake, HMdcSecListCells *pListCells)
Definition: hmdccluster.cc:579
Bool_t testMdc34Cluster(Int_t indArr, Int_t indClus, Int_t firstClst=0)
Definition: hmdccluster.cc:678
void setNMergClustM2(Short_t nmrc)
Definition: hmdcclus.h:126
Char_t flag
Definition: hmdccluster.h:21
HMdcCluster * clusMerg
Definition: hmdccluster.h:22
HMdcList12GroupCells lCells2
Definition: hmdccluster.h:13
void setSumWt(Float_t swt)
Definition: hmdcclus.h:88
void print(void)
Definition: hmdccluster.cc:265
void calcClusParam(void)
Definition: hmdccluster.cc:183
Int_t meanXXWt
Definition: hmdccluster.h:34
Bool_t testNLayersSeg1(void)
Definition: hmdccluster.cc:561
Int_t meanYWt
Definition: hmdccluster.h:33
Int_t getNUniqueAndRWiresSeg1(HMdcSecListCells *pListCells, Int_t &nRWires)
Definition: hmdccluster.cc:574
Int_t getNDrTimes(void) const
Bool_t isModClusNotTheSame(HMdcCluster &cls2)
Definition: hmdccluster.cc:555
Int_t meanYYWt
Definition: hmdccluster.h:35
static HMdcClustersArrs * pMdcClustersArrs
Definition: hmdccluster.h:148
void setNMergClust(Short_t nmrc)
Definition: hmdcclus.h:95
Bool_t addToClusCounters(Int_t seg, HMdcList12GroupCells &listCells)
void print(void) const
Int_t testForInc34CFnd(HMdcCluster &cl2)
Definition: hmdccluster.cc:430
void clearBinStat(void)
Definition: hmdccluster.cc:44
void setNDrTimesM2(Short_t nDrTm)
Definition: hmdcclus.h:125
static HMdcClustersArrs * getObject(void)
Definition: hmdccluster.cc:612
void setMod1ClusSkipMerg(HMdcCluster *clusM1)
Definition: hmdccluster.cc:541
Int_t sumWt
Definition: hmdccluster.h:26
void setShapeM1(Float_t s1, Float_t s2, Float_t al)
Definition: hmdcclus.h:120
Int_t getNUniqueWires2(Int_t seg, HMdcList12GroupCells &listCells) const
Int_t createAllArrays(Int_t size=500)
Definition: hmdccluster.cc:640
void clearMod2Par(void)
Definition: hmdcclus.h:77
Bool_t addToRClusCounters(Int_t seg, HMdcList12GroupCells &listCells)
static void deleteCont(void)
Definition: hmdccluster.cc:617
void testCluster(Int_t indArr, Int_t indClus)
Definition: hmdccluster.cc:665
Int_t getNUniqueAndRWires2(Int_t seg, HMdcList12GroupCells &listCells, Int_t &nWInReal) const
virtual Bool_t isGeant(void) const
Definition: hmdcclus.h:71
void setRealLevel(UChar_t rl)
Definition: hmdcclus.h:89
void addClus(HMdcCluster &clst2)
Definition: hmdccluster.cc:71
Int_t iYFirst
Definition: hmdccluster.h:38
void fillClusModTrackInf(HMdcClusSim *pClusSim, HMdcList12GroupCells *wrLst, Int_t modi)
Int_t getNUniqueWiresSeg1(HMdcSecListCells *pListCells)
Definition: hmdccluster.cc:569
Int_t nLayers1
Definition: hmdccluster.h:18
HMdcCluster * createArray(Int_t ind, Int_t size)
Definition: hmdccluster.cc:649
ClassImp(HMdcCluster) ClassImp(HMdcClustersArrs) void HMdcCluster
Definition: hmdccluster.cc:19
Int_t add(HMdcList12GroupCells *lst)
Int_t meanYY
Definition: hmdccluster.h:30
void setFakeFlagAndStatus(UChar_t fl)
Definition: hmdccluster.h:97
void printCellInfo(Int_t cell) const
HMdcCluster * clusMod2
Definition: hmdccluster.h:56
Int_t meanXX
Definition: hmdccluster.h:29
Int_t meanY
Definition: hmdccluster.h:28
Int_t getNUniqueWires(Int_t seg, HMdcList12GroupCells &listCells) const
void sumClus(HMdcCluster &clst1, HMdcCluster &clst2)
Definition: hmdccluster.cc:154
void setClusSizeM2(Short_t clSz)
Definition: hmdcclus.h:124
HMdcCluster * getCluster(Int_t indarr, Int_t indClus)
Definition: hmdccluster.cc:660
void fillClus(HMdcClus *clus, Int_t nLst, Bool_t fillTrList)
Definition: hmdccluster.cc:215
void fillClusTrackInf(HMdcClusSim *pClusSim)
Bool_t testNLayersSeg2(void)
Definition: hmdccluster.cc:565
Bool_t status
Definition: hmdccluster.h:20
Short_t nMergedClus
Definition: hmdccluster.h:23
void calcXY(void)
Definition: hmdccluster.cc:126
HMdcList12GroupCells lCells1
Definition: hmdccluster.h:12
void setShapeM2(Float_t s1, Float_t s2, Float_t al)
Definition: hmdcclus.h:127
Int_t iXFirst
Definition: hmdccluster.h:37
void setNMergClustM1(Short_t nmrc)
Definition: hmdcclus.h:119
Int_t meanX
Definition: hmdccluster.h:27
Int_t numCells1
Definition: hmdccluster.h:16
void setNBins(Int_t nBn)
Definition: hmdcclus.h:90
void resetRealFlagSeg1(Bool_t real, HMdcSecListCells *pListCells)
Definition: hmdccluster.cc:593
Int_t nLayers2
Definition: hmdccluster.h:19
static HMdcTrackInfSim * getMdcTrackInfSim(void)
Int_t minWt
Definition: hmdccluster.h:36