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>
51 TDirectory* oldDir = gDirectory;
52 TDirectory* dirDQM = (TDirectory*)gDirectory->Get(
"TRG");
54 dirDQM = oldDir->mkdir(
"TRG");
58 h_TCId =
new TH1D(
"h_TCId",
"Hit TC ID", 578, 0, 578);
59 h_TCthetaId =
new TH1D(
"h_TCthetaId",
"Hit TC #theta ID", 19, 0, 19);
60 h_TCphiId_FWD =
new TH1D(
"h_TCphiId_FWD",
"Hit TC #phi ID in FWD", 34, 0, 34);
61 h_TCphiId_BR =
new TH1D(
"h_TCphiId_BR",
"Hit TC #phi ID in BR", 38, 0, 38);
62 h_TCphiId_BWD =
new TH1D(
"h_TCphiId_BWD",
"Hit TC #phi ID in BWD", 34, 0, 34);
63 h_TotalEnergy =
new TH1D(
"h_TotalEnergy",
"Total TC Energy (ADC)", 100, 0, 3000);
64 h_TCEnergy =
new TH1D(
"h_TCEnergy",
"TC Energy (ADC)", 100, 0, 1500);
66 h_Narrow_TCEnergy =
new TH1D(
"h_Narrow_TCEnergy",
"TC Energy (ADC)", 100, 0, 100);
68 h_Cluster =
new TH1D(
"h_Cluster",
"N(Cluster) ", 20, 0, 20);
69 h_TCTiming =
new TH1D(
"h_TCTiming",
"TC Timing (ns)", 100, 3010, 3210);
70 h_TRGTiming =
new TH1D(
"h_TRGTiming",
"TRG Timing (ns)", 100, 3010, 3210);
71 h_Cal_TCTiming =
new TH1D(
"h_Cal_TCTiming",
"Cal TC Timing (ns)", 100, -400, 400);
72 h_Cal_TRGTiming =
new TH1D(
"h_Cal_TRGTiming",
"TRG Timing (ns)", 100, -400, 400);
73 h_ECL_TriggerBit =
new TH1D(
"h_ECL_TriggerBit",
"ECL Trigger Bit", 29, 0, 29);
74 h_Cluster_Energy_Sum =
new TH1D(
"h_Cluster_Energy_Sum",
"Energy Sum of 2 Clusters (ADC)", 300, 0, 3000);
117 double HitRevoFam = 0;
118 double HitRevoTrg = 0;
119 double HitFineTiming = 0;
120 double HitRevoEvtTiming = 0;
121 double HitCalTiming = 0;
127 HitFineTiming = aTRGECLUnpackerEvtStore -> getEvtTime();
128 HitRevoTrg = aTRGECLUnpackerEvtStore -> getL1Revo();
129 HitRevoEvtTiming = aTRGECLUnpackerEvtStore -> getEvtRevo();
130 CheckSum = aTRGECLUnpackerEvtStore -> getEvtExist() ;
138 if (CheckSum == 0) {
return;}
144 int TCID = (aTRGECLUnpackerStore->
getTCId());
145 int hit_win = aTRGECLUnpackerStore -> getHitWin();
146 HitEnergy = aTRGECLUnpackerStore -> getTCEnergy();
147 HitTiming = aTRGECLUnpackerStore ->
getTCTime();
149 if (TCID < 1 || TCID > 576 || HitEnergy == 0) {
continue;}
150 if (!(hit_win == 3 || hit_win == 4)) {
continue;}
152 HitRevoFam = aTRGECLUnpackerStore-> getRevoFAM() ;
154 TCId.push_back(TCID);
162 if (
TCId.size() == 0) {
return;}
189 std::vector<int> trgbit ;
190 trgbit.resize(44, 0);
197 b1type = aTRGECLUnpackerSumStore -> getBhabhaType();
198 b2v = aTRGECLUnpackerSumStore -> get3DBhabhaV();
199 b2s = aTRGECLUnpackerSumStore -> get3DBhabhaS() ;
200 etot = aTRGECLUnpackerSumStore -> getEtotType();
201 clover = aTRGECLUnpackerSumStore -> getICNOver();
202 vlm = aTRGECLUnpackerSumStore -> getLowMulti();
203 mu = aTRGECLUnpackerSumStore -> getMumu();
204 pre = aTRGECLUnpackerSumStore -> getPrescale();
205 eclburst = aTRGECLUnpackerSumStore -> getECLBST();
209 trgbit[1] = tsource & 0x1;
210 trgbit[2] = (tsource >> 1) & 0x1;
211 trgbit[3] = (tsource >> 2) & 0x1;
216 trgbit[8] = etot & 0x1;
217 trgbit[9] = (etot >> 1) & 0x1;
218 trgbit[10] = (etot >> 2) & 0x1;
221 for (
int j = 0; j < 14; j++) {
222 trgbit[12 + j] = (vlm >> j) & 0x1;
227 trgbit[28] = eclburst;
229 trgbit[29] = b1type & 0x1;
230 trgbit[30] = (b1type >> 1) & 0x1;
231 trgbit[31] = (b1type >> 2) & 0x1;
232 trgbit[32] = (b1type >> 3) & 0x1;
233 trgbit[33] = (b1type >> 4) & 0x1;
234 trgbit[34] = (b1type >> 5) & 0x1;
235 trgbit[35] = (b1type >> 6) & 0x1;
236 trgbit[36] = (b1type >> 7) & 0x1;
237 trgbit[37] = (b1type >> 8) & 0x1;
238 trgbit[38] = (b1type >> 9) & 0x1;
239 trgbit[39] = (b1type >> 10) & 0x1;
240 trgbit[40] = (b1type >> 11) & 0x1;
241 trgbit[41] = (b1type >> 12) & 0x1;
242 trgbit[42] = (b1type >> 13) & 0x1;
243 trgbit[43] = (b1type >> 14) & 0x1;
248 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"};
252 for (
int j = 0; j < 29; j++) {
271 std::vector<double> ClusterTiming;
272 std::vector<double> ClusterEnergy;
273 std::vector<int> MaxTCId;
274 ClusterTiming.clear();
275 ClusterEnergy.clear();
282 double clustertiming = aTRGECLCluster -> getTimeAve();
283 ClusterTiming.push_back(clustertiming);
284 ClusterEnergy.push_back(clusterenergy);
285 MaxTCId.push_back(maxTCId);
289 std::vector<double> maxClusterEnergy;
290 std::vector<double> maxClusterTiming;
291 std::vector<int> maxCenterTCId;
292 maxClusterTiming.clear();
293 maxClusterEnergy.clear();
294 maxCenterTCId.clear();
296 maxClusterEnergy.resize(2, 0.0);
297 maxClusterTiming.resize(2, 0.0);
298 maxCenterTCId.resize(2, 0.0);
299 const int cl_size = ClusterEnergy.size();
300 for (
int icl = 0; icl < cl_size; icl++) {
301 if (maxClusterEnergy[0] < ClusterEnergy[icl]) {
302 maxClusterEnergy[0] = ClusterEnergy[icl];
303 maxClusterTiming[0] = ClusterTiming[icl];
304 maxCenterTCId[0] = MaxTCId[icl];
305 }
else if (maxClusterEnergy[1] < ClusterEnergy[icl]) {
306 maxClusterEnergy[1] = ClusterEnergy[icl];
307 maxClusterTiming[1] = ClusterTiming[icl];
308 maxCenterTCId[1] = MaxTCId[icl];
315 std::vector<double> _3DBhabhaThreshold;
316 _3DBhabhaThreshold = {30, 45};
319 bool BtoBFlag =
false;
320 bool BhabhaFlag =
false;
321 int lut1 = _database.Get3DBhabhaLUT(maxCenterTCId[0]);
322 int lut2 = _database.Get3DBhabhaLUT(maxCenterTCId[1]);
323 int energy1 = 15 & lut1;
324 int energy2 = 15 & lut2;
327 int phi1 = 511 & lut1;
328 int phi2 = 511 & lut2;
333 int dphi = abs(phi1 - phi2);
334 if (dphi > 180) {dphi = 360 - dphi;}
335 int thetaSum = theta1 + theta2;
336 if (dphi > 160 && thetaSum > 165 && thetaSum < 190) {BtoBFlag =
true;}
338 if ((maxClusterEnergy[0] * 0.1) > _3DBhabhaThreshold[0] * energy1
339 && (maxClusterEnergy[1] * 0.1) > _3DBhabhaThreshold[0] * (energy2)
340 && ((maxClusterEnergy[0] * 0.1) > _3DBhabhaThreshold[1] * energy1
341 || (maxClusterEnergy[1] * 0.1) > _3DBhabhaThreshold[1] * (energy2))) {
342 if (BtoBFlag) {BhabhaFlag =
true;}
351 const int NofTCHit =
TCId.size();
353 double totalEnergy = 0;
356 double caltrgtiming = 0;
358 double trgtiming = 0;
360 for (
int ihit = 0; ihit < NofTCHit ; ihit ++) {
364 if (a->getTCThetaIdFromTCId(
TCId[ihit]) < 4) {
366 }
else if (a->getTCThetaIdFromTCId(
TCId[ihit]) > 3 && a->getTCThetaIdFromTCId(
TCId[ihit]) < 16) {
385 if (timing < 0) {timing = timing + 10240;}
388 trgtiming = 8 * HitRevoTrg - (128 * HitRevoEvtTiming + HitFineTiming);
390 if (trgtiming < 0) {trgtiming = trgtiming + 10240;}