Belle II Software  release-06-02-00
TrgEclCluster.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 //---------------------------------------------------------------
10 // Description :
11 // -A class to make cluster from TC Hit
12 // -ICN Logic ( function name : setICN(tcid) )
13 // Isolate cluster counting logic used in Belle for 3x3 TCs
14 //
15 // |5|1|6|
16 // |2|0|3| ICN = [ 0 and !(1 or 2) and !(4 and 7) ]
17 // |7|4|8|
18 //
19 // 3x3 TC
20 //
21 // -Clustering Logic (Function name : setICN(tcid, tcenergy, tctiming) )
22 // 1.Find TC Hit (0) satisfying ICN logic
23 // 2.Find the most energetic TC Hit in the neghbor TCs with 0 (9 TCs)
24 // 3.Bind neighbor TC hits with the most energetic TC (Center TC) as a Cluster
25 // 4.Cluster energy : Total energy in Cluster
26 // 5.Timing : Timing of the most energetic TC in a cluster or Energy weighted timing in a cluster
27 //
28 // -The limit number of Cluster is 6 due to hardware limitation (ETM)
29 // -The cluster information (energy, timing) is saved in the order of barrel, forward endcap and backwrd endcap
30 //---------------------------------------------------------------
31 
32 #define TRG_SHORT_NAMES
33 #define TRGECLCLUSTER_SHORT_NAMES
34 
35 #include <framework/datastore/StoreArray.h>
36 
37 
38 #include <trg/ecl/TrgEclCluster.h>
39 #include "trg/ecl/dataobjects/TRGECLCluster.h"
40 
41 
42 using namespace std;
43 using namespace Belle2;
44 //
45 //
46 //
47 TrgEclCluster::TrgEclCluster():
48  _BRICN(0), _FWDICN(0), _BWDICN(0),
49  _BRNofCluster(0), _FWDNofCluster(0), _BWDNofCluster(0),
50  _EventId(0), _Method(1), _LimitNCluster(6), _Position(1)
51 {
52  // initialize All parameters
53 
54  _icnfwbrbw.clear();
55  _BrCluster.clear();
56  _FwCluster.clear();
57  _BwCluster.clear();
58  _Quadrant.clear();
59 
60  TCId.clear();
61  Timing.clear();
62  Energy.clear();
63 
64  ClusterTiming.clear();
65  ClusterEnergy.clear();
66  ClusterPositionX.clear();
67  ClusterPositionY.clear();
68  ClusterPositionZ.clear();
69  NofTCinCluster.clear();
70  MaxTCId.clear();
71  TempCluster.clear();
72 
73  _icnfwbrbw.resize(3, 0);
74  TempCluster.resize(9);
75  _Quadrant.resize(3, std::vector<int>(4, 0.0));
76 
77  ClusterTiming.resize(3);
78  ClusterEnergy.resize(3);
79  ClusterPositionX.resize(3);
80  ClusterPositionY.resize(3);
81  ClusterPositionZ.resize(3);
82  NofTCinCluster.resize(3);
83  MaxTCId.resize(3);
84 
85 
86  _TCMap = new TrgEclMapping();
87 
88 
89 
90 }
91 //
92 //
93 //
95 {
96  delete _TCMap;
97 }
98 
99 
100 
101 //
102 int
104 {
105  // get ICN in Barrel and Forward Endcap except for the most inner (=Physics region : Theta Id 2 ~ 15)
106  return _icnfwbrbw[0] + _icnfwbrbw[1];
107 
108 }
109 //
110 //
111 //
112 int
114 {
115  // get ICN in Barrel and Backward endcap, Forward Endcap except for the most inner (=Physics region : Theta Id 2 ~ 15)
116 
117  return _icnfwbrbw[FwBrBw];
118 
119 }
120 //
121 //
122 //
123 int
124 TrgEclCluster::getBrICNCluster(int ICNId, int location)
125 {
126  // get the # of Cluster in Barrel.
127  return _BrCluster[ICNId][location];
128 
129 }
130 //
131 //
132 //
133 int
134 TrgEclCluster::getBwICNCluster(int ICNId, int location)
135 {
136 
137  return _BwCluster[ICNId][location];
138 
139 }
140 
141 //
142 //
143 //
144 int
145 TrgEclCluster::getFwICNCluster(int ICNId, int location)
146 {
147 
148  return _FwCluster[ICNId][location];
149 
150 }
151 //
152 //
153 //
154 void
155 TrgEclCluster::setICN(const std::vector<int>& tcid)
156 {
157  TCId = tcid ;
158  _Quadrant.clear();
159  _Quadrant.resize(3, std::vector<int>(4, 0.0));
160  _icnfwbrbw.clear();
161  _icnfwbrbw.resize(3, 0);
162  _BRICN = 0 ;
163  _FWDICN = 0;
164  _BWDICN = 0;
165 
166  _icnfwbrbw[1] = setBarrelICN();
167  _icnfwbrbw[0] = setForwardICN();
168  _icnfwbrbw[2] = setBackwardICN();
169 
170 
171  return;
172 }
173 void
174 TrgEclCluster::setICN(const std::vector<int>& tcid,
175  const std::vector<double>& tcenergy,
176  const std::vector<double>& tctiming)
177 {
178  TCId = tcid ;
179  Energy = tcenergy;
180  Timing = tctiming;
181 
185 
186  save(_EventId);
187 
188  return;
189 }
190 void
191 TrgEclCluster::save(int m_nEvent)
192 {
193  // Save Cluster
194  // Save order : Barrel, Forward, Backward
195 
196  int m_hitNum = 0;
197  int clusterId = 0;
198  int counter = 0;
199  for (int iposition = 0; iposition < 3 ; iposition ++) {
200  const int Ncluster = ClusterEnergy[iposition].size();
201  for (int icluster = 0; icluster < Ncluster; icluster++) {
202  if (ClusterEnergy[iposition][icluster] <= 0) {continue;}
203 
204  if (counter >= _LimitNCluster) {
205  continue;
206  } else {
207  counter ++;
208  }
209 
210  StoreArray<TRGECLCluster> ClusterArray;
211  ClusterArray.appendNew();
212  m_hitNum = ClusterArray.getEntries() - 1;
213  ClusterArray[m_hitNum]->setEventId(m_nEvent);
214  ClusterArray[m_hitNum]->setClusterId(clusterId);
215  ClusterArray[m_hitNum]->setMaxTCId(MaxTCId[iposition][icluster]);
216  ClusterArray[m_hitNum]->setMaxThetaId(_TCMap->getTCThetaIdFromTCId(MaxTCId[iposition][icluster]));
217  ClusterArray[m_hitNum]->setMaxPhiId(_TCMap->getTCPhiIdFromTCId(MaxTCId[iposition][icluster]));
218  ClusterArray[m_hitNum]->setNofTCinCluster(NofTCinCluster[iposition][icluster]);
219  ClusterArray[m_hitNum]->setEnergyDep(ClusterEnergy[iposition][icluster]);
220  ClusterArray[m_hitNum]->setTimeAve(ClusterTiming[iposition][icluster]);
221 
222  ClusterArray[m_hitNum]->setPositionX(ClusterPositionX[iposition][icluster]);
223  ClusterArray[m_hitNum]->setPositionY(ClusterPositionY[iposition][icluster]);
224  ClusterArray[m_hitNum]->setPositionZ(ClusterPositionZ[iposition][icluster]);
225  clusterId ++;
226  }
227  }
228 
229 
230 }
232 {
233 
234  std::vector<int> TCFire;
235  std::vector<double> TCFireEnergy;
236  std::vector<double> TCFireTiming;
237  std::vector<std::vector<double>> TCFirePosition;
238 
239  TCFire.clear();
240  TCFireEnergy.clear();
241  TCFireTiming.clear();
242  TCFirePosition.clear();
243 
244  TCFire.resize(432, 0);
245  TCFireEnergy.resize(432, 0.);
246  TCFireTiming.resize(432, 0.);
247  TCFirePosition.resize(432, std::vector<double>(3, 0.));
248 
249  const int hit_size = TCId.size();
250  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
251  if (TCId[ihit] >= 81 && TCId[ihit] <= 512) {
252  TCFire[TCId[ihit] - 81] = TCId[ihit];
253  TCFireEnergy[TCId[ihit] - 81] = Energy[ihit];
254  TCFireTiming[TCId[ihit] - 81] = Timing[ihit];
255  TCFirePosition[TCId[ihit] - 81][0] = (_TCMap->getTCPosition(TCId[ihit])).X();
256  TCFirePosition[TCId[ihit] - 81][1] = (_TCMap->getTCPosition(TCId[ihit])).Y();
257  TCFirePosition[TCId[ihit] - 81][2] = (_TCMap->getTCPosition(TCId[ihit])).Z();
258  }
259  }
260  //
261  //
262  //
263  int tc_upper = 0; // check upper TC
264  int tc_upper_right = 0; // check right TC
265  int tc_right = 0; // check right TC
266  int tc_lower_right = 0;
267  int tc_lower = 0; // check lower TC
268  int tc_lower_left = 0; // check lower TC
269  int tc_left = 0;
270  int tc_upper_left = 0;
271 
272  for (int iii = 0 ; iii < 432 ; iii++) {
273  if (TCFire[iii] == 0) { continue; }
274 
275  if (iii < 12) {
276  tc_upper = TCFire[iii + 420] ;
277  tc_upper_right = TCFire[iii + 419] ;
278  tc_right = TCFire[iii - 1] ;
279  tc_lower_right = TCFire[iii + 11] ;
280  tc_lower = TCFire[iii + 12] ;
281  tc_lower_left = TCFire[iii + 13] ;
282  tc_left = TCFire[iii + 1] ;
283  tc_upper_left = TCFire[iii + 421] ;
284  if (iii % 12 == 0) {
285  tc_upper_right = 0;
286  tc_right = 0;
287  tc_lower_right = 0;
288 
289  }
290  if (iii % 12 == 11) {
291  tc_lower_left = 0;
292  tc_left = 0;
293  tc_upper_left = 0;
294 
295  }
296  }
297  if (iii > 11 && iii < 420) {
298  tc_upper = TCFire[iii - 12] ;
299  // cppcheck-suppress negativeContainerIndex
300  tc_upper_right = TCFire[iii - 13] ;
301  tc_right = TCFire[iii - 1] ;
302  tc_lower_right = TCFire[iii + 11] ;
303  tc_lower = TCFire[iii + 12] ;
304  tc_lower_left = TCFire[iii + 13] ;
305  tc_left = TCFire[iii + 1] ;
306  tc_upper_left = TCFire[iii - 11] ;
307  if (iii % 12 == 0) {
308  tc_upper_right = 0;
309  tc_right = 0;
310  tc_lower_right = 0;
311 
312  }
313  if (iii % 12 == 11) {
314  tc_lower_left = 0;
315  tc_left = 0;
316  tc_upper_left = 0;
317 
318  }
319 
320  }
321  if (iii > 419) {
322  tc_upper = TCFire[iii - 12] ;
323  tc_upper_right = TCFire[iii - 13] ;
324  tc_right = TCFire[iii - 1] ;
325  // cppcheck-suppress negativeContainerIndex
326  tc_lower_right = TCFire[iii - 421] ;
327  tc_lower = TCFire[iii - 420] ;
328  tc_lower_left = TCFire[iii - 419];
329  tc_left = TCFire[iii + 1] ;
330  tc_upper_left = TCFire[iii - 11] ;
331  if (iii % 12 == 0) {
332  tc_upper_right = 0;
333  tc_right = 0;
334  tc_lower_right = 0;
335  }
336  if (iii % 12 == 11) {
337  tc_lower_left = 0;
338  tc_left = 0;
339  tc_upper_left = 0;
340 
341  }
342  }
343 
344 
345  TempCluster[0] = iii + 80 + 1; //middle of ICN
346  TempCluster[1] = tc_upper; // upper
347  TempCluster[2] = tc_upper_right; //right
348  TempCluster[3] = tc_right; //right
349  TempCluster[4] = tc_lower_right; //lower
350  TempCluster[5] = tc_lower; //lower
351  TempCluster[6] = tc_lower_left; //lower
352  TempCluster[7] = tc_left; //lower
353  TempCluster[8] = tc_upper_left; //lower right;
354 
355 
356  if (!(tc_upper != 0 || tc_left != 0)) {
357  if (!(tc_lower != 0 && tc_lower_left != 0)) {
358 
359  if (Method == 1) { //for cluster method2(Consider TC energy in oderto find the center of cluster)
360 
361  int maxTCid = 0;
362  double maxTCEnergy = 0;
363  for (int iTC = 0; iTC < 9; iTC++) { //find center of Cluster
364  if (TempCluster[iTC] == 0) {continue;}
365  if (maxTCEnergy < TCFireEnergy[TempCluster[iTC] - 81]) {
366  maxTCEnergy = TCFireEnergy[TempCluster[iTC] - 81];
367  maxTCid = TempCluster[iTC];
368  }
369  }
370  TempCluster[0] = maxTCid;
371 
372  if (maxTCid < 93) {
373 
374  TempCluster[1] = TCFire[maxTCid + 420 - 81 ] ;
375  TempCluster[2] = TCFire[maxTCid + 419 - 81 ] ;
376  TempCluster[3] = TCFire[maxTCid - 1 - 81 ] ;
377  TempCluster[4] = TCFire[maxTCid + 11 - 81 ] ;
378  TempCluster[5] = TCFire[maxTCid + 12 - 81 ] ;
379  TempCluster[6] = TCFire[maxTCid + 13 - 81 ] ;
380  TempCluster[7] = TCFire[maxTCid + 1 - 81 ] ;
381  TempCluster[8] = TCFire[maxTCid + 421 - 81 ] ;
382 
383 
384  if ((maxTCid - 81) % 12 == 0) {
385 
386  TempCluster[2] = 0 ;
387  TempCluster[3] = 0 ;
388  TempCluster[4] = 0 ;
389 
390  }
391  if ((maxTCid - 81) % 12 == 11) {
392 
393  TempCluster[6] = 0 ;
394  TempCluster[7] = 0 ;
395  TempCluster[8] = 0 ;
396 
397  }
398  }
399  if (maxTCid > 92 && maxTCid < 501) {
400 
401  TempCluster[1] = TCFire[maxTCid - 12 - 81] ;
402  // cppcheck-suppress negativeContainerIndex
403  TempCluster[2] = TCFire[maxTCid - 13 - 81] ;
404  TempCluster[3] = TCFire[maxTCid - 1 - 81] ;
405  TempCluster[4] = TCFire[maxTCid + 11 - 81] ;
406  TempCluster[5] = TCFire[maxTCid + 12 - 81] ;
407  TempCluster[6] = TCFire[maxTCid + 13 - 81] ;
408  TempCluster[7] = TCFire[maxTCid + 1 - 81] ;
409  TempCluster[8] = TCFire[maxTCid - 11 - 81] ;
410 
411  if ((maxTCid - 81) % 12 == 0) {
412  TempCluster[2] = 0 ;
413  TempCluster[3] = 0 ;
414  TempCluster[4] = 0 ;
415 
416  }
417  if ((maxTCid - 81) % 12 == 11) {
418 
419  TempCluster[6] = 0 ;
420  TempCluster[7] = 0 ;
421  TempCluster[8] = 0 ;
422 
423  }
424 
425  }
426  if (maxTCid > 500) {
427  TempCluster[1] = TCFire[maxTCid - 12 - 81] ;
428  TempCluster[2] = TCFire[maxTCid - 13 - 81] ;
429  TempCluster[3] = TCFire[maxTCid - 1 - 81] ;
430  // cppcheck-suppress negativeContainerIndex
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 < 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 < 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  Sort1D.push_back(TempICNTCId);
1013  Sort1D.push_back(clusterenergy);
1014  Sort1D.push_back(clustertiming);
1015  Sort1D.push_back(clusterpositionX);
1016  Sort1D.push_back(clusterpositionY);
1017  Sort1D.push_back(clusterpositionZ);
1018  Sort1D.push_back(noftcincluster);
1019  Sort1D.push_back(maxTCId);
1020 
1021  Sort2D.push_back(Sort1D);
1022  Sort1D.clear();
1023 
1024  }
1025 
1026  }
1027 
1028  // Sorting in the order of TC Id
1029 
1030  sort(Sort2D.begin(), Sort2D.end(),
1031  [](const vector<double>& aa1, const vector<double>& aa2) {return aa1[0] < aa2[0];});
1032 
1033  const int clustersize = Sort2D.size();
1034  for (int jtc = 0; jtc < clustersize; jtc++) {
1035 
1036  ClusterEnergy[1].push_back(Sort2D[jtc][1]);
1037  ClusterTiming[1].push_back(Sort2D[jtc][2]);
1038  ClusterPositionX[1].push_back(Sort2D[jtc][3]);
1039  ClusterPositionY[1].push_back(Sort2D[jtc][4]);
1040  ClusterPositionZ[1].push_back(Sort2D[jtc][5]);
1041  NofTCinCluster[1].push_back(Sort2D[jtc][6]);
1042  MaxTCId[1].push_back(Sort2D[jtc][7]);
1043  }
1044 
1045  _FWDNofCluster = MaxTCId[1].size();
1046 }
1047 //
1048 //
1049 //
1051 {
1052  std::vector<int> TCFire;
1053  std::vector<double> TCFireEnergy;
1054  std::vector<double> TCFireTiming;
1055  std::vector<std::vector<double>> TCFirePosition;
1056 
1057 
1058  std::vector<double> TempClusterEnergy;
1059  std::vector<double> TempClusterTiming;
1060  std::vector<double> TempClusterPositionX;
1061  std::vector<double> TempClusterPositionY;
1062  std::vector<double> TempClusterPositionZ;
1063  std::vector<int> TempNofTCinCluster;
1064  std::vector<int> TempMaxTCId;
1065 
1066  std::vector<double> Sort1D;
1067  std::vector<std::vector<double>> Sort2D;
1068 
1069  int TempICNTCId = 0;
1070 
1071  TempClusterEnergy.clear();
1072  TempClusterTiming.clear();
1073  TempClusterPositionX.clear();
1074  TempClusterPositionY.clear();
1075  TempClusterPositionZ.clear();
1076  TempNofTCinCluster.clear();
1077  TempMaxTCId.clear();
1078  Sort1D.clear();
1079  Sort2D.clear();
1080 
1081  TCFire.clear();
1082  TCFireEnergy.clear();
1083  TCFireTiming.clear();
1084  TCFirePosition.clear();
1085 
1086  TCFire.resize(64, 0);
1087  TCFireEnergy.resize(64, 0.);
1088  TCFireTiming.resize(64, 0.);
1089  TCFirePosition.resize(64, std::vector<double>(3, 0.));
1090 
1091  const int hit_size = TCId.size();
1092  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1093  if (TCId[ihit] < 513) {continue;}
1094  TCFireEnergy[TCId[ihit] - 513] = Energy[ihit];
1095  TCFireTiming[TCId[ihit] - 513] = Timing[ihit];
1096  TCFirePosition[TCId[ihit] - 513][0] = (_TCMap->getTCPosition(TCId[ihit])).X();
1097  TCFirePosition[TCId[ihit] - 513][1] = (_TCMap->getTCPosition(TCId[ihit])).Y();
1098  TCFirePosition[TCId[ihit] - 513][2] = (_TCMap->getTCPosition(TCId[ihit])).Z();
1099 
1100  //------------------------------------
1101  // To rearrange the hitted map
1102  //
1103  // orignal converted
1104  // (<- Theta) (<- Theta)
1105  //
1106  // 516 515 32 0
1107  // 513 514 33 1
1108  // 520 519 => 34 2
1109  // 517 518 35 3
1110  // ... .
1111  // 576 575 62 30
1112  // 573 574 63 31
1113  //
1114  // Here, TCId-1 becomes TCId=0 and 1.
1115  //------------------------------------
1116  int iTCId0 = TCId[ihit] - 1;
1117  int kkk = 0;
1118  if ((iTCId0 - 512) % 4 == 2) {
1119  kkk = (iTCId0 - 512) / 2 - 1;
1120  }
1121  if ((iTCId0 - 512) % 4 == 1) {
1122  kkk = ((iTCId0 - 512) + 1) / 2;
1123  }
1124  if ((iTCId0 - 512) % 4 == 3) {
1125  kkk = 32 + ((iTCId0 - 512) - 3) / 2;
1126  }
1127  if ((iTCId0 - 512) % 4 == 0) {
1128  kkk = 33 + ((iTCId0 - 512)) / 2;
1129  }
1130 
1131  TCFire[kkk] = iTCId0 + 1;
1132 
1133  }
1134 
1135 
1136  for (int iii = 0 ; iii < 64 ; iii ++) {
1137 
1138  if (TCFire[iii] == 0) { continue; }
1139 
1140  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1141  if (iii < 32) {
1142  if (iii == 0) {
1143  TempCluster[0] = TCFire[ 0];
1144  TempCluster[1] = TCFire[31]; // top
1145  TempCluster[2] = 0;// right top
1146  TempCluster[3] = 0; //right
1147  TempCluster[4] = 0; //right bottom
1148  TempCluster[5] = TCFire[ 1]; // bottom
1149  TempCluster[6] = TCFire[33]; // bottom left
1150  TempCluster[7] = TCFire[32]; // left
1151  TempCluster[8] = TCFire[63]; // top left
1152  } else if (iii == 31) {
1153  TempCluster[0] = TCFire[31];
1154  TempCluster[1] = TCFire[30];
1155  TempCluster[2] = 0;// right top
1156  TempCluster[3] = 0; //right
1157  TempCluster[4] = 0; //right bottom
1158  TempCluster[5] = TCFire[0]; //bottom
1159  TempCluster[6] = TCFire[32]; // bottom left
1160  TempCluster[7] = TCFire[63]; // left
1161  TempCluster[8] = TCFire[62]; //top left
1162  } else {
1163  TempCluster[0] = TCFire[iii];
1164  TempCluster[1] = TCFire[iii - 1]; // top
1165  TempCluster[2] = 0;// right top
1166  TempCluster[3] = 0; //right
1167  TempCluster[4] = 0; //right bottom
1168  TempCluster[5] = TCFire[iii + 1]; //bottom
1169  TempCluster[6] = TCFire[iii + 33]; //bottom left
1170  TempCluster[7] = TCFire[iii + 32]; // left
1171  TempCluster[8] = TCFire[iii + 31]; //top left
1172  }
1173  } else {
1174  if (iii == 32) {
1175  TempCluster[0] = TCFire[32];
1176  TempCluster[1] = TCFire[63]; // top
1177  TempCluster[2] = TCFire[31];// right top
1178  TempCluster[3] = TCFire[0]; //right
1179  TempCluster[4] = TCFire[1]; //right bottom
1180  TempCluster[5] = TCFire[33]; //bottom
1181  TempCluster[6] = 0; //bottom left
1182  TempCluster[7] = 0; // left
1183  TempCluster[8] = 0; //top left
1184  } else if (iii == 63) {
1185  TempCluster[0] = TCFire[63];
1186  TempCluster[1] = TCFire[62]; // top
1187  TempCluster[2] = TCFire[30];// right top
1188  TempCluster[3] = TCFire[31]; //right
1189  TempCluster[4] = TCFire[0]; //right bottom
1190  TempCluster[5] = TCFire[32]; //bottom
1191  TempCluster[6] = 0; //bottom left
1192  TempCluster[7] = 0; // left
1193  TempCluster[8] = 0; //top left
1194  } else {
1195  TempCluster[0] = TCFire[iii];
1196  TempCluster[1] = TCFire[iii - 1]; // top
1197  TempCluster[2] = TCFire[iii - 33]; // right top
1198  TempCluster[3] = TCFire[iii - 32]; //right
1199  TempCluster[4] = TCFire[iii - 31]; //right bottom
1200  TempCluster[5] = TCFire[iii + 1]; //bottom
1201  TempCluster[6] = 0; //bottom left
1202  TempCluster[7] = 0; // left
1203  TempCluster[8] = 0; //top left
1204  }
1205 
1206  }
1207 
1208  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1209  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1210  TempICNTCId = TCFire[iii];
1211 
1212  if (Method == 1) {
1213  int maxTCid = 0;
1214  double maxTCEnergy = 0;
1215  for (int iTC = 0; iTC < 9; iTC++) { //find center of Cluster
1216  if (TempCluster[iTC] == 0) {continue;}
1217  if (maxTCEnergy < TCFireEnergy[TempCluster[iTC] - 513]) {
1218  maxTCEnergy = TCFireEnergy[TempCluster[iTC] - 513];
1219  maxTCid = TempCluster[iTC];
1220  }
1221  }
1222  int kkk = 0;
1223  TempCluster[0] = maxTCid;
1224  if ((TempCluster[0] - 513) % 4 == 2) {
1225  kkk = (TempCluster[0] - 513) / 2 - 1;
1226  }
1227  if ((TempCluster[0] - 513) % 4 == 1) {
1228  kkk = ((TempCluster[0] - 513) + 1) / 2;
1229  }
1230  if ((TempCluster[0] - 513) % 4 == 3) {
1231  kkk = 32 + ((TempCluster[0] - 513) - 3) / 2;
1232  }
1233  if ((TempCluster[0] - 513) % 4 == 0) {
1234  kkk = 33 + ((TempCluster[0] - 513)) / 2;
1235  }
1236 
1237  if (kkk < 32) {
1238  if (kkk == 0) {
1239  TempCluster[0] = TCFire[ 0];
1240  TempCluster[1] = TCFire[31]; // top
1241  TempCluster[2] = 0;// right top
1242  TempCluster[3] = 0; //right
1243  TempCluster[4] = 0; //right bottom
1244  TempCluster[5] = TCFire[ 1]; // bottom
1245  TempCluster[6] = TCFire[33]; // bottom left
1246  TempCluster[7] = TCFire[32]; // left
1247  TempCluster[8] = TCFire[63]; // top left
1248  } else if (kkk == 31) {
1249  TempCluster[0] = TCFire[31];
1250  TempCluster[1] = TCFire[30];
1251  TempCluster[2] = 0;// right top
1252  TempCluster[3] = 0; //right
1253  TempCluster[4] = 0; //right bottom
1254  TempCluster[5] = TCFire[0]; //bottom
1255  TempCluster[6] = TCFire[32]; // bottom left
1256  TempCluster[7] = TCFire[63]; // left
1257  TempCluster[8] = TCFire[62]; //top left
1258  } else {
1259  TempCluster[0] = TCFire[kkk];
1260  TempCluster[1] = TCFire[kkk - 1]; // top
1261  TempCluster[2] = 0;// right top
1262  TempCluster[3] = 0; //right
1263  TempCluster[4] = 0; //right bottom
1264  TempCluster[5] = TCFire[kkk + 1]; //bottom
1265  TempCluster[6] = TCFire[kkk + 33]; //bottom left
1266  TempCluster[7] = TCFire[kkk + 32]; // left
1267  TempCluster[8] = TCFire[kkk + 31]; //top left
1268  }
1269  } else {
1270  if (kkk == 32) {
1271  TempCluster[0] = TCFire[32];
1272  TempCluster[1] = TCFire[63]; // top
1273  TempCluster[2] = TCFire[31];// right top
1274  TempCluster[3] = TCFire[0]; //right
1275  TempCluster[4] = TCFire[1]; //right bottom
1276  TempCluster[5] = TCFire[33]; //bottom
1277  TempCluster[6] = 0; //bottom left
1278  TempCluster[7] = 0; // left
1279  TempCluster[8] = 0; //top left
1280  } else if (kkk == 63) {
1281  TempCluster[0] = TCFire[63];
1282  TempCluster[1] = TCFire[62]; // top
1283  TempCluster[2] = TCFire[30];// right top
1284  TempCluster[3] = TCFire[31]; //right
1285  TempCluster[4] = TCFire[0]; //right bottom
1286  TempCluster[5] = TCFire[32]; //bottom
1287  TempCluster[6] = 0; //bottom left
1288  TempCluster[7] = 0; // left
1289  TempCluster[8] = 0; //top left
1290  } else {
1291  TempCluster[0] = TCFire[kkk];
1292  TempCluster[1] = TCFire[kkk - 1]; // top
1293  TempCluster[2] = TCFire[kkk - 33]; // right top
1294  TempCluster[3] = TCFire[kkk - 32]; //right
1295  TempCluster[4] = TCFire[kkk - 31]; //right bottom
1296  TempCluster[5] = TCFire[kkk + 1]; //bottom
1297  TempCluster[6] = 0; //bottom left
1298  TempCluster[7] = 0; // left
1299  TempCluster[8] = 0; //top left
1300  }
1301 
1302  }
1303  }
1304 
1305  for (int iNearTC = 1; iNearTC < 9; iNearTC ++) {
1306  for (int jNearTC = 1; jNearTC < 9; jNearTC ++) {
1307  if (TempCluster[iNearTC] == 0) {continue;}
1308  if (iNearTC == jNearTC) {continue;}
1309  if (TempCluster[iNearTC] == TempCluster[jNearTC]) {
1310  TempCluster[jNearTC] = 0;
1311  }
1312  }
1313  }
1314 
1315  int maxTCId = 999;
1316  double clusterenergy = 0;
1317  double clustertiming = 0;
1318  double clusterpositionX = 0;
1319  double clusterpositionY = 0;
1320  double clusterpositionZ = 0;
1321  int noftcincluster = 0;
1322  for (int iNearTC = 0; iNearTC < 9; iNearTC ++) {
1323  if (TempCluster[iNearTC] == 0) {continue;}
1324  else {noftcincluster++;}
1325 
1326  clusterenergy += TCFireEnergy[TempCluster[iNearTC] - 513];
1327  clustertiming += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFireTiming[TempCluster[iNearTC] - 513];
1328  clusterpositionX += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][0];
1329  clusterpositionY += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][1];
1330  clusterpositionZ += TCFireEnergy[TempCluster[iNearTC] - 513] * TCFirePosition[TempCluster[iNearTC] - 513][2];
1331 
1332 
1333  }
1334  //
1335  maxTCId = TempCluster[0];
1336  //
1337 
1338  clustertiming /= clusterenergy;
1339  if (_Position == 1) {
1340  clusterpositionX /= clusterenergy;
1341  clusterpositionY /= clusterenergy;
1342  clusterpositionZ /= clusterenergy;
1343  } else if (_Position == 0) {
1344  clustertiming = TCFireTiming[maxTCId - 513];
1345  clusterpositionX = TCFirePosition[maxTCId - 513][0];
1346  clusterpositionY = TCFirePosition[maxTCId - 513][1];
1347  clusterpositionZ = TCFirePosition[maxTCId - 513][2];
1348  }
1349 
1350  if (clustertiming == 0 && clusterenergy == 0) {continue;}
1351  TempClusterEnergy.push_back(clusterenergy);
1352  TempClusterTiming.push_back(clustertiming);
1353  TempClusterPositionX.push_back(clusterpositionX);
1354  TempClusterPositionY.push_back(clusterpositionY);
1355  TempClusterPositionZ.push_back(clusterpositionZ);
1356  TempNofTCinCluster.push_back(noftcincluster);
1357  TempMaxTCId.push_back(maxTCId);
1358 
1359 
1360  Sort1D.push_back(TempICNTCId);
1361  Sort1D.push_back(clusterenergy);
1362  Sort1D.push_back(clustertiming);
1363  Sort1D.push_back(clusterpositionX);
1364  Sort1D.push_back(clusterpositionY);
1365  Sort1D.push_back(clusterpositionZ);
1366  Sort1D.push_back(noftcincluster);
1367  Sort1D.push_back(maxTCId);
1368 
1369  Sort2D.push_back(Sort1D);
1370  Sort1D.clear();
1371 
1372 
1373  }
1374  }
1375  }
1376 
1377  sort(Sort2D.begin(), Sort2D.end(),
1378  [](const vector<double>& aa1, const vector<double>& aa2) {return aa1[0] < aa2[0];});
1379 
1380  const int clustersize = Sort2D.size();
1381  for (int jtc = 0; jtc < clustersize; jtc++) {
1382  ClusterEnergy[2].push_back(Sort2D[jtc][1]);
1383  ClusterTiming[2].push_back(Sort2D[jtc][2]);
1384  ClusterPositionX[2].push_back(Sort2D[jtc][3]);
1385  ClusterPositionY[2].push_back(Sort2D[jtc][4]);
1386  ClusterPositionZ[2].push_back(Sort2D[jtc][5]);
1387  NofTCinCluster[2].push_back(Sort2D[jtc][6]);
1388  MaxTCId[2].push_back(Sort2D[jtc][7]);
1389  }
1390 
1391  _BWDNofCluster = MaxTCId[2].size();
1392 }
1393 
1394 //
1395 //
1396 //
1397 int
1399 {
1400 
1401  std::vector<int> TCFire;
1402 
1403  TCFire.clear();
1404 
1405  TCFire.resize(432, 0);
1406 
1407  const int hit_size = TCId.size();
1408  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1409  if (TCId[ihit] >= 81 && TCId[ihit] <= 512) {
1410  TCFire[TCId[ihit] - 81] = TCId[ihit];
1411  }
1412  }
1413 
1414  //
1415  //
1416  //
1417  int tc_upper = 0; // check upper TC
1418  int tc_upper_right = 0; // check right TC
1419  int tc_right = 0; // check right TC
1420  int tc_lower_right = 0;
1421  int tc_lower = 0; // check lower TC
1422  int tc_lower_left = 0; // check lower TC
1423  int tc_left = 0;
1424  int tc_upper_left = 0;
1425 
1426  for (int iii = 0 ; iii < 432 ; iii++) {
1427  if (TCFire[iii] == 0) { continue; }
1428 
1429  if (iii < 12) {
1430  tc_upper = TCFire[iii + 420] ;
1431  tc_upper_right = TCFire[iii + 419] ;
1432  tc_right = TCFire[iii - 1] ;
1433  tc_lower_right = TCFire[iii + 11] ;
1434  tc_lower = TCFire[iii + 12] ;
1435  tc_lower_left = TCFire[iii + 13] ;
1436  tc_left = TCFire[iii + 1] ;
1437  tc_upper_left = TCFire[iii + 421] ;
1438  if (iii % 12 == 0) {
1439  tc_upper_right = 0;
1440  tc_right = 0;
1441  tc_lower_right = 0;
1442 
1443  }
1444  if (iii % 12 == 11) {
1445  tc_lower_left = 0;
1446  tc_left = 0;
1447  tc_upper_left = 0;
1448 
1449  }
1450  }
1451  if (iii > 11 && iii < 420) {
1452  tc_upper = TCFire[iii - 12] ;
1453  // cppcheck-suppress negativeContainerIndex
1454  tc_upper_right = TCFire[iii - 13] ;
1455  tc_right = TCFire[iii - 1] ;
1456  tc_lower_right = TCFire[iii + 11] ;
1457  tc_lower = TCFire[iii + 12] ;
1458  tc_lower_left = TCFire[iii + 13] ;
1459  tc_left = TCFire[iii + 1] ;
1460  tc_upper_left = TCFire[iii - 11] ;
1461  if (iii % 12 == 0) {
1462  tc_upper_right = 0;
1463  tc_right = 0;
1464  tc_lower_right = 0;
1465 
1466  }
1467  if (iii % 12 == 11) {
1468  tc_lower_left = 0;
1469  tc_left = 0;
1470  tc_upper_left = 0;
1471 
1472  }
1473 
1474  }
1475  if (iii > 419) {
1476  tc_upper = TCFire[iii - 12] ;
1477  tc_upper_right = TCFire[iii - 13] ;
1478  tc_right = TCFire[iii - 1] ;
1479  // cppcheck-suppress negativeContainerIndex
1480  tc_lower_right = TCFire[iii - 421] ;
1481  tc_lower = TCFire[iii - 420] ;
1482  tc_lower_left = TCFire[iii - 419];
1483  tc_left = TCFire[iii + 1] ;
1484  tc_upper_left = TCFire[iii - 11] ;
1485  if (iii % 12 == 0) {
1486  tc_upper_right = 0;
1487  tc_right = 0;
1488  tc_lower_right = 0;
1489  }
1490  if (iii % 12 == 11) {
1491  tc_lower_left = 0;
1492  tc_left = 0;
1493  tc_upper_left = 0;
1494 
1495  }
1496  }
1497 
1498  TempCluster[0] = iii + 80 + 1; //middle of ICN
1499  TempCluster[1] = tc_upper; // upper
1500  TempCluster[2] = tc_upper_right; //right
1501  TempCluster[3] = tc_right; //right
1502  TempCluster[4] = tc_lower_right; //lower
1503  TempCluster[5] = tc_lower; //lower
1504  TempCluster[6] = tc_lower_left; //lower
1505  TempCluster[7] = tc_left; //lower
1506  TempCluster[8] = tc_upper_left; //lower right;
1507 
1508  if (!(tc_upper != 0 || tc_left != 0)) {
1509  if (!(tc_lower != 0 && tc_lower_left != 0)) {
1510  _BRICN++;
1511  int phiid = _TCMap->getTCPhiIdFromTCId(iii + 80 + 1);
1512 
1513  if (phiid == 36 || (phiid > 0 && phiid < 11)) {
1514  _Quadrant[1][0]++;
1515  }
1516  if (phiid > 8 && phiid < 20) {
1517  _Quadrant[1][1]++;
1518  }
1519  if (phiid > 17 && phiid < 29) {
1520  _Quadrant[1][2]++;
1521  }
1522  if ((phiid > 26 && phiid < 37) || phiid == 1) {
1523  _Quadrant[1][3]++;
1524  }
1525 
1526  }
1527  }// iii loop
1528  }
1529  return _BRICN;
1530 
1531 }
1532 //
1533 //
1534 //
1535 int
1537 {
1538 
1539  std::vector<int> TCFire;
1540 
1541 
1542  TCFire.clear();
1543 
1544  TCFire.resize(96, 0);
1545 
1546 
1547  const int hit_size = TCId.size();
1548  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1549  if (TCId[ihit] > 80) {continue;}
1550 
1551 
1552  //------------------------------------
1553  // To rearrange the hitted map
1554  //
1555  // orignal converted
1556  // (<- Theta) (<- Theta)
1557  //
1558  // 3 2 1 64 32 0
1559  // 4 5 - 65 33 1
1560  // 8 7 6 => 66 34 2
1561  // 9 10 - 67 35 3
1562  // .... ...
1563  // 78 77 76 94 62 30
1564  // 79 80 - 95 63 31
1565  //
1566  // Here, TCId-1 becomes TCId=0 and 1.
1567  //------------------------------------
1568  int iTCId0 = TCId[ihit] - 1;
1569  int kkk = 0;
1570  if (iTCId0 % 5 == 0) {
1571  kkk = (iTCId0 / 5) * 2;
1572  TCFire[kkk] = TCId[ihit];
1573  TCFire[kkk + 1] = TCId[ihit];
1574  } else {
1575  kkk = iTCId0 / 5;
1576  switch (iTCId0 % 5) {
1577  case 1 :
1578  TCFire[32 + 2 * kkk] = TCId[ihit]; break;
1579  case 2 :
1580  TCFire[64 + 2 * kkk] = TCId[ihit]; break;
1581  case 3 :
1582  TCFire[64 + 2 * kkk + 1] = TCId[ihit]; break;
1583  case 4 :
1584  TCFire[32 + 2 * kkk + 1] = TCId[ihit]; break;
1585  default:
1586  break;
1587  }
1588  }
1589  }
1590 
1591 
1592  for (int iii = 32 ; iii < 96 ; iii++) {
1593  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1594  if (TCFire[iii] == 0) { continue; }
1595  if (iii < 64) {
1596  if (iii == 32) {
1597  TempCluster[0] = TCFire[iii];
1598  TempCluster[1] = TCFire[63]; // top
1599  TempCluster[2] = 0;// right top
1600  TempCluster[3] = 0; //right
1601  TempCluster[4] = 0; //right bottom
1602  TempCluster[5] = TCFire[iii + 1]; //bottom
1603  TempCluster[6] = TCFire[iii + 33]; //bottom left
1604  TempCluster[7] = TCFire[iii + 32]; // left
1605  TempCluster[8] = TCFire[95]; //top left
1606  } else if (iii == 63) {
1607  TempCluster[0] = TCFire[iii];
1608  TempCluster[1] = TCFire[iii - 1]; // top
1609  TempCluster[2] = 0; // right top
1610  TempCluster[3] = 0; //right
1611  TempCluster[4] = 0; //right bottom
1612  TempCluster[5] = TCFire[32]; //bottom
1613  TempCluster[6] = TCFire[64]; //bottom left
1614  TempCluster[7] = TCFire[iii + 32]; // left
1615  TempCluster[8] = TCFire[iii + 31]; //top left
1616  } else {
1617  TempCluster[0] = TCFire[iii];
1618  TempCluster[1] = TCFire[iii - 1]; // 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[iii + 31]; //top left
1626  }
1627  } else {
1628  if (iii == 64) {
1629  TempCluster[0] = TCFire[iii];
1630  TempCluster[1] = TCFire[95]; // top
1631  TempCluster[2] = TCFire[63];// right top
1632  TempCluster[3] = TCFire[iii - 32]; //right
1633  TempCluster[4] = TCFire[iii - 31]; //right bottom
1634  TempCluster[5] = TCFire[iii + 1]; //bottom
1635  TempCluster[6] = 0; //bottom left
1636  TempCluster[7] = 0; // left
1637  TempCluster[8] = 0; //top left
1638  } else if (iii == 95) {
1639  TempCluster[0] = TCFire[iii];
1640  TempCluster[1] = TCFire[iii - 1]; // top
1641  TempCluster[2] = TCFire[iii - 33]; // right top
1642  TempCluster[3] = TCFire[iii - 32]; //right
1643  TempCluster[4] = TCFire[32]; //right bottom
1644  TempCluster[5] = TCFire[64]; //bottom
1645  TempCluster[6] = 0; //bottom left
1646  TempCluster[7] = 0; // left
1647  TempCluster[8] = 0; //top left
1648 
1649  } else {
1650  TempCluster[0] = TCFire[iii];
1651  TempCluster[1] = TCFire[iii - 1]; // top
1652  TempCluster[2] = TCFire[iii - 33]; // right top
1653  TempCluster[3] = TCFire[iii - 32]; //right
1654  TempCluster[4] = TCFire[iii - 31]; //right bottom
1655  TempCluster[5] = TCFire[iii + 1]; //bottom
1656  TempCluster[6] = 0; //bottom left
1657  TempCluster[7] = 0; // left
1658  TempCluster[8] = 0; //top left
1659  }
1660 
1661  }
1662  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1663  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1664  _FWDICN++;
1665  int phiid = _TCMap->getTCPhiIdFromTCId(TCFire[iii]);
1666 
1667  if (phiid == 32 || (phiid > 0 && phiid < 10)) {
1668  _Quadrant[0][0]++;
1669  }
1670  if (phiid > 7 && phiid < 18) {
1671  _Quadrant[0][1]++;
1672  }
1673  if (phiid > 15 && phiid < 26) {
1674  _Quadrant[0][2]++;
1675  }
1676  if ((phiid > 22 && phiid < 33) || phiid == 1) {
1677  _Quadrant[0][3]++;
1678  }
1679 
1680 
1681  }
1682  }
1683  }
1684  return _FWDICN;
1685 }
1686 //
1687 //
1688 //
1690 {
1691  std::vector<int> TCFire;
1692 
1693 
1694  TCFire.clear();
1695 
1696  TCFire.resize(64, 0);
1697 
1698 
1699 
1700  const int hit_size = TCId.size();
1701  for (int ihit = 0 ; ihit < hit_size ; ihit++) {
1702  if (TCId[ihit] < 513) {continue;}
1703 
1704  // TCFire[TCId[ihit] - 513] = TCId[ihit];
1705  //------------------------------------
1706  // To rearrange the hitted map
1707  //
1708  // orignal converted
1709  // (<- Theta) (<- Theta)
1710  //
1711  // 516 515 32 0
1712  // 513 514 33 1
1713  // 520 519 => 34 2
1714  // 517 518 35 3
1715  // ... .
1716  // 576 575 62 30
1717  // 573 574 63 31
1718  //
1719  // Here, TCId-1 becomes TCId=0 and 1.
1720  //------------------------------------
1721  int iTCId0 = TCId[ihit] - 1;
1722  int kkk = 0;
1723  if ((iTCId0 - 512) % 4 == 2) {
1724  kkk = (iTCId0 - 512) / 2 - 1;
1725  }
1726  if ((iTCId0 - 512) % 4 == 1) {
1727  kkk = ((iTCId0 - 512) + 1) / 2;
1728  }
1729  if ((iTCId0 - 512) % 4 == 3) {
1730  kkk = 32 + ((iTCId0 - 512) - 3) / 2;
1731  }
1732  if ((iTCId0 - 512) % 4 == 0) {
1733  kkk = 33 + ((iTCId0 - 512)) / 2;
1734  }
1735 
1736  TCFire[kkk] = iTCId0 + 1;
1737 
1738  }
1739 
1740 
1741  for (int iii = 0 ; iii < 64 ; iii ++) {
1742 
1743  if (TCFire[iii] == 0) { continue; }
1744 
1745  for (int iinit = 0; iinit < 9; iinit ++) {TempCluster[iinit] = 0;}
1746  if (iii < 32) {
1747  if (iii == 0) {
1748  TempCluster[0] = TCFire[ 0];
1749  TempCluster[1] = TCFire[31]; // top
1750  TempCluster[2] = 0;// right top
1751  TempCluster[3] = 0; //right
1752  TempCluster[4] = 0; //right bottom
1753  TempCluster[5] = TCFire[ 1]; // bottom
1754  TempCluster[6] = TCFire[33]; // bottom left
1755  TempCluster[7] = TCFire[32]; // left
1756  TempCluster[8] = TCFire[63]; // top left
1757  } else if (iii == 31) {
1758  TempCluster[0] = TCFire[31];
1759  TempCluster[1] = TCFire[30];
1760  TempCluster[2] = 0;// right top
1761  TempCluster[3] = 0; //right
1762  TempCluster[4] = 0; //right bottom
1763  TempCluster[5] = TCFire[0]; //bottom
1764  TempCluster[6] = TCFire[32]; // bottom left
1765  TempCluster[7] = TCFire[63]; // left
1766  TempCluster[8] = TCFire[62]; //top left
1767  } else {
1768  TempCluster[0] = TCFire[iii];
1769  TempCluster[1] = TCFire[iii - 1]; // top
1770  TempCluster[2] = 0;// right top
1771  TempCluster[3] = 0; //right
1772  TempCluster[4] = 0; //right bottom
1773  TempCluster[5] = TCFire[iii + 1]; //bottom
1774  TempCluster[6] = TCFire[iii + 33]; //bottom left
1775  TempCluster[7] = TCFire[iii + 32]; // left
1776  TempCluster[8] = TCFire[iii + 31]; //top left
1777  }
1778  } else {
1779  if (iii == 32) {
1780  TempCluster[0] = TCFire[32];
1781  TempCluster[1] = TCFire[63]; // top
1782  TempCluster[2] = TCFire[31];// right top
1783  TempCluster[3] = TCFire[0]; //right
1784  TempCluster[4] = TCFire[1]; //right bottom
1785  TempCluster[5] = TCFire[33]; //bottom
1786  TempCluster[6] = 0; //bottom left
1787  TempCluster[7] = 0; // left
1788  TempCluster[8] = 0; //top left
1789  } else if (iii == 63) {
1790  TempCluster[0] = TCFire[63];
1791  TempCluster[1] = TCFire[62]; // top
1792  TempCluster[2] = TCFire[30];// right top
1793  TempCluster[3] = TCFire[31]; //right
1794  TempCluster[4] = TCFire[0]; //right bottom
1795  TempCluster[5] = TCFire[32]; //bottom
1796  TempCluster[6] = 0; //bottom left
1797  TempCluster[7] = 0; // left
1798  TempCluster[8] = 0; //top left
1799  } else {
1800  TempCluster[0] = TCFire[iii];
1801  TempCluster[1] = TCFire[iii - 1]; // top
1802  TempCluster[2] = TCFire[iii - 33]; // right top
1803  TempCluster[3] = TCFire[iii - 32]; //right
1804  TempCluster[4] = TCFire[iii - 31]; //right bottom
1805  TempCluster[5] = TCFire[iii + 1]; //bottom
1806  TempCluster[6] = 0; //bottom left
1807  TempCluster[7] = 0; // left
1808  TempCluster[8] = 0; //top left
1809  }
1810 
1811  }
1812 
1813  if (!(TempCluster[1] != 0 || TempCluster[7] != 0)) {
1814  if (!(TempCluster[5] != 0 && TempCluster[6] != 0)) {
1815  _BWDICN ++;
1816  int phiid = _TCMap->getTCPhiIdFromTCId(TCFire[iii]);
1817 
1818  if (phiid == 32 || (phiid > 0 && phiid < 10)) {
1819  _Quadrant[2][0]++;
1820  }
1821  if (phiid > 7 && phiid < 18) {
1822  _Quadrant[2][1]++;
1823  }
1824  if (phiid > 15 && phiid < 26) {
1825  _Quadrant[2][2]++;
1826  }
1827  if ((phiid > 22 && phiid < 33) || phiid == 1) {
1828  _Quadrant[2][3]++;
1829  }
1830 
1831 
1832  }
1833  }
1834  }
1835 
1836  return _BWDICN;
1837 }
1838 //
1839 //
1840 //
1841 //
1843 {
1844  int ncluster = ClusterEnergy[0].size() + ClusterEnergy[1].size() + ClusterEnergy[2].size();
1845  if (ncluster > _LimitNCluster) {
1846  return ncluster;
1847  } else {
1848  return 0;
1849  }
1850 }
1851 //
1852 //===<END>
1853 //
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
void save(int)
Save Cluster information in TRGECLCluster Table.
int _Position
Position calculation method(0:Most energetic TC Postion, 1 : Energy weighted Postion)
void setICN(const std::vector< int > &)
set ICN for each part(Fw,Br,Bw)
std::vector< std::vector< int > > _Quadrant
Quadrant for Beam Backgournd veto.
int _BRNofCluster
Cluster in Barrel.
std::vector< std::vector< int > > NofTCinCluster
N of TC in Cluster
std::vector< int > TempCluster
Temporal Cluster.
int getICNSub(int)
get ICN in each region(Fw(0), Br(1), Bw(2))
int _BWDNofCluster
Cluster in Backward Endcap.
std::vector< std::vector< int > > _FwCluster
cluster in forward endcap
int getICNFwBr(void)
get ICN in Barrel and Forward
std::vector< std::vector< double > > ClusterPositionX
Cluster position in X-axis.
int getNofExceedCluster()
get # Cluster in case of exceeding limit
int setBarrelICN()
calculate Belle ICN in Barrel
int setBackwardICN()
calculate Belle ICN in Backward endcap
std::vector< std::vector< double > > ClusterPositionZ
Cluster position in Z-axis.
std::vector< int > _icnfwbrbw
icn
std::vector< std::vector< int > > _BwCluster
cluster in backward endcap
int getBrICNCluster(int ICNId, int)
get ICN in QuadrantId in Fw or Br or Bw.
int setForwardICN()
calculate Belle ICN in Foward endcap
int getFwICNCluster(int ICNId, int)
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
int _Method
Clustering method.
int _BRICN
get Beam bkg veto flag.
std::vector< std::vector< double > > ClusterPositionY
Cluster position in Y-axis.
int _FWDNofCluster
Cluster in Forward Endcap.
virtual ~TrgEclCluster()
Constructor.
std::vector< std::vector< int > > MaxTCId
Maximum contribution TC Id in Cluster.
int _LimitNCluster
the Limit Number of Cluster
int getBwICNCluster(int ICNId, int)
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
int _EventId
event number
std::vector< std::vector< double > > ClusterTiming
Cluster timing.
std::vector< std::vector< double > > ClusterEnergy
Cluster enrgy
int _FWDICN
ICN in Forward Endcap.
TrgEclMapping * _TCMap
Object of TC Mapping.
int _BWDICN
ICN in Backward Endcap.
std::vector< int > TCId
TC Id.
std::vector< std::vector< int > > _BrCluster
cluster in barrel
std::vector< double > Energy
TC energy
std::vector< double > Timing
TC timing.
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
TVector3 getTCPosition(int)
TC position (cm)
int getTCPhiIdFromTCId(int)
get [TC Phi ID] from [TC ID]
Abstract base class for different kinds of events.