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