1 TH2S *h2Ped=0, *h2Sig=0;
2 TH1S *h1Stat=0, *h2CapStat;
3 TH2D *hT0=0, *hT1=0, *hT2=0;
8 void doBprsPedTonko(
char *crun=
"R9049049",
char * pathIn=
"/star/data05/scratch/balewski/sched-raw-ped4"){
9 gStyle->SetPalette(1,0);
10 gStyle->SetOptStat(0);
12 char *pathOut=
"calib-2.3m/";
13 char txt[1000], txt2[1000];
15 sprintf(txt,
"%s/%s.barCal.hist.root",pathIn,crun);
17 printf(
"Open=%s=\n",fd1->GetName());
18 if(!fd1->IsOpen()) { printf(
"FAIL run=%s\n", crun);
return;}
21 sprintf(txt,
"%s/pedBprs%s-allCap.hist.root",pathOut,crun);
22 fd2=
new TFile(txt,
"recreate");
24 hT0= (TH2D *)fd1->Get(
"bprsTnk0"); assert(hT0);
25 hT1= (TH2D *)fd1->Get(
"bprsTnk1"); assert(hT1);
26 hT2= (TH2D *)fd1->Get(
"bprsTnk2"); assert(hT2);
29 float x1=axX->GetXmin();
30 float x2=axX->GetXmax();
31 int nbX=axX->GetNbins();
35 float y1=axY->GetXmin();
36 float y2=axY->GetXmax();
37 int nbY=axY->GetNbins();
38 printf(
"Y-axis range --> [%.1f, %.1f], nb=%d %s\n",y1,y2,nbY,axX->GetTitle());
41 sprintf(txt,
"pedBPRScap");
42 sprintf(txt2,
"BPRS pedestal, average method (Z=10*ADC), %s ; BPRS soft ID; capID",crun);
43 h2Ped=
new TH2S(txt,txt2,nbX,x1,x2,nCap,-0.5,nCap-0.5);
45 sprintf(txt,
"rmsPedBPRScap");
46 sprintf(txt2,
"BPRS RMS(ped) (Z=10*ADC), %s ; BPRS soft ID; capID",crun);
47 h2Sig=
new TH2S(txt,txt2,nbX,x1,x2,nCap,-0.5,nCap-0.5);
49 sprintf(txt,
"statBPRSallCap");
50 sprintf(txt2,
"BPRS status from all caps, %s ; BPRS soft ID; # of bad caps",crun);
51 h1Stat=
new TH1S(txt,txt2,nbX,x1,x2);
53 sprintf(txt,
"capStatBPRSallSoft");
54 sprintf(txt2,
"BPRS status from all softID, %s ; BPRS capID; # of bad softID",crun);
55 h1CapStat=
new TH1S(txt,txt2,128,-0.5,127.5);
60 printf(
"H2 created\n");
62 for(
int cap=cap1;cap<=cap2;cap++) {
63 for(
int i=1;i<=nbX;i++) {
65 double nEve= hT0->GetBinContent(i,cap+1);
66 double sumX= hT1->GetBinContent(i,cap+1);
67 double sumX2= hT2->GetBinContent(i,cap+1);
68 if(nEve<=cut_minEve) { h1Stat->Fill(i);
continue; }
71 double rms=sqrt(sumX2/nEve -ped*ped);
73 if(rms< cut_minRms) { h1Stat->Fill(i);
continue; }
74 h2Ped->SetBinContent(i,cap+1,(
int)(10.*ped));
75 h2Sig->SetBinContent(i,cap+1,(
int)(10.*rms));
78 h1CapStat->Fill(cap,1);
85 for(
int i=1;i<=nbX;i++) {
86 if(h1Stat->GetBinContent(i)==0)
continue;
88 printf(
"%d dead, softID=%d\n",nDead,i);
90 h1Stat->SetEntries(nDead);
91 printf(
" accumulated nDead=%d\n",nDead);
98 printf(
"total entries=%d\n",h2Ped->GetEntries());
102 c->cd(1); h2Sig->Draw(
"colz"); h2Sig->SetMaximum(4);
110 for(
int k=120;k<=128;k++)
111 for(
int i=1;i<=nbX;i++)
112 for(
int j=1;j<=nbY;j++)
114 float val=h3->GetBinContent(i,j,k);
116 printf(
"chan(i)=%d, adc(j)=%d, cap(k)=%d val=%f\n", i-1,j+100,k-1,val);
122 void subtractRefPed() {
124 fd3=
new TFile(
"calib2.2n/pedBprsR9066001-allCap.hist.root");
125 assert(fd3->IsOpen());
126 printf(
"Opened=%s=\n",fd3->GetName());
128 hRef1= (TH2F *)fd3->Get(
"sigPedBPRScap"); assert(hRef1);
130 hRef1->SetMaximum(4);
133 hRef= (TH2F *)fd3->Get(
"pedBPRScap"); assert(hRef);
138 hRef->SetMaximum(1.01);
139 hRef->SetMinimum(0.98);