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