56 TDirectory* oldDir = gDirectory;
57 TDirectory* dirDQM = gDirectory->mkdir(
"TRG",
"",
true);
60 h_TCId =
new TH1D(
"h_TCId",
"[TRGECL] Hit TC ID", 578, 0, 578);
61 h_TCthetaId =
new TH1D(
"h_TCthetaId",
"[TRGECL] Hit TC #theta ID", 19, 0, 19);
62 h_TCphiId_FWD =
new TH1D(
"h_TCphiId_FWD",
"[TRGECL] Hit TC #phi ID in FWD", 34, 0, 34);
63 h_TCphiId_BR =
new TH1D(
"h_TCphiId_BR",
"[TRGECL] Hit TC #phi ID in BR", 38, 0, 38);
64 h_TCphiId_BWD =
new TH1D(
"h_TCphiId_BWD",
"[TRGECL] Hit TC #phi ID in BWD", 34, 0, 34);
65 h_TotalEnergy =
new TH1D(
"h_TotalEnergy",
"[TRGECL] Total TC Energy (ADC)", 100, 0, 3000);
66 h_TCEnergy =
new TH1D(
"h_TCEnergy",
"[TRGECL] TC Energy (ADC)", 100, 0, 1500);
67 h_Narrow_TotalEnergy =
new TH1D(
"h_Narrow_TotalEnergy",
"[TRGECL] Total TC Energy (ADC)", 100, 0, 500);
68 h_Narrow_TCEnergy =
new TH1D(
"h_Narrow_TCEnergy",
"[TRGECL] TC Energy (ADC)", 100, 0, 100);
69 h_n_TChit_event =
new TH1D(
"h_n_TChit_event",
"[TRGECL] N(TC) ", 50, 0, 50);
70 h_n_TChit_clean =
new TH1D(
"h_n_TChit_clean",
"[TRGECL] N(TC) (Injection BG Clean)", 300, 0, 300);
71 h_n_TChit_injHER =
new TH1D(
"h_n_TChit_injHER",
"[TRGECL] N(TC) (HER Injection BG)", 300, 0, 300);
72 h_n_TChit_injLER =
new TH1D(
"h_n_TChit_injLER",
"[TRGECL] N(TC) (LER Injection BG)", 300, 0, 300);
73 h_nTChit_injtime =
new TH2D(
"h_nTChit_injtime",
"[TRGECL] N(TC) vs. Time since injection", 201, 0, 200, 100, 0, 50);
74 h_Cluster =
new TH1D(
"h_Cluster",
"[TRGECL] N(Cluster) ", 20, 0, 20);
75 h_TCTiming =
new TH1D(
"h_TCTiming",
"[TRGECL] TC Timing (ns)", 100, 3010, 3210);
76 h_TRGTiming =
new TH1D(
"h_TRGTiming",
"[TRGECL] TRG Timing (ns)", 100, 3010, 3210);
77 h_Cal_TCTiming =
new TH1D(
"h_Cal_TCTiming",
"[TRGECL] Cal TC Timing (ns)", 100, -400, 400);
78 h_Cal_TRGTiming =
new TH1D(
"h_Cal_TRGTiming",
"[TRGECL] TRG Timing (ns)", 100, -400, 400);
79 h_ECL_TriggerBit =
new TH1D(
"h_ECL_TriggerBit",
"[TRGECL] ECL Trigger Bit", 29, 0, 29);
80 h_Cluster_Energy_Sum =
new TH1D(
"h_Cluster_Energy_Sum",
"[TRGECL] Energy Sum of 2 Clusters (ADC)", 300, 0, 3000);
85 std::stringstream ntcclk_titlebase_ss;
86 ntcclk_titlebase_ss <<
"[TRGECL] N(TC_" <<
m_grpclknum <<
"_clk)";
87 std::string ntcclk_titlebase = ntcclk_titlebase_ss.str();
89 h_n_TChit_clean_clkgrp =
new TH1D(
"h_n_TChit_clean_clkgrp", (ntcclk_titlebase +
" (Injection BG Clean)").c_str(),
91 h_n_TChit_injHER_clkgrp =
new TH1D(
"h_n_TChit_injHER_clkgrp", (ntcclk_titlebase +
" (HER Injection BG)").c_str(),
93 h_n_TChit_injLER_clkgrp =
new TH1D(
"h_n_TChit_injLER_clkgrp", (ntcclk_titlebase +
" (LER Injection BG)").c_str(),
95 h_nTChit_injtime_clkgrp =
new TH2D(
"h_nTChit_injtime_clkgrp", (ntcclk_titlebase +
" vs. Time since injection").c_str(), 201, 0, 200,
98 const std::vector<std::string> titleArr = {
99 "Forward",
"Barrel",
"Backward"
101 const std::vector<std::string> nameArr = {
105 for (
int i = 0; i < 3; i++) {
106 std::stringstream namebase_ss;
107 std::stringstream titlebase_ss;
109 namebase_ss <<
"h_n_TChit_" << nameArr[i] <<
"_";
110 titlebase_ss <<
"[TRGECL] N_" << titleArr[i] <<
"(TC_" <<
m_grpclknum <<
"clk)";
114 (titlebase_ss.str() +
" (Injection BG Clean)").c_str(), 300, 0, 300);
116 (titlebase_ss.str() +
" (HER Injection BG)").c_str(), 300, 0, 300);
118 (titlebase_ss.str() +
" (LER Injection BG)").c_str(), 300, 0, 300);
120 (titlebase_ss.str() +
" vs. Time since injection").c_str(), 201, 0, 200, 100, 0, 50);
123 const char* label[44] = {
"Hit",
"Timing Source(FWD)",
"Timing Source(BR)",
"Timing Source(BWD)",
"physics Trigger",
"2D Bhabha Veto",
"3D Bhabha veto",
"3D Bhabha Selection",
"E Low",
"E High",
"E LOM",
"Cluster Overflow",
"Low multi bit 0",
"Low multi bit 1",
"Low multi bit 2",
"Low multi bit 3",
"Low multi bit 4",
"Low multi bit 5",
"Low multi bit 6",
"Low multi bit 7",
"Low multi bit 8",
"Low multi bit 9",
"Low multi bit 10",
"Low multi bit 11",
"Low multi bit 12",
"Low multi bit 13",
"mumu bit",
"prescale bit",
"ECL burst bit",
"2D Bhabha bit 1",
"2D Bhabha bit 2",
"2D Bhabha bit 3",
"2D Bhabha bit 4",
"2D Bhabha bit 5",
"2D Bhabha bit 6",
"2D Bhabha bit 7",
"2D Bhabha bit 8",
"2D Bhabha bit 9",
"2D Bhabha bit 10",
"2D Bhabha bit 11",
"2D Bhabha bit 12",
"2D Bhabha bit 13",
"2D Bhabha bit 14"};
125 for (
int j = 0; j < 29; j++) {
174 double HitRevoFam = 0;
175 double HitRevoTrg = 0;
176 double HitFineTiming = 0;
177 double HitRevoEvtTiming = 0;
178 double HitCalTiming = 0;
184 HitFineTiming = aTRGECLUnpackerEvtStore -> getEvtTime();
185 HitRevoTrg = aTRGECLUnpackerEvtStore -> getL1Revo();
186 HitRevoEvtTiming = aTRGECLUnpackerEvtStore -> getEvtRevo();
187 CheckSum = aTRGECLUnpackerEvtStore -> getEvtExist() ;
195 if (CheckSum == 0) {
return;}
201 int TCID = (aTRGECLUnpackerStore->
getTCId());
202 int hit_win = aTRGECLUnpackerStore -> getHitWin();
203 HitEnergy = aTRGECLUnpackerStore -> getTCEnergy();
204 HitTiming = aTRGECLUnpackerStore ->
getTCTime();
206 if (TCID < 1 || TCID > 576 || HitEnergy == 0) {
continue;}
207 if (!(hit_win == 3 || hit_win == 4)) {
continue;}
209 HitRevoFam = aTRGECLUnpackerStore-> getRevoFAM() ;
220 if (
m_TCId.size() == 0) {
return;}
247 std::vector<int> trgbit ;
248 trgbit.resize(44, 0);
255 b1type = aTRGECLUnpackerSumStore -> getBhabhaType();
256 b2v = aTRGECLUnpackerSumStore -> get3DBhabhaV();
257 b2s = aTRGECLUnpackerSumStore -> get3DBhabhaS() ;
258 etot = aTRGECLUnpackerSumStore -> getEtotType();
259 clover = aTRGECLUnpackerSumStore -> getICNOver();
260 vlm = aTRGECLUnpackerSumStore -> getLowMulti();
261 mu = aTRGECLUnpackerSumStore -> getMumu();
262 pre = aTRGECLUnpackerSumStore -> getPrescale();
263 eclburst = aTRGECLUnpackerSumStore -> getECLBST();
267 trgbit[1] = tsource & 0x1;
268 trgbit[2] = (tsource >> 1) & 0x1;
269 trgbit[3] = (tsource >> 2) & 0x1;
274 trgbit[8] = etot & 0x1;
275 trgbit[9] = (etot >> 1) & 0x1;
276 trgbit[10] = (etot >> 2) & 0x1;
279 for (
int j = 0; j < 14; j++) {
280 trgbit[12 + j] = (vlm >> j) & 0x1;
285 trgbit[28] = eclburst;
287 trgbit[29] = b1type & 0x1;
288 trgbit[30] = (b1type >> 1) & 0x1;
289 trgbit[31] = (b1type >> 2) & 0x1;
290 trgbit[32] = (b1type >> 3) & 0x1;
291 trgbit[33] = (b1type >> 4) & 0x1;
292 trgbit[34] = (b1type >> 5) & 0x1;
293 trgbit[35] = (b1type >> 6) & 0x1;
294 trgbit[36] = (b1type >> 7) & 0x1;
295 trgbit[37] = (b1type >> 8) & 0x1;
296 trgbit[38] = (b1type >> 9) & 0x1;
297 trgbit[39] = (b1type >> 10) & 0x1;
298 trgbit[40] = (b1type >> 11) & 0x1;
299 trgbit[41] = (b1type >> 12) & 0x1;
300 trgbit[42] = (b1type >> 13) & 0x1;
301 trgbit[43] = (b1type >> 14) & 0x1;
306 for (
int j = 0; j < 29; j++) {
321 std::vector<double> ClusterTiming;
322 std::vector<double> ClusterEnergy;
323 std::vector<int> MaxTCId;
324 ClusterTiming.clear();
325 ClusterEnergy.clear();
332 double clustertiming = aTRGECLCluster -> getTimeAve();
333 ClusterTiming.push_back(clustertiming);
334 ClusterEnergy.push_back(clusterenergy);
335 MaxTCId.push_back(maxTCId);
339 std::vector<double> maxClusterEnergy;
340 std::vector<double> maxClusterTiming;
341 std::vector<int> maxCenterTCId;
342 maxClusterTiming.clear();
343 maxClusterEnergy.clear();
344 maxCenterTCId.clear();
346 maxClusterEnergy.resize(2, 0.0);
347 maxClusterTiming.resize(2, 0.0);
348 maxCenterTCId.resize(2, 0.0);
349 const int cl_size = ClusterEnergy.size();
350 for (
int icl = 0; icl < cl_size; icl++) {
351 if (maxClusterEnergy[0] < ClusterEnergy[icl]) {
352 maxClusterEnergy[0] = ClusterEnergy[icl];
353 maxClusterTiming[0] = ClusterTiming[icl];
354 maxCenterTCId[0] = MaxTCId[icl];
355 }
else if (maxClusterEnergy[1] < ClusterEnergy[icl]) {
356 maxClusterEnergy[1] = ClusterEnergy[icl];
357 maxClusterTiming[1] = ClusterTiming[icl];
358 maxCenterTCId[1] = MaxTCId[icl];
365 const double m_3DBhabhaThreshold[2] = {30, 45};
367 bool BtoBFlag =
false;
368 bool BhabhaFlag =
false;
371 int energy1 = 15 & lut1;
372 int energy2 = 15 & lut2;
375 int phi1 = 511 & lut1;
376 int phi2 = 511 & lut2;
381 int dphi = abs(phi1 - phi2);
382 if (dphi > 180) {dphi = 360 - dphi;}
383 int thetaSum = theta1 + theta2;
384 if (dphi > 160 && thetaSum > 165 && thetaSum < 190) {BtoBFlag =
true;}
386 if ((maxClusterEnergy[0] > m_3DBhabhaThreshold[0] * energy1 * 10 &&
387 maxClusterEnergy[1] > m_3DBhabhaThreshold[0] * energy2 * 10) &&
388 (maxClusterEnergy[0] > m_3DBhabhaThreshold[1] * energy1 * 10 ||
389 maxClusterEnergy[1] > m_3DBhabhaThreshold[1] * energy2 * 10)) {
390 if (BtoBFlag) {BhabhaFlag =
true;}
399 const int NofTCHit =
m_TCId.size();
401 int nTCHitPerClk_total[8] = {0};
402 int nTCHitPerClk_part[3][8] = {{0}};
403 double totalEnergy = 0;
406 double caltrgtiming = 0;
410 diff =
m_trgTime->getTimeSinceLastInjectionInMicroSeconds() / 1000.;
413 for (
int ihit = 0; ihit < NofTCHit ; ihit ++) {
417 if (a->getTCThetaIdFromTCId(
m_TCId[ihit]) < 4) {
419 }
else if (a->getTCThetaIdFromTCId(
m_TCId[ihit]) > 3 && a->getTCThetaIdFromTCId(
m_TCId[ihit]) < 16) {
437 if (timing < 0) {timing = timing + 10240;}
450 const double revotime_in_us = 5.120 /
m_hwclkdb->getAcceleratorRF();
452 double running_in_us, diff_in_us;
454 diff_in_us = diff * 1000.;
455 quotient = diff_in_us / revotime_in_us;
456 running_in_us = diff_in_us - quotient * revotime_in_us;
458 bool cond_clean, cond_injHER, cond_injLER;
460 cond_clean = !((1.2 < running_in_us && running_in_us < 1.6) || (2.2 < running_in_us && running_in_us < 2.4)) && (500 < diff
463 cond_injHER = isHER && ((diff < 0.5) || ((diff < 20) && (2 < running_in_us && running_in_us < 3)));
464 cond_injLER = !isHER && ((diff < 0.5) || ((diff < 20) && (1 < running_in_us && running_in_us < 2)));
471 }
else if (cond_injHER) {
473 }
else if (cond_injLER) {
477 for (
int iclk = 0; iclk < 8 - (
m_grpclknum - 1); iclk++) {
478 int group_tcnum_total = 0;
479 int group_tcnum_part[3] = {0};
481 group_tcnum_total += nTCHitPerClk_total[iclk + igrp];
482 for (
int ipart = 0; ipart < 3; ipart++) {
483 group_tcnum_part[ipart] += nTCHitPerClk_part[ipart][iclk + igrp];
492 }
else if (cond_injHER) {
494 }
else if (cond_injLER) {
498 for (
int ipart = 0; ipart < 3; ipart++) {
504 }
else if (cond_injHER) {
506 }
else if (cond_injLER) {
512 double trgtiming = 8 * HitRevoTrg - (128 * HitRevoEvtTiming + HitFineTiming);
514 if (trgtiming < 0) {trgtiming = trgtiming + 10240;}