13 #include "oflPedStat.h"
27 oflPedStat::initRun(
int index,TFile *f,TFile *fraw,FILE *fpout,FILE *fplog,
int rNum)
43 oflPedStat::procDetector(
char *name,
float maxPedPos,
float minPedPos,
float maxSig,
float minSig,
float deadentries,
int msk)
50 if(!strcmp(name+4,
"288"))
51 { fprintf(mfplog,
"%s is an edge strip\n",name);
53 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
56 if((strncmp(name,
"a03U",4)==0 || strncmp(name,
"a09U",4)==0) && atoi(name+4)>283 )
57 { fprintf(mfplog,
"%s is an edge strip\n",name);
59 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
62 if((strncmp(name,
"a04V",4)==0 || strncmp(name,
"a10V",4)==0) && atoi(name+4)> 283 )
63 { fprintf(mfplog,
"%s is an edge strip\n",name);
65 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
70 TH1F *h = (TH1F*)mfd ->Get(name);
71 TH1F *hraw = (TH1F*)mfdraw ->Get(name);
73 fprintf(mfplog,
"individual channel %s not found\n",name);
75 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
78 TF1 *fn = h->GetFunction(
"fPeak");
81 fprintf(mfplog,
"%s has no fit parameters\n",name);
82 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
87 char title[100],crate[4],txt[3];
88 sprintf(title,
"%s",h->GetTitle());
89 if(strncmp(title+35,
"tube=",5)==0 && name[3]!=
'T') {
90 sprintf(txt,
"%c%c%c",title[29],title[30],title[31]);
91 sprintf(crate,
"%c%c%c%c",title[40],title[41],title[42],title[43]);
99 if(!strcmp(name,
"a12TC05"))
101 fprintf(mfplog,
"%s masked out of trigger for whole run\n",name);
106 int entries=(int)h->GetEntries();
107 int integral=(int)h->Integral();
111 if(entries != integral)
114 int nb=h->GetNbinsX();
116 float *x = (
float*)malloc(nb*
sizeof(
float));
117 x =(
float*) h->GetArray();
130 { fprintf(mfplog,
"%s fails- all entries %.0f in one channel\n",name,ymax);
132 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
135 if(sum < 0.90*entries)
137 fprintf(mfplog,
"%s fails needed events - %.0f of %d\n",name,sum,entries);
139 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
143 float x0=h->GetBinCenter(jfind);
144 float ped = fn->GetParameter(1);
145 float sig = fn->GetParameter(2);
149 double zerobinContent=0;
150 int zerobin=h->GetXaxis()->FindBin(0.0);
151 zerobinContent = h->GetBinContent(zerobin);
154 if(zerobinContent > 0.001*entries) {
156 printf(
"%s fails due to ADC=0 counts = %f\n",name,zerobinContent);
157 fprintf(mfplog,
"%s has to many ADC=0 counts\n",name);
158 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
161 overflow = hraw->Integral(ped+100,5000);
162 if(overflow>0.001*entries) {
164 printf(
"%s fails due to overflow counts = %f\n",name,overflow);
165 fprintf(mfplog,
"%s has to many overflow counts\n",name);
166 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
171 overflow = hraw->Integral(ped+200,5000);
172 if(overflow>0.01*entries) {
174 printf(
"%s fails due to overflow counts = %f\n",name,overflow);
175 fprintf(mfplog,
"%s has to many overflow counts\n",name);
176 fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);
184 int bitcompare=1+2+4+8;
185 int biton=bitcompare;
189 for (
int k=0; k < (hraw->GetNbinsX()); k++)
191 if (hraw ->GetBinContent(k)>0)
193 bitoff = bitoff | adc;
201 if ( (bitoff & bitcompare) != bitcompare && nonzerohits >= 8)
203 printf(
"%s bit stuck off \n",name);
204 fprintf(mfplog,
"%s has stuck bits\n",name);
208 else if(biton && nonzerohits >= 5 && bitoff>70)
210 printf(
"%s bit stuck on \n",name);
211 fprintf(mfplog,
"%s has stuck bits\n",name);
217 if((!strcmp(name,
"a04TB07")||!strcmp(name,
"a06TA07")||!strcmp(name,
"a08TB07")) && nStuckBit==0){
218 printf(
"%s missed stuck bit, but hardcoded fix\n",name);
219 fprintf(mfplog,
"%s missed stuck bit, but hardcoded\n",name);
225 if(fabs(x0-ped)> 1.5 && !nStuckBit){
226 fprintf(mfplog,
"%s fails, diff of x0=%.0f and ped =%.1f > 1.5\n",name,x0,ped);
230 fprintf(mfplog,
"%s fails, ped <= 0\n",name);
233 if(ped >0 && ped < minPedPos){
234 fprintf(mfplog,
"%s fails,%.4f, ped too low\n",name,ped);
237 if(ped > maxPedPos) {
238 fprintf(mfplog,
"%s,%.4f, ped too high\n",name,ped);
242 if (sig < minSig && !nStuckBit){
243 fprintf(mfplog,
"%s, %.4f, sig too low\n",name,sig);
248 fprintf(mfplog,
"%s, %.4f, sig too high\n",name,sig);
253 int start5sig=jfind -(int)(5.0*sig);
254 int end5sig = jfind +(int)(5.0*sig);
256 for(i=start5sig; i<=end5sig; i++)
259 if(sum2 >= deadentries*entries && !nStuckBit){
260 fprintf(mfplog,
"%s ped=%.3f x0=%.0f sig=%.3f sum2=%.0f start5sig=%d end5sig=%d jfind=%d\n",name,ped,x0,sig,sum2,start5sig,end5sig,jfind);
261 fprintf(mfplog,
"%s is a dead channel\n",name);
267 if(nfail > 0 || nstat > 0)
268 { fprintf(mfpout,
"%s 0x%04x 0x%04x\n",name,nfail,nstat);}