1 #include "StFmsTrgQaMaker.h"
2 #include "StFmsTriggerMaker.h"
3 #include "StTriggerData.h"
5 static const char* BSname[68]={
6 "ST_A",
"ST_B",
"ST_BC",
"ST_C",
"ST_CD",
"ST_D",
8 "SB_D",
"SB_CD",
"SB_C",
"SB_BC",
"SB_B",
"SB_A",
9 "NB_A",
"NB_B",
"NB_BC",
"NB_C",
"NB_CD",
"NB_D",
11 "NT_D",
"NT_CD",
"NT_C",
"NT_BC",
"NT_B",
"NT_A",
12 "ST_E",
"ST_EF",
"ST_F",
"ST_G",
"ST_GH",
"ST_H",
"ST_HI",
"ST_I",
"ST_IJ",
"ST_J",
14 "SB_J",
"SB_IJ",
"SB_I",
"SB_HI",
"SB_H",
"SB_GH",
"SB_G",
"SB_F",
"SB_EF",
"SB_E",
15 "NB_E",
"NB_EF",
"NB_F",
"NB_G",
"NB_GH",
"NB_H",
"NB_HI",
"NB_I",
"NB_IJ",
"NB_J",
17 "NT_J",
"NT_IJ",
"NT_I",
"NT_HI",
"NT_H",
"NT_GH",
"NT_G",
"NT_F",
"NT_EF",
"NT_E"};
19 static const char* JPname[6]={
"STop",
"SMid",
"SBot",
"NBot",
"NMid",
"NTop"};
21 static const int BSGRP[68]={0,1,1,1,1,1,
27 6,6,7,7,7,7,7,7,7,7,
29 7,7,7,7,7,7,7,7,8,8,
30 9,9,10,10,10,10,10,10,10,10,
32 10,10,10,10,10,10,10,10,11,11};
34 inline int bt(
int x,
int pos) {
return x >> pos & 1; }
38 StFmsTrgQaMaker::StFmsTrgQaMaker(
const char* name):
StMaker(name), mRun(0), mPrint(0) {}
42 int StFmsTrgQaMaker::Init(){
44 sprintf(mFilename,
"%d/fmstrg.%d.root",yday,mRun);
45 printf(
"StFpsQaMaker::Init - Opening %s\n",mFilename);
46 mFile=
new TFile(mFilename,
"RECREATE");
47 mBS[0]=
new TH1F(
"BS3",
"BS3",NBS,0.0,
float(NBS));
48 mBS[1]=
new TH1F(
"BS2",
"BS2",NBS,0.0,
float(NBS));
49 mBS[2]=
new TH1F(
"BS1",
"BS1",NBS,0.0,
float(NBS));
50 mJP[0]=
new TH1F(
"JP2",
"JP2",NJP,0.0,
float(NJP));
51 mJP[1]=
new TH1F(
"JP1",
"JP1",NJP,0.0,
float(NJP));
52 mJP[2]=
new TH1F(
"JP0",
"JP0",NJP,0.0,
float(NJP));
53 mDIBSg=
new TH2F(
"DiBSg",
"DiBSg",NBSG,0.0,
float(NBSG),NBSG,0.0,
float(NBSG));
54 mDIBS=
new TH2F(
"DiBS",
"DiBS",NBS,0.0,
float(NBS),NBS,0.0,
float(NBS));
55 mDIJP=
new TH2F(
"DiJP",
"DiJP",NJP,0.0,
float(NJP),NJP,0.0,
float(NJP));
56 for(
int i=0; i<NBS; i++){ hBS[i]=
new TH1F(BSname[i],BSname[i],256,0.0,4096.0); }
57 for(
int i=0; i<NJP; i++){ hJP[i]=
new TH1F(JPname[i],JPname[i],64,0.0,256.0); }
63 printf(
"Nevent=%d NFMStriggeredEvent=%d NFSMtrg=%d overlap=%f\n",
64 count[0],count[1],count[2],
float(count[2])/
float(count[1]));
67 printf(
"StFmsTrgQaMaker::Finish - Closing %s\n",mFilename);
73 if(!mSIM) { printf(
"No StFmsTriggerMaker found\n");
return kStErr;}
75 if(!mTrgd) { printf(
"No StTriggerData found\n");
return kStErr;}
77 int npre=mTrgd->numberOfPreXing();
78 int npost=mTrgd->numberOfPostXing();
82 if(isTrg(
"FMS-LED"))
return kStOK;
92 void StFmsTrgQaMaker::fillDiBS(){
93 if(isTrg(
"FMS-DiBS")){
95 memset(BSbit,0,
sizeof(BSbit));
97 for(
int j=0; j<6; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 1,i+7),j)) {BSbit[k]=1;}}
98 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 1,i+7),j)) {BSbit[k]=1;}}
99 for(
int j=5; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 2,i+7),j)) {BSbit[k]=1;}}
101 for(
int j=0; j<6 ; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 4,i+7),j)) {BSbit[k]=1;}}
102 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 2,i+7),j)) {BSbit[k]=1;}}
103 for(
int j=5; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 3,i+7),j)) {BSbit[k]=1;}}
105 for(
int j=0; j<3; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 6,i+7),j)) {BSbit[k]=1;}}
106 for(
int j=0; j<7; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 5,i+7),j)) {BSbit[k]=1;}}
107 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 3,i+7),j)) {BSbit[k]=1;}}
108 for(
int j=6; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 7,i+7),j)) {BSbit[k]=1;}}
109 for(
int j=2; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 8,i+7),j)) {BSbit[k]=1;}}
111 for(
int j=0; j<3; j++){ k++;
if(bt(mSIM->FM0xxuserdata(12,i+7),j)) {BSbit[k]=1;}}
112 for(
int j=0; j<7; j++){ k++;
if(bt(mSIM->FM0xxuserdata(11,i+7),j)) {BSbit[k]=1;}}
113 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 4,i+7),j)) {BSbit[k]=1;}}
114 for(
int j=6; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 9,i+7),j)) {BSbit[k]=1;}}
115 for(
int j=2; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata(10,i+7),j)) {BSbit[k]=1;}}
119 char DBS[NBSG][NBSG];
121 for(
int i=0; i<36; i++) u.INT[i]=mSIM->FP201userdata(10+i);
122 for(
int j=0; j<NBSG; j++){
123 if(mPrint) printf(
"** DiBSg ");
124 for(
int i=0; i<NBSG; i++){
125 if(mPrint) printf(
" %1s", u.DBS[j][i]?
"1":
"0");
128 if(i==7 && j==10) w=0.2;
129 mDIBSg->Fill(
float(i),
float(NBSG-j-1),w);
131 for(
int jj=0; jj<NBS; jj++){
133 if(BSGRP[jj]==j && BSbit[jj]==1){
134 for(
int ii=0; ii<NBS; ii++){
135 if(BSGRP[ii]==i && BSbit[ii]==1){
136 mDIBS->Fill(
float(ii),
float(NBS-jj-1));
144 if(mPrint) printf(
"\n");
149 void StFmsTrgQaMaker::fillDiJp(){
150 if(isTrg(
"FMS-DiJP")){
155 for(
int i=0; i<9; i++) u.INT[i]=mSIM->FP201userdata(50+i);
156 for(
int j=0; j<NJP; j++){
157 if(mPrint) printf(
"** DiJp ");
158 for(
int i=0; i<NJP; i++){
159 if(mPrint) printf(
" %1s", u.DJp[j][i]?
"1":
"0");
160 if(u.DJp[j][i]) mDIJP->Fill(
float(i),
float(NJP-j-1));
162 if(mPrint) printf(
"\n");
167 void StFmsTrgQaMaker::fillJP(){
169 for(
int i=0; i<NTHR; i++){
170 sprintf(trg,
"FMS-JP%1d",2-i);
172 for(
int j=0; j<NJP; j++){
173 int b= ((mSIM->FP201userdata(i+7)) >> j) & 0x1;
174 if(b) mJP[i]->Fill(
float(j));
180 void StFmsTrgQaMaker::fillBS(){
183 for(
int i=0; i<NTHR; i++){
184 sprintf(trg,
"FMS-sm-bs%1d",3-i);
187 for(
int j=0; j<6; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 1,i+7),j)) {mBS[i]->Fill(
float(k));}}
188 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 1,i+7),j)) {mBS[i]->Fill(
float(k));}}
189 for(
int j=5; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 2,i+7),j)) {mBS[i]->Fill(
float(k));}}
191 for(
int j=0; j<6 ; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 4,i+7),j)) {mBS[i]->Fill(
float(k));}}
192 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 2,i+7),j)) {mBS[i]->Fill(
float(k));}}
193 for(
int j=5; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 3,i+7),j)) {mBS[i]->Fill(
float(k));}}
196 sprintf(trg,
"FMS-lg-bs%1d",3-i);
199 for(
int j=0; j<3; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 6,i+7),j)) {mBS[i]->Fill(
float(k));}}
200 for(
int j=0; j<7; j++){ k++;
if(bt(mSIM->FM0xxuserdata( 5,i+7),j)) {mBS[i]->Fill(
float(k));}}
201 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 3,i+7),j)) {mBS[i]->Fill(
float(k));}}
202 for(
int j=6; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 7,i+7),j)) {mBS[i]->Fill(
float(k));}}
203 for(
int j=2; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 8,i+7),j)) {mBS[i]->Fill(
float(k));}}
205 for(
int j=0; j<3; j++){ k++;
if(bt(mSIM->FM0xxuserdata(12,i+7),j)) {mBS[i]->Fill(
float(k));}}
206 for(
int j=0; j<7; j++){ k++;
if(bt(mSIM->FM0xxuserdata(11,i+7),j)) {mBS[i]->Fill(
float(k));}}
207 for(
int j=0; j<1; j++){ k++;
if(bt(mSIM->FM1xxuserdata( 4,i+7),j)) {mBS[i]->Fill(
float(k));}}
208 for(
int j=6; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata( 9,i+7),j)) {mBS[i]->Fill(
float(k));}}
209 for(
int j=2; j>=0; j--){ k++;
if(bt(mSIM->FM0xxuserdata(10,i+7),j)) {mBS[i]->Fill(
float(k));}}
214 void StFmsTrgQaMaker::fillJPsum(){
216 sum[ 0]=mSIM->FP201userdata(0);
217 sum[ 1]=mSIM->FP201userdata(1);
218 sum[ 2]=mSIM->FP201userdata(2);
219 sum[ 3]=mSIM->FP201userdata(3);
220 sum[ 4]=mSIM->FP201userdata(4);
221 sum[ 5]=mSIM->FP201userdata(5);
222 for(
int i=0; i<NJP; i++){
223 hJP[i]->Fill(
float(sum[i]));
228 void StFmsTrgQaMaker::fillBSsum(){
230 sum[ 0]=mSIM->FM0xxuserdata( 1,0);
231 sum[ 1]=mSIM->FM0xxuserdata( 1,1);
232 sum[ 2]=mSIM->FM0xxuserdata( 1,2);
233 sum[ 3]=mSIM->FM0xxuserdata( 1,3);
234 sum[ 4]=mSIM->FM0xxuserdata( 1,4);
235 sum[ 5]=mSIM->FM0xxuserdata( 1,5);
236 sum[ 6]=mSIM->FM1xxuserdata( 1,0);
237 sum[ 7]=mSIM->FM0xxuserdata( 2,5);
238 sum[ 8]=mSIM->FM0xxuserdata( 2,4);
239 sum[ 9]=mSIM->FM0xxuserdata( 2,3);
240 sum[10]=mSIM->FM0xxuserdata( 2,2);
241 sum[11]=mSIM->FM0xxuserdata( 2,1);
242 sum[12]=mSIM->FM0xxuserdata( 2,0);
244 sum[13]=mSIM->FM0xxuserdata( 4,0);
245 sum[14]=mSIM->FM0xxuserdata( 4,1);
246 sum[15]=mSIM->FM0xxuserdata( 4,2);
247 sum[16]=mSIM->FM0xxuserdata( 4,3);
248 sum[17]=mSIM->FM0xxuserdata( 4,4);
249 sum[18]=mSIM->FM0xxuserdata( 4,5);
250 sum[19]=mSIM->FM1xxuserdata( 2,0);
251 sum[20]=mSIM->FM0xxuserdata( 3,5);
252 sum[21]=mSIM->FM0xxuserdata( 3,4);
253 sum[22]=mSIM->FM0xxuserdata( 3,3);
254 sum[23]=mSIM->FM0xxuserdata( 3,2);
255 sum[24]=mSIM->FM0xxuserdata( 3,1);
256 sum[25]=mSIM->FM0xxuserdata( 3,0);
258 sum[26]=mSIM->FM0xxuserdata( 6,0);
259 sum[27]=mSIM->FM0xxuserdata( 6,1);
260 sum[28]=mSIM->FM0xxuserdata( 6,2);
261 sum[29]=mSIM->FM0xxuserdata( 5,0);
262 sum[30]=mSIM->FM0xxuserdata( 5,1);
263 sum[31]=mSIM->FM0xxuserdata( 5,2);
264 sum[32]=mSIM->FM0xxuserdata( 5,3);
265 sum[33]=mSIM->FM0xxuserdata( 5,4);
266 sum[34]=mSIM->FM0xxuserdata( 5,5);
267 sum[35]=mSIM->FM0xxuserdata( 5,6);
268 sum[36]=mSIM->FM1xxuserdata( 3,0);
269 sum[37]=mSIM->FM0xxuserdata( 7,6);
270 sum[38]=mSIM->FM0xxuserdata( 7,5);
271 sum[39]=mSIM->FM0xxuserdata( 7,4);
272 sum[40]=mSIM->FM0xxuserdata( 7,3);
273 sum[41]=mSIM->FM0xxuserdata( 7,2);
274 sum[42]=mSIM->FM0xxuserdata( 7,1);
275 sum[43]=mSIM->FM0xxuserdata( 7,0);
276 sum[44]=mSIM->FM0xxuserdata( 8,2);
277 sum[45]=mSIM->FM0xxuserdata( 8,1);
278 sum[46]=mSIM->FM0xxuserdata( 8,0);
280 sum[47]=mSIM->FM0xxuserdata(12,0);
281 sum[48]=mSIM->FM0xxuserdata(12,1);
282 sum[49]=mSIM->FM0xxuserdata(12,2);
283 sum[50]=mSIM->FM0xxuserdata(11,0);
284 sum[51]=mSIM->FM0xxuserdata(11,1);
285 sum[52]=mSIM->FM0xxuserdata(11,2);
286 sum[53]=mSIM->FM0xxuserdata(11,3);
287 sum[54]=mSIM->FM0xxuserdata(11,4);
288 sum[55]=mSIM->FM0xxuserdata(11,5);
289 sum[56]=mSIM->FM0xxuserdata(11,6);
290 sum[57]=mSIM->FM1xxuserdata( 4,0);
291 sum[58]=mSIM->FM0xxuserdata( 9,6);
292 sum[59]=mSIM->FM0xxuserdata( 9,5);
293 sum[60]=mSIM->FM0xxuserdata( 9,4);
294 sum[61]=mSIM->FM0xxuserdata( 9,3);
295 sum[62]=mSIM->FM0xxuserdata( 9,2);
296 sum[63]=mSIM->FM0xxuserdata( 9,1);
297 sum[64]=mSIM->FM0xxuserdata( 9,0);
298 sum[65]=mSIM->FM0xxuserdata(10,2);
299 sum[66]=mSIM->FM0xxuserdata(10,1);
300 sum[67]=mSIM->FM0xxuserdata(10,0);
301 for(
int i=0; i<NBS; i++){
302 hBS[i]->Fill(
float(sum[i]));
306 void StFmsTrgQaMaker::readtrgid(){
307 int i,yearday=mRun/1000;
308 char filename[200],trgn[200];
309 sprintf(filename,
"%d/%d.trgid",yearday,mRun);
310 FILE* fp=fopen(filename,
"r");
311 if(!fp) {printf(
"Cannot open %s\n",filename);
return; }
313 fscanf(fp,
"%d %s",&i,trgn);
314 printf(
"%d %s\n",i,trgn);
320 int StFmsTrgQaMaker::isTrg(
const char* trgn){
322 unsigned long long one=1;
330 for(
int i=0; i<64; i++){
331 if( trgname[i].EqualTo(trgn) ) {
id=i;
break;}
334 unsigned long long flag=(mTrgd->l2sum() & (one << id));
340 void StFmsTrgQaMaker::printTriggers(){
342 unsigned long long one=1;
343 printf(
"l2sum=%16llx TRG=",mTrgd->l2sum());
344 for(
int i=0; i<64; i++){
345 if(mTrgd->l2sum() & (one << i)) printf(
"%s ",trgname[i].Data());
351 void StFmsTrgQaMaker::countOverlap(){
352 static const int NTRG=11;
353 const char* tname[NTRG]={
"FMS-sm-bs1",
"FMS-sm-bs2",
"FMS-sm-bs3",
354 "FMS-lg-bs1",
"FMS-lg-bs2",
"FMS-lg-bs3",
355 "FMS-JP0",
"FMS-JP1",
"FMS-JP2",
356 "FMS-DiBS",
"FMS-DiJP"};
358 for(
int i=0; i<NTRG; i++){
359 if(isTrg(tname[i])) {count[2]++; flag=1;}
361 if(flag==1) count[1]++;
void Clear(Option_t *option="")
User defined functions.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)