Belle II Software  release-05-01-25
TrgEclTiming.cc
1 //---------------------------------------------------------------
2 // $Id$
3 //---------------------------------------------------------------
4 // Filename : TrgEclTiming.cc
5 // Section : TRG ECL
6 // Owner : InSu Lee/Yuuji Unno
7 // Email : islee@hep.hanyang.ac.kr / yunno@post.kek.jp
8 //---------------------------------------------------------------
9 // Description : A class to represent TRG ECL
10 //---------------------------------------------------------------
11 // $Log$
12 //---------------------------------------------------------------
13 
14 #define TRG_SHORT_NAMES
15 #define TRGECLCLUSTER_SHORT_NAMES
16 #include <framework/gearbox/Unit.h>
17 
18 #include "trg/ecl/TrgEclTiming.h"
19 
20 using namespace std;
21 using namespace Belle2;
22 //
23 //
24 //
25 TrgEclTiming::TrgEclTiming() : NofTopTC(3), Source(0)
26 {
27 
28  _TCMap = new TrgEclMapping();
29  TCEnergy.clear();
30  TCTiming.clear();
31  TCId.clear();
32 
33 }
34 
36 {
37 
38  delete _TCMap;
39 }
40 void TrgEclTiming::Setup(std::vector<int> HitTCId, std::vector<double>HitTCEnergy, std::vector<double> HitTCTiming)
41 {
42  TCId = HitTCId;
43  TCEnergy = HitTCEnergy;
44  TCTiming = HitTCTiming;
45  return;
46 }
47 
48 double TrgEclTiming::GetEventTiming(int method)
49 {
50  double EventTiming = 0;
51 
52  if (method == 0) { // Fastest timing (belle)
53  EventTiming = GetEventTiming00();
54  } else if (method == 1) { // Maximum energy
55  EventTiming = GetEventTiming01();
56  } else { // Energy weighted timing
57 
58  EventTiming = GetEventTiming02();
59  }
60 
61  return EventTiming;
62 }
64 {
65  Source = 0;
66  double Fastest = 9999;
67  int FastestTCId = 0;
68  const int hit_size = TCTiming.size();
69 
70  for (int ihit = 0; ihit < hit_size; ihit++) {
71  if (TCTiming[ihit] < Fastest) {
72  Fastest = TCTiming[ihit];
73  FastestTCId = TCId[ihit];
74  }
75  }
76 
77  if (FastestTCId < 81) {Source = 1;}
78  else if (FastestTCId > 80 && FastestTCId < 513) {Source = 2;}
79  else {Source = 4;}
80  return Fastest ;
81 
82 }
83 
85 {
86  Source = 0;
87 
88  double maxEnergy = 0;
89  double maxTiming = 0;
90  int maxTCId = 0;
91  const int hit_size = TCTiming.size();
92 
93  for (int ihit = 0; ihit < hit_size; ihit++) {
94  if (TCEnergy[ihit] > maxEnergy) {
95  maxEnergy = TCEnergy[ihit] ;
96  maxTiming = TCTiming[ihit] ;
97  maxTCId = TCId[ihit];
98  }
99  }
100  if (maxTCId < 81) {Source = 1;}
101  else if (maxTCId > 80 && maxTCId < 513) {Source = 2;}
102  else {Source = 4;}
103 
104 
105  return maxTiming;
106 
107 }
108 
109 
111 {
112  Source = 0;
113  std::vector<double> maxEnergy;
114  std::vector<double> maxTiming;
115 
116  const int NtopTC = NofTopTC;
117  int maxTCId = 0;
118 
119  maxEnergy.clear();
120  maxTiming.clear();
121  maxEnergy.resize(NtopTC, 0);
122  maxTiming.resize(NtopTC, 0);
123 
124  const int hit_size = TCTiming.size();
125  double E_sum = 0;
126  double EventTiming = 0;
127 
128  for (int iNtopTC = 0; iNtopTC < NtopTC ; iNtopTC++) {
129  for (int ihit = 0; ihit < hit_size; ihit++) {
130  if (iNtopTC == 0) {
131  if (maxEnergy[iNtopTC] < TCEnergy[ihit]) {
132  maxEnergy[iNtopTC] = TCEnergy[ihit];
133  maxTiming[iNtopTC] = TCTiming[ihit];
134  maxTCId = TCId[ihit];
135  }
136  } else if (iNtopTC > 0) {
137  if (maxEnergy[iNtopTC - 1] > TCEnergy[ihit] && maxEnergy[iNtopTC] < TCEnergy[ihit]) {
138  maxEnergy[iNtopTC] = TCEnergy[ihit];
139  maxTiming[iNtopTC] = TCTiming[ihit];
140  }
141  }
142  }
143  E_sum += maxEnergy[iNtopTC];
144  EventTiming += maxEnergy[iNtopTC] * maxTiming[iNtopTC];
145  }
146 
147  EventTiming /= E_sum;
148 
149  if (maxTCId < 81) {Source = 1;}
150  else if (maxTCId > 80 && maxTCId < 513) {Source = 2;}
151  else {Source = 4;}
152 
153 
154 
155  return EventTiming;
156 
157 }
158 
159 
160 //
161 //===<END>
162 //
Belle2::TrgEclTiming::~TrgEclTiming
virtual ~TrgEclTiming()
Constructor.
Definition: TrgEclTiming.cc:35
Belle2::TrgEclTiming::GetEventTiming00
double GetEventTiming00()
Fastest TC Timing.
Definition: TrgEclTiming.cc:63
Belle2::TrgEclTiming::Setup
void Setup(std::vector< int >, std::vector< double >, std::vector< double >)
Destructor.
Definition: TrgEclTiming.cc:40
Belle2::TrgEclTiming::TCTiming
std::vector< double > TCTiming
TC Timing.
Definition: TrgEclTiming.h:62
Belle2::TrgEclTiming::TCId
std::vector< int > TCId
TC Id.
Definition: TrgEclTiming.h:64
Belle2::TrgEclTiming::GetEventTiming02
double GetEventTiming02()
Energy weighted Timing of Top 3 energetic TC.
Definition: TrgEclTiming.cc:110
Belle2::TrgEclTiming::Source
int Source
Timing Source (FWD, Barrel, Backward)
Definition: TrgEclTiming.h:71
Belle2::TrgEclMapping
A class of TC Mapping.
Definition: TrgEclMapping.h:31
Belle2::TrgEclTiming::_TCMap
TrgEclMapping * _TCMap
Object of TC Mapping.
Definition: TrgEclTiming.h:69
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrgEclTiming::TCEnergy
std::vector< double > TCEnergy
TC Energy.
Definition: TrgEclTiming.h:60
Belle2::TrgEclTiming::NofTopTC
int NofTopTC
Definition: TrgEclTiming.h:67
Belle2::TrgEclTiming::GetEventTiming
double GetEventTiming(int)
Get Evnet-timing.
Definition: TrgEclTiming.cc:48
Belle2::TrgEclTiming::GetEventTiming01
double GetEventTiming01()
The Most energetic TC Timing.
Definition: TrgEclTiming.cc:84