7 #include "StFpostQaMaker.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"
28 StFpostQaMaker::StFpostQaMaker(
const Char_t* name) :
StMaker(name),mFmsDbMkr(0),mFmsCollectionPtr(0), mRun(0) {};
31 StFpostQaMaker::~StFpostQaMaker(){};
34 Int_t StFpostQaMaker::Init()
37 mFmsDbMkr =
static_cast< StFmsDbMaker*
>(GetMaker(
"fmsDb"));
40 LOG_FATAL <<
"Error finding StFmsDbMaker"<< endm;
47 sprintf(mFilename,
"%d/%d.root",yday,mRun);
48 printf(
"StFpostQaMaker::Init - Opening %s\n",mFilename);
49 mFile=
new TFile(mFilename,
"RECREATE");
54 mDataSize[0] =
new TH1F(
"TotalSize",
"TotalSize",100,-1.0,4.0);
55 mDataSize[1] =
new TH1F(
"DataSize",
"DataSize",100,-1.0,3.0);
57 mRccDiff[0] =
new TH1F(
"RccDiff_Full",
"RccDiff_Full",100,0,120000);
58 mRccDiff[1] =
new TH1F(
"RccDiff_Zoom",
"RccDiff_Zoom",100,0,10000);
61 for(
int i=0; i<mNPREPOST*2+1; i++)
64 sprintf(name,
"Xing=%d",x);
65 mXing[i] =
new TH1F(name,name,100,0.0,3000.0);
71 mAdc2[0] =
new TH2F(
"Adc2",
"Adc2", 252,0.0,252.0,64,0.0,4096.0);
72 mAdc2[1] =
new TH2F(
"Adc2z",
"Adc2z",252,0.0,252.0,50,0.0,200.0);
73 for(
int i=0; i<mNID; i++){
74 sprintf(name,
"ADC%03d",i);
75 mAdc[i][0]=
new TH1F(name,name,128,0.0,4096.0);
76 sprintf(name,
"ADC%03dz",i);
77 mAdc[i][1]=
new TH1F(name,name,150,0.0,300.0);
82 mAdc2[0] =
new TH2F(
"Adc2",
"Adc2", 252,0.0,252.0, 100,64.0,4096.0);
83 mAdc2[1] =
new TH2F(
"Adc2z",
"Adc2z",252,0.0,252.0, 100,0.0,200.0);
84 for(
int i=0; i<mNID; i++){
85 sprintf(name,
"ADC%03d",i);
86 mAdc[i][0]=
new TH1F(name,name,128,0.0,4096.0);
87 sprintf(name,
"ADC%03dz",i);
88 mAdc[i][1]=
new TH1F(name,name,100,0.0,200.0);
126 for(
int q=0; q<mNQ; q++)
128 for(
int l=0; l<mNL; l++)
130 sprintf(name,
"NHIT_Q%1dL%1d",q+1,l+1);
131 mNHit[q][l]=
new TH1F(name,name,22,0.0,22.0);
132 sprintf(name,
"HIT_Q%1dL%1d",q+1,l+1);
133 mHit[q][l]=
new TH1F(name,name,43,0.5,43.5);
138 for(
int t=0; t<mNTRG+1; t++)
140 sprintf(name,
"NHIT_TRG%02d",t);
141 mNHitTrg[t]=
new TH1F(name,name,241,0.0,241.0);
143 sprintf(name,
"NHIT_TRG");
144 mNHitTrg2=
new TH2F(name,name,241,0.0,241.0,64,0.0,64.0);
156 eventPtr= (
StEvent*)GetInputDS(
"StEvent");
157 if(!eventPtr) { LOG_INFO <<
"No StEvent found" << endm;}
158 else{ mFmsCollectionPtr=eventPtr->fmsCollection();}
159 if(!mFmsCollectionPtr)
161 LOG_INFO <<
"No StFmsCollection found" << endm;
165 unsigned int nhit=mFmsCollectionPtr->numberOfHits();
166 StSPtrVecFmsHit hits = mFmsCollectionPtr->hits();
167 printf(
"StFpostQaMaker found %d hits\n",nhit);
177 int nh[mNQ][mNL]; memset(nh,0,
sizeof(nh));
182 for (
unsigned int i=0; i<nhit; i++)
185 int det = hits[i]->detectorId();
192 int xing = hits[i]->tdc();
if(xing>65536/2){xing-=65536;}
193 int adc = hits[i]->adc();
194 int qt = hits[i]->qtSlot();
195 int ch = hits[i]->qtChannel();
196 int slatid = mFmsDbMkr->fpostSlatidFromQT(qt,ch);
198 int q=0;
int l=0;
int s=0;
199 mFmsDbMkr->fpostQLSfromSlatId(slatid,&q,&l,&s);
203 if( q>0 && l>0 && s>0 && abs(xing) <= mNPREPOST )
205 mXing[xing+mNPREPOST]->Fill((
float)adc);
206 if( xing == 0 || mPed != 0 )
209 mAdc2[0]->Fill((
float)slatid,(
float)adc);
210 mAdc2[1]->Fill((
float)slatid,(
float)adc);
214 mAdc[slatid][0]->Fill((
float)adc);
215 mAdc[slatid][1]->Fill((
float)adc);
220 mHit[q-1][l-1]->Fill(
float(s));
231 mDataSize[0]->Fill(log10(nfpostdatatot));
232 mDataSize[1]->Fill(log10(nfpostdata));
234 for(
int q=0; q<mNQ; q++)
236 for(
int l=0; l<mNL; l++)
238 mNHit[q][l]->Fill(
float(nh[q][l]));
245 mNHitTrg[64]->Fill(
float(nhtot));
246 unsigned long long one=1;
248 if( fpsraw == 0 ){
return kStOK;}
251 unsigned long long tmask = fpsraw->trgMask();
253 for(
int t=0; t<mNTRG; t++)
256 if( tmask & (one<<t) )
258 mNHitTrg[t]->Fill(
float(nhtot));
259 mNHitTrg2->Fill(
float(nhtot),
float(t));
270 unsigned int tcu=trg->tcuCounter();
271 unsigned int rfpo=fpsraw->rccFpost();
272 unsigned int dfpo=rfpo-tcu;
279 const long long one=1;
280 const long long m=one<<32;
283 dfpo=(
unsigned int)(r+m-t);
285 mRccDiff[0]->Fill(dfpo);
286 mRccDiff[1]->Fill(dfpo);
291 printf(
"No StTriggerData found\n");
308 cout <<
"This run has FPOST" << endl;
311 printf(
"StFpostQaMaker::Finish - Closing %s\n",mFilename);
316 cout <<
"This run has no FPOST" << endl;
318 int yday = mRun/1000;
319 stringstream outFile_name;
320 outFile_name <<
"/ldaphome/dkap7827/fpost_onl_monitoring/" << yday <<
"/" << mRun <<
".empty.txt";
321 ofstream outFile( outFile_name.str().c_str() );
322 if( !outFile.is_open() )
324 cout <<
"Could not open file: " << outFile_name.str() << endl;
330 printf(
"StFpostQaMaker::Finish - Closing %s and %s\n",outFile_name.str().c_str(),mFilename);