You are on page 1of 3

#include

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

"Riostream.h"
"TTimer.h"
"TROOT.h"
"TStyle.h"
"TFile.h"
"TH1F.h"
"TH2F.h"
"TNtuple.h"
"TCanvas.h"
"TPad.h"
"TF1.h"
"TProfile.h"
"TLegend.h"
"TMath.h"
"TGraphErrors.h"
"TFrame.h"

void Calibration() {
gROOT->Reset();
//
ifstream in;
//inizializziamo array
Int_t n
Float_t
Float_t
Float_t
Float_t
Float_t
Float_t

= 24;
x[n];
xerr[n];
y1[n];
y1err[n];
y2[n];
y2err[n];

Float_t a1,a2;
Int_t nlines = 0;
TH1F * h1 = new TH1F("","",1000,0,1000);
TH1F * h2 = new TH1F("","",1000,0,1000);
in.open("calibrazione.dat");
for(Int_t i=0; i<n; i++){
while (1) {
in >> a1 >> a2 ;
if (nlines > 200*(1+i)) break;
h1->Fill(a1);
h2->Fill(a2);
nlines++;
}
1

y1[i] = h1->GetMean();
y1err[i] = h1->GetRMS();
y2[i] = h2->GetMean();
y2err[i] = h2->GetRMS();
// cout<<y1[i]<<" "<<y1err[i]<<" "<<y2[i]<<" "<<y2err[i]
<<endl;
h1->Reset();
h2->Reset();
}
//aggiungo errore strumentale in quadratura
for(Int_t i=0;i<n;i++) {
y1err[i]=TMath::Sqrt(y1err[i]*y1err[i]/200+1/12);
y2err[i]=TMath::Sqrt(y2err[i]*y2err[i]/200+1/12);
}
// Fare array x
Double_t
Double_t
Double_t
Double_t

db;
v;
norm = 0.25/sqrt(3)/20;
deltav;

for(Int_t j=0; j<n; j++){


db = j;
v = TMath::Power(10,(-db/20));
deltav = v*norm;
x[j] = v;
xerr[j] = deltav;
//

cout<<x[j]<<" "<<xerr[j];

}
//Fitlineare
TCanvas *c1 = new TCanvas("c1", "Calibrazione lineare ADC0",
500, 500, 700, 700);
c1->SetGrid();
TGraphErrors *gr1 = new TGraphErrors(n,x,y1,xerr,y1err);
gr1->SetTitle("Fit lineare ADC 0");
gr1->SetMarkerColor(4);
gr1->SetMarkerStyle(21);
gr1->Draw("AP");
gStyle->SetOptFit(1111);
TF1 *funz = new TF1("funz","[0]*x+[1]",0,1);
gr1->Fit("funz","","",0.1,1);
c1->Update();
TCanvas *c2 = new TCanvas("c2", "Calibrazione lineare ADC1",
2

500, 500, 700, 700);


c2->SetGrid();
TGraphErrors *gr2 = new TGraphErrors(n,x,y2,xerr,y2err);
gr2->SetTitle("Fit lineare ADC 1");
gr2->SetMarkerColor(4);
gr2->SetMarkerStyle(21);
gr2->Draw("AP");
gStyle->SetOptFit(1111);
gr2->Fit("funz","","",0.1,1);
c1->Update();
}

You might also like