6 #include <TClonesArray.h>
11 #include "BbcVertex.h"
22 memset(hA,0,
sizeof(hA));
27 char cEW[mxEW]={
'E',
'W'};
28 for(iew=0;iew<mxEW;iew++) {
29 for(ih=0;ih<mxHex;ih++) {
31 sprintf(name,
"bbc%c%02d",cEW[iew],ih+1);
43 BbcVertex::~BbcVertex() {}
48 void BbcVertex::clear(){
51 for(iew=0;iew<mxEW;iew++)
52 for(ih=0;ih<mxHex;ih++)
53 hex[iew][ih]->clear();
63 void BbcVertex::initRun(
int runID){
64 printf(
" BbcVertex::initRun(%d), cm2tdcCh=%f\n",runID, cm2tdcCh);
65 assert(TMath::Abs(cm2tdcCh)<20);
71 void BbcVertex::init(){
73 hA[0]=
new TH1F (
"onlvd",
"zTpc - Z(BBC) ; (cm)",50,-100,100);
74 hA[1]=(TH1F*)
new TH2F (
"onlvv",
"BBC zTPC vs. onlTdiff; (TDC ch); Z vert (cm)",50,150,350,50,-200,200);
75 hA[2]=(TH1F*)
new TH2F (
"onlvd2",
"BBC (onlZbbc-zTPC)/cm2ch vs. onlTdiff; (TDC ch); #D Z vert (TDC ch)",50,150,350,50,-20,20);
77 for(i=0;i<3;i++) hA[i]->SetLineColor(kGreen);
80 hA[7]=(TH1F*)
new TH2F (
"vd2",
"BBC (oflZbbc-zTPC)/cm2ch vs. oflTdiff+256; (TDC ch); #D Z vert (TDC ch)",50,150,350,50,-20,20);
82 hA[8]=(TH1F*)
new TH2F (
"vk",
"BBC iW vs. iE",16,.5,16.5,16,0.5,16.5);
83 hA[9]=(TH1F*)
new TH2F (
"va",
"BBC adcW vs. adcE",156,-0.5,155.5,156,-0.5,155.5);
84 hA[10]=(TH1F*)
new TH2F (
"vt",
"BBC tdcW vs. tdcE",128,-0.5,255.5,128,-0.5,255.5);
85 hA[11]=(TH1F*)
new TH2F (
"vv",
"BBC zTPC vs. oflTdiff+256; (TDC ch); Z vert (cm)",50,150,350,50,-200,200);
87 hA[12]=
new TH1F (
"vd",
"zTpc - Z(BBC) ; (cm)",50,-100,100);
88 hA[13]=(TH1F*)
new TH2F (
"vE",
"BBC zTpc - Z(BBC) vs. adcE ; ADC; (cm)",120,0.5,120.5,50,-100,100);
89 hA[14]=(TH1F*)
new TH2F (
"vW",
"BBC zTpc - Z(BBC) vs. adcW ; ADC; (cm)",120,0.5,120.5,50,-100,100);
91 hA[15]=(TH1F*)
new TH2F (
"vU",
"TPC vertex Z vs run time ; minutes; cm ",120,0,60, 50,-200,200);
92 hA[16]=(TH1F*)
new TH2F (
"vD",
"Ztpc - Zbbc vs run time ; minutes; cm ",120,0,60, 50,-200,200);
94 hA[17]=
new TH1F (
"ts",
"sum of T_E + T_W ; raw chan",100,0,300);
99 if(hA[i]==0)
continue;
104 char cEW[mxEW]={
'E',
'W'};
106 for(iew=0;iew<mxEW;iew++) {
107 for(ih=0;ih<mxHex;ih++) {
108 char tt1[100],tt2[100];
109 sprintf(tt1,
"w%c%02d",cEW[iew],ih+1);
110 sprintf(tt2,
"%s , dZ vs. ADC ; ADC(chan) ;#Delta Z (cm)",tt1);
111 TH2F *h=
new TH2F (tt1,tt2,60,0.5,120.5,25,-100,100);
121 void BbcVertex::finish(){
123 printf(
"\n BbcVertex::finish() nInpEve=%d\n",nInpEve);
130 int BbcVertex:: findTime(
BbcHex **D){
134 for(i=0;i<mxHex;i++) {
136 if(D[i]->adc<5)
continue;
137 if(D[i]->tdc>245)
continue;
138 if(D[i]->
tof<tMax)
continue;
150 void BbcVertex:: export2NN(
BbcHex **D){
152 memset(key,0,
sizeof(key));
159 for(i=0;i<mxHex;i++) {
162 if(D[i]->adc<5)
continue;
163 if(D[i]->tdc>245)
continue;
164 if(D[i]->
tof<tMax)
continue;
170 printf(
"%d %d %d ",iT,D[iT]->adc,D[iT]->tdc);
182 void BbcVertex::print(){
183 printf(
"\n BbcVertex::print()\n dump:\n");
188 void BbcVertex:: doVertex(){
192 float onlZ=-(onlTdiff-256)*cm2tdcCh;
193 float onlDz=onlZ-zTpc;
194 float onlTcorr=onlDz/cm2tdcCh;
198 ( (TH2F*) hA[1])->Fill(onlTdiff,zTpc);
199 ( (TH2F*) hA[2])->Fill(onlTdiff,onlTcorr);
206 printf(
" %f\n",zTpc);
209 int iE=findTime(hex[0]);
210 int iW=findTime(hex[1]);
214 float tE=hex[0][iE]->tof;
215 float tW=hex[1][iW]->tof;
216 float aE=hex[0][iE]->adc;
217 float aW=hex[1][iW]->adc;
218 float oflTdiff=256.+(tE-tW);
220 float oflZ=-(oflTdiff-256)*cm2tdcCh;
221 float oflDz=oflZ-zTpc;
222 float oflTcorr=oflDz/cm2tdcCh;
227 float diff=onlTdiff -oflTdiff;
228 if(TMath::Abs(diff)>0.01)
229 printf(
"DIFIDIF: Z=%f onlTd=%f oflTd=%f difT=%f\n",zTpc,onlTdiff,oflTdiff,diff);
240 ( (TH2F*) hA[8])->Fill(kE,kW);
241 ( (TH2F*) hA[9])->Fill(aE,aW);
242 ( (TH2F*) hA[10])->Fill(tE,tW);
243 ( (TH2F*) hA[11])->Fill(oflTdiff,zTpc);
244 ( (TH2F*) hA[7])->Fill(oflTdiff,oflTcorr);
247 float time1= unixTime-unixTime0;
249 ( (TH2F*) hA[15])->Fill(time1,zTpc);
250 ( (TH2F*) hA[16])->Fill(time1,oflDz);
253 calibWalk(hex[1][iW],hex[0][iE],oflDz,hC[0]);
254 calibWalk(hex[0][iE],hex[1][iW],oflDz,hC[1]);
257 ( (TH2F*) hA[13])->Fill(aE,oflDz);
258 ( (TH2F*) hA[14])->Fill(aW,oflDz);
265 for(iew=0;iew<mxEW;iew++){
267 for(ih=0;ih<mxHex;ih++) {
268 if( hex[iew][ih]->adc<adcMin)
continue;
270 hex[iew][ih]->print();
273 printf(
"nT-E=%d nT-W=%d\n\n",nT[0],nT[1]);
282 void BbcVertex::calibWalk(
BbcHex *x,
BbcHex *y,
float dz, TH2F **h){
288 assert(y->id>=0 && y->id<mxHex);
289 h[y->id]->Fill(y->adc,dz);
295 void BbcVertex::readCalib(
char *fname) {
296 printf(
"readCalib('%s')\n",fname);
297 FILE *fd=fopen(fname,
"r");
300 printf(
"file %s was not open\n",fname);
301 printf(
" fix it, (JB)\n\n");
309 char * ret=fgets(buf,mx,fd);
312 if(buf[0]==
'#')
continue;
315 int n=sscanf(buf,
"%s %f %f %f %f",name,&a,&b,&c,&d);
317 printf(
"faulty %d line in %s\n",nl,fname);
318 printf(
"n=%d buf='%s'\n fix it, (JB)\n\n",n,buf);
326 for(iew=0;iew<mxEW;iew++)
327 for(ih=0;ih<mxHex;ih++){
328 if(strstr(hex[iew][ih]->name,name)==0)
continue;
330 hex[iew][ih]->setCalib(a,b,c,d);
334 printf(
"faulty BbcPMT name=%s in %d line in %s\n",name,nl,fname);
335 printf(
"n=%d buf='%s'\n fix it, (JB)\n\n",n,buf);
341 printf(
"BbcVertex::readCalib() done, found %d valid records\n",nd);