Belle II Software  release-06-00-14
TrgEclMaster.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 : A class to represent TRG ECL
11 //---------------------------------------------------------------------------------
12 //
13 // ECL trigger bit
14 // ---------------------------------------------------------------------------------
15 // Variable(in Tsim) | N(bit) | Address | Parameter
16 // -------------------------------------- ------------------------------------------
17 // | 1 | 0 | TRG(Hit or not)
18 // | 7 | 7 downto 1 | Timing (LSB = 1 ns )
19 // _Triggerbit[0] | 7 | 14 downto 8 | Revoclk from FAM (LSB = 125 ns)
20 // (upto 12th | 3 | 17 downto 15 | ECL-TRG Timing Source
21 // bhabha bit) | 1 | 18 | Physics TRG
22 // (32bit) | 1 | 19 | Belle type Bhabha
23 // ------------------| 14 | 33 downto 20 | Bhabha Type
24 // | 13 | 46 downto 34 | Total Energy
25 // | 1 | 47 | E low (Etot >0.5 GeV)
26 // | 1 | 48 | E High (Etot > 1.0 GeV)
27 // _Triggerbit[1] | 1 | 49 | E lom (Etot > 3.0 GeV)
28 // | 7 | 56 dwonto 50 | ICN
29 // | 3 | 59 downto 57 | BG veto
30 // | 1 | 60 | Cluster Overflow
31 // | 1 | 61 | 3D Bhabha Trigger for Veto
32 // | 1 | 62 | N Cluster >= 3, at least one Cluster >300 MeV (LAB), not 3D ECL Bhabha
33 // _________________ | 1 | 63 | one Cluster >= 2GeV(CM) with Theta Id = 4~14
34 // | 1 | 64 | one Cluster >= 2GeV(CM) with Theta Id = 2,3,15 or 16 and not a 3D ECL Bhabha
35 // | 1 | 65 | one Cluster >= 2GeV(CM) with Theta Id = 2, 3, 15 or 16 and not a 3D ECL Bhabha
36 // | 1 | 66 | one Cluster >= 2GeV(CM) with Theta Id = 1 or 17 and not a 3D ECL Bhabha
37 // | 1 | 67 | one Cluster >= 2GeV(CM) with Theta Id = 1 or 17 and a 3D ECL Bhabha
38 // _Triggerbit[2] | 1 | 68 | exactly one Cluster >= 1GeV(CM) and one Cluster > 300 MeV (LAB ), in Theta Id 4~15(Barrel)
39 // | 1 | 69 | exactly one Cluster >= 1GeV(CM) and one Cluster > 300 MeV (LAB), in Theta Id 2, 3 or 16
40 // | 1 | 70 | 170 < delta phi(CM) < 190 degree, both Clusters > 250 MeV (LAB), and no 2GeV (CM) Cluster
41 // | 1 | 71 | 170 < delta phi(CM) < 190 degree, one Cluster < 250 MeV (LAB), the other Cluster > 250 MeV(LAB), and no 2GeV (CM) Cluster
42 // | 1 | 72 | 160 < delta phi(CM) < 200 degree, 160 < Sum Theta (CM)< 200 degree, no 2 GeV(CM) cluster
43 // | 1 | 74 | 3D Bhabha Trigger for selection
44 // | 1 | 75 | mumu bit
45 // | 1 | 76 | Bhabha prescale bit
46 // | 1 | 77 | E_tot > 20 GeV
47 // | 1 | 78 | N Cluster >= 3, at least one Cluster >500 MeV (LAB) with Theta Id 2~16, not 3D ECL Bhabha
48 // | 1 | 79 | Only one Cluster >500 MeV (CM) with Theta Id 6~11 and no other CL >= 300 MeV(LAB) anywhere
49 // | 1 | 83 downto 80 | clock counter(set to be "0000" in tsim)
50 // | 1 | 85 downto 84 | event timing quality flag
51 // | 1 | 86 | 3D Bhabha Veto Intrk
52 // | 1 | 88 downto 87 | 3D Bhabha selection theta flag
53 // | 1 | 89 | ecltaub2b for 1x1 tau process (110<delta phi(CM)<250, 130<Thata Sum(CM)<230, Etot1to17(Lab)<7GeV, E(1CL)(Lab)<1.9GeV)
54 // | 1 | 90 | hie && 1CL veto(not (N(CL)=1 && CL in FW)) && 2CL veto-1(not (N(CL)=2 && 160 < dphi < 200 && 150 < sum theta < 250))
55 // | 1 | 91 | hie && 1CL veto(not (N(CL)=1 && CL in FW)) && 2CL veto-2(not (N(CL)=2 && 160 < dphi < 200 || 150 < sum theta < 250))
56 // | 1 | 92 | hie && 1CL veto(not (N(CL)=1 && CL in FW)) && 2CL veto-3(not (N(CL)=2 && CL_lowe in FW or BW)
57 // ---------------------------------------------------------------------------------
58 
59 #define TRG_SHORT_NAMES
60 #define TRGECL_SHORT_NAMES
61 
62 #include "framework/datastore/StoreArray.h"
63 #include "trg/ecl/TrgEclMaster.h"
64 #include "trg/ecl/TrgEclCluster.h"
65 
66 #include "trg/ecl/dataobjects/TRGECLTrg.h"
67 #include "trg/ecl/dataobjects/TRGECLHit.h"
68 #include "trg/ecl/dataobjects/TRGECLCluster.h"
69 //
70 #include <math.h>
71 #include <TRandom3.h>
72 //
73 //
74 using namespace std;
75 using namespace Belle2;
76 //
77 //
78 //
79 TrgEclMaster::TrgEclMaster():
80  TimeWindow(250.0), OverlapWindow(0.0), _Clustering(1), _Bhabha(0),
81  _EventTiming(1), _NofTopTC(3), _ClusterLimit(6), _Lowmultibit(0),
82  _PrescaleFactor(0), _PrescaleCounter(0), _mumuThreshold(20),
83  _n300MeVCluster(1), _ECLBurstThreshold(200)
84 {
85 
86  TCEnergy.clear();
87  TCTiming.clear();
88  TCBeamBkgTag.clear();
89  HitTCId.clear();
90  TCHitEnergy.clear();
91  TCHitTiming.clear();
92  TCHitBeamBkgTag.clear();
93 
94 
95  TCEnergy.resize(576);
96  TCTiming.resize(576);
97  TCBeamBkgTag.resize(576);
98 
99  _Triggerbit[0] = 0;
100  _Triggerbit[1] = 0;
101  _Triggerbit[2] = 0;
102  _Triggerbit[3] = 0;
103 
104 
105  _2DBhabhaThresholdFWD.clear();
106  _2DBhabhaThresholdBWD.clear();
108  _3DBhabhaVetoThreshold.clear();
109  _3DBhabhaSelectionAngle.clear();
110  _3DBhabhaVetoAngle.clear();
111  _mumuAngle.clear();
112  m_3DBhabhaAddAngleCut.clear();
113  m_taub2bAngleCut.clear();
114 
115  _TotalEnergy.clear();
116  _LowMultiThreshold.clear();
117 
118  _TotalEnergy = {5, 10, 30}; // /100 MeV
119  _2DBhabhaThresholdFWD = {40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 30, 35}; // /100 MeV
120  _2DBhabhaThresholdBWD = {25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 30}; // /100 MeV
121  _3DBhabhaVetoThreshold = {30, 45}; // /100 MeV
122  _3DBhabhaSelectionThreshold = {20, 40}; // /100 MeV
123  _3DBhabhaVetoAngle = {160, 200, 165, 190}; // /100 MeV
124  _3DBhabhaSelectionAngle = {140, 220, 160, 200}; // /100 MeV
125  _mumuAngle = {160, 200, 165, 190}; // degree
126  m_3DBhabhaAddAngleCut = {150, 210, 160, 200}; // degree
127  _LowMultiThreshold = {10, 20, 25, 30}; // degree
128 
129  m_3DBhabhaVetoInTrackThetaRegion = {3, 15};
130  m_EventTimingQualityThresholds = {5, 6}; // GeV
131 
132  m_taub2bAngleCut = {110, 250, 130, 230}; // degree
133  m_taub2bEtotCut = 7; // GeV
134  m_taub2bClusterECut1 = 1.9; // GeV
135  m_taub2bClusterECut2 = 999; // GeV
136 
137  //ThetaRingSum.resize(3,std::vector<double>(36,0));
138  //PhiRingSum.resize(17,0);
139 
140  // obf_timing = new TrgEclTiming();
141  obj_cluster = new TrgEclCluster();
142  obj_beambkg = new TrgEclBeamBKG();
143  obj_bhabha = new TrgEclBhabha();
144  obj_timing = new TrgEclTiming();
145  obj_map = new TrgEclMapping();
147 }
148 //
149 //
150 //
152 {
153  delete obj_cluster;
154  delete obj_beambkg;
155  delete obj_bhabha;
156  delete obj_timing;
157  delete obj_map;
158 }
159 //
160 //
161 //
162 std::string
164 {
165  return "TrgEclMaster";
166 }
167 //
168 //
169 //
170 std::string
172 {
173  return std::string("TrgEclMaster 2.1");
174 }
175 //
176 //
177 //
178 void
180 {
181 }
182 //
183 //
184 //
186 //
187 //
188 //
191 {
192 
193  if (_ecl) { delete _ecl; }
194  _ecl = new TrgEclMaster();
195 
196  return _ecl;
197 }
198 //========================================================
199 //
200 //========================================================
201 void
202 TrgEclMaster::simulate01(int m_nEvent) // Firmware simulator(time window 250 ns )
203 {
204  // TrgEclFAM* obj_trgeclfam = new TrgEclFAM();
205  // obj_trgeclfam->setup(m_nEvent, 1);
206  // setPRS(obj_trgeclfam);
207  //
208  //----------
209  // TC Etot
210  //----------
211  //
212  // Energy sum of forward and barrel except for extreme forward
213  // so Etot is sum of "phi ring ID" = 1-14
214  // Etot threshold are
215  // 1.0 GeV for Etot01
216  // 0.5 GeV for Etot02nt
217  // 3.0 GeV for Etot03
218  //
219  // Read FAM Output
220  TCTiming.clear();
221  TCEnergy.clear();
222  TCBeamBkgTag.clear();
223  TCEnergy.resize(576);
224  TCTiming.resize(576);
225  TCBeamBkgTag.resize(576);
226 
227  StoreArray<TRGECLHit> trgeclHitArray;
228  for (int ii = 0; ii < trgeclHitArray.getEntries(); ii++) {
229 
230  TRGECLHit* aTRGECLHit = trgeclHitArray[ii];
231  int iTCID = (aTRGECLHit->getTCId() - 1);
232  double HitTiming = aTRGECLHit->getTimeAve();
233  double HitEnergy = aTRGECLHit->getEnergyDep();
234  double HitBeamBkg = aTRGECLHit->getBeamBkgTag();
235 
236  TCTiming[iTCID].push_back(HitTiming);
237  TCEnergy[iTCID].push_back(HitEnergy);
238  TCBeamBkgTag[iTCID].push_back(HitBeamBkg);
239  }
240  //
241  //
242  int nBin = 8000 / (TimeWindow / 2) ; //8000/125
243  /* cppcheck-suppress variableScope */
244  double WindowStart;
245  /* cppcheck-suppress variableScope */
246  double WindowEnd;
247  double fluctuation = ((gRandom->Uniform(-1, 0))) * 125;
248  /* cppcheck-suppress variableScope */
249  double check_window_start;
250  /* cppcheck-suppress variableScope */
251  double check_window_end;
252 
253  for (int iBin = 0 ; iBin < nBin; iBin ++) {
254 
255  check_window_start = iBin * (TimeWindow / 3) + fluctuation - 4000;
256  WindowStart = check_window_start;
257  check_window_end = check_window_start + TimeWindow / 3;
258  WindowEnd = WindowStart + TimeWindow;
259  HitTCId.clear();
260  TCHitTiming.clear();
261  TCHitEnergy.clear();
262  TCHitBeamBkgTag.clear();
263 
264  // prepare TC Hit in time window --
265  for (int iTCId = 0; iTCId < 576; iTCId++) {
266  const int hitsize = TCTiming[iTCId].size();
267  for (int ihit = 0; ihit < hitsize; ihit++) {
268  if (TCTiming[iTCId][ihit] > check_window_start &&
269  TCTiming[iTCId][ihit] < check_window_end) {
270  HitTCId.push_back(iTCId + 1);
271 
272  }
273  }
274  }
275  if (HitTCId.size() == 0) {continue;}
276  else {
277  HitTCId.clear();
278  for (int iTCId = 0; iTCId < 576; iTCId++) {
279  const int hitsize = TCTiming[iTCId].size();
280  for (int ihit = 0; ihit < hitsize; ihit++) {
281  if (TCTiming[iTCId][ihit] > WindowStart &&
282  TCTiming[iTCId][ihit] < WindowEnd) {
283  HitTCId.push_back(iTCId + 1);
284  TCHitTiming.push_back(TCTiming[iTCId][ihit]);
285  TCHitEnergy.push_back(TCEnergy[iTCId][ihit]);
286  }
287  }
288  }
289  iBin = iBin + 2;
290  }
291  int noftchit = HitTCId.size();
292  if (noftchit == 0) {continue;}
293 
294  double eventtiming = 0;
295  // Get EventTiming
298  // obj_timing->setEventTimingQualityThresholds(m_EventTimingQualityThresholds);
299 
300  eventtiming = obj_timing->GetEventTiming(_EventTiming);
301  int timingsource = obj_timing->GetTimingSource();
302  int EventTimingQualityFlag = obj_timing->getEventTimingQualityFlag();
303  //--------------------------------------------------
304  // Ring sum and Total Energy Sum
305  //-------------------------------------------------
306  std::vector<std::vector<double>> thetaringsum;
307  std::vector<double> phiringsum;
308 
309  thetaringsum.clear();
310  phiringsum.clear();
311  thetaringsum.resize(3, std::vector<double>(36, 0));
312  phiringsum.resize(17, 0);
313  setRS(HitTCId, TCHitEnergy, phiringsum, thetaringsum);
314 
315  double E_phys = 0;
316  double E_total = 0;
317  int E_burst = 0;
318  for (int iii = 0; iii <= 16; iii++) {
319  if (iii > 0 && iii < 15) {E_phys += phiringsum[iii];}
320  E_total += phiringsum[iii];
321  }
322  if (E_total == 0) {continue;}
323  int ELow = 0, EHigh = 0, ELum = 0;
324 
325  if (E_total > _ECLBurstThreshold / 10) {
326  E_burst = 0x01;
327  }
328  if (E_phys > _TotalEnergy[0] / 10) { // GeV
329  ELow = 0x01;
330  }
331  if (E_phys > _TotalEnergy[1] / 10) { // GeV
332  EHigh = 0x01;
333  }
334  if (E_phys > _TotalEnergy[2] / 10) { // GeV
335  ELum = 0x01;
336  }
337  //--------------
338  // Clustering
339  //--------------
340  //
341  // TrgEclCluster obj_cluster;
344  obj_cluster->setEventId(m_nEvent);
346  obj_cluster->setICN(HitTCId); // Belle Cluster Counting
347 
348  int icn = obj_cluster->getICNFwBr();
349  int icnfwd = obj_cluster->getICNSub(0);
350  int icnbr = obj_cluster->getICNSub(1);
351  int icnbwd = obj_cluster->getICNSub(2);
352  //--------------
353  // Low Multiplicity bit
354  //--------------
355  std::vector<double> ClusterTiming;
356  std::vector<double> ClusterEnergy;
357  std::vector<int> MaxTCId;
358  ClusterTiming.clear();
359  ClusterEnergy.clear();
360  MaxTCId.clear();
361  StoreArray<TRGECLCluster> trgeclClusterArray;
362  for (int ii = 0; ii < trgeclClusterArray.getEntries(); ii++) {
363  TRGECLCluster* aTRGECLCluster = trgeclClusterArray[ii];
364  int maxTCId = aTRGECLCluster->getMaxTCId();
365  double clusterenergy = aTRGECLCluster->getEnergyDep();
366  double clustertiming = aTRGECLCluster->getTimeAve();
367  TVector3 clusterposition(aTRGECLCluster->getPositionX(),
368  aTRGECLCluster->getPositionY(),
369  aTRGECLCluster->getPositionZ());
370  ClusterTiming.push_back(clustertiming);
371  ClusterEnergy.push_back(clusterenergy);
372  MaxTCId.push_back(maxTCId);
373  }
374  // const int ncluster = ClusterEnergy.size();
375 
376  makeLowMultiTriggerBit(MaxTCId, ClusterEnergy);
377  //--------------
378  // Bhabha veto
379  //--------------
387  obj_bhabha->set3DBhabhaAddAngleCut(m_3DBhabhaAddAngleCut);
388  obj_bhabha->setTaub2bAngleCut(m_taub2bAngleCut);
389  obj_bhabha->setTaub2bEtotCut(m_taub2bEtotCut);
390  obj_bhabha->setTaub2bClusterECut(m_taub2bClusterECut1,
391  m_taub2bClusterECut2);
392 
393  std::vector<double> vct_bhabha;
394  vct_bhabha.clear();
395  int bhabha2D = 0 ;
396  int bhabha3D_veto = 0 ;
397  int bhabha3D_sel = 0;
398  int mumu = 0;
399  int bhabha3DVetoInTrackFlag = 0;
400  int bhabha3DSelectionThetaFlag = 0;
401  int taub2bFlag = 0;
402 
403  bool b_2Dbhabha = obj_bhabha->GetBhabha00(phiringsum);
404  vct_bhabha = obj_bhabha->GetBhabhaComb();
405  if (b_2Dbhabha && (icn < 4)) {bhabha2D = 1;}
406  bool b_3Dbhabha = obj_bhabha->GetBhabha01();
407  if (b_3Dbhabha) {bhabha3D_veto = 1;}
408  bool b_3Dbhabha_sel = obj_bhabha->GetBhabha02();
409  if (b_3Dbhabha_sel) {bhabha3D_sel = 1;}
410  bool b_mumu = obj_bhabha->Getmumu();
411  if (b_mumu) {mumu = 1;}
412  bhabha3DVetoInTrackFlag = obj_bhabha->get3DBhabhaVetoInTrackFlag();
413  bhabha3DSelectionThetaFlag = obj_bhabha->get3DBhabhaSelectionThetaFlag();
414  taub2bFlag = obj_bhabha->GetTaub2b(E_total);
415  //------------------------
416  // Beam Background veto (Old cosmic veto)
417  //------------------------
418  int beambkgtag = 0;
419  beambkgtag = obj_beambkg->GetBeamBkg(thetaringsum);
420 
421  int bhabhaprescale = 0;
423  bhabhaprescale = 1;
424  _PrescaleCounter = 0;
425  } else if (_PrescaleFactor > _PrescaleCounter) {
426  _PrescaleCounter ++;
427  }
428  //-------------
429  // Make ECL Trigger Bit
430  //-------------
431  int hit = 1; // hit or not
432  int Timing = (int)(eventtiming + 0.5);
433  int RevoFAM = 0;
434  int TimingSource = obj_timing->GetTimingSource(); // FWD(0), Barrel(0), Backward(0);
435  int etot = (int)(E_phys * 1000 + 0.5); // total Energy in theta ID [2~15]
436  int physics = 0;
437  if ((etot > 1000 || icn > 3) && !(bhabha2D == 1)) {physics = 1;}
438  std::vector<int> bhabhabit;
439  bhabhabit.clear();
440  int bhabhabitsize = vct_bhabha.size();
441  for (int ibhabha = 0; ibhabha < bhabhabitsize; ibhabha++) {
442  bhabhabit.push_back((int)vct_bhabha[ibhabha]);
443  }
444  int ClusterOverflow = obj_cluster->getNofExceedCluster();
445  int flagoverflow = 0;
446  if (ClusterOverflow > 0) {
447  flagoverflow = 1;
448  }
449 
450  makeTriggerBit(hit, Timing, 0, timingsource, E_phys,
451  bhabha2D, physics, bhabhabit, icn, beambkgtag,
452  flagoverflow, bhabha3D_veto, _Lowmultibit,
453  bhabha3D_sel, mumu, bhabhaprescale, E_burst,
454  EventTimingQualityFlag,
455  bhabha3DVetoInTrackFlag,
456  bhabha3DSelectionThetaFlag,
457  taub2bFlag, 0);
458 
459  int m_hitEneNum = 0;
460  StoreArray<TRGECLTrg> trgEcltrgArray;
461  trgEcltrgArray.appendNew();
462  m_hitEneNum = trgEcltrgArray.getEntries() - 1;
463  //-------------
464  // Store
465  //-------------
466  trgEcltrgArray[m_hitEneNum]->setEventId(m_nEvent);
467  trgEcltrgArray[m_hitEneNum]->setPRS01(phiringsum[0]);
468  trgEcltrgArray[m_hitEneNum]->setPRS02(phiringsum[1]);
469  trgEcltrgArray[m_hitEneNum]->setPRS03(phiringsum[2]);
470  trgEcltrgArray[m_hitEneNum]->setPRS04(phiringsum[3]);
471  trgEcltrgArray[m_hitEneNum]->setPRS05(phiringsum[4]);
472  trgEcltrgArray[m_hitEneNum]->setPRS06(phiringsum[5]);
473  trgEcltrgArray[m_hitEneNum]->setPRS07(phiringsum[6]);
474  trgEcltrgArray[m_hitEneNum]->setPRS08(phiringsum[7]);
475  trgEcltrgArray[m_hitEneNum]->setPRS09(phiringsum[8]);
476  trgEcltrgArray[m_hitEneNum]->setPRS10(phiringsum[9]);
477  trgEcltrgArray[m_hitEneNum]->setPRS11(phiringsum[10]);
478  trgEcltrgArray[m_hitEneNum]->setPRS12(phiringsum[11]);
479  trgEcltrgArray[m_hitEneNum]->setPRS13(phiringsum[12]);
480  trgEcltrgArray[m_hitEneNum]->setPRS14(phiringsum[13]);
481  trgEcltrgArray[m_hitEneNum]->setPRS15(phiringsum[14]);
482  trgEcltrgArray[m_hitEneNum]->setPRS16(phiringsum[15]);
483  trgEcltrgArray[m_hitEneNum]->setPRS17(phiringsum[16]);
484  //
485  trgEcltrgArray[m_hitEneNum]->setEtot(E_phys);
486  trgEcltrgArray[m_hitEneNum]->setNofTCHit(noftchit);
487  //
488  trgEcltrgArray[m_hitEneNum]->setBhabha01(vct_bhabha[0]);
489  trgEcltrgArray[m_hitEneNum]->setBhabha02(vct_bhabha[1]);
490  trgEcltrgArray[m_hitEneNum]->setBhabha03(vct_bhabha[2]);
491  trgEcltrgArray[m_hitEneNum]->setBhabha04(vct_bhabha[3]);
492  trgEcltrgArray[m_hitEneNum]->setBhabha05(vct_bhabha[4]);
493  trgEcltrgArray[m_hitEneNum]->setBhabha06(vct_bhabha[5]);
494  trgEcltrgArray[m_hitEneNum]->setBhabha07(vct_bhabha[6]);
495  trgEcltrgArray[m_hitEneNum]->setBhabha08(vct_bhabha[7]);
496  trgEcltrgArray[m_hitEneNum]->setBhabha09(vct_bhabha[8]);
497  trgEcltrgArray[m_hitEneNum]->setBhabha10(vct_bhabha[9]);
498  trgEcltrgArray[m_hitEneNum]->setBhabha11(vct_bhabha[10]);
499  trgEcltrgArray[m_hitEneNum]->setBhabha12(vct_bhabha[11]);
500  trgEcltrgArray[m_hitEneNum]->setBhabha13(vct_bhabha[12]);
501  trgEcltrgArray[m_hitEneNum]->setBhabha14(vct_bhabha[13]);
502  trgEcltrgArray[m_hitEneNum]->setBhabha15(vct_bhabha[14]);
503  trgEcltrgArray[m_hitEneNum]->setBhabha16(vct_bhabha[15]);
504  trgEcltrgArray[m_hitEneNum]->setBhabha17(vct_bhabha[16]);
505  trgEcltrgArray[m_hitEneNum]->setBhabha18(vct_bhabha[17]);
506  //
507  trgEcltrgArray[m_hitEneNum]->setICN(icn);
508  trgEcltrgArray[m_hitEneNum]->setICNFw(icnfwd);
509  trgEcltrgArray[m_hitEneNum]->setICNBr(icnbr);
510  trgEcltrgArray[m_hitEneNum]->setICNBw(icnbwd);
511  //
512  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[0], 0);
513  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[1], 1);
514  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[2], 2);
515  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[3], 3);
516 
517  trgEcltrgArray[m_hitEneNum]->setBhabhaVeto(bhabha2D);
518  trgEcltrgArray[m_hitEneNum]->setBeamBkgVeto(beambkgtag);
519  trgEcltrgArray[m_hitEneNum]->setEventTiming(eventtiming);
520 
521  trgEcltrgArray[m_hitEneNum]->setHit(hit);
522  trgEcltrgArray[m_hitEneNum]->setRevoclk(RevoFAM);
523  trgEcltrgArray[m_hitEneNum]->setTimingSource(TimingSource);
524  trgEcltrgArray[m_hitEneNum]->setPhysics(physics) ;
525  trgEcltrgArray[m_hitEneNum]->set2DBhabha(bhabha2D);
526  trgEcltrgArray[m_hitEneNum]->set3DBhabha(bhabha3D_veto);
527  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSel(bhabha3D_sel);
528  trgEcltrgArray[m_hitEneNum]->setmumuBit(mumu);
529  trgEcltrgArray[m_hitEneNum]->setBhabhaPrescaleBit(bhabhaprescale);
530 
531  trgEcltrgArray[m_hitEneNum]->setELow(ELow) ;
532  trgEcltrgArray[m_hitEneNum]->setEHihg(EHigh);
533  trgEcltrgArray[m_hitEneNum]->setELum(ELum) ;
534  trgEcltrgArray[m_hitEneNum]->setClusterOverflow(ClusterOverflow) ;
535  trgEcltrgArray[m_hitEneNum]->setLowMultiBit(_Lowmultibit);
536  }
537 
538  return;
539 }
540 //========================================================
541 //
542 //========================================================
543 void
544 TrgEclMaster::simulate02(int m_nEvent) // select one window for analyze trigger logic
545 {
546  // TrgEclFAM* obj_trgeclfam = new TrgEclFAM();
547  // obj_trgeclfam->setup(m_nEvent, 1);
548  // setPRS(obj_trgeclfam);
549  //
550  //----------
551  // TC Etot
552  //----------
553  //
554  // Energy sum of forward and barrel except for extreme forward
555  // so Etot is sum of "phi ring ID" = 1-14
556  // Etot threshold are
557  // 1.0 GeV for Etot01
558  // 0.5 GeV for Etot02nt
559  // 3.0 GeV for Etot03
560  //
561  // Read FAM Output
562  TCTiming.clear();
563  TCEnergy.clear();
564  TCBeamBkgTag.clear();
565  TCEnergy.resize(576);
566  TCTiming.resize(576);
567  TCBeamBkgTag.resize(576);
568 
569  StoreArray<TRGECLHit> trgeclHitArray;
570  for (int ii = 0; ii < trgeclHitArray.getEntries(); ii++) {
571 
572  TRGECLHit* aTRGECLHit = trgeclHitArray[ii];
573  int iTCID = (aTRGECLHit->getTCId() - 1);
574  double HitTiming = aTRGECLHit->getTimeAve();
575  double HitEnergy = aTRGECLHit->getEnergyDep();
576  double HitBeamBkg = aTRGECLHit->getBeamBkgTag();
577 
578  TCTiming[iTCID].push_back(HitTiming);
579  TCEnergy[iTCID].push_back(HitEnergy);
580  TCBeamBkgTag[iTCID].push_back(HitBeamBkg);
581  }
582  //
583  //
584  int nBin = 2 * 8000 / TimeWindow ;
585  double WindowStart = 0;
586  double WindowEnd = 0;
587  double fluctuation = ((gRandom->Uniform(-1, 0))) * 125;
588 
589  int startBin = nBin / 2 - 1; //start previous bin near 0s
590 
591  int endBin = nBin / 2 + 1; //start next bin near 0s
592 
593  if (_EventTiming == 0) {
594  TimeWindow = 500;
595  OverlapWindow = 0;
596  }
597 
598  double maxE = 0;
599  int max_bin = 0;
600 
601  for (int iBin = startBin ; iBin <= endBin; iBin ++) {
602  WindowStart = iBin * (TimeWindow - OverlapWindow) + fluctuation - 4000;
603  if (iBin == 0) {WindowStart = - 4000 + fluctuation;}
604  WindowEnd = WindowStart + TimeWindow;
605 
606  double totalE = 0;
607  // prepare TC Hit in time window --
608  for (int iTCId = 0; iTCId < 576; iTCId++) {
609  const int hitsize = TCTiming[iTCId].size();
610  for (int ihit = 0; ihit < hitsize; ihit++) {
611  if (TCTiming[iTCId][ihit] > WindowStart &&
612  TCTiming[iTCId][ihit] < WindowEnd) {
613  totalE += TCEnergy[iTCId][ihit] ;
614  }
615  }
616  }
617  if (totalE == 0) {continue;}
618  if (maxE < totalE) { //select the bin having the highest total energy
619  maxE = totalE;
620  max_bin = iBin;
621  }
622  }
623 
624  WindowStart = max_bin * (TimeWindow - OverlapWindow) + fluctuation - 4000;
625  if (max_bin == 0) {WindowStart = - 4000 + fluctuation;}
626  WindowEnd = WindowStart + TimeWindow;
627 
628  HitTCId.clear();
629  TCHitTiming.clear();
630  TCHitEnergy.clear();
631  TCHitBeamBkgTag.clear();
632  // prepare TC Hit in time window --
633  for (int iTCId = 0; iTCId < 576; iTCId++) {
634  const int hitsize = TCTiming[iTCId].size();
635  for (int ihit = 0; ihit < hitsize; ihit++) {
636  if (TCTiming[iTCId][ihit] > WindowStart &&
637  TCTiming[iTCId][ihit] < WindowEnd) {
638  HitTCId.push_back(iTCId + 1);
639  TCHitTiming.push_back(TCTiming[iTCId][ihit]);
640  TCHitEnergy.push_back(TCEnergy[iTCId][ihit]);
641  TCHitBeamBkgTag.push_back(TCBeamBkgTag[iTCId][ihit]);
642  }
643  }
644  }
645 
646  int noftchit = HitTCId.size();
647  if (noftchit == 0) { return;}
648 
649  double eventtiming = 0;
650  // Get EventTiming
653  obj_timing->setEventTimingQualityThresholds(m_EventTimingQualityThresholds);
654 
655  eventtiming = obj_timing->GetEventTiming(_EventTiming);
656  int timingsource = obj_timing->GetTimingSource();
657 
658  int EventTimingQualityFlag = obj_timing->getEventTimingQualityFlag();
659  //--------------------------------------------------
660  // Ring sum and Total Energy Sum
661  //-------------------------------------------------
662  std::vector<std::vector<double>> thetaringsum;
663  std::vector<double> phiringsum;
664 
665  thetaringsum.clear();
666  phiringsum.clear();
667  thetaringsum.resize(3, std::vector<double>(36, 0));
668  phiringsum.resize(17, 0);
669  setRS(HitTCId, TCHitEnergy, phiringsum, thetaringsum);
670 
671  //double E_br; //variable not used
672  //double E_fwd; //variable not used
673  //double E_bwd; //variable not used
674  double E_phys = 0;
675  double E_total = 0;
676  int E_burst = 0;
677 
678  for (int iii = 0; iii <= 16; iii++) {
679  if (iii > 0 && iii < 15) {E_phys += phiringsum[iii];}
680  //if (iii < 3) {E_fwd += phiringsum[iii];} //TODO variable not used, should be?
681  //if (iii > 2 && iii < 15) {E_br += phiringsum[iii];} //TODO not used, should be?
682  //if (iii > 14) {E_bwd += phiringsum[iii];} //TODO not used, should be?
683  E_total += phiringsum[iii];
684  }
685  if (E_total == 0) {return;}
686  int ELow = 0, EHigh = 0, ELum = 0;
687  if (E_total > _ECLBurstThreshold) {
688  E_burst = 0x01;
689  }
690 
691  if (E_phys > _TotalEnergy[0] / 10) { // GeV
692  ELow = 0x01;
693  }
694  if (E_phys > _TotalEnergy[1] / 10) { // GeV
695  EHigh = 0x01;
696  }
697  if (E_phys > _TotalEnergy[2] / 10) { // GeV
698  ELum = 0x01;
699  }
700  //--------------
701  // Clustering
702  //--------------
703  //
704  // TrgEclCluster obj_cluster;
707  obj_cluster->setEventId(m_nEvent);
709  obj_cluster->setICN(HitTCId); // Belle Cluster Counting
710 
711  int icn = obj_cluster->getICNFwBr();
712  int icnfwd = obj_cluster->getICNSub(0);
713  int icnbr = obj_cluster->getICNSub(1);
714  int icnbwd = obj_cluster->getICNSub(2);
715 
716  int NofCluster1to17 = obj_cluster->getNofCluster();
717  //--------------
718  // Low Multiplicity bit
719  //--------------
720  std::vector<double> ClusterTiming;
721  std::vector<double> ClusterEnergy;
722  std::vector<int> MaxTCId;
723  std::vector<int> MaxThetaId;
724  ClusterTiming.clear();
725  ClusterEnergy.clear();
726  MaxTCId.clear();
727  MaxThetaId.clear();
728  StoreArray<TRGECLCluster> trgeclClusterArray;
729  for (int ii = 0; ii < trgeclClusterArray.getEntries(); ii++) {
730  TRGECLCluster* aTRGECLCluster = trgeclClusterArray[ii];
731  int maxTCId = aTRGECLCluster->getMaxTCId();
732  int maxThetaId = aTRGECLCluster->getMaxThetaId();
733  double clusterenergy = aTRGECLCluster->getEnergyDep();
734  double clustertiming = aTRGECLCluster->getTimeAve();
735  TVector3 clusterposition(aTRGECLCluster->getPositionX(),
736  aTRGECLCluster->getPositionY(),
737  aTRGECLCluster->getPositionZ());
738  ClusterTiming.push_back(clustertiming);
739  ClusterEnergy.push_back(clusterenergy);
740  MaxTCId.push_back(maxTCId);
741  MaxThetaId.push_back(maxThetaId);
742  }
743  // int NofCluster = obj_cluster->getNofCluster();
744  makeLowMultiTriggerBit(MaxTCId, ClusterEnergy);
745  //--------------
746  // Bhabha veto (and mumu and tau b2b trigger)
747  //--------------
756  obj_bhabha->set3DBhabhaAddAngleCut(m_3DBhabhaAddAngleCut);
757  obj_bhabha->set3DBhabhaVetoInTrackThetaRegion(m_3DBhabhaVetoInTrackThetaRegion);
758  obj_bhabha->setTaub2bAngleCut(m_taub2bAngleCut);
759  obj_bhabha->setTaub2bEtotCut(m_taub2bEtotCut);
760  obj_bhabha->setTaub2bClusterECut(m_taub2bClusterECut1,
761  m_taub2bClusterECut2);
762 
763  std::vector<double> vct_bhabha;
764  vct_bhabha.clear();
765  int bhabha2D = 0 ;
766  int bhabha3D_veto = 0 ;
767  int bhabha3D_sel = 0;
768  int mumu = 0;
769  int bhabha3DVetoInTrackFlag = -1;
770  int bhabha3DSelectionThetaFlag = -1;
771  int taub2bFlag = 0;
772 
773  bool b_2Dbhabha = obj_bhabha->GetBhabha00(phiringsum);
774  vct_bhabha = obj_bhabha->GetBhabhaComb();
775  if (b_2Dbhabha && (icn < 4)) {bhabha2D = 1;}
776  bool b_3Dbhabha = obj_bhabha->GetBhabha01();
777  if (b_3Dbhabha) {bhabha3D_veto = 1;}
778  bool b_3Dbhabha_sel = obj_bhabha->GetBhabha02();
779  if (b_3Dbhabha_sel) {bhabha3D_sel = 1;}
780  bool b_mumu = obj_bhabha->Getmumu();
781  if (b_mumu) {mumu = 1;}
782  int bhabhaprescale = 0;
784  bhabhaprescale = 1;
785  _PrescaleCounter = 0;
786  } else if (_PrescaleFactor > _PrescaleCounter) {
787  _PrescaleCounter ++;
788  }
789  bhabha3DVetoInTrackFlag = obj_bhabha->get3DBhabhaVetoInTrackFlag();
790  bhabha3DSelectionThetaFlag = obj_bhabha->get3DBhabhaSelectionThetaFlag();
791  taub2bFlag = (obj_bhabha->GetTaub2b(E_total)) ? 1 : 0;
792  //------------------------
793  // additional Bhabha veto
794  //------------------------
795  int bhabha_addition = obj_bhabha->GetBhabhaAddition();
796  //------------------------
797  // hie with additional Bhabha veto
798  //------------------------
799  int beambkgtag = 0;
800  beambkgtag = obj_beambkg->GetBeamBkg(thetaringsum);
801 
802  int bit_hie_bhav = 0;
803  if (E_phys > 1.0) {
804  bit_hie_bhav |= (~bhabha_addition & 0x01) & (~bhabha_addition >> 3 & 0x01);
805  bit_hie_bhav <<= 1;
806  bit_hie_bhav |= (~bhabha_addition & 0x01) & (~bhabha_addition >> 2 & 0x01);
807  bit_hie_bhav <<= 1;
808  bit_hie_bhav |= (~bhabha_addition & 0x01) & (~bhabha_addition >> 1 & 0x01);
809  }
810  //-------------
811  // Make ECL Trigger Bit
812  //-------------
813  int hit = 1; // hit or not
814  int Timing = (int)(eventtiming + 0.5);
815  int RevoFAM = 0;
816  int TimingSource = obj_timing->GetTimingSource(); // FWD(0), Barrel(0), Backward(0);
817  int etot = (int)(E_phys * 1000 + 0.5); // total Energy in theta ID [2~15]
818 
819  //int bhabha2D = BtoBTag ;
820  int physics = 0;
821  if ((etot > 1000 || icn > 3) && !(bhabha2D == 1)) {physics = 1;}
822  std::vector<int> bhabhabit;
823  bhabhabit.clear();
824  int bhabhabitsize = vct_bhabha.size();
825  for (int ibhabha = 0; ibhabha < bhabhabitsize; ibhabha++) {
826  bhabhabit.push_back((int)vct_bhabha[ibhabha]);
827  }
828  int ClusterOverflow = obj_cluster->getNofExceedCluster();
829  int flagoverflow = 0;
830  if (ClusterOverflow > 0) {
831  flagoverflow = 1;
832  }
833 
834  makeTriggerBit(hit, Timing, 0, timingsource, E_phys, bhabha2D,
835  physics, bhabhabit, icn, beambkgtag, flagoverflow,
836  bhabha3D_veto, _Lowmultibit, bhabha3D_sel, mumu,
837  bhabhaprescale, E_burst,
838  EventTimingQualityFlag,
839  bhabha3DVetoInTrackFlag,
840  bhabha3DSelectionThetaFlag,
841  taub2bFlag,
842  bit_hie_bhav);
843 
844  //----------------------------------------------------
845  // ECL trigger
846  //----------------------------------------------------
847  // Integer GDL "Output word to GDL:"
848  // "bit0-2 = Etot1,2,3"
849  // "bit3 = Bhabha,"
850  // "bit4 = prescaled Bhabha,"
851  // "bit5-8 = ICN(3bits)+FORWARD(1bit) OR ICN(3+1 carry),"
852  // "bit9 = cosmic,"
853  // "bit10 = neutral timing trigger"
854  //
855  //------------------------------
856  // 2 10 16
857  //------------------------------
858  // 1 0000000000001 1 1 Etot1
859  // 2 0000000000010 2 2 Etot2
860  // 3 0000000000100 4 4 Etot3
861  // 4 0000000001000 8 8 Bhabha
862  // 5 0000000010000 16 10 preBhabha
863  // 6 0000000100000 32 20 ICN
864  // 7 0000001000000 64 40 ICN
865  // 8 0000010000000 128 80 ICN
866  // 9 0000100000000 256 100 ForwardICN
867  // 10 0001000000000 512 200 BeamBkgVeto
868  // 11 0010000000000 1024 400 Timing
869  //------------------------------
870  // int bitEtot1 = 0x0001;
871  // int bitEtot2 = 0x0002;
872  // int bitEtot3 = 0x0004;
873  // int bitBhabha = 0x0008;
874  // int bitPreBhabha = 0x0010;
875  // int bitForwardICN = 0x0100;
876  // int bitBeamBkgVeto = 0x0200;
877  // int bitTiming = 0x0400;
878 
879  // bool boolEtot[3] = {false};
880  // if (E_phys > 1.0) boolEtot[1] = true;
881  // bool boolBhabha = (boolBtoBTag && icn > 4);
882  // bool boolPreBhabha = false;
883  // bool boolForwardICN = icnfwd;
884  // bool boolBeamBkgVeto = boolBeamBkgTag;
885  // int bit = 0;
886  // //
887  // // bit 5-7
888  // bit = (icn >= 7) ? 0x0007 : icn;
889  // bit <<= 5;
890  // // bit 0
891  // bit |= boolEtot[0] ? bitEtot1 : 0;
892  // // bit 1
893  // bit |= boolEtot[1] ? bitEtot2 : 0;
894  // // bit 2
895  // bit |= boolEtot[2] ? bitEtot3 : 0;
896  // // bit 3
897  // bit |= boolBhabha ? bitBhabha : 0;
898  // // bit 4
899  // bit |= boolPreBhabha ? bitPreBhabha : 0;
900  // // bit 8
901  // bit |= boolForwardICN ? bitForwardICN : 0;
902  // // bit 9
903  // bit |= boolBeamBkgVeto ? bitBeamBkgVeto : 0;
904  // // bit 10
905  // bit |= bitTiming;
906  //
907  // printf("bit = %i \n", bit);
908  //----------------------
909  // if (0){ // check bit by "binary" output
910  // int xxx = bit;
911  // int yyy = 0;
912  // int iii = 0;
913  // int ans = 0;
914  // while (xxx > 0) {
915  // yyy = xxx % 2;
916  // ans = ans + yyy * pow(10,iii);
917  // xxx = xxx / 2;
918  // iii = iii++;
919  // }
920  // printf("xxx = %i \n", ans);
921  // }
922 
923 
924  int m_hitEneNum = 0;
925  StoreArray<TRGECLTrg> trgEcltrgArray;
926  trgEcltrgArray.appendNew();
927  m_hitEneNum = trgEcltrgArray.getEntries() - 1;
928  //----------------------------------------------------
929  // Store
930  //----------------------------------------------------
931  trgEcltrgArray[m_hitEneNum]->setEventId(m_nEvent);
932  trgEcltrgArray[m_hitEneNum]->setPRS01(phiringsum[0]);
933  trgEcltrgArray[m_hitEneNum]->setPRS02(phiringsum[1]);
934  trgEcltrgArray[m_hitEneNum]->setPRS03(phiringsum[2]);
935  trgEcltrgArray[m_hitEneNum]->setPRS04(phiringsum[3]);
936  trgEcltrgArray[m_hitEneNum]->setPRS05(phiringsum[4]);
937  trgEcltrgArray[m_hitEneNum]->setPRS06(phiringsum[5]);
938  trgEcltrgArray[m_hitEneNum]->setPRS07(phiringsum[6]);
939  trgEcltrgArray[m_hitEneNum]->setPRS08(phiringsum[7]);
940  trgEcltrgArray[m_hitEneNum]->setPRS09(phiringsum[8]);
941  trgEcltrgArray[m_hitEneNum]->setPRS10(phiringsum[9]);
942  trgEcltrgArray[m_hitEneNum]->setPRS11(phiringsum[10]);
943  trgEcltrgArray[m_hitEneNum]->setPRS12(phiringsum[11]);
944  trgEcltrgArray[m_hitEneNum]->setPRS13(phiringsum[12]);
945  trgEcltrgArray[m_hitEneNum]->setPRS14(phiringsum[13]);
946  trgEcltrgArray[m_hitEneNum]->setPRS15(phiringsum[14]);
947  trgEcltrgArray[m_hitEneNum]->setPRS16(phiringsum[15]);
948  trgEcltrgArray[m_hitEneNum]->setPRS17(phiringsum[16]);
949  //
950  trgEcltrgArray[m_hitEneNum]->setEtot(E_phys);
951  trgEcltrgArray[m_hitEneNum]->setNofTCHit(noftchit);
952  //
953  trgEcltrgArray[m_hitEneNum]->setBhabha01(vct_bhabha[0]);
954  trgEcltrgArray[m_hitEneNum]->setBhabha02(vct_bhabha[1]);
955  trgEcltrgArray[m_hitEneNum]->setBhabha03(vct_bhabha[2]);
956  trgEcltrgArray[m_hitEneNum]->setBhabha04(vct_bhabha[3]);
957  trgEcltrgArray[m_hitEneNum]->setBhabha05(vct_bhabha[4]);
958  trgEcltrgArray[m_hitEneNum]->setBhabha06(vct_bhabha[5]);
959  trgEcltrgArray[m_hitEneNum]->setBhabha07(vct_bhabha[6]);
960  trgEcltrgArray[m_hitEneNum]->setBhabha08(vct_bhabha[7]);
961  trgEcltrgArray[m_hitEneNum]->setBhabha09(vct_bhabha[8]);
962  trgEcltrgArray[m_hitEneNum]->setBhabha10(vct_bhabha[9]);
963  trgEcltrgArray[m_hitEneNum]->setBhabha11(vct_bhabha[10]);
964  trgEcltrgArray[m_hitEneNum]->setBhabha12(vct_bhabha[11]);
965  trgEcltrgArray[m_hitEneNum]->setBhabha13(vct_bhabha[12]);
966  trgEcltrgArray[m_hitEneNum]->setBhabha14(vct_bhabha[13]);
967  trgEcltrgArray[m_hitEneNum]->setBhabha15(vct_bhabha[14]);
968  trgEcltrgArray[m_hitEneNum]->setBhabha16(vct_bhabha[15]);
969  trgEcltrgArray[m_hitEneNum]->setBhabha17(vct_bhabha[16]);
970  trgEcltrgArray[m_hitEneNum]->setBhabha18(vct_bhabha[17]);
971  //
972  trgEcltrgArray[m_hitEneNum]->setICN(icn);
973  trgEcltrgArray[m_hitEneNum]->setICNFw(icnfwd);
974  trgEcltrgArray[m_hitEneNum]->setICNBr(icnbr);
975  trgEcltrgArray[m_hitEneNum]->setICNBw(icnbwd);
976  //
977  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[0], 0);
978  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[1], 1);
979  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[2], 2);
980  trgEcltrgArray[m_hitEneNum]->setECLtoGDL(_Triggerbit[3], 3);
981 
982  trgEcltrgArray[m_hitEneNum]->setBhabhaVeto(bhabha2D);
983  trgEcltrgArray[m_hitEneNum]->setBeamBkgVeto(beambkgtag);
984  trgEcltrgArray[m_hitEneNum]->setEventTiming(eventtiming);
985 
986  trgEcltrgArray[m_hitEneNum]->setHit(hit);
987  trgEcltrgArray[m_hitEneNum]->setRevoclk(RevoFAM);
988  trgEcltrgArray[m_hitEneNum]->setTimingSource(TimingSource);
989  trgEcltrgArray[m_hitEneNum]->setPhysics(physics) ;
990  trgEcltrgArray[m_hitEneNum]->set2DBhabha(bhabha2D);
991  trgEcltrgArray[m_hitEneNum]->set3DBhabha(bhabha3D_veto);
992  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSel(bhabha3D_sel);
993  trgEcltrgArray[m_hitEneNum]->setmumuBit(mumu);
994  trgEcltrgArray[m_hitEneNum]->setBhabhaPrescaleBit(bhabhaprescale);
995 
996  trgEcltrgArray[m_hitEneNum]->setELow(ELow) ;
997  trgEcltrgArray[m_hitEneNum]->setEHihg(EHigh);
998  trgEcltrgArray[m_hitEneNum]->setELum(ELum) ;
999  trgEcltrgArray[m_hitEneNum]->setClusterOverflow(ClusterOverflow) ;
1000  trgEcltrgArray[m_hitEneNum]->setLowMultiBit(_Lowmultibit);
1001 
1002  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoInTrackFlag(obj_bhabha->get3DBhabhaVetoInTrackFlag());
1003  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterTCId(obj_bhabha->get3DBhabhaVetoClusterTCId(0), 0);
1004  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterTCId(obj_bhabha->get3DBhabhaVetoClusterTCId(1), 1);
1005  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterEnergy(obj_bhabha->get3DBhabhaVetoClusterEnergy(0), 0);
1006  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterEnergy(obj_bhabha->get3DBhabhaVetoClusterEnergy(1), 1);
1007  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterTiming(obj_bhabha->get3DBhabhaVetoClusterTiming(0), 0);
1008  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterTiming(obj_bhabha->get3DBhabhaVetoClusterTiming(1), 1);
1009  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterThetaId(obj_bhabha->get3DBhabhaVetoClusterThetaId(0), 0);
1010  trgEcltrgArray[m_hitEneNum]->set3DBhabhaVetoClusterThetaId(obj_bhabha->get3DBhabhaVetoClusterThetaId(1), 1);
1011 
1012  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionThetaFlag(obj_bhabha->get3DBhabhaSelectionThetaFlag());
1013  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterTCId(obj_bhabha->get3DBhabhaSelectionClusterTCId(0), 0);
1014  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterTCId(obj_bhabha->get3DBhabhaSelectionClusterTCId(1), 1);
1015  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterEnergy(obj_bhabha->get3DBhabhaSelectionClusterEnergy(0), 0);
1016  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterEnergy(obj_bhabha->get3DBhabhaSelectionClusterEnergy(1), 1);
1017  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterTiming(obj_bhabha->get3DBhabhaSelectionClusterTiming(0), 0);
1018  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterTiming(obj_bhabha->get3DBhabhaSelectionClusterTiming(1), 1);
1019  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterThetaId(obj_bhabha->get3DBhabhaSelectionClusterThetaId(0), 0);
1020  trgEcltrgArray[m_hitEneNum]->set3DBhabhaSelectionClusterThetaId(obj_bhabha->get3DBhabhaSelectionClusterThetaId(1), 1);
1021 
1022  trgEcltrgArray[m_hitEneNum]->setEventTimingQualityFlag(obj_timing->getEventTimingQualityFlag());
1023  trgEcltrgArray[m_hitEneNum]->setEventTimingTCId(obj_timing->getEventTimingTCId());
1024  trgEcltrgArray[m_hitEneNum]->setEventTimingTCThetaId(obj_timing->getEventTimingTCThetaId());
1025  trgEcltrgArray[m_hitEneNum]->setEventTimingTCEnergy(obj_timing->getEventTimingTCEnergy());
1026 
1027  trgEcltrgArray[m_hitEneNum]->setEtot1to17(E_total);
1028  trgEcltrgArray[m_hitEneNum]->setTaub2bFlag(taub2bFlag);
1029  trgEcltrgArray[m_hitEneNum]->setTaub2bAngleFlag(obj_bhabha->getTaub2bAngleFlag());
1030  trgEcltrgArray[m_hitEneNum]->setTaub2bEtotFlag(obj_bhabha->getTaub2bEtotFlag());
1031  trgEcltrgArray[m_hitEneNum]->setTaub2bClusterEFlag(obj_bhabha->getTaub2bClusterEFlag());
1032 
1033  trgEcltrgArray[m_hitEneNum]->setNofCluster1to17(NofCluster1to17);
1034 
1035  trgEcltrgArray[m_hitEneNum]->setDataClockWindowStartTime(WindowStart);
1036 
1037  return;
1038 }
1039 //========================================================
1040 //
1041 //========================================================
1042 void
1043 TrgEclMaster::setRS(std::vector<int> TCId,
1044  std::vector<double> TCHit,
1045  std::vector<double>& phiringsum,
1046  std::vector<std::vector<double>>& thetaringsum)
1047 {
1048  //
1049  //
1050  // TC Phi & Theta ring sum
1051  //
1052  //----------------------------------------
1053  // FW BR BW total
1054  //----------------------------------------
1055  //TC phi ring 3 12 2 17
1056  //ID 1-3 4-15 16-17
1057  //TC Theta ring 32 36 32
1058  //ID 1-32 1-36 1-32
1059 
1060  //----------------------------------------
1061  //
1062  thetaringsum.resize(3, std::vector<double>(36, 0.));
1063  phiringsum.resize(17);
1064  const int size_hit = TCHit.size();
1065  for (int iHit = 0; iHit < size_hit; iHit++) {
1066  int iTCId = TCId[iHit] - 1;
1067  if (TCHit[iHit] > 0) {
1068  int iTCThetaId = obj_map->getTCThetaIdFromTCId(iTCId + 1) - 1 ;
1069  int iTCPhiId = obj_map->getTCPhiIdFromTCId(iTCId + 1) - 1 ;
1070  phiringsum[iTCThetaId] += TCHit[iHit];
1071  if (iTCThetaId < 3) {
1072  //fwd
1073  if (iTCThetaId != 0) {
1074  thetaringsum[0][iTCPhiId] += TCHit[iHit];
1075  }
1076  } else if (iTCThetaId < 15) {
1077  //barrel
1078  thetaringsum[1][iTCPhiId] += TCHit[iHit];
1079  } else {
1080  //bwd
1081  thetaringsum[2][iTCPhiId] += TCHit[iHit];
1082  }
1083 
1084  }
1085 
1086  }
1087 
1088 }
1089 //========================================================
1090 //
1091 //========================================================
1092 void
1093 TrgEclMaster::makeTriggerBit(int hit, int Timing, int RevoFAM, int TimingSource,
1094  double etot, int bhabha2D, int physics,
1095  std::vector<int> bhabhatype, int ICN, int BGVeto,
1096  int ClusterOverflow, int bhabha3D, int lowmultibit,
1097  int bhabha3D_sel, int mumubit, int prescale, int burst,
1098  int EventTimingQualityFlag, int bhabha3DVetoInTrackFlag,
1099  int bhabha3DSelectionThetaFlag,
1100  int taub2bFlag,
1101  int bit_hie_bhav)
1102 {
1103 
1104  _Triggerbit[0] = 0;
1105  _Triggerbit[1] = 0;
1106  _Triggerbit[2] = 0;
1107  _Triggerbit[3] = 0;
1108 
1109  // int physics = 0;
1110  int elow = 0;
1111  int ehigh = 0;
1112  int elum = 0;
1113  int bhabhaveto = 0;
1114  int Bhabhatype = bhabha2D;
1115 
1116  if (etot > 0.5) {
1117  elow = 0x01;
1118  }
1119  if (etot > 1.0) {
1120  ehigh = 0x01;
1121  }
1122  if (etot > 3.0) {
1123  elum = 0x01;
1124  }
1125 
1126  if (bhabhatype.size() > 14) {
1127  for (int ibhabha = 0; ibhabha < 13; ibhabha++) {
1128  int type = 0x00;
1129  if (bhabhatype[ibhabha] == 1) {type = 0x01;}
1130 
1131  Bhabhatype |= type;
1132  Bhabhatype <<= 1;
1133 
1134  }
1135  }
1136 
1137  int bit_hit = hit & 0x01;
1138  int bit_Timing = (Timing & 0x7F) ;
1139  int bit_RevoFAM = (RevoFAM & 0x7F) ;
1140  int bit_TimingSource = (TimingSource & 0x07) ;
1141  int bit_physics = (physics & 0x01) ;
1142  int bit_2Dbhabha = (bhabhaveto & 0x01) ;
1143  int bit_bhabhatype = (Bhabhatype & 0x3FFF);
1144  int bit_etot = (((int)etot) & 0x1FFF) ;
1145  int bit_elow = (elow & 0x01);
1146  int bit_ehigh = (ehigh & 0x01) ;
1147  int bit_elum = (elum & 0x01) ;
1148  int bit_ICN = (ICN & 0x7F) ;
1149  int bit_BGVeto = (BGVeto & 0x07) ;
1150  int bit_ClusterOverflow = (ClusterOverflow & 0x01);
1151  int bit_3Dbhabha = (bhabha3D & 0x01);
1152 
1153  int bit_lowmulti1 = lowmultibit & 0x0FFF;
1154  int bit_lowmulti2 = (lowmultibit >>= 12) & 0x3;
1155  int bit_3DBhabha_sel = bhabha3D_sel & 0x01;
1156  int bit_mumu = mumubit & 0x01;
1157  int bit_prescale = prescale & 0x01;
1158  int bit_burst = burst & 0x01;
1159  int bit_clkcc = 0; // 4 bits for revo counter (set to be 0 in tsim)
1160  int bit_eventtimingqualityflag = EventTimingQualityFlag & 0x03;
1161  int bit_bhabha3dvetointrackflag = 0;
1162  if (bhabha3D == 1) {
1163  bit_bhabha3dvetointrackflag = bhabha3DVetoInTrackFlag & 0x01;
1164  }
1165  int bit_bhabha3dselectionthetaflag = 0;
1166  if (bhabha3D_sel == 1) {
1167  bit_bhabha3dselectionthetaflag = bhabha3DSelectionThetaFlag & 0x03;
1168  }
1169  int bit_taub2bflag = taub2bFlag & 0x01;
1170 
1171  _Triggerbit[2] |= bit_hie_bhav;
1172  _Triggerbit[2] <<= 1;
1173  _Triggerbit[2] |= bit_taub2bflag;
1174  _Triggerbit[2] <<= 2;
1175  _Triggerbit[2] |= bit_bhabha3dselectionthetaflag;
1176  _Triggerbit[2] <<= 1;
1177  _Triggerbit[2] |= bit_bhabha3dvetointrackflag;
1178  _Triggerbit[2] <<= 2;
1179  _Triggerbit[2] |= bit_eventtimingqualityflag;
1180  _Triggerbit[2] <<= 4;
1181  _Triggerbit[2] |= bit_clkcc;
1182  _Triggerbit[2] <<= 2;
1183  _Triggerbit[2] |= bit_lowmulti2;
1184  _Triggerbit[2] <<= 1;
1185  _Triggerbit[2] |= bit_burst;
1186  _Triggerbit[2] <<= 1;
1187  _Triggerbit[2] |= bit_prescale;
1188  _Triggerbit[2] <<= 1;
1189  _Triggerbit[2] |= bit_mumu;
1190  _Triggerbit[2] <<= 1;
1191  _Triggerbit[2] |= bit_3DBhabha_sel;
1192  _Triggerbit[2] <<= 10;
1193  _Triggerbit[2] |= ((bit_lowmulti1) >> 2) & 0x3FF;
1194 
1195  _Triggerbit[1] |= (bit_lowmulti1 & 0x03);
1196  _Triggerbit[1] <<= 1;
1197  _Triggerbit[1] |= bit_3Dbhabha;
1198  _Triggerbit[1] <<= 1;
1199  _Triggerbit[1] |= bit_ClusterOverflow;
1200  _Triggerbit[1] <<= 3;
1201  _Triggerbit[1] |= bit_BGVeto;
1202  _Triggerbit[1] <<= 7;
1203  _Triggerbit[1] |= bit_ICN;
1204  _Triggerbit[1] <<= 1;
1205  _Triggerbit[1] |= bit_elum;
1206  _Triggerbit[1] <<= 1;
1207  _Triggerbit[1] |= bit_ehigh;
1208  _Triggerbit[1] <<= 1;
1209  _Triggerbit[1] |= bit_elow;
1210  _Triggerbit[1] <<= 13;
1211  _Triggerbit[1] |= bit_etot;
1212  _Triggerbit[1] <<= 2;
1213  _Triggerbit[1] |= ((bit_bhabhatype >> 12) & 0x03);
1214 
1215  _Triggerbit[0] |= (bit_bhabhatype & 0x0FFF);
1216  _Triggerbit[0] <<= 1;
1217  _Triggerbit[0] |= bit_2Dbhabha;
1218  _Triggerbit[0] <<= 1;
1219  _Triggerbit[0] |= bit_physics;
1220  _Triggerbit[0] <<= 3;
1221  _Triggerbit[0] |= bit_TimingSource;
1222  _Triggerbit[0] <<= 7;
1223  _Triggerbit[0] |= bit_RevoFAM;
1224  _Triggerbit[0] <<= 7;
1225  _Triggerbit[0] |= bit_Timing;
1226  _Triggerbit[0] <<= 1;
1227  _Triggerbit[0] |= bit_hit;
1228 
1229  // int tmp = (_Triggerbit[2] >> 24) & 0x03;
1230  // printf("%5i %5i %i\n", bit_bhabha3dselectionthetaflag, tmp, _Triggerbit[2]);
1231 }
1232 //
1233 //
1234 //
1235 void
1236 TrgEclMaster::makeLowMultiTriggerBit(std::vector<int> CenterTCId,
1237  std::vector<double> clusterenergy)
1238 {
1239 
1240  //---------------------------------------------------------------------------------
1241  // ECL trigger
1242  //---------------------------------------------------------------------------------
1243  //Variable(in Tsim) | N(bit) | Address | Parameter
1244  //-------------------------------------- ------------------------------------------
1245  // | 1 | 62 | N Cluster >= 3, at least one Cluster >300 MeV (LAB), not 3D ECL Bhabha
1246  // | 1 | 63 | one Cluster >= 2GeV(CM) with Theta Id = 4~14
1247  // _Lowmultibit | 1 | 64 | one Cluster >= 2GeV(CM) with Theta Id = 2,3,15 or 16 and not a 3D ECL Bhabha
1248  // | 1 | 65 | one Cluster >= 2GeV(CM) with Theta Id = 2, 3, 15 or 16 and not a 3D ECL Bhabha
1249  // | 1 | 66 | one Cluster >= 2GeV(CM) with Theta Id = 1 or 17 and not a 3D ECL Bhabha
1250  // | 1 | 67 | one Cluster >= 2GeV(CM) with Theta Id = 1 or 17 and a 3D ECL Bhabha
1251  // | 1 | 68 | exactly one Cluster >= 1GeV(CM) and one Cluster > 300 MeV (LAB ), in Theta Id 4~15(Barrel)
1252  // | 1 | 69 | exactly one Cluster >= 1GeV(CM) and one Cluster > 300 MeV (LAB), in Theta Id 2, 3 or 16
1253  // | 1 | 70 | 170 < delta phi(CM) < 190 degree, both Clusters > 250 MeV (LAB), and no 2GeV (CM) Cluster
1254  // | 1 | 71 | 170 < delta phi(CM) < 190 degree, one Cluster < 250 MeV (LAB), the other Cluster > 250 MeV(LAB), and no 2GeV (CM) Cluster
1255  // | 1 | 72 | 160 < delta phi(CM) < 200 degree, 160 < Sum Theta (CM)< 200 degree, no 2 GeV(CM) cluster
1256  // | 1 | 73 | No 2GeV (CM) Cluster
1257  //---------------------------------------------------------------------------------
1258  _Lowmultibit = 0;
1259  int _nClust = CenterTCId.size();
1260  int _n300MeV = 0;
1261  int _n2GeV = 0;
1262  int _n2GeV414 = 0;
1263  int _n2GeV231516 = 0;
1264  int _n2GeV117 = 0;
1265  int _n1GeV415 = 0;
1266  int _n1GeV2316 = 0;
1267  int _n1GeV117 = 0;
1268  int _nClust216 = 0;
1269  int _n500MeV216 = 0;
1270  int _n500MeV611 = 0;
1271  for (int ic = 0; ic < _nClust; ic++) {
1272  if (clusterenergy[ic] > 0.3) {_n300MeV++;}
1273  int thetaid = obj_map->getTCThetaIdFromTCId(CenterTCId[ic]);
1274  int lut = obj_database->Get3DBhabhaLUT(CenterTCId[ic]);
1275  int thresh = 15 & lut;
1276  if (thetaid >= 2 && thetaid <= 16) {_nClust216++;}
1277  if (thetaid >= 6 && thetaid <= 11) {
1278  if (clusterenergy[ic] * 100 > 5 * thresh) {
1279  _n500MeV611++;
1280  }
1281  }
1282 
1283  if (clusterenergy[ic] > 0.5 && thetaid >= 2 && thetaid <= 16) {_n500MeV216++;}
1284  if (clusterenergy[ic] * 100 > (thresh * _LowMultiThreshold[1])) { //200 <MeV
1285  _n2GeV++;
1286  if (thetaid >= 4 && thetaid <= 14) {_n2GeV414++;}
1287  if (thetaid == 2 || thetaid == 3 || thetaid == 15 || thetaid == 16) {_n2GeV231516++;}
1288  if (thetaid == 1 || thetaid == 17) {_n2GeV117++;}
1289  }
1290  if (clusterenergy[ic] * 100 > thresh * _LowMultiThreshold[0]) { // 100 MeV
1291  if (thetaid >= 4 && thetaid <= 15) {_n1GeV415++;}
1292  if (thetaid == 2 || thetaid == 3 || thetaid == 16) {_n1GeV2316++;}
1293  if (thetaid == 1 || thetaid == 17) {_n1GeV117++;}
1294  }
1295  }
1296  //---------------------------------------------------------------------
1297  //..Trigger objects using back-to-back ECL clusters, plus Bhabha vetoes
1298  // nPhiPairHigh nPhiPairLow n3DPair nECLBhabha nTrkBhabha
1299 
1300  int _nPhiPairHigh = 0;
1301  int _nPhiPairLow = 0;
1302  int _n3DPair = 0;
1303  int _nECLBhabha = 0;
1304  for (int i0 = 0; i0 < _nClust - 1; i0++) {
1305  for (int i1 = i0 + 1; i1 < _nClust; i1++) {
1306  int lut1 = obj_database->Get3DBhabhaLUT(CenterTCId[i0]);
1307  int lut2 = obj_database->Get3DBhabhaLUT(CenterTCId[i1]);
1308 
1309  int energy1 = 15 & lut1;
1310  int energy2 = 15 & lut2;
1311  lut1 >>= 4;
1312  lut2 >>= 4;
1313  int phi1 = 511 & lut1;
1314  int phi2 = 511 & lut2;
1315  lut1 >>= 9;
1316  lut2 >>= 9;
1317  int theta1 = lut1;
1318  int theta2 = lut2;
1319 
1320  //..back to back in phi
1321  int dphi = abs(phi1 - phi2);
1322  if (dphi > 180) {dphi = 360 - dphi;}
1323  int thetaSum = theta1 + theta2;
1324 
1325  // cout << dphi << " " << thetaSum << endl;
1326  // cout << clusterenergy[i0] << " " << clusterenergy[i1] << endl;
1327  // if (dphi > 180.) {dphi = 360 - dphi;}
1328  if (dphi > 170. && clusterenergy[i0] > _LowMultiThreshold[2] / 100
1329  && clusterenergy[i1] > _LowMultiThreshold[2] / 100) {_nPhiPairHigh++;}
1330  if (dphi > 170. &&
1331  ((clusterenergy[i0] < _LowMultiThreshold[2] / 100 &&
1332  clusterenergy[i1] > _LowMultiThreshold[2] / 100) ||
1333  (clusterenergy[i0] > _LowMultiThreshold[2] / 100 &&
1334  clusterenergy[i1] < _LowMultiThreshold[2] / 100))) {_nPhiPairLow++;}
1335  //..3D
1336  if (dphi > 160. && thetaSum > 160. && thetaSum < 200) {_n3DPair++;}
1337  //..ecl Bhabha
1338  if (dphi > 160 &&
1339  thetaSum > 165 &&
1340  thetaSum < 190 &&
1341  clusterenergy[i0] * 100 > _3DBhabhaVetoThreshold[0] * energy1 &&
1342  clusterenergy[i1] * 100 > _3DBhabhaVetoThreshold[0] * energy2 &&
1343  (clusterenergy[i0] * 100 > _3DBhabhaVetoThreshold[1] * energy1 ||
1344  clusterenergy[i1] * 100 > _3DBhabhaVetoThreshold[1] * energy2)) {
1345  _nECLBhabha++;
1346 
1347  }
1348  }
1349  }
1350  int bit1 = 0;
1351  int bit2 = 0;
1352  int bit3 = 0;
1353  int bit4 = 0;
1354  int bit5 = 0;
1355  int bit6 = 0;
1356  int bit7 = 0;
1357  int bit8 = 0;
1358  int bit9 = 0;
1359  int bit10 = 0;
1360  int bit11 = 0;
1361  int bit12 = 0;
1362  int bit13 = 0;
1363  int bit14 = 0;
1364 
1365 
1366  if (_nClust >= 3 && _n300MeV >= _n300MeVCluster && _nECLBhabha == 0) {
1367  bit1 = 0x01; //6
1368  }
1369  if (_n2GeV414 > 0) {
1370  bit2 = 0x01; //7
1371  }
1372  if (_n2GeV231516 && _nECLBhabha == 0) {
1373  bit3 = 0x01; //9
1374  }
1375  if (_n2GeV231516 && _nECLBhabha != 0) {
1376  bit4 = 0x01; //10
1377  }
1378  if (_n2GeV117 && _nECLBhabha == 0) {
1379  bit5 = 0x01; //11
1380  }
1381  if (_n2GeV117 && _nECLBhabha != 0) {
1382  bit6 = 0x01; //12
1383  }
1384  if (_n1GeV415 == 1 && _n300MeV == 1) {
1385  bit7 = 0x01; //13
1386  }
1387  if (_n1GeV2316 == 1 && _n300MeV == 1) {
1388  bit8 = 0x01; //14
1389  }
1390  if (_nPhiPairHigh > 0 && _n2GeV == 0) {
1391  bit9 = 0x01; //15
1392  }
1393  if (_nPhiPairLow > 0 && _n2GeV == 0) {
1394  bit10 = 0x01; //16
1395  }
1396  if (_n3DPair > 0 && _n2GeV == 0) {
1397  bit11 = 0x01; //17;
1398  }
1399  if (_n2GeV == 0) {
1400  bit12 = 0x01; //4
1401  }
1402  if (_nClust216 >= 3 && _n500MeV216 > 0 && _nECLBhabha == 0) {
1403  bit13 = 0x01; //6
1404  }
1405  if (_n500MeV611 == 1 && _n300MeV == 1) {
1406  bit14 = 0x01; //6
1407  }
1408 
1409  int total_bit = 0;
1410  total_bit |= bit14;
1411  total_bit <<= 1;
1412  total_bit |= bit13;
1413  total_bit <<= 1;
1414  total_bit |= bit12;
1415  total_bit <<= 1;
1416  total_bit |= bit11;
1417  total_bit <<= 1;
1418  total_bit |= bit10;
1419  total_bit <<= 1;
1420  total_bit |= bit9;
1421  total_bit <<= 1;
1422  total_bit |= bit8;
1423  total_bit <<= 1;
1424  total_bit |= bit7;
1425  total_bit <<= 1;
1426  total_bit |= bit6;
1427  total_bit <<= 1;
1428  total_bit |= bit5;
1429  total_bit <<= 1;
1430  total_bit |= bit4;
1431  total_bit <<= 1;
1432  total_bit |= bit3;
1433  total_bit <<= 1;
1434  total_bit |= bit2;
1435  total_bit <<= 1;
1436  total_bit |= bit1;
1437 
1438  _Lowmultibit = total_bit ;
1439 }
1440 //
1441 //
1442 //
1443 double TrgEclMaster::setTotalEnergy(std::vector<double> phisum)
1444 {
1445 
1446  double E_phys = 0;
1447  for (int iii = 0; iii <= 16; iii++) {
1448  if (iii > 0 && iii < 15) {E_phys += phisum[iii];}
1449  }
1450  return E_phys;
1451 }
1452 //
1453 //
1454 //
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
Example Detector.
Definition: TRGECLCluster.h:24
double getTimeAve() const
The method to get hit average time.
double getPositionZ() const
Get Energy weighted position Z.
int getMaxThetaId()
The method to set Theta Id of maximum TC in Cluster.
double getEnergyDep() const
The method to get deposited energy.
double getPositionX() const
The method to get hit average time Get Energy weighted position X.
double getPositionY() const
Get Energy weighted position Y.
int getMaxTCId() const
The method to get the Maximum(center) TC id.
Example Detector.
Definition: TRGECLHit.h:22
double getTimeAve() const
The method to get hit average time.
Definition: TRGECLHit.h:64
double getEnergyDep() const
The method to get deposited energy.
Definition: TRGECLHit.h:61
int getBeamBkgTag() const
The method to get Beam Background tag.
Definition: TRGECLHit.h:66
int getTCId() const
The method to get TC id.
Definition: TRGECLHit.h:58
A Class of ECL Trigger clustering
Definition: TrgEclBeamBKG.h:29
A Class of ECL Trigger clustering
Definition: TrgEclBhabha.h:31
bool GetBhabha00(std::vector< double >)
Belle 2D Bhabha veto method.
bool Getmumu()
MuMu selection for calibration.
std::vector< double > GetBhabhaComb()
Output 2D Bhabha combination.
Definition: TrgEclBhabha.h:60
void set3DBhabhaAddAngleCut(const std::vector< double > &i3DBhabhaAddAngleCut)
set 3D Bhabha addtion Angle selection
Definition: TrgEclBhabha.h:95
void setmumuThreshold(int mumuThreshold)
set mumu bit Threshold
Definition: TrgEclBhabha.h:91
void set2DBhabhaThreshold(const std::vector< double > &i2DBhabhaThresholdFWD, const std::vector< double > &i2DBhabhaThresholdBWD)
set 2D Bhabha Energy Threshold
Definition: TrgEclBhabha.h:64
void set3DBhabhaVetoAngle(const std::vector< double > &i3DBhabhaVetoAngle)
set 3D veto Bhabha Energy Angle
Definition: TrgEclBhabha.h:86
bool GetBhabha02()
Belle II 3D Bhabha method for selection.
void set3DBhabhaSelectionAngle(const std::vector< double > &i3DBhabhaSelectionAngle)
set 3D selection Bhabha Energy Angle
Definition: TrgEclBhabha.h:81
void set3DBhabhaSelectionThreshold(const std::vector< double > &i3DBhabhaSelectionThreshold)
set 3D selection Bhabha Energy Threshold
Definition: TrgEclBhabha.h:71
bool GetTaub2b(double)
Taub2b selection.
bool GetBhabha01()
Belle II 3D Bhabha method for veto.
void set3DBhabhaVetoThreshold(const std::vector< double > &i3DBhabhaVetoThreshold)
set 3D veto Bhabha Energy Threshold
Definition: TrgEclBhabha.h:76
void setmumuAngle(const std::vector< double > &imumuAngle)
set mumu bit Angle selection
Definition: TrgEclBhabha.h:93
A Class of ECL Trigger clustering
Definition: TrgEclCluster.h:30
void setICN(const std::vector< int > &)
set ICN for each part(Fw,Br,Bw)
int getICNSub(int)
get ICN in each region(Fw(0), Br(1), Bw(2))
int getICNFwBr(void)
get ICN in Barrel and Forward
int getNofExceedCluster()
get # Cluster in case of exceeding limit
void setClusterLimit(int limit)
Set Limit of Cluster.
Definition: TrgEclCluster.h:70
int getNofCluster()
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
Definition: TrgEclCluster.h:92
void setClusteringMethod(int method)
Set.
Definition: TrgEclCluster.h:68
void setEventId(int eventId)
Set EventId.
Definition: TrgEclCluster.h:66
class TrgEclDataBase;
int Get3DBhabhaLUT(int)
TC CM Phi
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
int getTCPhiIdFromTCId(int)
get [TC Phi ID] from [TC ID]
int _Clustering
clutering option
Definition: TrgEclMaster.h:225
double _ECLBurstThreshold
ECL Burst Bit Threshold.
Definition: TrgEclMaster.h:272
std::vector< std::vector< double > > TCEnergy
Hit TC Energy.
Definition: TrgEclMaster.h:194
double m_taub2bEtotCut
tau b2b total energy (TC theta ID =1-17) (GeV)
Definition: TrgEclMaster.h:265
std::vector< double > TCHitEnergy
Hit TC Energy in time window.
Definition: TrgEclMaster.h:203
int _PrescaleCounter
Bhabha Prescale Countor.
Definition: TrgEclMaster.h:241
int _ClusterLimit
The limit number of Cluster.
Definition: TrgEclMaster.h:233
std::vector< int > m_taub2bAngleCut
tau b2b 2 cluster angle cut (degree)
Definition: TrgEclMaster.h:263
void simulate02(int)
simulates ECL trigger for Data Analysis
double TimeWindow
Hit TC Energy in time window.
Definition: TrgEclMaster.h:220
TrgEclTiming * obj_timing
EventTiming object.
Definition: TrgEclMaster.h:289
double _mumuThreshold
mumu bit Energy Threshold
Definition: TrgEclMaster.h:256
std::string version(void) const
returns version.
TrgEclMaster(void)
TrgEclMaster Constructor.
Definition: TrgEclMaster.cc:79
void initialize(int)
initialize
double setTotalEnergy(std::vector< double >)
Set Total Energy.
void setRS(std::vector< int >, std::vector< double >, std::vector< double > &, std::vector< std::vector< double >> &)
ECL bit information for GDL.
TrgEclCluster * obj_cluster
Cluster object.
Definition: TrgEclMaster.h:287
void makeLowMultiTriggerBit(std::vector< int >, std::vector< double >)
make LowMultiTriggerBit
int _PrescaleFactor
Bhabha Prescale Factor.
Definition: TrgEclMaster.h:239
int _n300MeVCluster
The number of Cluster exceeding 300 MeV.
Definition: TrgEclMaster.h:270
std::vector< double > _TotalEnergy
Total Energy Theshold (low, high, lum)
Definition: TrgEclMaster.h:274
std::vector< double > _mumuAngle
mumu bit Angle
Definition: TrgEclMaster.h:258
static TrgEclMaster * getTrgEclMaster(void)
get pointer of TrgEclMaster object
std::vector< double > _3DBhabhaVetoThreshold
3D Veto Bhabha Energy Threshold
Definition: TrgEclMaster.h:250
std::vector< double > _LowMultiThreshold
Low Multiplicity Threshold.
Definition: TrgEclMaster.h:276
std::vector< double > TCHitTiming
Hit TC Timing in time window.
Definition: TrgEclMaster.h:205
int _EventTiming
EventTiming option.
Definition: TrgEclMaster.h:229
std::vector< std::vector< int > > TCBeamBkgTag
Hit TC Beam Background tag.
Definition: TrgEclMaster.h:198
TrgEclBhabha * obj_bhabha
Bhabha object.
Definition: TrgEclMaster.h:291
TrgEclBeamBKG * obj_beambkg
Beam Backgroud veto object.
Definition: TrgEclMaster.h:293
std::vector< double > _3DBhabhaSelectionAngle
3D Selection Bhabha Energy Angle
Definition: TrgEclMaster.h:252
std::vector< double > _2DBhabhaThresholdBWD
2D Bhabha Energy Threshold
Definition: TrgEclMaster.h:246
int _Triggerbit[4]
ECL Trigger bit.
Definition: TrgEclMaster.h:235
std::string name(void) const
returns name.
std::vector< double > _3DBhabhaSelectionThreshold
3D Selection Bhabha Energy Threshold
Definition: TrgEclMaster.h:248
double OverlapWindow
TRG Decision overlap window.
Definition: TrgEclMaster.h:222
static TrgEclMaster * _ecl
ecl object
Definition: TrgEclMaster.h:283
TrgEclDataBase * obj_database
Beam Backgroud veto object.
Definition: TrgEclMaster.h:295
void simulate01(int)
simulates ECL trigger for Global Cosmic data
TrgEclMapping * obj_map
Mapping object.
Definition: TrgEclMaster.h:285
double m_taub2bClusterECut1
tau b2b 1 Cluster energy selection (GeV)
Definition: TrgEclMaster.h:267
std::vector< int > HitTCId
Hit TC Energy in time window.
Definition: TrgEclMaster.h:201
virtual ~TrgEclMaster()
TrgEclMaster Destructor.
int _Lowmultibit
Low Multiplicity bit.
Definition: TrgEclMaster.h:237
std::vector< int > TCHitBeamBkgTag
Hit TC Beam Background tag in time window.
Definition: TrgEclMaster.h:207
std::vector< double > _2DBhabhaThresholdFWD
2D Bhabha Energy Threshold
Definition: TrgEclMaster.h:244
std::vector< double > _3DBhabhaVetoAngle
3D Veto Bhabha Energy Angle
Definition: TrgEclMaster.h:254
std::vector< std::vector< double > > TCTiming
Hit TC Timing.
Definition: TrgEclMaster.h:196
void makeTriggerBit(int, int, int, int, double, int, int, std::vector< int >, int, int, int, int, int, int, int, int, int, int, int, int, int, int)
make Trigger bit except for Low Multiplicity related bit
A Class of ECL Trigger clustering
Definition: TrgEclTiming.h:29
void Setup(const std::vector< int > &, const std::vector< double > &, const std::vector< double > &)
SetUp.
Definition: TrgEclTiming.cc:43
void SetNofTopTC(int NtopTC)
Set # of considered TC in Energy weighted timing method.
Definition: TrgEclTiming.h:56
double GetEventTiming(int)
Get Evnet-timing.
Definition: TrgEclTiming.cc:55
int GetTimingSource()
Get Timing Source.
Definition: TrgEclTiming.h:58
Abstract base class for different kinds of events.