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