Belle II Software development
TrgEclTiming.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#define TRG_SHORT_NAMES
10#define TRGECLCLUSTER_SHORT_NAMES
11#include <framework/gearbox/Unit.h>
12
13#include "trg/ecl/TrgEclTiming.h"
14
15using namespace std;
16using namespace Belle2;
17//
18//
19//
20TrgEclTiming::TrgEclTiming() : NofTopTC(3), Source(0)
21{
22 _TCMap = new TrgEclMapping();
23 TCEnergy.clear();
24 TCTiming.clear();
25 TCId.clear();
26 m_EventTimingQualityFlag = -1;
27 m_EventTimingTCId = 0;
28 m_EventTimingTCThetaId = 0;
29 m_EventTimingTCEnergy = 0;
30 m_EventTimingQualityThresholds = {0.5, 2.0}; // GeV
31}
32//
33//
34//
36{
37 delete _TCMap;
38}
39//
40//
41//
42void
43TrgEclTiming::Setup(const std::vector<int>& HitTCId,
44 const std::vector<double>& HitTCEnergy,
45 const std::vector<double>& HitTCTiming)
46{
47 TCId = HitTCId;
48 TCEnergy = HitTCEnergy;
49 TCTiming = HitTCTiming;
50 return;
51}
52//========================================================
53// timing method selection
54//========================================================
56{
57 double EventTiming = 0;
58
59 if (method == 0) {
60 // Fastest timing (belle)
61 EventTiming = GetEventTiming00();
62 } else if (method == 1) {
63 // Maximum energy
64 EventTiming = GetEventTiming01();
65 } else {
66 // Energy weighted timing
67 EventTiming = GetEventTiming02();
68 }
69
70 return EventTiming;
71}
72//========================================================
73// Fastest TC timing ( same as belle )
74//========================================================
76{
77 Source = 0;
78 double FastestEnergy = 0;
79 double FastestTiming = 9999;
80 int FastestTCId = 0;
81 const int hit_size = TCTiming.size();
82
83 for (int ihit = 0; ihit < hit_size; ihit++) {
84 if (TCTiming[ihit] < FastestTiming) {
85 FastestTiming = TCTiming[ihit];
86 FastestTCId = TCId[ihit];
87 FastestEnergy = TCEnergy[ihit];
88 }
89 }
90
91 if (FastestTCId < 81) {
92 Source = 1;
93 } else if (FastestTCId < 513) {
94 Source = 2;
95 } else {
96 Source = 4;
97 }
98
99 m_EventTimingTCId = FastestTCId;
100 m_EventTimingTCThetaId = _TCMap->getTCThetaIdFromTCId(FastestTCId);
101 m_EventTimingTCEnergy = FastestEnergy;
102
103 return FastestTiming;
104}
105//========================================================
106// Timing from most energetic TC timing
107//========================================================
109{
110 Source = 0;
111
112 double maxEnergy = 0;
113 double maxTiming = 0;
114 int maxTCId = 0;
115 const int hit_size = TCTiming.size();
116
117 for (int ihit = 0; ihit < hit_size; ihit++) {
118 if (TCEnergy[ihit] > maxEnergy) {
119 maxEnergy = TCEnergy[ihit] ;
120 maxTiming = TCTiming[ihit] ;
121 maxTCId = TCId[ihit];
122 }
123 }
124 if (maxTCId < 81) {
125 Source = 1;
126 } else if (maxTCId < 513) {
127 Source = 2;
128 } else {
129 Source = 4;
130 }
131
132 if (hit_size == 0) {
133 m_EventTimingQualityFlag = 0;
134 } else {
135 if (maxEnergy > m_EventTimingQualityThresholds[1]) {
136 m_EventTimingQualityFlag = 3;
137 } else if (maxEnergy > m_EventTimingQualityThresholds[0]) {
138 m_EventTimingQualityFlag = 2;
139 } else {
140 m_EventTimingQualityFlag = 1;
141 }
142 }
143
144 m_EventTimingTCId = maxTCId;
145 m_EventTimingTCThetaId = _TCMap->getTCThetaIdFromTCId(maxTCId);
146 m_EventTimingTCEnergy = maxEnergy;
147
148 return maxTiming;
149}
150//========================================================
151// Energy weighted TC timing
152//========================================================
154{
155 Source = 0;
156 std::vector<double> maxEnergy;
157 std::vector<double> maxTiming;
158
159 const int NtopTC = NofTopTC;
160 int maxTCId = 0;
161
162 maxEnergy.clear();
163 maxTiming.clear();
164 maxEnergy.resize(NtopTC, 0);
165 maxTiming.resize(NtopTC, 0);
166
167 const int hit_size = TCTiming.size();
168 double E_sum = 0;
169 double EventTiming = 0;
170
171 for (int iNtopTC = 0; iNtopTC < NtopTC ; iNtopTC++) {
172 for (int ihit = 0; ihit < hit_size; ihit++) {
173 if (iNtopTC == 0) {
174 if (maxEnergy[iNtopTC] < TCEnergy[ihit]) {
175 maxEnergy[iNtopTC] = TCEnergy[ihit];
176 maxTiming[iNtopTC] = TCTiming[ihit];
177 maxTCId = TCId[ihit];
178 }
179 } else if (iNtopTC > 0) {
180 if (maxEnergy[iNtopTC - 1] > TCEnergy[ihit] &&
181 maxEnergy[iNtopTC] < TCEnergy[ihit]) {
182 maxEnergy[iNtopTC] = TCEnergy[ihit];
183 maxTiming[iNtopTC] = TCTiming[ihit];
184 }
185 }
186 }
187 E_sum += maxEnergy[iNtopTC];
188 EventTiming += maxEnergy[iNtopTC] * maxTiming[iNtopTC];
189 }
190
191 EventTiming /= E_sum;
192
193 if (maxTCId < 81) {
194 Source = 1;
195 } else if (maxTCId < 513) {
196 Source = 2;
197 } else {
198 Source = 4;
199 }
200
201 return EventTiming;
202}
203//========================================================
204//
205//========================================================
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
std::vector< double > TCEnergy
TC Energy.
Definition: TrgEclTiming.h:87
void Setup(const std::vector< int > &, const std::vector< double > &, const std::vector< double > &)
SetUp.
Definition: TrgEclTiming.cc:43
double GetEventTiming(int)
Get Evnet-timing.
Definition: TrgEclTiming.cc:55
double GetEventTiming00()
Fastest TC Timing.
Definition: TrgEclTiming.cc:75
std::vector< double > TCTiming
TC Timing.
Definition: TrgEclTiming.h:89
virtual ~TrgEclTiming()
Constructor.
Definition: TrgEclTiming.cc:35
TrgEclTiming()
Constructor.
Definition: TrgEclTiming.cc:20
double GetEventTiming01()
The Most energetic TC Timing.
int Source
Timing Source (FWD, Barrel, Backward)
Definition: TrgEclTiming.h:113
double GetEventTiming02()
Energy weighted Timing of Top 3 energetic TC.
TrgEclMapping * _TCMap
Object of TC Mapping.
Definition: TrgEclTiming.h:111
std::vector< int > TCId
TC Id.
Definition: TrgEclTiming.h:91
Abstract base class for different kinds of events.
STL namespace.