Belle II Software  release-05-01-25
TrgEclCluster.cc
1 //---------------------------------------------------------------
2 // $Id$
3 //---------------------------------------------------------------
4 // Filename : TrgEclCluster.cc
5 // Section : TRG ECL
6 // Owner : InSoo Lee/Yuuji Unno
7 // Email : islee@hep.hanyang.ac.kr / yunno@post.kek.jp
8 //---------------------------------------------------------------
9 // Description :
10 // -A class to make cluster from TC Hit
11 // -ICN Logic ( function name : setICN(tcid) )
12 // Isolate cluster counting logic used in Belle for 3x3 TCs
13 //
14 // |5|1|6|
15 // |2|0|3| ICN = [ 0 and !(1 or 2) and !(4 and 7) ]
16 // |7|4|8|
17 //
18 // 3x3 TC
19 //
20 // -Clustering Logic (Function name : setICN(tcid, tcenergy, tctiming) )
21 // 1.Find TC Hit (0) satisfying ICN logic
22 // 2.Find the most energetic TC Hit in the neghbor TCs with 0 (9 TCs)
23 // 3.Bind neighbor TC hits with the most energetic TC (Center TC) as a Cluster
24 // 4.Cluster energy : Total energy in Cluster
25 // 5.Timing : Timing of the most energetic TC in a cluster or Energy weighted timing in a cluster
26 //
27 // -The limit number of Cluster is 6 due to hardware limitation (ETM)
28 // -The cluster information (energy, timing) is saved in the order of barrel, forward endcap and backwrd endcap
29 //---------------------------------------------------------------
30 // $Log$
31 // 2018-07-30 : Add the limit number of Cluster (defult : 6)
32 // 2020-05-13 : Bug Fixed for BWD ICN by SungHyun Kim
33 //---------------------------------------------------------------
34 
35 #define TRG_SHORT_NAMES
36 #define TRGECLCLUSTER_SHORT_NAMES
37 
38 #include <framework/datastore/StoreArray.h>
39 
40 
41 #include <trg/ecl/TrgEclCluster.h>
42 #include "trg/ecl/dataobjects/TRGECLCluster.h"
43 
44 
45 using namespace std;
46 using namespace Belle2;
47 //
48 //
49 //
50 TrgEclCluster::TrgEclCluster(): _BRICN(0), _FWDICN(0), _BWDICN(0), _BRNofCluster(0), _FWDNofCluster(0), _BWDNofCluster(0),
51  _EventId(0), _Method(1), _LimitNCluster(6), _Position(1)
52 {
53  // initialize All parameters
54 
55  _icnfwbrbw.clear();
56  _BrCluster.clear();
57  _FwCluster.clear();
58  _BwCluster.clear();
59  _Quadrant.clear();
60 
61  TCId.clear();
62  Timing.clear();
63  Energy.clear();
64 
65  ClusterTiming.clear();
66  ClusterEnergy.clear();
67  ClusterPositionX.clear();
68  ClusterPositionY.clear();
69  ClusterPositionZ.clear();
70  NofTCinCluster.clear();
71  MaxTCId.clear();
72  TempCluster.clear();
73 
74  _icnfwbrbw.resize(3, 0);
75  TempCluster.resize(9);
76  _Quadrant.resize(3, std::vector<int>(4, 0.0));
77 
78  ClusterTiming.resize(3);
79  ClusterEnergy.resize(3);
80  ClusterPositionX.resize(3);
81  ClusterPositionY.resize(3);
82  ClusterPositionZ.resize(3);
83  NofTCinCluster.resize(3);
84  MaxTCId.resize(3);
85 
86 
87  _TCMap = new TrgEclMapping();
88 
89 
90 
91 }
92 //
93 //
94 //
96 {
97  delete _TCMap;
98 }
99 
100 
101 
102 //
103 int
105 {
106  // get ICN in Barrel and Forward Endcap except for the most inner (=Physics region : Theta Id 2 ~ 15)
107  return _icnfwbrbw[0] + _icnfwbrbw[1];
108 
109 }
110 //
111 //
112 //
113 int
115 {
116  // get ICN in Barrel and Backward endcap, Forward Endcap except for the most inner (=Physics region : Theta Id 2 ~ 15)
117 
118  return _icnfwbrbw[FwBrBw];
119 
120 }
121 //
122 //
123 //
124 int
125 TrgEclCluster::getBrICNCluster(int ICNId, int location)
126 {
127  // get the # of Cluster in Barrel.
128  return _BrCluster[ICNId][location];
129 
130 }
131 //
132 //
133 //
134 int
135 TrgEclCluster::getBwICNCluster(int ICNId, int location)
136 {
137 
138  return _BwCluster[ICNId][location];
139 
140 }
141 
142 //
143 //
144 //
145 int
146 TrgEclCluster::getFwICNCluster(int ICNId, int location)
147 {
148 
149  return _FwCluster[ICNId][location];
150 
151 }
152 //
153 //
154 //
155 void
156 TrgEclCluster::setICN(std::vector<int> tcid)
157 {
158  TCId = tcid ;
159  _Quadrant.clear();
160  _Quadrant.resize(3, std::vector<int>(4, 0.0));
161  _icnfwbrbw.clear();
162  _icnfwbrbw.resize(3, 0);
163  _BRICN = 0 ;
164  _FWDICN = 0;
165  _BWDICN = 0;
166 
167  _icnfwbrbw[1] = setBarrelICN();
168  _icnfwbrbw[0] = setForwardICN();
169  _icnfwbrbw[2] = setBackwardICN();
170 
171 
172  return;
173 }
174 void
175 TrgEclCluster::setICN(std::vector<int> tcid, std::vector<double> tcenergy, std::vector<double> tctiming)
176 {
177  TCId = tcid ;
178  Energy = tcenergy;
179  Timing = tctiming;
180 
184 
185  save(_EventId);
186 
187  return;
188 }
189 void
190 TrgEclCluster::save(int m_nEvent)
191 {
192  // Save Cluster
193  // Save order : Barrel, Forward, Backward
194 
195  int m_hitNum = 0;
196  int clusterId = 0;
197  int counter = 0;
198  for (int iposition = 0; iposition < 3 ; iposition ++) {
199  const int Ncluster = ClusterEnergy[iposition].size();
200  for (int icluster = 0; icluster < Ncluster; icluster++) {
201  if (ClusterEnergy[iposition][icluster] <= 0) {continue;}
202 
203  if (counter >= _LimitNCluster) {
204  continue;
205  } else {
206  counter ++;
207  }
208 
209  StoreArray<TRGECLCluster> ClusterArray;
210  ClusterArray.appendNew();
211  m_hitNum = ClusterArray.getEntries() - 1;
212  ClusterArray[m_hitNum]->setEventId(m_nEvent);
213  ClusterArray[m_hitNum]->setClusterId(clusterId);
214  ClusterArray[m_hitNum]->setMaxTCId(MaxTCId[iposition][icluster]);
215  ClusterArray[m_hitNum]->setMaxThetaId(_TCMap->getTCThetaIdFromTCId(MaxTCId[iposition][icluster]));
216  ClusterArray[m_hitNum]->setMaxPhiId(_TCMap->getTCPhiIdFromTCId(MaxTCId[iposition][icluster]));
217  ClusterArray[m_hitNum]->setNofTCinCluster(NofTCinCluster[iposition][icluster]);
218  ClusterArray[m_hitNum]->setEnergyDep(ClusterEnergy[iposition][icluster]);
219  ClusterArray[m_hitNum]->setTimeAve(ClusterTiming[iposition][icluster]);
220 
221  ClusterArray[m_hitNum]->setPositionX(ClusterPositionX[iposition][icluster]);
222  ClusterArray[m_hitNum]->setPositionY(ClusterPositionY[iposition][icluster]);
223  ClusterArray[m_hitNum]->setPositionZ(ClusterPositionZ[iposition][icluster]);
224  clusterId ++;
225  }
226  }
227 
228 
229 }
231 {
232 
233  std::vector<int> TCFire;
234  std::vector<double> TCFireEnergy;
235  std::vector<double> TCFireTiming;
236  std::vector<std::vector<double>> TCFirePosition;
237 
238  TCFire.clear();
239  TCFireEnergy.clear();
240  TCFireTiming.clear();
241  TCFirePosition.clear();
242 
243  TCFire.resize(432, 0);
244  TCFireEnergy.resize(432, 0.);
245  TCFireTiming.resize(432, 0.);
246  TCFirePosition.resize(432, std::vector<double>(3, 0.));
247 
248 
249 
250 
251  const int hit_size = TCId.size();
252  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
253  if (TCId[ihit] >= 81 && TCId[ihit] <= 512) {
254  TCFire[TCId[ihit] - 81] = TCId[ihit];
255  TCFireEnergy[TCId[ihit] - 81] = Energy[ihit];
256  TCFireTiming[TCId[ihit] - 81] = Timing[ihit];
257  TCFirePosition[TCId[ihit] - 81][0] = (_TCMap->getTCPosition(TCId[ihit])).X();
258  TCFirePosition[TCId[ihit] - 81][1] = (_TCMap->getTCPosition(TCId[ihit])).Y();
259  TCFirePosition[TCId[ihit] - 81][2] = (_TCMap->getTCPosition(TCId[ihit])).Z();
260  }
261  }
262 
263 
264  // // //
265  // // //
266  // // //
267  int tc_upper = 0; // check upper TC
268  int tc_upper_right = 0; // check right TC
269  int tc_right = 0; // check right TC
270  int tc_lower_right = 0;
271  int tc_lower = 0; // check lower TC
272  int tc_lower_left = 0; // check lower TC
273  int tc_left = 0;
274  int tc_upper_left = 0;
275 
276  for (int iii = 0 ; iii < 432 ; iii++) {
277  if (TCFire[iii] == 0) { continue; }
278 
279  if (iii < 12) {
280  tc_upper = TCFire[iii + 420] ;
281  tc_upper_right = TCFire[iii + 419] ;
282  tc_right = TCFire[iii - 1] ;
283  tc_lower_right = TCFire[iii + 11] ;
284  tc_lower = TCFire[iii + 12] ;
285  tc_lower_left = TCFire[iii + 13] ;
286  tc_left = TCFire[iii + 1] ;
287  tc_upper_left = TCFire[iii + 421] ;
288  if (iii % 12 == 0) {
289  tc_upper_right = 0;
290  tc_right = 0;
291  tc_lower_right = 0;
292 
293  }
294  if (iii % 12 == 11) {
295  tc_lower_left = 0;
296  tc_left = 0;
297  tc_upper_left = 0;
298 
299  }
300  }
301  if (iii > 11 && iii < 420) {
302  tc_upper = TCFire[iii - 12] ;
303  tc_upper_right = TCFire[iii - 13] ;
304  tc_right = TCFire[iii - 1] ;
305  tc_lower_right = TCFire[iii + 11] ;
306  tc_lower = TCFire[iii + 12] ;
307  tc_lower_left = TCFire[iii + 13] ;
308  tc_left = TCFire[iii + 1] ;
309  tc_upper_left = TCFire[iii - 11] ;
310  if (iii % 12 == 0) {
311  tc_upper_right = 0;
312  tc_right = 0;
313  tc_lower_right = 0;
314 
315  }
316  if (iii % 12 == 11) {
317  tc_lower_left = 0;
318  tc_left = 0;
319  tc_upper_left = 0;
320 
321  }
322 
323  }
324  if (iii > 419) {
325  tc_upper = TCFire[iii - 12] ;
326  tc_upper_right = TCFire[iii - 13] ;
327  tc_right = TCFire[iii - 1] ;
328  tc_lower_right = TCFire[iii - 421] ;
329  tc_lower = TCFire[iii - 420] ;
330  tc_lower_left = TCFire[iii - 419];
331  tc_left = TCFire[iii + 1] ;
332  tc_upper_left = TCFire[iii - 11] ;
333  if (iii % 12 == 0) {
334  tc_upper_right = 0;
335  tc_right = 0;
336  tc_lower_right = 0;
337  }
338  if (iii % 12 == 11) {
339  tc_lower_left = 0;
340  tc_left = 0;
341  tc_upper_left = 0;
342 
343  }
344  }
345 
346 
347  TempCluster[0] = iii + 80 + 1; //middle of ICN
348  TempCluster[1] = tc_upper; // upper
349  TempCluster[2] = tc_upper_right; //right
350  TempCluster[3] = tc_right; //right
351  TempCluster[4] = tc_lower_right; //lower
352  TempCluster[5] = tc_lower; //lower
353  TempCluster[6] = tc_lower_left; //lower
354  TempCluster[7] = tc_left; //lower
355  TempCluster[8] = tc_upper_left; //lower right;
356 
357 
358  if (!(tc_upper != 0 || tc_left != 0)) {
359  if (!(tc_lower != 0 && tc_lower_left != 0)) {
360 
361  if (Method == 1) { //for cluster method2(Consider TC energy in oderto find the center of cluster)
362 
363  int maxTCid = 0;
364  double maxTCEnergy = 0;
365  for (int iTC = 0; iTC < 9; iTC++) { //find center of Cluster
366  if (TempCluster[iTC] == 0) {continue;}
367  if (maxTCEnergy < TCFireEnergy[TempCluster[iTC] - 81]) {
368  maxTCEnergy = TCFireEnergy[TempCluster[iTC] - 81];
369  maxTCid = TempCluster[iTC];
370  }
371  }
372  TempCluster[0] = maxTCid;
373 
374  if (maxTCid < 93) {
375 
376  TempCluster[1] = TCFire[maxTCid + 420 - 81 ] ;
377  TempCluster[2] = TCFire[maxTCid + 419 - 81 ] ;
378  TempCluster[3] = TCFire[maxTCid - 1 - 81 ] ;
379  TempCluster[4] = TCFire[maxTCid + 11 - 81 ] ;
380  TempCluster[5] = TCFire[maxTCid + 12 - 81 ] ;
381  TempCluster[6] = TCFire[maxTCid + 13 - 81 ] ;
382  TempCluster[7] = TCFire[maxTCid + 1 - 81 ] ;
383  TempCluster[8] = TCFire[maxTCid + 421 - 81 ] ;
384 
385 
386  if ((maxTCid - 81) % 12 == 0) {
387 
388  TempCluster[2] = 0 ;
389  TempCluster[3] = 0 ;
390  TempCluster[4] = 0 ;
391 
392  }
393  if ((maxTCid - 81) % 12 == 11) {
394 
395  TempCluster[6] = 0 ;
396  TempCluster[7] = 0 ;
397  TempCluster[8] = 0 ;
398 
399  }
400  }
401  if (maxTCid > 92 && maxTCid < 501) {
402 
403  TempCluster[1] = TCFire[maxTCid - 12 - 81] ;
404  TempCluster[2] = TCFire[maxTCid - 13 - 81] ;
405  TempCluster[3] = TCFire[maxTCid - 1 - 81] ;
406  TempCluster[4] = TCFire[maxTCid + 11 - 81] ;
407  TempCluster[5] = TCFire[maxTCid + 12 - 81] ;
408  TempCluster[6] = TCFire[maxTCid + 13 - 81] ;
409  TempCluster[7] = TCFire[maxTCid + 1 - 81] ;
410  TempCluster[8] = TCFire[maxTCid - 11 - 81] ;
411 
412  if ((maxTCid - 81) % 12 == 0) {
413  TempCluster[2] = 0 ;
414  TempCluster[3] = 0 ;
415  TempCluster[4] = 0 ;
416 
417  }
418  if ((maxTCid - 81) % 12 == 11) {
419 
420  TempCluster[6] = 0 ;
421  TempCluster[7] = 0 ;
422  TempCluster[8] = 0 ;
423 
424  }
425 
426  }
427  if (maxTCid > 500) {
428  TempCluster[1] = TCFire[maxTCid - 12 - 81] ;
429  TempCluster[2] = TCFire[maxTCid - 13 - 81] ;
430  TempCluster[3] = TCFire[maxTCid - 1 - 81] ;
431  TempCluster[4] = TCFire[maxTCid - 421 - 81] ;
432  TempCluster[5] = TCFire[maxTCid - 420 - 81] ;
433  TempCluster[6] = TCFire[maxTCid - 419 - 81] ;
434  TempCluster[7] = TCFire[maxTCid + 1 - 81] ;
435  TempCluster[8] = TCFire[maxTCid - 11 - 81] ;
436 
437 
438 
439  if ((maxTCid - 81) % 12 == 0) {
440  TempCluster[2] = 0 ;
441  TempCluster[3] = 0 ;
442  TempCluster[4] = 0 ;
443 
444  }
445  if ((maxTCid - 81) % 12 == 11) {
446 
447  TempCluster[6] = 0 ;
448  TempCluster[7] = 0 ;
449  TempCluster[8] = 0 ;
450 
451  }
452 
453  }
454 
455 
456  }
457 
458  for (int iNearTC = 1; iNearTC < 9; iNearTC ++) {
459  for (int jNearTC = 1; jNearTC < 9; jNearTC ++) {
460  if (TempCluster[iNearTC] == 0) {continue;}
461  if (iNearTC == jNearTC) {continue;}
462  if (TempCluster[iNearTC] == TempCluster[jNearTC]) {
463  TempCluster[jNearTC] = 0;
464  }
465  }
466  }
467 
468  int maxTCId = 999;
469  double clusterenergy = 0;
470  double clustertiming = 0;
471  double clusterpositionX = 0;
472  double clusterpositionY = 0;
473  double clusterpositionZ = 0;
474  int noftcincluster = 0;
475  for (int iNearTC = 0; iNearTC < 9; iNearTC ++) {
476  if (TempCluster[iNearTC] == 0) {continue;}
477  else {noftcincluster++;}
478  clusterenergy += TCFireEnergy[TempCluster[iNearTC] - 81];
479  clustertiming += TCFireEnergy[TempCluster[iNearTC] - 81] * TCFireTiming[TempCluster[iNearTC] - 81];
480  clusterpositionX += TCFireEnergy[TempCluster[iNearTC] - 81] * TCFirePosition[TempCluster[iNearTC] - 81][0];
481  clusterpositionY += TCFireEnergy[TempCluster[iNearTC] - 81] * TCFirePosition[TempCluster[iNearTC] - 81][1];
482  clusterpositionZ += TCFireEnergy[TempCluster[iNearTC] - 81] * TCFirePosition[TempCluster[iNearTC] - 81][2];
483 
484 
485 
486  }
487  //
488  maxTCId = TempCluster[0];
489  //
490  clustertiming /= clusterenergy;
491  if (_Position == 1) {
492  clusterpositionX /= clusterenergy;
493  clusterpositionY /= clusterenergy;
494  clusterpositionZ /= clusterenergy;
495  } else if (_Position == 0) {
496  clustertiming = TCFireTiming[maxTCId - 81];
497  clusterpositionX = TCFirePosition[maxTCId - 81][0];
498  clusterpositionY = TCFirePosition[maxTCId - 81][1];
499  clusterpositionZ = TCFirePosition[maxTCId - 81][2];
500  }
501  if (clustertiming == 0 && clusterenergy == 0) {continue;}
502  _BrCluster.push_back(TempCluster);
503  ClusterEnergy[0].push_back(clusterenergy);
504  ClusterTiming[0].push_back(clustertiming);
505  ClusterPositionX[0].push_back(clusterpositionX);
506  ClusterPositionY[0].push_back(clusterpositionY);
507  ClusterPositionZ[0].push_back(clusterpositionZ);
508  NofTCinCluster[0].push_back(noftcincluster);
509  MaxTCId[0].push_back(maxTCId);
510  }
511  }
512  }// iii loop
513  _BRNofCluster = MaxTCId[0].size();
514 
515 }
516 void
518 {
519 
520  std::vector<int> TCFire;
521  std::vector<double> TCFireEnergy;
522  std::vector<double> TCFireTiming;
523  std::vector<std::vector<double>> TCFirePosition;
524 
525  std::vector<double> TempClusterEnergy;
526  std::vector<double> TempClusterTiming;
527  std::vector<double> TempClusterPositionX;
528  std::vector<double> TempClusterPositionY;
529  std::vector<double> TempClusterPositionZ;
530  std::vector<double> Sort1D;
531  std::vector<std::vector<double>> Sort2D;
532 
533  std::vector<int> TempNofTCinCluster;
534  std::vector<int> TempMaxTCId;
535 
536  int TempICNTCId = 0;;
537 
538  TempClusterEnergy.clear();
539  TempClusterTiming.clear();
540  TempClusterPositionX.clear();
541  TempClusterPositionY.clear();
542  TempClusterPositionZ.clear();
543  TempNofTCinCluster.clear();
544  TempMaxTCId.clear();
545 
546  Sort2D.clear();
547  Sort1D.clear();
548 
549 
550 
551 
552 
553  TCFire.clear();
554  TCFireEnergy.clear();
555  TCFireTiming.clear();
556  TCFirePosition.clear();
557 
558  TCFire.resize(96, 0);
559  TCFireEnergy.resize(96, 0.);
560  TCFireTiming.resize(96, 0.);
561 
562  TCFirePosition.resize(96, std::vector<double>(3, 0.));
563 
564 
565  const int hit_size = TCId.size();
566  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
567  if (TCId[ihit] > 80) {continue;}
568 
569  TCFireEnergy[TCId[ihit] - 1] = Energy[ihit];
570  TCFireTiming[TCId[ihit] - 1] = Timing[ihit];
571  TCFirePosition[TCId[ihit] - 1][0] = (_TCMap->getTCPosition(TCId[ihit])).X();
572  TCFirePosition[TCId[ihit] - 1][1] = (_TCMap->getTCPosition(TCId[ihit])).Y();
573  TCFirePosition[TCId[ihit] - 1][2] = (_TCMap->getTCPosition(TCId[ihit])).Z();
574 
575 
576 
577  //------------------------------------
578  // To rearrange the hitted map
579  //
580  // orignal converted
581  // (<- Theta) (<- Theta)
582  //
583  // 3 2 1 64 32 0
584  // 4 5 - 65 33 1
585  // 8 7 6 => 66 34 2
586  // 9 10 - 67 35 3
587  // .... ...
588  // 78 77 76 94 62 30
589  // 79 80 - 95 63 31
590  //
591  // Here, TCId-1 becomes TCId=0 and 1.
592  //------------------------------------
593  int iTCId0 = TCId[ihit] - 1;
594  int kkk = 0;
595  if (iTCId0 % 5 == 0) {
596  kkk = (iTCId0 / 5) * 2;
597  TCFire[kkk] = TCId[ihit];
598  TCFire[kkk + 1] = TCId[ihit];
599  } else {
600  kkk = iTCId0 / 5;
601  switch (iTCId0 % 5) {
602  case 1 :
603  TCFire[32 + 2 * kkk] = TCId[ihit]; break;
604  case 2 :
605  TCFire[64 + 2 * kkk] = TCId[ihit]; break;
606  case 3 :
607  TCFire[64 + 2 * kkk + 1] = TCId[ihit]; break;
608  case 4 :
609  TCFire[32 + 2 * kkk + 1] = TCId[ihit]; break;
610  default:
611  break;
612  }
613  }
614  }
615 
616  for (int iii = 0 ; iii < 96 ; iii++) {
617  int icn_flag = 0;
618  if (iii < 32) {
619  if (iii % 2 == 1) {
620  continue;
621  }
622  }
623  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
624  if (TCFire[iii] == 0) { continue; }
625  if (iii < 32) { // most inner
626  if (iii == 0) {
627  TempCluster[0] = TCFire[iii];
628  TempCluster[1] = TCFire[30]; // top
629  TempCluster[2] = TCFire[63]; // left up
630  TempCluster[3] = TCFire[iii + 32] ; // left 1
631  TempCluster[4] = TCFire[iii + 33]; // left 2
632  TempCluster[5] = TCFire[iii + 34]; // left bottom
633  TempCluster[6] = TCFire[iii + 2]; // bottom
634  TempCluster[7] = 0;
635  TempCluster[8] = 0;
636 
637  } else if (iii == 30) {
638  TempCluster[0] = TCFire[iii];
639  TempCluster[1] = TCFire[iii - 2]; // top
640  TempCluster[2] = TCFire[iii + 31]; // left up
641  TempCluster[3] = TCFire[iii + 32] ; // left 1
642  TempCluster[4] = TCFire[iii + 33]; // left 2
643  TempCluster[5] = TCFire[32]; // left bottom
644  TempCluster[6] = TCFire[0]; // bottom
645  TempCluster[7] = 0;
646  TempCluster[8] = 0;
647 
648  } else {
649  TempCluster[0] = TCFire[iii];
650  TempCluster[1] = TCFire[iii - 2]; // top
651  TempCluster[2] = TCFire[iii + 31]; // left up
652  TempCluster[3] = TCFire[iii + 32] ; // left 1
653  TempCluster[4] = TCFire[iii + 33]; // left 2
654  TempCluster[5] = TCFire[iii + 34]; // left bottom
655  TempCluster[6] = TCFire[iii + 2]; // bottom
656  TempCluster[7] = 0;
657  TempCluster[8] = 0;
658 
659  }
660  if (!(TempCluster[1] != 0 || (TempCluster[3] != 0 || TempCluster[4] != 0))) {
661  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
662  icn_flag = 1;
663 
664 
665  }
666  }
667 
668  } else if (iii > 31 && iii < 64) {
669  if (iii == 32) {
670  TempCluster[0] = TCFire[iii];
671  TempCluster[1] = TCFire[63]; // up
672  TempCluster[2] = TCFire[iii - 2]; // up right
673  TempCluster[3] = TCFire[iii - 32]; // right
674  TempCluster[4] = 0; //right bottom
675  TempCluster[5] = TCFire[iii + 1]; // bottom
676  TempCluster[6] = TCFire[iii + 33]; // left bottom
677  TempCluster[7] = TCFire[iii + 32]; // left
678  TempCluster[8] = TCFire[95]; // up left
679 
680  } else if (iii == 33) {
681 
682  TempCluster[0] = TCFire[iii];
683  TempCluster[1] = TCFire[iii - 1]; // up
684  TempCluster[2] = 0; // up right
685  TempCluster[3] = TCFire[iii - 32]; // right
686  TempCluster[4] = TCFire[iii - 30]; //right bottom
687  TempCluster[5] = TCFire[iii + 1]; // bottom
688  TempCluster[6] = TCFire[iii + 33]; // left bottom
689  TempCluster[7] = TCFire[iii + 32]; // left
690  TempCluster[8] = TCFire[iii + 31]; // up left
691 
692  }
693 
694  else if (iii == 62) {
695  TempCluster[0] = TCFire[iii];
696  TempCluster[1] = TCFire[iii - 1]; // up
697  TempCluster[2] = TCFire[iii - 34]; // up right
698  TempCluster[3] = TCFire[iii - 32]; // right
699  TempCluster[4] = 0; //right bottom
700  TempCluster[5] = TCFire[iii + 1]; // bottom
701  TempCluster[6] = TCFire[iii + 33]; // left bottom
702  TempCluster[7] = TCFire[iii + 32]; // left
703  TempCluster[8] = TCFire[iii + 31]; // up left
704 
705 
706  } else if (iii == 63) {
707  TempCluster[0] = TCFire[iii];
708  TempCluster[1] = TCFire[iii - 1]; // up
709  TempCluster[2] = 0; // up right
710  TempCluster[3] = TCFire[iii - 32]; // right
711  TempCluster[4] = TCFire[1]; //right bottom
712  TempCluster[5] = TCFire[32]; // bottom
713  TempCluster[6] = TCFire[64]; // left bottom
714  TempCluster[7] = TCFire[iii + 32]; // left
715  TempCluster[8] = TCFire[iii + 31]; // up left
716 
717  }
718 
719  else {
720 
721  TempCluster[0] = TCFire[iii];
722  TempCluster[1] = TCFire[iii - 1]; // up
723  TempCluster[2] = TCFire[iii - 34]; // up right
724  TempCluster[3] = TCFire[iii - 32]; // right
725  TempCluster[4] = TCFire[iii - 30]; //right bottom
726  TempCluster[5] = TCFire[iii + 1]; // bottom
727  TempCluster[6] = TCFire[iii + 33]; // left bottom
728  TempCluster[7] = TCFire[iii + 32]; // left
729  TempCluster[8] = TCFire[iii + 31]; // up left
730  if (iii % 2 == 0) {
731  TempCluster[4] = 0;
732  } else {
733  TempCluster[2] = 0;
734  }
735  }
736  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
737  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
738  icn_flag = 1;
739 
740 
741  }
742  }
743 
744 
745 
746  } else {
747  if (iii == 64) {
748  TempCluster[0] = TCFire[iii];
749  TempCluster[1] = TCFire[95]; // top
750  TempCluster[2] = TCFire[63];// right top
751  TempCluster[3] = TCFire[iii - 32]; //right
752  TempCluster[4] = TCFire[iii - 31]; //right bottom
753  TempCluster[5] = TCFire[iii + 1]; //bottom
754  TempCluster[6] = 0; //bottom left
755  TempCluster[7] = 0; // left
756  TempCluster[8] = 0; //top left
757  } else if (iii == 95) {
758  TempCluster[0] = TCFire[iii];
759  TempCluster[1] = TCFire[iii - 1]; // top
760  TempCluster[2] = TCFire[iii - 33]; // right top
761  TempCluster[3] = TCFire[iii - 32]; //right
762  TempCluster[4] = TCFire[32]; //right bottom
763  TempCluster[5] = TCFire[64]; //bottom
764  TempCluster[6] = 0; //bottom left
765  TempCluster[7] = 0; // left
766  TempCluster[8] = 0; //top left
767 
768  } else {
769  TempCluster[0] = TCFire[iii];
770  TempCluster[1] = TCFire[iii - 1]; // top
771  TempCluster[2] = TCFire[iii - 33]; // right top
772  TempCluster[3] = TCFire[iii - 32]; //right
773  TempCluster[4] = TCFire[iii - 31]; //right bottom
774  TempCluster[5] = TCFire[iii + 1]; //bottom
775  TempCluster[6] = 0; //bottom left
776  TempCluster[7] = 0; // left
777  TempCluster[8] = 0; //top left
778  }
779  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
780  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
781  icn_flag = 1;
782 
783  }
784  }
785 
786 
787  }
788 
789  if (icn_flag == 1) {
790  TempICNTCId = TCFire[iii];
791 
792  if (Method == 1) { //for cluster method2
793  int maxTCid = 0;
794  double maxTCEnergy = 0;
795  for (int iTC = 0; iTC < 9; iTC++) { //find center of Cluster
796  if (TempCluster[iTC] == 0) {continue;}
797  if (maxTCEnergy < TCFireEnergy[TempCluster[iTC] - 1]) {
798  maxTCEnergy = TCFireEnergy[TempCluster[iTC] - 1];
799  maxTCid = TempCluster[iTC];
800  }
801  }
802  TempCluster.resize(9, 0);
803  TempCluster[0] = maxTCid;
804  int kkk = (TempCluster[0] - 1) / 5;
805  if ((TempCluster[0] - 1) % 5 == 0) {
806  kkk = kkk * 2;
807  } else if ((TempCluster[0] - 1) % 5 == 1) {
808  kkk = 32 + 2 * kkk;
809  } else if ((TempCluster[0] - 1) % 5 == 2) {
810  kkk = 64 + 2 * kkk;
811  } else if ((TempCluster[0] - 1) % 5 == 3) {
812  kkk = 64 + 1 + 2 * kkk;
813  } else if ((TempCluster[0] - 1) % 5 == 4) {
814  kkk = 32 + 1 + 2 * kkk;
815  }
816 
817  if (kkk < 32) { // most inner
818  if (kkk == 0) {
819  TempCluster[0] = TCFire[kkk];
820  TempCluster[1] = TCFire[30]; // top
821  TempCluster[2] = TCFire[63]; // left up
822  TempCluster[3] = TCFire[kkk + 32] ; // left 1
823  TempCluster[4] = TCFire[kkk + 33]; // left 2
824  TempCluster[5] = TCFire[kkk + 34]; // left bottom
825  TempCluster[6] = TCFire[kkk + 2]; // bottom
826  TempCluster[7] = 0;
827  TempCluster[8] = 0;
828 
829  } else if (kkk == 30) {
830  TempCluster[0] = TCFire[kkk];
831  TempCluster[1] = TCFire[kkk - 2]; // top
832  TempCluster[2] = TCFire[kkk + 31]; // left up
833  TempCluster[3] = TCFire[kkk + 32] ; // left 1
834  TempCluster[4] = TCFire[kkk + 33]; // left 2
835  TempCluster[5] = TCFire[32]; // left bottom
836  TempCluster[6] = TCFire[0]; // bottom
837  TempCluster[7] = 0;
838  TempCluster[8] = 0;
839 
840  } else {
841  TempCluster[0] = TCFire[kkk];
842  TempCluster[1] = TCFire[kkk - 2]; // top
843  TempCluster[2] = TCFire[kkk + 31]; // left up
844  TempCluster[3] = TCFire[kkk + 32] ; // left 1
845  TempCluster[4] = TCFire[kkk + 33]; // left 2
846  TempCluster[5] = TCFire[kkk + 34]; // left bottom
847  TempCluster[6] = TCFire[kkk + 2]; // bottom
848  TempCluster[7] = 0;
849  TempCluster[8] = 0;
850 
851  }
852 
853  } else if (kkk > 31 && kkk < 64) {
854  if (kkk == 32) {
855  TempCluster[0] = TCFire[kkk];
856  TempCluster[1] = TCFire[63]; // up
857  TempCluster[2] = TCFire[kkk - 2]; // up right
858  TempCluster[3] = TCFire[kkk - 32]; // right
859  TempCluster[4] = 0; //right bottom
860  TempCluster[5] = TCFire[kkk + 1]; // bottom
861  TempCluster[6] = TCFire[kkk + 33]; // left bottom
862  TempCluster[7] = TCFire[kkk + 32]; // left
863  TempCluster[8] = TCFire[95]; // up left
864 
865  } else if (kkk == 33) {
866 
867  TempCluster[0] = TCFire[kkk];
868  TempCluster[1] = TCFire[kkk - 1]; // up
869  TempCluster[2] = 0; // up right
870  TempCluster[3] = TCFire[kkk - 32]; // right
871  TempCluster[4] = TCFire[kkk - 30]; //right bottom
872  TempCluster[5] = TCFire[kkk + 1]; // bottom
873  TempCluster[6] = TCFire[kkk + 33]; // left bottom
874  TempCluster[7] = TCFire[kkk + 32]; // left
875  TempCluster[8] = TCFire[kkk + 31]; // up left
876 
877  }
878 
879  else if (kkk == 62) {
880  TempCluster[0] = TCFire[kkk];
881  TempCluster[1] = TCFire[kkk - 1]; // up
882  TempCluster[2] = TCFire[kkk - 34]; // up right
883  TempCluster[3] = TCFire[kkk - 32]; // right
884  TempCluster[4] = 0; //right bottom
885  TempCluster[5] = TCFire[kkk + 1]; // bottom
886  TempCluster[6] = TCFire[kkk + 33]; // left bottom
887  TempCluster[7] = TCFire[kkk + 32]; // left
888  TempCluster[8] = TCFire[kkk + 31]; // up left
889 
890 
891  } else if (kkk == 63) {
892  TempCluster[0] = TCFire[kkk];
893  TempCluster[1] = TCFire[kkk - 1]; // up
894  TempCluster[2] = 0; // up right
895  TempCluster[3] = TCFire[kkk - 32]; // right
896  TempCluster[4] = TCFire[1]; //right bottom
897  TempCluster[5] = TCFire[32]; // bottom
898  TempCluster[6] = TCFire[64]; // left bottom
899  TempCluster[7] = TCFire[kkk + 32]; // left
900  TempCluster[8] = TCFire[kkk + 31]; // up left
901 
902  }
903 
904  else {
905  TempCluster[0] = TCFire[kkk];
906  TempCluster[1] = TCFire[kkk - 1]; // up
907  TempCluster[2] = TCFire[kkk - 34]; // up right
908  TempCluster[3] = TCFire[kkk - 32]; // right
909  TempCluster[4] = TCFire[kkk - 30]; //right bottom
910  TempCluster[5] = TCFire[kkk + 1]; // bottom
911  TempCluster[6] = TCFire[kkk + 33]; // left bottom
912  TempCluster[7] = TCFire[kkk + 32]; // left
913  TempCluster[8] = TCFire[kkk + 31]; // up left
914  if (kkk % 2 == 0) {
915  TempCluster[4] = 0;
916  } else {
917  TempCluster[2] = 0;
918  }
919 
920  }
921 
922 
923 
924  } else {
925  if (kkk == 64) {
926  TempCluster[0] = TCFire[kkk];
927  TempCluster[1] = TCFire[95]; // top
928  TempCluster[2] = TCFire[63];// right top
929  TempCluster[3] = TCFire[kkk - 32]; //right
930  TempCluster[4] = TCFire[kkk - 31]; //right bottom
931  TempCluster[5] = TCFire[kkk + 1]; //bottom
932  TempCluster[6] = 0; //bottom left
933  TempCluster[7] = 0; // left
934  TempCluster[8] = 0; //top left
935  } else if (kkk == 95) {
936  TempCluster[0] = TCFire[kkk];
937  TempCluster[1] = TCFire[kkk - 1]; // top
938  TempCluster[2] = TCFire[kkk - 33]; // right top
939  TempCluster[3] = TCFire[kkk - 32]; //right
940  TempCluster[4] = TCFire[32]; //right bottom
941  TempCluster[5] = TCFire[64]; //bottom
942  TempCluster[6] = 0; //bottom left
943  TempCluster[7] = 0; // left
944  TempCluster[8] = 0; //top left
945 
946  } else {
947  TempCluster[0] = TCFire[kkk];
948  TempCluster[1] = TCFire[kkk - 1]; // top
949  TempCluster[2] = TCFire[kkk - 33]; // right top
950  TempCluster[3] = TCFire[kkk - 32]; //right
951  TempCluster[4] = TCFire[kkk - 31]; //right bottom
952  TempCluster[5] = TCFire[kkk + 1]; //bottom
953  TempCluster[6] = 0; //bottom left
954  TempCluster[7] = 0; // left
955  TempCluster[8] = 0; //top left
956  }
957 
958  }
959  }
960  for (int iNearTC = 1; iNearTC < 9; iNearTC ++) {
961  for (int jNearTC = 1; jNearTC < 9; jNearTC ++) {
962  if (TempCluster[iNearTC] == 0) {continue;}
963  if (iNearTC == jNearTC)continue;
964  if (TempCluster[iNearTC] == TempCluster[jNearTC]) {
965  TempCluster[jNearTC] = 0;
966  }
967  }
968  }
969 
970  int maxTCId = 999;
971  double clusterenergy = 0;
972  double clustertiming = 0;
973  double clusterpositionX = 0;
974  double clusterpositionY = 0;
975  double clusterpositionZ = 0;
976  int noftcincluster = 0;
977  for (int iNearTC = 0; iNearTC < 9; iNearTC ++) {
978  if (TempCluster[iNearTC] == 0) {continue;}
979  else {noftcincluster++;}
980  clusterenergy += TCFireEnergy[TempCluster[iNearTC] - 1];
981  clustertiming += TCFireEnergy[TempCluster[iNearTC] - 1] * TCFireTiming[TempCluster[iNearTC] - 1];
982  clusterpositionX += TCFireEnergy[TempCluster[iNearTC] - 1] * TCFirePosition[TempCluster[iNearTC] - 1][0];
983  clusterpositionY += TCFireEnergy[TempCluster[iNearTC] - 1] * TCFirePosition[TempCluster[iNearTC] - 1][1];
984  clusterpositionZ += TCFireEnergy[TempCluster[iNearTC] - 1] * TCFirePosition[TempCluster[iNearTC] - 1][2];
985 
986  }
987  //
988  maxTCId = TempCluster[0];
989  //
990 
991  clustertiming /= clusterenergy;
992  if (_Position == 1) {
993  clusterpositionX /= clusterenergy;
994  clusterpositionY /= clusterenergy;
995  clusterpositionZ /= clusterenergy;
996  } else if (_Position == 0) {
997  clustertiming = TCFireTiming[maxTCId - 1];
998  clusterpositionX = TCFirePosition[maxTCId - 1][0];
999  clusterpositionY = TCFirePosition[maxTCId - 1][1];
1000  clusterpositionZ = TCFirePosition[maxTCId - 1][2];
1001  }
1002  if (clustertiming == 0 && clusterenergy == 0) {continue;}
1003 
1004  TempClusterEnergy.push_back(clusterenergy);
1005  TempClusterTiming.push_back(clustertiming);
1006  TempClusterPositionX.push_back(clusterpositionX);
1007  TempClusterPositionY.push_back(clusterpositionY);
1008  TempClusterPositionZ.push_back(clusterpositionZ);
1009  TempNofTCinCluster.push_back(noftcincluster);
1010  TempMaxTCId.push_back(maxTCId);
1011 
1012 
1013  Sort1D.push_back(TempICNTCId);
1014  Sort1D.push_back(clusterenergy);
1015  Sort1D.push_back(clustertiming);
1016  Sort1D.push_back(clusterpositionX);
1017  Sort1D.push_back(clusterpositionY);
1018  Sort1D.push_back(clusterpositionZ);
1019  Sort1D.push_back(noftcincluster);
1020  Sort1D.push_back(maxTCId);
1021 
1022  Sort2D.push_back(Sort1D);
1023  Sort1D.clear();
1024 
1025  }
1026 
1027  }
1028 
1029  // Sorting in the order of TC Id
1030 
1031  sort(Sort2D.begin(), Sort2D.end(),
1032  [](const vector<double>& aa1, const vector<double>& aa2) {return aa1[0] < aa2[0];});
1033 
1034  const int clustersize = Sort2D.size();
1035  for (int jtc = 0; jtc < clustersize; jtc++) {
1036 
1037  ClusterEnergy[1].push_back(Sort2D[jtc][1]);
1038  ClusterTiming[1].push_back(Sort2D[jtc][2]);
1039  ClusterPositionX[1].push_back(Sort2D[jtc][3]);
1040  ClusterPositionY[1].push_back(Sort2D[jtc][4]);
1041  ClusterPositionZ[1].push_back(Sort2D[jtc][5]);
1042  NofTCinCluster[1].push_back(Sort2D[jtc][6]);
1043  MaxTCId[1].push_back(Sort2D[jtc][7]);
1044 
1045 
1046  }
1047 
1048 
1049 
1050 
1051  _FWDNofCluster = MaxTCId[1].size();
1052 
1053 }
1054 //
1055 //
1056 //
1058 {
1059  std::vector<int> TCFire;
1060  std::vector<double> TCFireEnergy;
1061  std::vector<double> TCFireTiming;
1062  std::vector<std::vector<double>> TCFirePosition;
1063 
1064 
1065  std::vector<double> TempClusterEnergy;
1066  std::vector<double> TempClusterTiming;
1067  std::vector<double> TempClusterPositionX;
1068  std::vector<double> TempClusterPositionY;
1069  std::vector<double> TempClusterPositionZ;
1070  std::vector<int> TempNofTCinCluster;
1071  std::vector<int> TempMaxTCId;
1072 
1073  std::vector<double> Sort1D;
1074  std::vector<std::vector<double>> Sort2D;
1075 
1076  int TempICNTCId = 0;
1077 
1078  TempClusterEnergy.clear();
1079  TempClusterTiming.clear();
1080  TempClusterPositionX.clear();
1081  TempClusterPositionY.clear();
1082  TempClusterPositionZ.clear();
1083  TempNofTCinCluster.clear();
1084  TempMaxTCId.clear();
1085  Sort1D.clear();
1086  Sort2D.clear();
1087 
1088 
1089 
1090  TCFire.clear();
1091  TCFireEnergy.clear();
1092  TCFireTiming.clear();
1093  TCFirePosition.clear();
1094 
1095  TCFire.resize(64, 0);
1096  TCFireEnergy.resize(64, 0.);
1097  TCFireTiming.resize(64, 0.);
1098  TCFirePosition.resize(64, std::vector<double>(3, 0.));
1099 
1100 
1101 
1102  const int hit_size = TCId.size();
1103  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1104  if (TCId[ihit] < 513) {continue;}
1105  TCFireEnergy[TCId[ihit] - 513] = Energy[ihit];
1106  TCFireTiming[TCId[ihit] - 513] = Timing[ihit];
1107  TCFirePosition[TCId[ihit] - 513][0] = (_TCMap->getTCPosition(TCId[ihit])).X();
1108  TCFirePosition[TCId[ihit] - 513][1] = (_TCMap->getTCPosition(TCId[ihit])).Y();
1109  TCFirePosition[TCId[ihit] - 513][2] = (_TCMap->getTCPosition(TCId[ihit])).Z();
1110 
1111  //------------------------------------
1112  // To rearrange the hitted map
1113  //
1114  // orignal converted
1115  // (<- Theta) (<- Theta)
1116  //
1117  // 516 515 32 0
1118  // 513 514 33 1
1119  // 520 519 => 34 2
1120  // 517 518 35 3
1121  // ... .
1122  // 576 575 62 30
1123  // 573 574 63 31
1124  //
1125  // Here, TCId-1 becomes TCId=0 and 1.
1126  //------------------------------------
1127  int iTCId0 = TCId[ihit] - 1;
1128  int kkk = 0;
1129  if ((iTCId0 - 512) % 4 == 2) {
1130  kkk = (iTCId0 - 512) / 2 - 1;
1131  }
1132  if ((iTCId0 - 512) % 4 == 1) {
1133  kkk = ((iTCId0 - 512) + 1) / 2;
1134  }
1135  if ((iTCId0 - 512) % 4 == 3) {
1136  kkk = 32 + ((iTCId0 - 512) - 3) / 2;
1137  }
1138  if ((iTCId0 - 512) % 4 == 0) {
1139  kkk = 33 + ((iTCId0 - 512)) / 2;
1140  }
1141 
1142  TCFire[kkk] = iTCId0 + 1;
1143 
1144  }
1145 
1146 
1147  for (int iii = 0 ; iii < 64 ; iii ++) {
1148 
1149  if (TCFire[iii] == 0) { continue; }
1150 
1151  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1152  if (iii < 32) {
1153  if (iii == 0) {
1154  TempCluster[0] = TCFire[ 0];
1155  TempCluster[1] = TCFire[31]; // top
1156  TempCluster[2] = 0;// right top
1157  TempCluster[3] = 0; //right
1158  TempCluster[4] = 0; //right bottom
1159  TempCluster[5] = TCFire[ 1]; // bottom
1160  TempCluster[6] = TCFire[33]; // bottom left
1161  TempCluster[7] = TCFire[32]; // left
1162  TempCluster[8] = TCFire[63]; // top left
1163  } else if (iii == 31) {
1164  TempCluster[0] = TCFire[31];
1165  TempCluster[1] = TCFire[30];
1166  TempCluster[2] = 0;// right top
1167  TempCluster[3] = 0; //right
1168  TempCluster[4] = 0; //right bottom
1169  TempCluster[5] = TCFire[0]; //bottom
1170  TempCluster[6] = TCFire[32]; // bottom left
1171  TempCluster[7] = TCFire[63]; // left
1172  TempCluster[8] = TCFire[62]; //top left
1173  } else {
1174  TempCluster[0] = TCFire[iii];
1175  TempCluster[1] = TCFire[iii - 1]; // top
1176  TempCluster[2] = 0;// right top
1177  TempCluster[3] = 0; //right
1178  TempCluster[4] = 0; //right bottom
1179  TempCluster[5] = TCFire[iii + 1]; //bottom
1180  TempCluster[6] = TCFire[iii + 33]; //bottom left
1181  TempCluster[7] = TCFire[iii + 32]; // left
1182  TempCluster[8] = TCFire[iii + 31]; //top left
1183  }
1184  } else if (iii > 31) {
1185  if (iii == 32) {
1186  TempCluster[0] = TCFire[32];
1187  TempCluster[1] = TCFire[63]; // top
1188  TempCluster[2] = TCFire[31];// right top
1189  TempCluster[3] = TCFire[0]; //right
1190  TempCluster[4] = TCFire[1]; //right bottom
1191  TempCluster[5] = TCFire[33]; //bottom
1192  TempCluster[6] = 0; //bottom left
1193  TempCluster[7] = 0; // left
1194  TempCluster[8] = 0; //top left
1195  } else if (iii == 63) {
1196  TempCluster[0] = TCFire[63];
1197  TempCluster[1] = TCFire[62]; // top
1198  TempCluster[2] = TCFire[30];// right top
1199  TempCluster[3] = TCFire[31]; //right
1200  TempCluster[4] = TCFire[0]; //right bottom
1201  TempCluster[5] = TCFire[32]; //bottom
1202  TempCluster[6] = 0; //bottom left
1203  TempCluster[7] = 0; // left
1204  TempCluster[8] = 0; //top left
1205  } else {
1206  TempCluster[0] = TCFire[iii];
1207  TempCluster[1] = TCFire[iii - 1]; // top
1208  TempCluster[2] = TCFire[iii - 33]; // right top
1209  TempCluster[3] = TCFire[iii - 32]; //right
1210  TempCluster[4] = TCFire[iii - 31]; //right bottom
1211  TempCluster[5] = TCFire[iii + 1]; //bottom
1212  TempCluster[6] = 0; //bottom left
1213  TempCluster[7] = 0; // left
1214  TempCluster[8] = 0; //top left
1215  }
1216 
1217  }
1218 
1219  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1220  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1221  TempICNTCId = TCFire[iii];
1222 
1223  if (Method == 1) {
1224  int maxTCid = 0;
1225  double maxTCEnergy = 0;
1226  for (int iTC = 0; iTC < 9; iTC++) { //find center of Cluster
1227  if (TempCluster[iTC] == 0) {continue;}
1228  if (maxTCEnergy < TCFireEnergy[TempCluster[iTC] - 513]) {
1229  maxTCEnergy = TCFireEnergy[TempCluster[iTC] - 513];
1230  maxTCid = TempCluster[iTC];
1231  }
1232  }
1233  int kkk = 0;
1234  TempCluster[0] = maxTCid;
1235  if ((TempCluster[0] - 513) % 4 == 2) {
1236  kkk = (TempCluster[0] - 513) / 2 - 1;
1237  }
1238  if ((TempCluster[0] - 513) % 4 == 1) {
1239  kkk = ((TempCluster[0] - 513) + 1) / 2;
1240  }
1241  if ((TempCluster[0] - 513) % 4 == 3) {
1242  kkk = 32 + ((TempCluster[0] - 513) - 3) / 2;
1243  }
1244  if ((TempCluster[0] - 513) % 4 == 0) {
1245  kkk = 33 + ((TempCluster[0] - 513)) / 2;
1246  }
1247 
1248  if (kkk < 32) {
1249  if (kkk == 0) {
1250  TempCluster[0] = TCFire[ 0];
1251  TempCluster[1] = TCFire[31]; // top
1252  TempCluster[2] = 0;// right top
1253  TempCluster[3] = 0; //right
1254  TempCluster[4] = 0; //right bottom
1255  TempCluster[5] = TCFire[ 1]; // bottom
1256  TempCluster[6] = TCFire[33]; // bottom left
1257  TempCluster[7] = TCFire[32]; // left
1258  TempCluster[8] = TCFire[63]; // top left
1259  } else if (kkk == 31) {
1260  TempCluster[0] = TCFire[31];
1261  TempCluster[1] = TCFire[30];
1262  TempCluster[2] = 0;// right top
1263  TempCluster[3] = 0; //right
1264  TempCluster[4] = 0; //right bottom
1265  TempCluster[5] = TCFire[0]; //bottom
1266  TempCluster[6] = TCFire[32]; // bottom left
1267  TempCluster[7] = TCFire[63]; // left
1268  TempCluster[8] = TCFire[62]; //top left
1269  } else {
1270  TempCluster[0] = TCFire[kkk];
1271  TempCluster[1] = TCFire[kkk - 1]; // top
1272  TempCluster[2] = 0;// right top
1273  TempCluster[3] = 0; //right
1274  TempCluster[4] = 0; //right bottom
1275  TempCluster[5] = TCFire[kkk + 1]; //bottom
1276  TempCluster[6] = TCFire[kkk + 33]; //bottom left
1277  TempCluster[7] = TCFire[kkk + 32]; // left
1278  TempCluster[8] = TCFire[kkk + 31]; //top left
1279  }
1280  } else if (kkk > 31) {
1281  if (kkk == 32) {
1282  TempCluster[0] = TCFire[32];
1283  TempCluster[1] = TCFire[63]; // top
1284  TempCluster[2] = TCFire[31];// right top
1285  TempCluster[3] = TCFire[0]; //right
1286  TempCluster[4] = TCFire[1]; //right bottom
1287  TempCluster[5] = TCFire[33]; //bottom
1288  TempCluster[6] = 0; //bottom left
1289  TempCluster[7] = 0; // left
1290  TempCluster[8] = 0; //top left
1291  } else if (kkk == 63) {
1292  TempCluster[0] = TCFire[63];
1293  TempCluster[1] = TCFire[62]; // top
1294  TempCluster[2] = TCFire[30];// right top
1295  TempCluster[3] = TCFire[31]; //right
1296  TempCluster[4] = TCFire[0]; //right bottom
1297  TempCluster[5] = TCFire[32]; //bottom
1298  TempCluster[6] = 0; //bottom left
1299  TempCluster[7] = 0; // left
1300  TempCluster[8] = 0; //top left
1301  } else {
1302  TempCluster[0] = TCFire[kkk];
1303  TempCluster[1] = TCFire[kkk - 1]; // top
1304  TempCluster[2] = TCFire[kkk - 33]; // right top
1305  TempCluster[3] = TCFire[kkk - 32]; //right
1306  TempCluster[4] = TCFire[kkk - 31]; //right bottom
1307  TempCluster[5] = TCFire[kkk + 1]; //bottom
1308  TempCluster[6] = 0; //bottom left
1309  TempCluster[7] = 0; // left
1310  TempCluster[8] = 0; //top left
1311  }
1312 
1313  }
1314  }
1315 
1316  for (int iNearTC = 1; iNearTC < 9; iNearTC ++) {
1317  for (int jNearTC = 1; jNearTC < 9; jNearTC ++) {
1318  if (TempCluster[iNearTC] == 0) {continue;}
1319  if (iNearTC == jNearTC) {continue;}
1320  if (TempCluster[iNearTC] == TempCluster[jNearTC]) {
1321  TempCluster[jNearTC] = 0;
1322  }
1323  }
1324  }
1325 
1326  int maxTCId = 999;
1327  double clusterenergy = 0;
1328  double clustertiming = 0;
1329  double clusterpositionX = 0;
1330  double clusterpositionY = 0;
1331  double clusterpositionZ = 0;
1332  int noftcincluster = 0;
1333  for (int iNearTC = 0; iNearTC < 9; iNearTC ++) {
1334  if (TempCluster[iNearTC] == 0) {continue;}
1335  else {noftcincluster++;}
1336 
1337  clusterenergy += TCFireEnergy[TempCluster[iNearTC] - 513];
1338  clustertiming += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFireTiming[TempCluster[iNearTC] - 513];
1339  clusterpositionX += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][0];
1340  clusterpositionY += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][1];
1341  clusterpositionZ += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][2];
1342 
1343 
1344  }
1345  //
1346  maxTCId = TempCluster[0];
1347  //
1348 
1349  clustertiming /= clusterenergy;
1350  if (_Position == 1) {
1351  clusterpositionX /= clusterenergy;
1352  clusterpositionY /= clusterenergy;
1353  clusterpositionZ /= clusterenergy;
1354  } else if (_Position == 0) {
1355  clustertiming = TCFireTiming[maxTCId - 513];
1356  clusterpositionX = TCFirePosition[maxTCId - 513][0];
1357  clusterpositionY = TCFirePosition[maxTCId - 513][1];
1358  clusterpositionZ = TCFirePosition[maxTCId - 513][2];
1359  }
1360 
1361  if (clustertiming == 0 && clusterenergy == 0) {continue;}
1362  TempClusterEnergy.push_back(clusterenergy);
1363  TempClusterTiming.push_back(clustertiming);
1364  TempClusterPositionX.push_back(clusterpositionX);
1365  TempClusterPositionY.push_back(clusterpositionY);
1366  TempClusterPositionZ.push_back(clusterpositionZ);
1367  TempNofTCinCluster.push_back(noftcincluster);
1368  TempMaxTCId.push_back(maxTCId);
1369 
1370 
1371  Sort1D.push_back(TempICNTCId);
1372  Sort1D.push_back(clusterenergy);
1373  Sort1D.push_back(clustertiming);
1374  Sort1D.push_back(clusterpositionX);
1375  Sort1D.push_back(clusterpositionY);
1376  Sort1D.push_back(clusterpositionZ);
1377  Sort1D.push_back(noftcincluster);
1378  Sort1D.push_back(maxTCId);
1379 
1380  Sort2D.push_back(Sort1D);
1381  Sort1D.clear();
1382 
1383 
1384  }
1385  }
1386  }
1387 
1388  sort(Sort2D.begin(), Sort2D.end(),
1389  [](const vector<double>& aa1, const vector<double>& aa2) {return aa1[0] < aa2[0];});
1390 
1391  const int clustersize = Sort2D.size();
1392  for (int jtc = 0; jtc < clustersize; jtc++) {
1393 
1394  ClusterEnergy[2].push_back(Sort2D[jtc][1]);
1395  ClusterTiming[2].push_back(Sort2D[jtc][2]);
1396  ClusterPositionX[2].push_back(Sort2D[jtc][3]);
1397  ClusterPositionY[2].push_back(Sort2D[jtc][4]);
1398  ClusterPositionZ[2].push_back(Sort2D[jtc][5]);
1399  NofTCinCluster[2].push_back(Sort2D[jtc][6]);
1400  MaxTCId[2].push_back(Sort2D[jtc][7]);
1401 
1402 
1403  }
1404 
1405  _BWDNofCluster = MaxTCId[2].size();
1406 
1407 
1408 
1409 }
1410 
1411 //
1412 //
1413 //
1414 int
1416 {
1417 
1418  std::vector<int> TCFire;
1419 
1420  TCFire.clear();
1421 
1422  TCFire.resize(432, 0);
1423 
1424  const int hit_size = TCId.size();
1425  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1426  if (TCId[ihit] >= 81 && TCId[ihit] <= 512) {
1427  TCFire[TCId[ihit] - 81] = TCId[ihit];
1428  }
1429  }
1430 
1431  //
1432  //
1433  //
1434  int tc_upper = 0; // check upper TC
1435  int tc_upper_right = 0; // check right TC
1436  int tc_right = 0; // check right TC
1437  int tc_lower_right = 0;
1438  int tc_lower = 0; // check lower TC
1439  int tc_lower_left = 0; // check lower TC
1440  int tc_left = 0;
1441  int tc_upper_left = 0;
1442 
1443 
1444 
1445  for (int iii = 0 ; iii < 432 ; iii++) {
1446  if (TCFire[iii] == 0) { continue; }
1447 
1448  if (iii < 12) {
1449  tc_upper = TCFire[iii + 420] ;
1450  tc_upper_right = TCFire[iii + 419] ;
1451  tc_right = TCFire[iii - 1] ;
1452  tc_lower_right = TCFire[iii + 11] ;
1453  tc_lower = TCFire[iii + 12] ;
1454  tc_lower_left = TCFire[iii + 13] ;
1455  tc_left = TCFire[iii + 1] ;
1456  tc_upper_left = TCFire[iii + 421] ;
1457  if (iii % 12 == 0) {
1458  tc_upper_right = 0;
1459  tc_right = 0;
1460  tc_lower_right = 0;
1461 
1462  }
1463  if (iii % 12 == 11) {
1464  tc_lower_left = 0;
1465  tc_left = 0;
1466  tc_upper_left = 0;
1467 
1468  }
1469  }
1470  if (iii > 11 && iii < 420) {
1471  tc_upper = TCFire[iii - 12] ;
1472  tc_upper_right = TCFire[iii - 13] ;
1473  tc_right = TCFire[iii - 1] ;
1474  tc_lower_right = TCFire[iii + 11] ;
1475  tc_lower = TCFire[iii + 12] ;
1476  tc_lower_left = TCFire[iii + 13] ;
1477  tc_left = TCFire[iii + 1] ;
1478  tc_upper_left = TCFire[iii - 11] ;
1479  if (iii % 12 == 0) {
1480  tc_upper_right = 0;
1481  tc_right = 0;
1482  tc_lower_right = 0;
1483 
1484  }
1485  if (iii % 12 == 11) {
1486  tc_lower_left = 0;
1487  tc_left = 0;
1488  tc_upper_left = 0;
1489 
1490  }
1491 
1492  }
1493  if (iii > 419) {
1494  tc_upper = TCFire[iii - 12] ;
1495  tc_upper_right = TCFire[iii - 13] ;
1496  tc_right = TCFire[iii - 1] ;
1497  tc_lower_right = TCFire[iii - 421] ;
1498  tc_lower = TCFire[iii - 420] ;
1499  tc_lower_left = TCFire[iii - 419];
1500  tc_left = TCFire[iii + 1] ;
1501  tc_upper_left = TCFire[iii - 11] ;
1502  if (iii % 12 == 0) {
1503  tc_upper_right = 0;
1504  tc_right = 0;
1505  tc_lower_right = 0;
1506  }
1507  if (iii % 12 == 11) {
1508  tc_lower_left = 0;
1509  tc_left = 0;
1510  tc_upper_left = 0;
1511 
1512  }
1513  }
1514 
1515 
1516  TempCluster[0] = iii + 80 + 1; //middle of ICN
1517  TempCluster[1] = tc_upper; // upper
1518  TempCluster[2] = tc_upper_right; //right
1519  TempCluster[3] = tc_right; //right
1520  TempCluster[4] = tc_lower_right; //lower
1521  TempCluster[5] = tc_lower; //lower
1522  TempCluster[6] = tc_lower_left; //lower
1523  TempCluster[7] = tc_left; //lower
1524  TempCluster[8] = tc_upper_left; //lower right;
1525 
1526 
1527 
1528  if (!(tc_upper != 0 || tc_left != 0)) {
1529  if (!(tc_lower != 0 && tc_lower_left != 0)) {
1530  _BRICN++;
1531  int phiid = _TCMap -> getTCPhiIdFromTCId(iii + 80 + 1);
1532 
1533  if (phiid == 36 || (phiid > 0 && phiid < 11)) {
1534  _Quadrant[1][0]++;
1535  }
1536  if (phiid > 8 && phiid < 20) {
1537  _Quadrant[1][1]++;
1538  }
1539  if (phiid > 17 && phiid < 29) {
1540  _Quadrant[1][2]++;
1541  }
1542  if ((phiid > 26 && phiid < 37) || phiid == 1) {
1543  _Quadrant[1][3]++;
1544  }
1545 
1546  }
1547  }// iii loop
1548  }
1549  return _BRICN;
1550 
1551 }
1552 //
1553 //
1554 //
1555 int
1557 {
1558 
1559  std::vector<int> TCFire;
1560 
1561 
1562  TCFire.clear();
1563 
1564  TCFire.resize(96, 0);
1565 
1566 
1567  const int hit_size = TCId.size();
1568  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1569  if (TCId[ihit] > 80) {continue;}
1570 
1571 
1572  //------------------------------------
1573  // To rearrange the hitted map
1574  //
1575  // orignal converted
1576  // (<- Theta) (<- Theta)
1577  //
1578  // 3 2 1 64 32 0
1579  // 4 5 - 65 33 1
1580  // 8 7 6 => 66 34 2
1581  // 9 10 - 67 35 3
1582  // .... ...
1583  // 78 77 76 94 62 30
1584  // 79 80 - 95 63 31
1585  //
1586  // Here, TCId-1 becomes TCId=0 and 1.
1587  //------------------------------------
1588  int iTCId0 = TCId[ihit] - 1;
1589  int kkk = 0;
1590  if (iTCId0 % 5 == 0) {
1591  kkk = (iTCId0 / 5) * 2;
1592  TCFire[kkk] = TCId[ihit];
1593  TCFire[kkk + 1] = TCId[ihit];
1594  } else {
1595  kkk = iTCId0 / 5;
1596  switch (iTCId0 % 5) {
1597  case 1 :
1598  TCFire[32 + 2 * kkk] = TCId[ihit]; break;
1599  case 2 :
1600  TCFire[64 + 2 * kkk] = TCId[ihit]; break;
1601  case 3 :
1602  TCFire[64 + 2 * kkk + 1] = TCId[ihit]; break;
1603  case 4 :
1604  TCFire[32 + 2 * kkk + 1] = TCId[ihit]; break;
1605  default:
1606  break;
1607  }
1608  }
1609  }
1610 
1611 
1612  for (int iii = 32 ; iii < 96 ; iii++) {
1613  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1614  if (TCFire[iii] == 0) { continue; }
1615  if (iii < 64) {
1616  if (iii == 32) {
1617  TempCluster[0] = TCFire[iii];
1618  TempCluster[1] = TCFire[63]; // top
1619  TempCluster[2] = 0;// right top
1620  TempCluster[3] = 0; //right
1621  TempCluster[4] = 0; //right bottom
1622  TempCluster[5] = TCFire[iii + 1]; //bottom
1623  TempCluster[6] = TCFire[iii + 33]; //bottom left
1624  TempCluster[7] = TCFire[iii + 32]; // left
1625  TempCluster[8] = TCFire[95]; //top left
1626  } else if (iii == 63) {
1627  TempCluster[0] = TCFire[iii];
1628  TempCluster[1] = TCFire[iii - 1]; // top
1629  TempCluster[2] = 0; // right top
1630  TempCluster[3] = 0; //right
1631  TempCluster[4] = 0; //right bottom
1632  TempCluster[5] = TCFire[32]; //bottom
1633  TempCluster[6] = TCFire[64]; //bottom left
1634  TempCluster[7] = TCFire[iii + 32]; // left
1635  TempCluster[8] = TCFire[iii + 31]; //top left
1636  } else {
1637  TempCluster[0] = TCFire[iii];
1638  TempCluster[1] = TCFire[iii - 1]; // top
1639  TempCluster[2] = 0; // right top
1640  TempCluster[3] = 0; //right
1641  TempCluster[4] = 0; //right bottom
1642  TempCluster[5] = TCFire[iii + 1]; //bottom
1643  TempCluster[6] = TCFire[iii + 33]; //bottom left
1644  TempCluster[7] = TCFire[iii + 32]; // left
1645  TempCluster[8] = TCFire[iii + 31]; //top left
1646  }
1647  } else {
1648  if (iii == 64) {
1649  TempCluster[0] = TCFire[iii];
1650  TempCluster[1] = TCFire[95]; // top
1651  TempCluster[2] = TCFire[63];// right top
1652  TempCluster[3] = TCFire[iii - 32]; //right
1653  TempCluster[4] = TCFire[iii - 31]; //right bottom
1654  TempCluster[5] = TCFire[iii + 1]; //bottom
1655  TempCluster[6] = 0; //bottom left
1656  TempCluster[7] = 0; // left
1657  TempCluster[8] = 0; //top left
1658  } else if (iii == 95) {
1659  TempCluster[0] = TCFire[iii];
1660  TempCluster[1] = TCFire[iii - 1]; // top
1661  TempCluster[2] = TCFire[iii - 33]; // right top
1662  TempCluster[3] = TCFire[iii - 32]; //right
1663  TempCluster[4] = TCFire[32]; //right bottom
1664  TempCluster[5] = TCFire[64]; //bottom
1665  TempCluster[6] = 0; //bottom left
1666  TempCluster[7] = 0; // left
1667  TempCluster[8] = 0; //top left
1668 
1669  } else {
1670  TempCluster[0] = TCFire[iii];
1671  TempCluster[1] = TCFire[iii - 1]; // top
1672  TempCluster[2] = TCFire[iii - 33]; // right top
1673  TempCluster[3] = TCFire[iii - 32]; //right
1674  TempCluster[4] = TCFire[iii - 31]; //right bottom
1675  TempCluster[5] = TCFire[iii + 1]; //bottom
1676  TempCluster[6] = 0; //bottom left
1677  TempCluster[7] = 0; // left
1678  TempCluster[8] = 0; //top left
1679  }
1680 
1681  }
1682  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1683  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1684  _FWDICN++;
1685  int phiid = _TCMap -> getTCPhiIdFromTCId(TCFire[iii]);
1686 
1687  if (phiid == 32 || (phiid > 0 && phiid < 10)) {
1688  _Quadrant[0][0]++;
1689  }
1690  if (phiid > 7 && phiid < 18) {
1691  _Quadrant[0][1]++;
1692  }
1693  if (phiid > 15 && phiid < 26) {
1694  _Quadrant[0][2]++;
1695  }
1696  if ((phiid > 22 && phiid < 33) || phiid == 1) {
1697  _Quadrant[0][3]++;
1698  }
1699 
1700 
1701  }
1702  }
1703  }
1704  return _FWDICN;
1705 }
1706 //
1707 //
1708 //
1710 {
1711  std::vector<int> TCFire;
1712 
1713 
1714  TCFire.clear();
1715 
1716  TCFire.resize(64, 0);
1717 
1718 
1719 
1720  const int hit_size = TCId.size();
1721  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1722  if (TCId[ihit] < 513) {continue;}
1723 
1724  // TCFire[TCId[ihit] - 513] = TCId[ihit];
1725  //------------------------------------
1726  // To rearrange the hitted map
1727  //
1728  // orignal converted
1729  // (<- Theta) (<- Theta)
1730  //
1731  // 516 515 32 0
1732  // 513 514 33 1
1733  // 520 519 => 34 2
1734  // 517 518 35 3
1735  // ... .
1736  // 576 575 62 30
1737  // 573 574 63 31
1738  //
1739  // Here, TCId-1 becomes TCId=0 and 1.
1740  //------------------------------------
1741  int iTCId0 = TCId[ihit] - 1;
1742  int kkk = 0;
1743  if ((iTCId0 - 512) % 4 == 2) {
1744  kkk = (iTCId0 - 512) / 2 - 1;
1745  }
1746  if ((iTCId0 - 512) % 4 == 1) {
1747  kkk = ((iTCId0 - 512) + 1) / 2;
1748  }
1749  if ((iTCId0 - 512) % 4 == 3) {
1750  kkk = 32 + ((iTCId0 - 512) - 3) / 2;
1751  }
1752  if ((iTCId0 - 512) % 4 == 0) {
1753  kkk = 33 + ((iTCId0 - 512)) / 2;
1754  }
1755 
1756  TCFire[kkk] = iTCId0 + 1;
1757 
1758  }
1759 
1760 
1761  for (int iii = 0 ; iii < 64 ; iii ++) {
1762 
1763  if (TCFire[iii] == 0) { continue; }
1764 
1765  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1766  if (iii < 32) {
1767  if (iii == 0) {
1768  TempCluster[0] = TCFire[ 0];
1769  TempCluster[1] = TCFire[31]; // top
1770  TempCluster[2] = 0;// right top
1771  TempCluster[3] = 0; //right
1772  TempCluster[4] = 0; //right bottom
1773  TempCluster[5] = TCFire[ 1]; // bottom
1774  TempCluster[6] = TCFire[33]; // bottom left
1775  TempCluster[7] = TCFire[32]; // left
1776  TempCluster[8] = TCFire[63]; // top left
1777  } else if (iii == 31) {
1778  TempCluster[0] = TCFire[31];
1779  TempCluster[1] = TCFire[30];
1780  TempCluster[2] = 0;// right top
1781  TempCluster[3] = 0; //right
1782  TempCluster[4] = 0; //right bottom
1783  TempCluster[5] = TCFire[0]; //bottom
1784  TempCluster[6] = TCFire[32]; // bottom left
1785  TempCluster[7] = TCFire[63]; // left
1786  TempCluster[8] = TCFire[62]; //top left
1787  } else {
1788  TempCluster[0] = TCFire[iii];
1789  TempCluster[1] = TCFire[iii - 1]; // top
1790  TempCluster[2] = 0;// right top
1791  TempCluster[3] = 0; //right
1792  TempCluster[4] = 0; //right bottom
1793  TempCluster[5] = TCFire[iii + 1]; //bottom
1794  TempCluster[6] = TCFire[iii + 33]; //bottom left
1795  TempCluster[7] = TCFire[iii + 32]; // left
1796  TempCluster[8] = TCFire[iii + 31]; //top left
1797  }
1798  } else if (iii > 31) {
1799  if (iii == 32) {
1800  TempCluster[0] = TCFire[32];
1801  TempCluster[1] = TCFire[63]; // top
1802  TempCluster[2] = TCFire[31];// right top
1803  TempCluster[3] = TCFire[0]; //right
1804  TempCluster[4] = TCFire[1]; //right bottom
1805  TempCluster[5] = TCFire[33]; //bottom
1806  TempCluster[6] = 0; //bottom left
1807  TempCluster[7] = 0; // left
1808  TempCluster[8] = 0; //top left
1809  } else if (iii == 63) {
1810  TempCluster[0] = TCFire[63];
1811  TempCluster[1] = TCFire[62]; // top
1812  TempCluster[2] = TCFire[30];// right top
1813  TempCluster[3] = TCFire[31]; //right
1814  TempCluster[4] = TCFire[0]; //right bottom
1815  TempCluster[5] = TCFire[32]; //bottom
1816  TempCluster[6] = 0; //bottom left
1817  TempCluster[7] = 0; // left
1818  TempCluster[8] = 0; //top left
1819  } else {
1820  TempCluster[0] = TCFire[iii];
1821  TempCluster[1] = TCFire[iii - 1]; // top
1822  TempCluster[2] = TCFire[iii - 33]; // right top
1823  TempCluster[3] = TCFire[iii - 32]; //right
1824  TempCluster[4] = TCFire[iii - 31]; //right bottom
1825  TempCluster[5] = TCFire[iii + 1]; //bottom
1826  TempCluster[6] = 0; //bottom left
1827  TempCluster[7] = 0; // left
1828  TempCluster[8] = 0; //top left
1829  }
1830 
1831  }
1832 
1833  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1834  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1835  _BWDICN ++;
1836  int phiid = _TCMap -> getTCPhiIdFromTCId(TCFire[iii]);
1837 
1838  if (phiid == 32 || (phiid > 0 && phiid < 10)) {
1839  _Quadrant[2][0]++;
1840  }
1841  if (phiid > 7 && phiid < 18) {
1842  _Quadrant[2][1]++;
1843  }
1844  if (phiid > 15 && phiid < 26) {
1845  _Quadrant[2][2]++;
1846  }
1847  if ((phiid > 22 && phiid < 33) || phiid == 1) {
1848  _Quadrant[2][3]++;
1849  }
1850 
1851 
1852  }
1853  }
1854 
1855  }
1856 
1857 
1858 
1859 
1860  return _BWDICN;
1861 
1862 }
1863 //
1864 //
1865 //
1866 //
1868 {
1869  int ncluster = ClusterEnergy[0].size() + ClusterEnergy[1].size() + ClusterEnergy[2].size();
1870  if (ncluster > _LimitNCluster) {
1871  return ncluster;
1872  } else {
1873  return 0;
1874  }
1875 }
1876 //
1877 //===<END>
1878 //
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::TrgEclCluster::ClusterPositionZ
std::vector< std::vector< double > > ClusterPositionZ
Cluster position in Z-axis.
Definition: TrgEclCluster.h:157
Belle2::TrgEclCluster::_BWDNofCluster
int _BWDNofCluster
Cluster in Backward Endcap.
Definition: TrgEclCluster.h:116
Belle2::TrgEclCluster::_EventId
int _EventId
event number
Definition: TrgEclCluster.h:118
Belle2::TrgEclCluster::_BRICN
int _BRICN
get Beam bkg veto flag.
Definition: TrgEclCluster.h:106
Belle2::TrgEclCluster::setBackwardICN
int setBackwardICN()
calculate Belle ICN in Backward endcap
Definition: TrgEclCluster.cc:1709
Belle2::TrgEclCluster::_BrCluster
std::vector< std::vector< int > > _BrCluster
cluster in barrel
Definition: TrgEclCluster.h:140
Belle2::TrgEclCluster::Timing
std::vector< double > Timing
TC timing.
Definition: TrgEclCluster.h:132
Belle2::TrgEclCluster::MaxTCId
std::vector< std::vector< int > > MaxTCId
Maximum contribution TC Id in Cluster.
Definition: TrgEclCluster.h:161
Belle2::TrgEclCluster::ClusterTiming
std::vector< std::vector< double > > ClusterTiming
Cluster timing.
Definition: TrgEclCluster.h:149
Belle2::TrgEclCluster::_FWDICN
int _FWDICN
ICN in Forward Endcap.
Definition: TrgEclCluster.h:108
Belle2::TrgEclCluster::_FWDNofCluster
int _FWDNofCluster
Cluster in Forward Endcap.
Definition: TrgEclCluster.h:114
Belle2::TrgEclCluster::_Position
int _Position
Position calculation method(0:Most energetic TC Postion, 1 : Energy weighted Postion)
Definition: TrgEclCluster.h:124
Belle2::TrgEclMapping::getTCPhiIdFromTCId
int getTCPhiIdFromTCId(int)
get [TC Phi ID] from [TC ID]
Definition: TrgEclMapping.cc:227
Belle2::TrgEclCluster::getICNSub
int getICNSub(int)
get ICN in each region(Fw(0), Br(1), Bw(2))
Definition: TrgEclCluster.cc:114
Belle2::TrgEclCluster::_icnfwbrbw
std::vector< int > _icnfwbrbw
icn
Definition: TrgEclCluster.h:128
Belle2::TrgEclCluster::TCId
std::vector< int > TCId
TC Id.
Definition: TrgEclCluster.h:130
Belle2::TrgEclMapping
A class of TC Mapping.
Definition: TrgEclMapping.h:31
Belle2::TrgEclCluster::TempCluster
std::vector< int > TempCluster
Temporal Cluster.
Definition: TrgEclCluster.h:163
Belle2::TrgEclCluster::_BwCluster
std::vector< std::vector< int > > _BwCluster
cluster in backward endcap
Definition: TrgEclCluster.h:144
Belle2::TrgEclCluster::_BRNofCluster
int _BRNofCluster
Cluster in Barrel.
Definition: TrgEclCluster.h:112
Belle2::TrgEclCluster::_Method
int _Method
Clustering method.
Definition: TrgEclCluster.h:120
Belle2::TrgEclCluster::ClusterPositionY
std::vector< std::vector< double > > ClusterPositionY
Cluster position in Y-axis.
Definition: TrgEclCluster.h:155
Belle2::TrgEclCluster::getBwICNCluster
int getBwICNCluster(int ICNId, int)
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
Definition: TrgEclCluster.cc:135
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrgEclCluster::getICNFwBr
int getICNFwBr(void)
get ICN in Barrel and Forward
Definition: TrgEclCluster.cc:104
Belle2::TrgEclMapping::getTCPosition
TVector3 getTCPosition(int)
TC position (cm)
Definition: TrgEclMapping.cc:251
Belle2::TrgEclCluster::getNofExceedCluster
int getNofExceedCluster()
get # Cluster in case of exceeding limit
Definition: TrgEclCluster.cc:1867
Belle2::TrgEclCluster::getFwICNCluster
int getFwICNCluster(int ICNId, int)
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
Definition: TrgEclCluster.cc:146
Belle2::TrgEclCluster::ClusterPositionX
std::vector< std::vector< double > > ClusterPositionX
Cluster position in X-axis.
Definition: TrgEclCluster.h:153
Belle2::TrgEclCluster::setBarrelICN
int setBarrelICN()
calculate Belle ICN in Barrel
Definition: TrgEclCluster.cc:1415
Belle2::TrgEclCluster::_FwCluster
std::vector< std::vector< int > > _FwCluster
cluster in forward endcap
Definition: TrgEclCluster.h:142
Belle2::TrgEclCluster::save
void save(int)
Save Cluster information in TRGECLCluster Table.
Definition: TrgEclCluster.cc:190
Belle2::TrgEclCluster::_TCMap
TrgEclMapping * _TCMap
Object of TC Mapping.
Definition: TrgEclCluster.h:165
Belle2::TrgEclCluster::setICN
void setICN(std::vector< int >)
Destructor.
Definition: TrgEclCluster.cc:156
Belle2::TrgEclCluster::_Quadrant
std::vector< std::vector< int > > _Quadrant
Quadrant for Beam Backgournd veto.
Definition: TrgEclCluster.h:137
Belle2::TrgEclCluster::_BWDICN
int _BWDICN
ICN in Backward Endcap.
Definition: TrgEclCluster.h:110
Belle2::TrgEclMapping::getTCThetaIdFromTCId
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
Definition: TrgEclMapping.cc:200
Belle2::TrgEclCluster::ClusterEnergy
std::vector< std::vector< double > > ClusterEnergy
Cluster enrgy
Definition: TrgEclCluster.h:151
Belle2::TrgEclCluster::setForwardICN
int setForwardICN()
calculate Belle ICN in Foward endcap
Definition: TrgEclCluster.cc:1556
Belle2::TrgEclCluster::NofTCinCluster
std::vector< std::vector< int > > NofTCinCluster
N of TC in Cluster
Definition: TrgEclCluster.h:159
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::TrgEclCluster::getBrICNCluster
int getBrICNCluster(int ICNId, int)
get ICN in QuadrantId in Fw or Br or Bw.
Definition: TrgEclCluster.cc:125
Belle2::TrgEclCluster::_LimitNCluster
int _LimitNCluster
the Limit Number of Cluster
Definition: TrgEclCluster.h:122
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::TrgEclCluster::~TrgEclCluster
virtual ~TrgEclCluster()
Constructor.
Definition: TrgEclCluster.cc:95
Belle2::TrgEclCluster::Energy
std::vector< double > Energy
TC energy
Definition: TrgEclCluster.h:134