Rev 218 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 218 | Rev 315 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | #include <TStyle.h> |
7 | #include <TStyle.h> |
8 | #include <TCanvas.h> |
8 | #include <TCanvas.h> |
9 | #include <TLegend.h> |
9 | #include <TLegend.h> |
10 | // Program za analizo podatkov zajetih z AITSiPMDAQ |
10 | // Program za analizo podatkov zajetih z AITSiPMDAQ |
11 | 11 | ||
12 | int aitana( const char *fname="a1.dat", int range= |
12 | int aitana( const char *fname="a1.dat", int range=5, float cut=300, int *offset = NULL) |
13 | { |
13 | { |
14 | int debug=0; |
14 | int debug=0; |
15 | //int off[4]={507,521,497,459}; |
15 | //int off[4]={507,521,497,459}; |
- | 16 | //int off[4]={198,203,190,150}; /// run 1 |
|
16 | int off[4]={ |
17 | int off[4]={120,120,120,120}; /// run 6 |
17 | if (offset) for (int i=0;i<4;i++){off[i]=offset[i];}; |
18 | if (offset) for (int i=0;i<4;i++){off[i]=offset[i];}; |
18 | - | ||
19 | gStyle->SetOptStat(0); |
19 | gStyle->SetOptStat(0); |
20 | 20 | ||
21 | char rootname[0xFF]; |
21 | char rootname[0xFF]; |
22 | sprintf(rootname, "%s.root", fname); |
22 | sprintf(rootname, "%s.root", fname); |
23 | TFile *froot = new TFile(rootname,"RECREATE"); |
23 | TFile *froot = new TFile(rootname,"RECREATE"); |
Line 25... | Line 25... | ||
25 | TLegend * leg = new TLegend(0.8, 0.8, 1, 1); |
25 | TLegend * leg = new TLegend(0.8, 0.8, 1, 1); |
26 | TH1F *hadc[4]; |
26 | TH1F *hadc[4]; |
27 | TH1F *hadcsum; |
27 | TH1F *hadcsum; |
28 | TH1F *hadcsumx; |
28 | TH1F *hadcsumx; |
29 | TH1F *hadcsumy; |
29 | TH1F *hadcsumy; |
30 | TH2F * |
30 | TH2F *hxy,*hxy1,*hxy2; |
31 | TH2F *h2d=NULL; |
31 | TH2F *h2d=NULL; |
32 | TH2F *h2dx=NULL; |
32 | TH2F *h2dx=NULL; |
33 | TH2F *h2dy=NULL; |
33 | TH2F *h2dy=NULL; |
34 | TH2F *hxcorr=NULL; |
34 | TH2F *hxcorr=NULL; |
35 | TH2F *hycorr=NULL; |
35 | TH2F *hycorr=NULL; |
Line 40... | Line 40... | ||
40 | hadc[i]=new TH1F(histname,histname,200,0.5,200*range+0.5); |
40 | hadc[i]=new TH1F(histname,histname,200,0.5,200*range+0.5); |
41 | } |
41 | } |
42 | hadcsum=new TH1F("adcsum","adcsum",200,0.5,8*200*range+0.5); |
42 | hadcsum=new TH1F("adcsum","adcsum",200,0.5,8*200*range+0.5); |
43 | hadcsumx=new TH1F("adcsumx","adcsumx",200,0.5,200*range+0.5); |
43 | hadcsumx=new TH1F("adcsumx","adcsumx",200,0.5,200*range+0.5); |
44 | hadcsumy=new TH1F("adcsumy","adcsumy",200,0.5,200*range+0.5); |
44 | hadcsumy=new TH1F("adcsumy","adcsumy",200,0.5,200*range+0.5); |
45 | hxy=new TH2F("hxy","Center of gravity;ycog(a.u.);xcog(a.u.)",200, |
45 | hxy=new TH2F("hxy","Center of gravity;ycog(a.u.);xcog(a.u.)",200,-0.1,1.1,200,-0.1,1.1); |
46 | - | ||
- | 46 | hxy1=new TH2F("hxy1","Center of gravity for position 1;ycog(a.u.);xcog(a.u.)",200,-0.1,1.1,200,-0.1,1.1); |
|
- | 47 | hxy2=new TH2F("hxy2","Center of gravity for position 2;ycog(a.u.);xcog(a.u.)",200,-0.1,1.1,200,-0.1,1.1); |
|
47 | FILE *fin=fopen(fname,"rb"); |
48 | FILE *fin=fopen(fname,"rb"); |
48 | if (fin==NULL) { |
49 | if (fin==NULL) { |
49 | printf("Error opening file %s\n",fname); |
50 | printf("Error opening file %s\n",fname); |
50 | return 0; |
51 | return 0; |
51 | } |
52 | } |
Line 79... | Line 80... | ||
79 | sum=0; |
80 | sum=0; |
80 | for (int j=0;j<4;j++){ |
81 | for (int j=0;j<4;j++){ |
81 | a[j]=adc[j]&0xFFF; |
82 | a[j]=adc[j]&0xFFF; |
82 | //sum+=a[j]; |
83 | //sum+=a[j]; |
83 | hadc[j]->Fill(a[j]); |
84 | hadc[j]->Fill(a[j]); |
84 | b[j]=a[j]-off[j] |
85 | b[j]=a[j]-off[j]; |
- | 86 | if (b[j]< 0) b[j]=0; |
|
85 | sum+=b[j]; |
87 | sum+=b[j]; |
86 | } |
88 | } |
87 | hadcsum->Fill(sum); |
89 | hadcsum->Fill(sum); |
88 | hadcsumx->Fill(a[0]+a[1]); |
90 | hadcsumx->Fill(a[0]+a[1]); |
89 | hadcsumy->Fill(a[2]+a[3]); |
91 | hadcsumy->Fill(a[2]+a[3]); |
Line 93... | Line 95... | ||
93 | if (h2dx) h2dx->Fill(posx,posy,b[0]+b[1]); |
95 | if (h2dx) h2dx->Fill(posx,posy,b[0]+b[1]); |
94 | if (h2dy) h2dy->Fill(posx,posy,b[2]+b[3]); |
96 | if (h2dy) h2dy->Fill(posx,posy,b[2]+b[3]); |
95 | 97 | ||
96 | if (sum>cut) { |
98 | if (sum>cut) { |
97 | hxy->Fill(y,x); |
99 | hxy->Fill(y,x); |
- | 100 | if (pos[3]==poshdr[6]/4 && pos[4]==poshdr[7]/4) hxy1->Fill(y,x); |
|
- | 101 | if (pos[3]==poshdr[6]/4*3 && pos[4]==poshdr[7]/4*3) hxy2->Fill(y,x); |
|
98 | if (hxcorr) hxcorr->Fill(pos[0],y); |
102 | if (hxcorr) hxcorr->Fill(pos[0],y); |
99 | if (hycorr) hycorr->Fill(pos[1],x); |
103 | if (hycorr) hycorr->Fill(pos[1],x); |
100 | } |
104 | } |
101 | 105 | ||
102 | } |
106 | } |
Line 159... | Line 163... | ||
159 | */ |
163 | */ |
160 | c->Print(rootname,"pdf"); |
164 | c->Print(rootname,"pdf"); |
161 | 165 | ||
162 | 166 | ||
163 | c= new TCanvas("c1","ait reconstruction",750,50,700,700); |
167 | c= new TCanvas("c1","ait reconstruction",750,50,700,700); |
164 | c->Divide(2, |
168 | c->Divide(2,4); |
165 | if (!h2d){ |
169 | if (!h2d){ |
166 | c->Clear(); |
170 | c->Clear(); |
167 | c->Divide( |
171 | c->Divide(2,3); |
168 | } |
172 | } |
169 | 173 | ||
170 | 174 | ||
171 | hxy->SetMinimum(-1); |
175 | hxy->SetMinimum(-1); |
172 | hxy->SetMaximum(1000); |
176 | hxy->SetMaximum(1000); |
173 | c->cd(1)->SetLogz(); hxy->DrawCopy("colz"); |
177 | c->cd(1)->SetLogz(); hxy->DrawCopy("colz"); |
- | 178 | c->cd(3)->SetLogz(); hxy1->DrawCopy("colz"); |
|
- | 179 | c->cd(4)->SetLogz(); hxy2->DrawCopy("colz"); |
|
174 | c->cd( |
180 | c->cd(2)->SetLogy(); hadcsum->DrawCopy(); |
175 | 181 | ||
176 | if (h2d){ |
182 | if (h2d){ |
177 | hxcorr->SetMinimum(-1); |
183 | hxcorr->SetMinimum(-1); |
178 | hycorr->SetMinimum(-1); |
184 | hycorr->SetMinimum(-1); |
179 | c->cd( |
185 | c->cd(7); hxcorr->DrawCopy("colz"); |
180 | c->cd( |
186 | c->cd(8); hycorr->DrawCopy("colz"); |
181 | } |
187 | } |
182 | TH1D *px = hxy->ProjectionX("_px",0,-1); |
188 | TH1D *px = hxy->ProjectionX("_px",0,-1); |
183 | c->cd( |
189 | c->cd(5); px->DrawCopy(); |
184 | 190 | ||
185 | TH1D *py = hxy->ProjectionY("_py",0,-1); |
191 | TH1D *py = hxy->ProjectionY("_py",0,-1); |
186 | c->cd( |
192 | c->cd(6); py->DrawCopy(); |
187 | 193 | ||
188 | c->Modified(); |
194 | c->Modified(); |
189 | c->Update(); |
195 | c->Update(); |
190 | c->Print(rootname,"pdf"); |
196 | c->Print(rootname,"pdf"); |
191 | 197 |