12,17 → 12,12 |
int aitana( const char *fname="a1.dat", int range=10, float cut=500, int *offset = NULL) |
{ |
int debug=0; |
//int off[4]={507,521,497,459}; |
int off[4]={87,125,95,80}; |
if (offset) for (int i=0;i<4;i++){off[i]=offset[i];}; |
|
FILE *fin; |
|
unsigned short hdr[2]; |
|
int off[4]={507,521,497,459}; |
if (offset) for (int i=0;i<4;i++){off[i]=offset[i];}; |
// gStyle->SetOptStat(1111111); |
gStyle->SetOptStat(0); |
// gStyle->SetPalette(52); |
|
|
char rootname[0xFF]; |
sprintf(rootname, "%s.root", fname); |
TFile *froot = new TFile(rootname,"RECREATE"); |
34,40 → 29,34 |
TH1F *hadcsumy; |
TH2F *hxy; |
TH2F *h2d=NULL; |
TH2F *h2dx=NULL; |
TH2F *h2dy=NULL; |
TH2F *hxcorr=NULL; |
TH2F *hycorr=NULL; |
unsigned short buf[10000]; |
|
|
for (int i=0; i<4; i++) { |
sprintf(histname,"adc%d",i); |
hadc[i]=new TH1F(histname,histname,200,0.5,200*range+0.5); |
} |
|
sprintf(histname,"adcsum"); |
hadcsum=new TH1F(histname,histname,200,0.5,8*200*range+0.5); |
|
sprintf(histname,"adcsumx"); |
hadcsumx=new TH1F(histname,histname,200,0.5,200*range+0.5); |
|
sprintf(histname,"adcsumy"); |
hadcsumy=new TH1F(histname,histname,200,0.5,200*range+0.5); |
|
sprintf(histname,"hxy"); |
hxy=new TH2F(histname,"Center of gravity;ycog(a.u.);xcog(a.u.)",200,0,1,200,0,1); |
|
|
|
fin=fopen(fname,"rb"); |
hadcsum=new TH1F("adcsum","adcsum",200,0.5,8*200*range+0.5); |
hadcsumx=new TH1F("adcsumx","adcsumx",200,0.5,200*range+0.5); |
hadcsumy=new TH1F("adcsumy","adcsumy",200,0.5,200*range+0.5); |
hxy=new TH2F("hxy","Center of gravity;ycog(a.u.);xcog(a.u.)",200,0,1,200,0,1); |
|
FILE *fin=fopen(fname,"rb"); |
if (fin==NULL) { |
printf("Error opening file %s\n",fname); |
return 0; |
} |
|
int pos[7]={0,0,0,0,0,0,0}; |
unsigned short hdr[2]; |
int pos[7]={0,0,0,0,0,0,0}; |
int poshdr[9]={0,0,0,0,0,0,0,0,0}; |
float b[4], sum=0; |
unsigned short a[4]; |
|
unsigned short buf[10000]; |
float posx=0, posy=0; |
while(!feof(fin)) { |
|
int stat=fread(hdr,1,4,fin); |
91,10 → 80,7 |
for (int j=0;j<4;j++){ |
a[j]=adc[j]&0xFFF; |
sum+=a[j]; |
hadc[j]->Fill(a[j]); |
//const int off[4]={87,125,95,80}; |
|
|
hadc[j]->Fill(a[j]); |
b[j]=a[j]-off[j]+10; |
sum+=b[j]; |
} |
103,7 → 89,10 |
hadcsumy->Fill(a[2]+a[3]); |
float y = (b[0]+b[1])? b[0]/(b[0]+b[1]) : 0; |
float x = (b[2]+b[3])? b[2]/(b[2]+b[3]) : 0; |
if (h2d) h2d->Fill(pos[0],pos[1],sum); |
if (h2d) h2d->Fill(posx,posy,sum); |
if (h2dx) h2dx->Fill(posx,posy,b[0]+b[1]); |
if (h2dy) h2dy->Fill(posx,posy,b[2]+b[3]); |
|
if (sum>cut) { |
hxy->Fill(y,x); |
if (hxcorr) hxcorr->Fill(pos[0],y); |
116,22 → 105,32 |
int *p= (int *) &buf[0]; |
for (int k=0;k<7;k++) pos[k]=p[k]; |
printf("Position: %d %d\n",pos[3], pos[4] ); |
posx = poshdr[0]+pos[3]* poshdr[3]; |
posy = poshdr[1]+pos[4]* poshdr[4]; |
} |
break; |
case 0x3:{ |
int *p= (int *) &buf[0]; |
for (int k=0;k<9;k++) poshdr[k]=p[k]; |
sprintf(histname,"h2d"); |
h2d=new TH2F(histname,"Position dependency of sum;x(step);y(step)",poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5) ); |
|
h2d=new TH2F("h2d","Position dependency of sum;x(step);y(step)", |
poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5) ); |
|
sprintf(histname,"hxcorr"); |
hxcorr=new TH2F(histname,"Correlation stage position vs cog;x(step);xcog(a.u.)", |
poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), 100 , 0, 1); |
|
sprintf(histname,"hycorr"); |
hycorr=new TH2F(histname,"Correlation stage position vs cog;y(step);ycog(a.u.)", |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5), 100 , 0, 1); |
h2dx=new TH2F("h2dx","Position dependency of xsum;x(step);y(step)", |
poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5) ); |
|
h2dy=new TH2F("h2dy","Position dependency of ysum;x(step);y(step)", |
poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5) ); |
|
|
hxcorr=new TH2F("hxcorr","Correlation stage position vs cog;x(step);xcog(a.u.)", |
poshdr[6],poshdr[0]-poshdr[3]*0.5 ,poshdr[0]+poshdr[6]*(poshdr[3]-0.5), 100 , 0, 1); |
|
hycorr=new TH2F("hycorr","Correlation stage position vs cog;y(step);ycog(a.u.)", |
poshdr[7],poshdr[1]-poshdr[4]*0.5 ,poshdr[1]+poshdr[7]*(poshdr[4]-0.5), 100 , 0, 1); |
} |
break; |
default: break; |
165,26 → 164,43 |
c->Divide(2,3); |
if (!h2d){ |
c->Clear(); |
c->Divide(1,3); |
c->Divide(1,4); |
} |
c->cd(3)->SetLogy(); hadcsum->DrawCopy(); |
|
|
hxy->SetMinimum(-1); |
hxy->SetMaximum(1000); |
c->cd(1)->SetLogz(); hxy->DrawCopy("colz"); |
c->cd(4)->SetLogy(); hadcsum->DrawCopy(); |
|
if (h2d){ |
hxcorr->SetMinimum(-1); |
hycorr->SetMinimum(-1); |
c->cd(4); hxcorr->DrawCopy("colz"); |
c->cd(5); hycorr->DrawCopy("colz"); |
c->cd(6); h2d->DrawCopy("colz"); |
c->cd(5); hxcorr->DrawCopy("colz"); |
c->cd(6); hycorr->DrawCopy("colz"); |
} |
TH1D *px = hxy->ProjectionX("_px",0,-1); |
c->cd(2); px->DrawCopy(); |
|
TH1D *py = hxy->ProjectionY("_py",0,-1); |
c->cd(3); py->DrawCopy(); |
|
c->Modified(); |
c->Update(); |
c->Print(rootname,"pdf"); |
|
|
if (h2d){ |
c= new TCanvas("c2","position dependence sum, xsum, ysum",750,50,700,700); |
c->Divide(1,3); |
c->cd(1); h2d->DrawCopy("colz"); |
c->cd(2); h2dx->DrawCopy("colz"); |
c->cd(3); h2dy->DrawCopy("colz"); |
c->Modified(); |
c->Update(); |
c->Print(rootname,"pdf"); |
} |
|
c->Print(TString(rootname) + "]","pdf"); |
froot->Write(); |
froot->Close(); |