7 #include "StFpsQaMaker.h"
9 #include "StRoot/StEvent/StEvent.h"
10 #include "StRoot/St_base/StMessMgr.h"
11 #include "StRoot/StEvent/StTriggerData.h"
12 #include "StRoot/StEvent/StFmsCollection.h"
13 #include "StRoot/StEvent/StFmsHit.h"
14 #include "StRoot/StFmsDbMaker/StFmsDbMaker.h"
15 #include "StRoot/StSpinPool/StFpsRawDaqReader/StFpsRawDaqReader.h"
26 StFpsQaMaker::StFpsQaMaker(
const Char_t* name) :
StMaker(name),mFmsDbMkr(0),mFmsCollectionPtr(0), mRun(0) {};
28 StFpsQaMaker::~StFpsQaMaker(){};
30 Int_t StFpsQaMaker::Init(){
31 mFmsDbMkr =
static_cast< StFmsDbMaker*
>(GetMaker(
"fmsDb"));
33 LOG_FATAL <<
"Error finding StFmsDbMaker"<< endm;
37 sprintf(mFilename,
"%d/%d.root",yday,mRun);
38 printf(
"StFpsQaMaker::Init - Opening %s\n",mFilename);
39 mFile=
new TFile(mFilename,
"RECREATE");
41 mDataSize[0] =
new TH1F(
"TotalSize",
"TotalSize",100,-1.0,4.0);
42 mDataSize[1] =
new TH1F(
"DataSize",
"DataSize",100,-1.0,3.0);
43 for(
int i=0; i<mNPREPOST*2+1; i++){
45 sprintf(name,
"Xing=%d",x);
46 mXing[i] =
new TH1F(name,name,100,0.0,300.0);
49 mAdc2[0] =
new TH2F(
"Adc2",
"Adc2", 252,0.0,252.0,64,0.0,4096.0);
50 mAdc2[1] =
new TH2F(
"Adc2z",
"Adc2z",252,0.0,252.0,50,0.0,200.0);
51 for(
int i=0; i<mNID; i++){
52 sprintf(name,
"ADC%03d",i);
53 mAdc[i][0]=
new TH1F(name,name,128,0.0,4096.0);
54 sprintf(name,
"ADC%03dz",i);
55 mAdc[i][1]=
new TH1F(name,name,150,0.0,300.0);
58 mAdc2[0] =
new TH2F(
"Adc2",
"Adc2", 252,0.0,252.0, 100,64.0,4096.0);
59 mAdc2[1] =
new TH2F(
"Adc2z",
"Adc2z",252,0.0,252.0, 100,50.0,150.0);
60 for(
int i=0; i<mNID; i++){
61 sprintf(name,
"ADC%03d",i);
62 mAdc[i][0]=
new TH1F(name,name,128,0.0,4096.0);
63 sprintf(name,
"ADC%03dz",i);
64 mAdc[i][1]=
new TH1F(name,name,100,50.0,150.0);
67 for(
int q=0; q<mNQ; q++){
68 for(
int l=0; l<mNL; l++){
69 sprintf(name,
"NHIT_Q%1dL%1d",q+1,l+1);
70 mNHit[q][l]=
new TH1F(name,name,22,0.0,22.0);
71 sprintf(name,
"HIT_Q%1dL%1d",q+1,l+1);
72 mHit[q][l]=
new TH1F(name,name,21,0.5,21.5);
75 for(
int t=0; t<mNTRG+1; t++){
76 sprintf(name,
"NHIT_TRG%02d",t);
77 mNHitTrg[t]=
new TH1F(name,name,241,0.0,241.0);
79 sprintf(name,
"NHIT_TRG");
80 mNHitTrg2=
new TH2F(name,name,241,0.0,241.0,64,0.0,64.0);
91 LOG_ERROR <<
"Canot find fpsRawDaqReader" << endm;
96 LOG_ERROR <<
"Canot find Trigger Data" << endm;
100 unsigned int detmask=trg->getTrgDetMask();
102 if(! ((detmask >> 10) & 0x1)){
107 eventPtr= (
StEvent*)GetInputDS(
"StEvent");
108 if(!eventPtr) { LOG_INFO <<
"No StEvent found" << endm;}
109 else{ mFmsCollectionPtr=eventPtr->fmsCollection();}
110 if(!mFmsCollectionPtr){
111 LOG_INFO <<
"No StFmsCollection found" << endm;
114 int nhit=mFmsCollectionPtr->numberOfHits();
115 StSPtrVecFmsHit hits = mFmsCollectionPtr->hits();
119 int nh[mNQ][mNL]; memset(nh,0,
sizeof(nh));
121 for (
int i=0; i<nhit; i++){
122 int det = hits[i]->detectorId();
125 int xing=hits[i]->tdc();
if(xing>65536/2) xing-=65536;
126 int adc=hits[i]->adc();
127 int qt=hits[i]->qtSlot();
128 int ch=hits[i]->qtChannel();
129 int slatid = mFmsDbMkr->fpsSlatidFromQT(qt,ch);
131 mFmsDbMkr->fpsQLSfromSlatId(slatid,&q,&l,&s);
132 if(q>0 && l>0 && s>0 && abs(xing)<=mNPREPOST) {
133 mXing[xing+mNPREPOST]->Fill((
float)adc);
136 mAdc2[0]->Fill((
float)slatid,(
float)adc);
137 mAdc2[1]->Fill((
float)slatid,(
float)adc);
138 mAdc[slatid][0]->Fill((
float)adc);
139 mAdc[slatid][1]->Fill((
float)adc);
140 if( (l!=3 && adc>50) || (l==3 && adc>25) ){
143 if(l==1 && (q==2 || q==4)){
144 mHit[q-1][l-1]->Fill(
float(s+2));
146 mHit[q-1][l-1]->Fill(
float(s));
154 mDataSize[0]->Fill(log10(nfpsdatatot));
155 mDataSize[1]->Fill(log10(nfpsdata));
156 for(
int q=0; q<mNQ; q++){
157 for(
int l=0; l<mNL; l++){
158 mNHit[q][l]->Fill(
float(nh[q][l]));
163 mNHitTrg[64]->Fill(
float(nhtot));
164 unsigned long long one=1;
165 unsigned long long tmask = fpsraw->trgMask();
166 for(
int t=0; t<mNTRG; t++){
167 if(tmask & (one<<t)) {
168 mNHitTrg[t]->Fill(
float(nhtot));
169 mNHitTrg2->Fill(
float(nhtot),
float(t));
174 unsigned int tcu=trg->tcuCounter();
175 unsigned int rfps=fpsraw->rccFps();
176 unsigned int dfps=rfps-tcu;
180 const long long one=1;
181 const long long m=one<<32;
184 dfps=(
unsigned int)(r+m-t);
186 unsigned int rfpo=fpsraw->rccFpost();
187 unsigned int dfpo=rfpo-tcu;
190 }
else if(rfps < tcu){
191 const long long one=1;
192 const long long m=one<<32;
195 dfpo=(
unsigned int)(r+m-t);
197 printf(
"FPS RCC =%10d TCU=%10d DIFF=%10d ",rfps,tcu,dfps);
198 printf(
"FPOST RCC=%10d TCU=%10d DIFF=%10d\n",rfpo,tcu,dfpo);
213 printf(
"StFpsQaMaker::Finish - Closing %s\n",mFilename);