12 #include <trg/ecl/modules/trgeclDQM/TRGECLDQMModule.h>
13 #include <trg/ecl/TrgEclMapping.h>
14 #include <trg/ecl/TrgEclCluster.h>
15 #include <trg/ecl/TrgEclDataBase.h>
17 #include <framework/datastore/StoreArray.h>
19 #include <TDirectory.h>
56 TDirectory* oldDir = gDirectory;
57 TDirectory* dirDQM = (TDirectory*)gDirectory->Get(
"TRG");
59 dirDQM = oldDir->mkdir(
"TRG");
63 h_TCId =
new TH1D(
"h_TCId",
"[TRGECL] Hit TC ID", 578, 0, 578);
64 h_TCthetaId =
new TH1D(
"h_TCthetaId",
"[TRGECL] Hit TC #theta ID", 19, 0, 19);
65 h_TCphiId_FWD =
new TH1D(
"h_TCphiId_FWD",
"[TRGECL] Hit TC #phi ID in FWD", 34, 0, 34);
66 h_TCphiId_BR =
new TH1D(
"h_TCphiId_BR",
"[TRGECL] Hit TC #phi ID in BR", 38, 0, 38);
67 h_TCphiId_BWD =
new TH1D(
"h_TCphiId_BWD",
"[TRGECL] Hit TC #phi ID in BWD", 34, 0, 34);
68 h_TotalEnergy =
new TH1D(
"h_TotalEnergy",
"[TRGECL] Total TC Energy (ADC)", 100, 0, 3000);
69 h_TCEnergy =
new TH1D(
"h_TCEnergy",
"[TRGECL] TC Energy (ADC)", 100, 0, 1500);
70 h_Narrow_TotalEnergy =
new TH1D(
"h_Narrow_TotalEnergy",
"[TRGECL] Total TC Energy (ADC)", 100, 0, 500);
71 h_Narrow_TCEnergy =
new TH1D(
"h_Narrow_TCEnergy",
"[TRGECL] TC Energy (ADC)", 100, 0, 100);
72 h_n_TChit_event =
new TH1D(
"h_n_TChit_event",
"[TRGECL] N(TC) ", 50, 0, 50);
73 h_n_TChit_clean =
new TH1D(
"h_n_TChit_clean",
"[TRGECL] N(TC) (Injection BG Clean)", 300, 0, 300);
74 h_n_TChit_injHER =
new TH1D(
"h_n_TChit_injHER",
"[TRGECL] N(TC) (HER Injection BG)", 300, 0, 300);
75 h_n_TChit_injLER =
new TH1D(
"h_n_TChit_injLER",
"[TRGECL] N(TC) (LER Injection BG)", 300, 0, 300);
76 h_nTChit_injtime =
new TH2D(
"h_nTChit_injtime",
"[TRGECL] N(TC) vs. Time since injection", 201, 0, 200, 100, 0, 50);
77 h_Cluster =
new TH1D(
"h_Cluster",
"[TRGECL] N(Cluster) ", 20, 0, 20);
78 h_TCTiming =
new TH1D(
"h_TCTiming",
"[TRGECL] TC Timing (ns)", 100, 3010, 3210);
79 h_TRGTiming =
new TH1D(
"h_TRGTiming",
"[TRGECL] TRG Timing (ns)", 100, 3010, 3210);
80 h_Cal_TCTiming =
new TH1D(
"h_Cal_TCTiming",
"[TRGECL] Cal TC Timing (ns)", 100, -400, 400);
81 h_Cal_TRGTiming =
new TH1D(
"h_Cal_TRGTiming",
"[TRGECL] TRG Timing (ns)", 100, -400, 400);
82 h_ECL_TriggerBit =
new TH1D(
"h_ECL_TriggerBit",
"[TRGECL] ECL Trigger Bit", 29, 0, 29);
83 h_Cluster_Energy_Sum =
new TH1D(
"h_Cluster_Energy_Sum",
"[TRGECL] Energy Sum of 2 Clusters (ADC)", 300, 0, 3000);
88 std::stringstream ntcclk_titlebase_ss;
89 ntcclk_titlebase_ss <<
"[TRGECL] N(TC_" <<
m_grpclknum <<
"_clk)";
90 std::string ntcclk_titlebase = ntcclk_titlebase_ss.str();
92 h_n_TChit_clean_clkgrp =
new TH1D(
"h_n_TChit_clean_clkgrp", (ntcclk_titlebase +
" (Injection BG Clean)").c_str(),
94 h_n_TChit_injHER_clkgrp =
new TH1D(
"h_n_TChit_injHER_clkgrp", (ntcclk_titlebase +
" (HER Injection BG)").c_str(),
96 h_n_TChit_injLER_clkgrp =
new TH1D(
"h_n_TChit_injLER_clkgrp", (ntcclk_titlebase +
" (LER Injection BG)").c_str(),
98 h_nTChit_injtime_clkgrp =
new TH2D(
"h_nTChit_injtime_clkgrp", (ntcclk_titlebase +
" vs. Time since injection").c_str(), 201, 0, 200,
101 const std::vector<std::string> titleArr = {
102 "Forward",
"Barrel",
"Backward"
104 const std::vector<std::string> nameArr = {
108 for (
int i = 0; i < 3; i++) {
109 std::stringstream namebase_ss;
110 std::stringstream titlebase_ss;
112 namebase_ss <<
"h_n_TChit_" << nameArr[i] <<
"_";
113 titlebase_ss <<
"[TRGECL] N_" << titleArr[i] <<
"(TC_" <<
m_grpclknum <<
"clk)";
117 (titlebase_ss.str() +
" (Injection BG Clean)").c_str(), 300, 0, 300);
119 (titlebase_ss.str() +
" (HER Injection BG)").c_str(), 300, 0, 300);
121 (titlebase_ss.str() +
" (LER Injection BG)").c_str(), 300, 0, 300);
123 (titlebase_ss.str() +
" vs. Time since injection").c_str(), 201, 0, 200, 100, 0, 50);
126 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"};
128 for (
int j = 0; j < 29; j++) {
139 if (m_grpclknum <= 0 || m_grpclknum >= 9) {
140 B2WARNING(
"The number of grouping clocks for N(TC) is wrong (It should be 1 <= clk_num <= 8). The value will set to 2.");
177 double HitRevoFam = 0;
178 double HitRevoTrg = 0;
179 double HitFineTiming = 0;
180 double HitRevoEvtTiming = 0;
181 double HitCalTiming = 0;
187 HitFineTiming = aTRGECLUnpackerEvtStore -> getEvtTime();
188 HitRevoTrg = aTRGECLUnpackerEvtStore -> getL1Revo();
189 HitRevoEvtTiming = aTRGECLUnpackerEvtStore -> getEvtRevo();
190 CheckSum = aTRGECLUnpackerEvtStore -> getEvtExist() ;
198 if (CheckSum == 0) {
return;}
204 int TCID = (aTRGECLUnpackerStore->
getTCId());
205 int hit_win = aTRGECLUnpackerStore -> getHitWin();
206 HitEnergy = aTRGECLUnpackerStore -> getTCEnergy();
207 HitTiming = aTRGECLUnpackerStore ->
getTCTime();
209 if (TCID < 1 || TCID > 576 || HitEnergy == 0) {
continue;}
210 if (!(hit_win == 3 || hit_win == 4)) {
continue;}
212 HitRevoFam = aTRGECLUnpackerStore-> getRevoFAM() ;
214 TCId.push_back(TCID);
223 if (
TCId.size() == 0) {
return;}
250 std::vector<int> trgbit ;
251 trgbit.resize(44, 0);
258 b1type = aTRGECLUnpackerSumStore -> getBhabhaType();
259 b2v = aTRGECLUnpackerSumStore -> get3DBhabhaV();
260 b2s = aTRGECLUnpackerSumStore -> get3DBhabhaS() ;
261 etot = aTRGECLUnpackerSumStore -> getEtotType();
262 clover = aTRGECLUnpackerSumStore -> getICNOver();
263 vlm = aTRGECLUnpackerSumStore -> getLowMulti();
264 mu = aTRGECLUnpackerSumStore -> getMumu();
265 pre = aTRGECLUnpackerSumStore -> getPrescale();
266 eclburst = aTRGECLUnpackerSumStore -> getECLBST();
270 trgbit[1] = tsource & 0x1;
271 trgbit[2] = (tsource >> 1) & 0x1;
272 trgbit[3] = (tsource >> 2) & 0x1;
277 trgbit[8] = etot & 0x1;
278 trgbit[9] = (etot >> 1) & 0x1;
279 trgbit[10] = (etot >> 2) & 0x1;
282 for (
int j = 0; j < 14; j++) {
283 trgbit[12 + j] = (vlm >> j) & 0x1;
288 trgbit[28] = eclburst;
290 trgbit[29] = b1type & 0x1;
291 trgbit[30] = (b1type >> 1) & 0x1;
292 trgbit[31] = (b1type >> 2) & 0x1;
293 trgbit[32] = (b1type >> 3) & 0x1;
294 trgbit[33] = (b1type >> 4) & 0x1;
295 trgbit[34] = (b1type >> 5) & 0x1;
296 trgbit[35] = (b1type >> 6) & 0x1;
297 trgbit[36] = (b1type >> 7) & 0x1;
298 trgbit[37] = (b1type >> 8) & 0x1;
299 trgbit[38] = (b1type >> 9) & 0x1;
300 trgbit[39] = (b1type >> 10) & 0x1;
301 trgbit[40] = (b1type >> 11) & 0x1;
302 trgbit[41] = (b1type >> 12) & 0x1;
303 trgbit[42] = (b1type >> 13) & 0x1;
304 trgbit[43] = (b1type >> 14) & 0x1;
309 for (
int j = 0; j < 29; j++) {
324 std::vector<double> ClusterTiming;
325 std::vector<double> ClusterEnergy;
326 std::vector<int> MaxTCId;
327 ClusterTiming.clear();
328 ClusterEnergy.clear();
335 double clustertiming = aTRGECLCluster -> getTimeAve();
336 ClusterTiming.push_back(clustertiming);
337 ClusterEnergy.push_back(clusterenergy);
338 MaxTCId.push_back(maxTCId);
342 std::vector<double> maxClusterEnergy;
343 std::vector<double> maxClusterTiming;
344 std::vector<int> maxCenterTCId;
345 maxClusterTiming.clear();
346 maxClusterEnergy.clear();
347 maxCenterTCId.clear();
349 maxClusterEnergy.resize(2, 0.0);
350 maxClusterTiming.resize(2, 0.0);
351 maxCenterTCId.resize(2, 0.0);
352 const int cl_size = ClusterEnergy.size();
353 for (
int icl = 0; icl < cl_size; icl++) {
354 if (maxClusterEnergy[0] < ClusterEnergy[icl]) {
355 maxClusterEnergy[0] = ClusterEnergy[icl];
356 maxClusterTiming[0] = ClusterTiming[icl];
357 maxCenterTCId[0] = MaxTCId[icl];
358 }
else if (maxClusterEnergy[1] < ClusterEnergy[icl]) {
359 maxClusterEnergy[1] = ClusterEnergy[icl];
360 maxClusterTiming[1] = ClusterTiming[icl];
361 maxCenterTCId[1] = MaxTCId[icl];
368 std::vector<double> _3DBhabhaThreshold;
369 _3DBhabhaThreshold = {30, 45};
372 bool BtoBFlag =
false;
373 bool BhabhaFlag =
false;
376 int energy1 = 15 & lut1;
377 int energy2 = 15 & lut2;
380 int phi1 = 511 & lut1;
381 int phi2 = 511 & lut2;
386 int dphi = abs(phi1 - phi2);
387 if (dphi > 180) {dphi = 360 - dphi;}
388 int thetaSum = theta1 + theta2;
389 if (dphi > 160 && thetaSum > 165 && thetaSum < 190) {BtoBFlag =
true;}
391 if ((maxClusterEnergy[0] * 0.1) > _3DBhabhaThreshold[0] * energy1
392 && (maxClusterEnergy[1] * 0.1) > _3DBhabhaThreshold[0] * (energy2)
393 && ((maxClusterEnergy[0] * 0.1) > _3DBhabhaThreshold[1] * energy1
394 || (maxClusterEnergy[1] * 0.1) > _3DBhabhaThreshold[1] * (energy2))) {
395 if (BtoBFlag) {BhabhaFlag =
true;}
404 const int NofTCHit =
TCId.size();
406 int nTCHitPerClk_total[8] = {0};
407 int nTCHitPerClk_part[3][8] = {0};
408 double totalEnergy = 0;
411 double caltrgtiming = 0;
415 diff =
m_trgTime->getTimeSinceLastInjectionInMicroSeconds() / 1000.;
418 for (
int ihit = 0; ihit < NofTCHit ; ihit ++) {
422 if (a->getTCThetaIdFromTCId(
TCId[ihit]) < 4) {
424 }
else if (a->getTCThetaIdFromTCId(
TCId[ihit]) > 3 && a->getTCThetaIdFromTCId(
TCId[ihit]) < 16) {
441 double timing = 8 * HitRevoTrg - (128 *
RevoFAM[ihit] +
TCTiming[ihit]);
442 if (timing < 0) {timing = timing + 10240;}
444 nTCHitPerClk_total[
TCHitWin[ihit]]++;
446 if (
TCId[ihit] <= 80) {
447 nTCHitPerClk_part[0][
TCHitWin[ihit]]++;
448 }
else if (80 <
TCId[ihit] &&
TCId[ihit] <= 512) {
449 nTCHitPerClk_part[1][
TCHitWin[ihit]]++;
451 nTCHitPerClk_part[2][
TCHitWin[ihit]]++;
455 const double revotime_in_us = 5.120 /
m_hwclkdb->getAcceleratorRF();
457 double running_in_us, diff_in_us;
459 diff_in_us = diff * 1000.;
460 quotient = diff_in_us / revotime_in_us;
461 running_in_us = diff_in_us - quotient * revotime_in_us;
463 bool cond_clean, cond_injHER, cond_injLER;
465 cond_clean = (6 < running_in_us && running_in_us < 8) && (50 < diff && diff < 70);
467 cond_injHER = isHER && ((diff < 0.5) || ((diff < 20) && (2 < running_in_us && running_in_us < 3)));
468 cond_injLER = !isHER && ((diff < 0.5) || ((diff < 20) && (1 < running_in_us && running_in_us < 2)));
475 }
else if (cond_injHER) {
477 }
else if (cond_injLER) {
481 for (
int iclk = 0; iclk < 8 - (
m_grpclknum - 1); iclk++) {
482 int group_tcnum_total = 0;
483 int group_tcnum_part[3] = {0};
485 group_tcnum_total += nTCHitPerClk_total[iclk + igrp];
486 for (
int ipart = 0; ipart < 3; ipart++) {
487 group_tcnum_part[ipart] += nTCHitPerClk_part[ipart][iclk + igrp];
496 }
else if (cond_injHER) {
498 }
else if (cond_injLER) {
502 for (
int ipart = 0; ipart < 3; ipart++) {
508 }
else if (cond_injHER) {
510 }
else if (cond_injLER) {
516 double trgtiming = 8 * HitRevoTrg - (128 * HitRevoEvtTiming + HitFineTiming);
518 if (trgtiming < 0) {trgtiming = trgtiming + 10240;}
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
double getEnergyDep() const
The method to get deposited energy.
int getMaxTCId() const
The method to get the Maximum(center) TC id.
TH1 * h_n_TChit_part_injHER_clkgrp[3]
N of TC Hit / events in the injection BG clean region vs. time since injection per two ETM clocks for...
TH1 * h_n_TChit_clean
N of TC Hit / event vs. time since injection.
TH1 * h_n_TChit_injLER_clkgrp
N of TC Hit / events in the HER injection BG region vs. time since injection per two ETM clocks.
std::vector< double > TCEnergy
Hit TC Energy.
TH1 * h_TCId
TCId histogram.
TH1 * h_TCphiId_BWD
TCphiId histogram.
TH1 * h_Narrow_TotalEnergy
Total Energy on narrow range.
TH1 * h_TotalEnergy
Total Energy.
TH1 * h_n_TChit_clean_clkgrp
N of TC Hit / event vs. time since injection per two ETM clocks.
TH1 * h_Cluster
N of Cluster / event.
virtual void initialize() override
initialize
TH1 * h_n_TChit_part_event_clkgrp[3]
N of TC Hit / event per two ETM clocks.
StoreArray< TRGECLUnpackerStore > trgeclHitArray
Trg ECL Unpakcer TC output.
virtual void event() override
Event.
TH1 * h_Cal_TRGTiming
Event Timing / event.
TRGECLDQMModule()
Costructor.
TH1 * h_n_TChit_injHER
N of TC Hit / events in the injection BG clean region vs. time since injection.
TH1 * h_Narrow_TCEnergy
TC Energy histogram on narrow range.
TH2 * h_nTChit_injtime_clkgrp
N of TC Hit / events in the LER injection BG region vs. time since injection per two ETM clocks.
virtual void endRun() override
End Run.
DBObjPtr< HardwareClockSettings > m_hwclkdb
DB pointerto access the hardware clock information.
TH1 * h_Cluster_Energy_Sum
Energy sum of 2 Top energetic clusters when 3D bhabnha bit on.
virtual void terminate() override
terminate
TH1 * h_n_TChit_event_clkgrp
N of TC Hit / event per two ETM clocks.
virtual ~TRGECLDQMModule()
Destrunctor.
TH1 * h_n_TChit_injHER_clkgrp
N of TC Hit / events in the injection BG clean region vs. time since injection per two ETM clocks.
std::vector< int > TCHitWin
Hit TCHitWin.
TH1 * h_TCphiId_FWD
TCphiId histogram.
TH1 * h_TRGTiming
Event Timing / event.
TH2 * h_nTChit_injtime
N of TC Hit / events in the LER injection BG region vs. time since injection.
TH1 * h_ECL_TriggerBit
ECL Trigger Bit.
std::vector< double > TCTiming
Hit TC Timing.
StoreArray< TRGECLUnpackerEvtStore > trgeclEvtArray
Trg ECL Unpakcer Event output.
TH1 * h_TCthetaId
TCthetaId histogram.
virtual void beginRun() override
begin Run
StoreArray< TRGECLUnpackerSumStore > trgeclSumArray
Trg Ecl Unpacker Summary output.
TH1 * h_n_TChit_part_clean_clkgrp[3]
N of TC Hit / event vs. time since injection per two ETM clocks for each part (FWD,...
TH2 * h_nTChit_part_injtime_clkgrp[3]
N of TC Hit / events in the LER injection BG region vs. time since injection per two ETM clocks for e...
TH1 * h_TCphiId_BR
TCphiId histogram.
TH1 * h_Cal_TCTiming
TC Timing / event.
TH1 * h_TCEnergy
TC Energy.
std::vector< double > FineTiming
Event Timing.
int m_grpclknum
The number of clocks to group the number of TCs of ECLTRG.
std::vector< double > RevoTrg
GDL Revolution Clk.
TH1 * h_TCTiming
TC Timing / event.
TH1 * h_n_TChit_event
N of TC Hit / event.
std::vector< double > RevoFAM
FAM Revolution Clk.
TH1 * h_n_TChit_part_injLER_clkgrp[3]
N of TC Hit / events in the HER injection BG region vs. time since injection per two ETM clocks for e...
TH1 * h_n_TChit_injLER
N of TC Hit / events in the HER injection BG region vs. time since injection.
StoreArray< TRGECLCluster > trgeclCluster
Trg ECL Cluster output.
StoreObjPtr< EventLevelTriggerTimeInfo > m_trgTime
Array to access the FTSW information.
std::vector< int > TCId
Hit TCId.
virtual void defineHisto() override
Define Histogram.
int getTCCALTime() const
The method to get cal timing.
int getTCId() const
The method to get cell id.
int getTCTime() const
The method to get hit average time.
int get2DBhabha() const
The mothod to get 2D Bhabha bit.
int getPhysics() const
The mothod to get Physics bit.
int getTimeType() const
The mothod to get Timing Type.
A Class of ECL Trigger clustering
void setICN(const std::vector< int > &)
set ICN for each part(Fw,Br,Bw)
int getNofCluster()
0 : center , 1; upper , 2: right , 3: lower , 4: lower right
int Get3DBhabhaLUT(int)
TC CM Phi
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Abstract base class for different kinds of events.