1 #include "StFmsBitCheckMaker.h"
2 #include "StFmsTriggerMaker.h"
3 #include "StTriggerData.h"
5 enum {MAXD=MAXPP*2, MAXDT=MAXD*2+1};
11 static int NPRE,NPOST;
12 static unsigned int N0[12][MAXDT][4][32][4];
13 static unsigned int N1[4][MAXDT][4][32][4];
14 static unsigned int N2[MAXDT][4][32][4];
15 static unsigned int N3[16][4];
16 static float MM[MAXDT][18];
18 void printMismatch(
int run){
19 printf(
"Run Mismatch% = FM001 FM002 FM003 FM004 FM005 FM006 FM007 FM008 FM009 FM010 FM011 FM012 | FM101 FM102 FM03 FM104 | FP201 | TCU | Average\n");
20 printf(
"%8d mismatch\% = ",run);
22 for(
int id=0;
id<18;
id++) {
24 printf(
"%6.3f ",MM[MAXD][
id]);
25 if(
id==11 ||
id==15 ||
id==16) printf(
"| ");
27 printf(
"| ave=%6.3f\n",ave/18.0);
28 printf(
"%8.4f AVGMM\n",ave/18.0);
31 void printCount(
int id,
const char* name,
unsigned int n[MAXDT][4][32][4],
int run,
int layer2=0){
33 dmin=-(NPRE+NPOST); dmax=NPRE+NPOST;
38 memset(nt,0,
sizeof(nt));
39 memset(ng,0,
sizeof(ng));
40 for(
int dt=0; dt<MAXDT; dt++){
42 if(d<dmin || d>dmax)
continue;
43 printf(
"%8d %15s : %2d ",run,name,d);
44 for(
int i=0; i<4; i++){
45 for(
int j=31; j>=0; j--){
47 int n00=n[dt][i][j][0];
48 int n01=n[dt][i][j][1];
49 int n10=n[dt][i][j][2];
50 int n11=n[dt][i][j][3];
51 nt[dt]+=n00+n01+n10+n11;
53 if(n01==0 && n10==0) {
56 float r = float(n00+n11)/float(n00+n01+n10+n11)*10.0;
57 sprintf(a,
"%1d",(
int)r);
58 if(n00==0 && n01==0) sprintf(a,
"!");
59 if(n10==0 && n11==0) sprintf(a,
"o");
67 printf(
"%8d %15s MMdeltaT\% = ",run,name);
68 for(
int dt=0; dt<MAXDT; dt++){
70 if(d<dmin || d>dmax)
continue;
71 float mm=float(nt[dt]-ng[dt])/float(nt[dt])*100.0;
76 printf(
"%8d %15s Mismatch\% = ",run,name);
79 float mm=float(nt[dt]-ng[dt])/float(nt[dt])*100.0;
85 void printCount3(
int id,
const char* name,
unsigned int n[32][4],
int run){
87 printf(
"%8d %15s : 0 ",run,name);
88 for(
int j=15; j>=0; j--){
96 if(n01==0 && n10==0) {
99 float r = float(n00+n11)/float(n00+n01+n10+n11)*10.0;
100 sprintf(a,
"%1d",(
int)r);
101 if(n00==0 && n01==0) sprintf(a,
"!");
102 if(n10==0 && n11==0) sprintf(a,
"o");
107 float mm=float(nt-ng)/float(nt)*100.0;
108 printf(
"%8d %15s Mismatch\% = %6.3f\n",run,name,mm);
112 void Count(
int d1,
int d2,
int d3,
int d4,
int s1,
int s2,
int s3,
int s4,
unsigned int n[4][32][4]){
114 for(
int i=0; i<32; i++){
115 c = ((d1>>i) & 0x1)*2 + ((s1>>i) & 0x1); n[0][i][c]++;
116 c = ((d2>>i) & 0x1)*2 + ((s2>>i) & 0x1); n[1][i][c]++;
117 c = ((d3>>i) & 0x1)*2 + ((s3>>i) & 0x1); n[2][i][c]++;
118 c = ((d4>>i) & 0x1)*2 + ((s4>>i) & 0x1); n[3][i][c]++;
122 void Count3(
int d1,
int s1,
unsigned int n[32][4]){
124 for(
int i=0; i<16; i++){
125 c = ((d1>>i) & 0x1)*2 + ((s1>>i) & 0x1); n[i][c]++;
129 void Comp0(
const char* name,
int slot,
int num,
int t1,
int t2,
int run){
138 unsigned int d1=SIM->FM0xxdata(num,0,t1);
139 unsigned int d2=SIM->FM0xxdata(num,1,t1);
140 unsigned int d3=SIM->FM0xxdata(num,2,t1);
141 unsigned int d4=SIM->FM0xxdata(num,3,t1);
142 unsigned int s1=SIM->FM0xxinput(num,0,t2);
143 unsigned int s2=SIM->FM0xxinput(num,1,t2);
144 unsigned int s3=SIM->FM0xxinput(num,2,t2);
145 unsigned int s4=SIM->FM0xxinput(num,3,t2);
147 printf(
"%8d %15s | %2d %2d %2d | %08x %08x %08x %08x | %08x %08x %08x %08x | %08x %08x %08x %08x\n",
148 run,name,x1-x2,x1,x2,
151 d1^s1, d2^s2, d3^s3, d4^s4);
153 Count(d1,d2,d3,d4,s1,s2,s3,s4,N0[num-1][x1-x2+MAXD]);
156 void Comp1(
const char* name,
int slot,
int num,
int t1,
int t2,
int run){
165 unsigned int d1=SIM->FM1xxdata(num,0,t1);
166 unsigned int d2=SIM->FM1xxdata(num,1,t1);
167 unsigned int d3=SIM->FM1xxdata(num,2,t1);
168 unsigned int d4=SIM->FM1xxdata(num,3,t1);
169 unsigned int s1=SIM->FM1xxinput(num,0,t2);
170 unsigned int s2=SIM->FM1xxinput(num,1,t2);
171 unsigned int s3=SIM->FM1xxinput(num,2,t2);
172 unsigned int s4=SIM->FM1xxinput(num,3,t2);
174 printf(
"%8d %15s | %2d %2d %2d | %08x %08x %08x %08x | %08x %08x %08x %08x | %08x %08x %08x %08x\n",
175 run,name,x1-x2,x1,x2,
178 d1^s1, d2^s2, d3^s3, d4^s4);
179 Count(d1,d2,d3,d4,s1,s2,s3,s4,N1[num-1][x1-x2+MAXD]);
182 void Comp2(
const char* name,
int t2,
int run){
191 unsigned int d1=SIM->FP201data(0);
192 unsigned int d2=SIM->FP201data(1);
193 unsigned int d3=SIM->FP201data(2);
194 unsigned int d4=SIM->FP201data(3);
195 unsigned int s1=SIM->FP201input(0,t2);
196 unsigned int s2=SIM->FP201input(1,t2);
197 unsigned int s3=SIM->FP201input(2,t2);
198 unsigned int s4=SIM->FP201input(3,t2);
200 printf(
"%8d %15s | %2d %2d %2d | %08x %08x %08x %08x | %08x %08x %08x %08x | %08x %08x %08x %08x\n",
201 run,name,x1-x2,x1,x2,
204 d1^s1, d2^s2, d3^s3, d4^s4);
205 Count(d1,d2,d3,d4,s1,s2,s3,s4,N2[x1-x2+MAXD]);
208 void Comp3(
const char* name,
int run){
210 unsigned int s1=SIM->FP201output();
211 int jp0=SIM->FP201userdata(1);
213 printf(
"%8d %15s | %04x / %04x | %04x DiJp=",
216 for(
int i=5; i>=0; i--) printf(
"%1x",(jp0>>i)&0x1);
224 StFmsBitCheckMaker::StFmsBitCheckMaker(
const char* name):
StMaker(name), mPrint(0) {
230 int StFmsBitCheckMaker::Init(){
231 memset(N0,0,
sizeof(N0));
232 memset(N1,0,
sizeof(N1));
233 memset(N2,0,
sizeof(N2));
234 memset(N3,0,
sizeof(N3));
239 int StFmsBitCheckMaker::InitRun(
int runNumber){
244 printf(
"Run Name Mismatch% Data Xing - Previous layer&Emulation xing\n");
245 printCount(0,
"QT1/DCBA=>FM001",N0[0],mRun);
246 printCount(1,
"QT2/DCBA=>FM002",N0[1],mRun);
247 printCount(2,
"QT3/DCBA=>FM003",N0[2],mRun);
248 printCount(3,
"QT4/DCBA=>FM004",N0[3],mRun);
249 printCount(4,
"QT1/JIHG=>FM005",N0[4],mRun);
250 printCount(5,
"QT1/FE =>FM006",N0[5],mRun);
251 printCount(6,
"QT2/JIHG=>FM007",N0[6],mRun);
252 printCount(7,
"QT2/FE =>FM008",N0[7],mRun);
253 printCount(8,
"QT3/JIHG=>FM009",N0[8],mRun);
254 printCount(9,
"QT3/FE =>FM010",N0[9],mRun);
255 printCount(10,
"QT4/JIHG=>FM011",N0[10],mRun);
256 printCount(11,
"QT4/FE =>FM012",N0[11],mRun);
257 printCount(12,
"FM001/2 =>FM101", N1[0],mRun);
258 printCount(13,
"FM003/4 =>FM102", N1[1],mRun);
259 printCount(14,
"FM005/8 =>FM103", N1[2],mRun);
260 printCount(15,
"FM09/12 =>FM104", N1[3],mRun);
261 printCount(16,
"FM101/4 =>FP201", N2,mRun,1);
262 printCount3(17,
"FP201 =>TCU ",N3,mRun);
268 if(!td) {printf(
"No StTriggerData found\n");
return kStErr;}
270 if(!SIM) {printf(
"No StFmsTriggerMaker found\n");
return kStErr;}
273 unsigned int cratemask=td->getTrgCrateMask();
281 if(! (cratemask>>FMS_CONF_NUM) & 0x1)
return kStOK;
282 if(! (cratemask>>QT1_CONF_NUM) & 0x1)
return kStOK;
283 if(! (cratemask>>QT2_CONF_NUM) & 0x1)
return kStOK;
284 if(! (cratemask>>QT3_CONF_NUM) & 0x1)
return kStOK;
285 if(! (cratemask>>QT4_CONF_NUM) & 0x1)
return kStOK;
287 static int dbc0 = -999;
288 unsigned long long bxinghi,bxing1,bxinglo,bx,bxdiff;
289 bxinghi = td->bcData(3);
290 bxing1 = td->bcData(10);
291 bxinglo = (bxing1 << 16) + td->bcData(11);
292 bx = (bxinghi << 32) + bxinglo;
293 int bunchid7 = td->bunchId7Bit();
294 int bunchid48 = td->bunchId48Bit();
295 if(bx%120 != bunchid48)
296 printf(
"BC48 check : (BX from BCdata)\%120=%d is not consistent with bunchId48Bit=%d\n",bx%120,bunchid48);
297 int dbc = bunchid7-bunchid48;
299 if(dbc0==-999) dbc0=dbc;
301 int bc48c=bunchid48+dbc0;
if(bc48c<0) bc48c+=120;
if(bc48c>119)bc48c-=120;
303 printf(
"BC7: bc7=%3d bc48%120=%3d bc48corr=%3d D=%3d D0=%3d DD=%3d BC48=%llx\n",bunchid7,bunchid48,bc48c,dbc,dbc0,dd,bx);
305 if(td->bcData(12)&0x1==1 && bunchid7!=1) {
307 printf(
"Revtick : bc7=%3d %3d RT1=%x %x %x %x %x %x RT2=%1d BC48=%llx\n",
308 bunchid7,td->bcData(2)&0x7f,
315 td->bcData(12)&0x1,bx);
320 TCU = td->lastDSM(5);
321 NPRE=td->numberOfPreXing();
322 NPOST=td->numberOfPostXing();
325 for(
int t1=0; t1<MAXT; t1++){
327 if(-x1>NPRE || x1>NPOST)
continue;
328 for(
int t2=0; t2<MAXT; t2++){
330 if(-x2>NPRE || x2>NPOST)
continue;
331 Comp0(
"QT1/DCBA=>FM001",0,1,t1,t2,mRun);
332 Comp0(
"QT2/DCBA=>FM002",1,2,t1,t2,mRun);
333 Comp0(
"QT3/DCBA=>FM003",3,3,t1,t2,mRun);
334 Comp0(
"QT4/DCBA=>FM004",4,4,t1,t2,mRun);
335 Comp0(
"QT1/JIHG=>FM005",6,5,t1,t2,mRun);
336 Comp0(
"QT1/FE =>FM006",7,6,t1,t2,mRun);
337 Comp0(
"QT2/JIHG=>FM007",8,7,t1,t2,mRun);
338 Comp0(
"QT2/FE =>FM008",9,8,t1,t2,mRun);
339 Comp0(
"QT3/JIHG=>FM009",11,9,t1,t2,mRun);
340 Comp0(
"QT3/FE =>FM010",12,10,t1,t2,mRun);
341 Comp0(
"QT4/JIHG=>FM011",13,11,t1,t2,mRun);
342 Comp0(
"QT4/FE =>FM012",14,12,t1,t2,mRun);
345 Comp1(
"FM001/2 =>FM101", 2,1,t1,t2,mRun);
346 Comp1(
"FM003/4 =>FM102", 5,2,t1,t2,mRun);
347 Comp1(
"FM005/8 =>FM103",10,3,t1,t2,mRun);
348 Comp1(
"FM09/12 =>FM104",15,4,t1,t2,mRun);
351 if(t1==MAXPP) Comp2(
"FM101/4 =>FP201",t2,mRun);
354 if(t1==MAXPP && t2==MAXPP) Comp3(
"FP201 =>TCU",mRun);
void Clear(Option_t *option="")
User defined functions.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)