Commit e3b614b1 authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

fitting function modified

parent 76dbc9ea
......@@ -71,6 +71,8 @@ void fit_modified_erf(TH1D* hist_255,int colors,int markers,double injected_volt
fitpars<< std::setw(3)<< std::setfill('0')<< pixel_address <<"_"
<< std::setw(3)<< std::setfill('0')<<pixel_address<<"\t"
<<injected_voltage<<"\t"<< fiterf->GetParameter(1)<<std::endl;
// fitpars <<injected_voltage<<"\t"<< fiterf->GetParameter(1)<<std::endl;
hist_255->GetListOfFunctions()->FindObject("fiterf")->Draw("same");
hist_255->SetStats(0);
}
......@@ -138,52 +140,59 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
return hist_255;
}
void linear_fit(int x)
{
ifstream fitpars("fit_parameters.txt");
void linear_fit(int x){
ifstream fitpars;
fitpars.open("fit_parameters.txt");
std::string pixel_address;
std::vector<double>injected_amp_vec,signals_vec;
double injected_amplitude,signals;
std::vector<double>amp_vec,mean_vec;
double amp_vals,mean_vals;
std::vector<TGraph*>gr;
std::vector<TGraph*>gr3;
TGraph* gr2 = new TGraph();
int ctr=0;
int k=0;
while(fitpars>>pixel_address){
fitpars>>amp_vals>>mean_vals;
amp_vec.push_back(amp_vals);
mean_vec.push_back(mean_vals);
gr.push_back(new TGraph(amp_vec.size(),&amp_vec[0],&mean_vec[0]));
ctr++;
}
if(fitpars.is_open()){
while(!fitpars.eof()){
while(fitpars>>pixel_address){
// cout<<"The injected amplitudes and the corresponding mean values for "<<pixel_address<<"are : " <<std::endl;
fitpars>>injected_amplitude>>signals;
//cout<<injected_amplitude<<" "<<signals<<std::endl;
injected_amp_vec.push_back(injected_amplitude);
signals_vec.push_back(signals);
for(int i=0;i<3;i++){
gr.push_back(new TGraph(injected_amp_vec.size(),&(injected_amp_vec[i]),&(signals_vec[i])));
}
}
for(int j=0;j<256;j++){
auto linear_fit = new TF1("linear_fit","[0]*x +[1]",0,300);
linear_fit->SetParNames("slope","offset");
linear_fit->SetParameter(0,2);
linear_fit->SetParameter(1,1200);
linear_fit->SetLineColor(2);
gr.at(j)->Fit(linear_fit);
gr.at(j)->Draw("AL*");
gr.at(j)->GetXaxis()->SetTitle("Injected amplitude");
gr.at(j)->GetYaxis()->SetTitle("mean values");
std::ofstream slopes;
slopes.open("slopes.txt",std::ofstream::app);
slopes<<linear_fit->GetParameter(0)<<" ";
for(ctr=0;ctr<amp_vec.size();ctr++){
if(ctr%3==0&&ctr>=0&&ctr<amp_vec.size()){
for(k=ctr;k<ctr+3;k++){
gr2->SetPoint(gr.at(k)->GetN(),amp_vec[k],mean_vec[k]);
}
gr3.push_back(gr2);
}
}
cout<<gr3.size()<<std::endl;
for(int j=0;j<gr3.size();j++){
auto linear_fit = new TF1("linear_fit","[0]*x +[1]",0,300);
linear_fit->SetParNames("slope","offset");
linear_fit->SetParameter(0,2);
linear_fit->SetParameter(1,1200);
linear_fit->SetLineColor(2);
gr3.at(j)->Fit(linear_fit);
gr3.at(j)->SetTitle("injected voltage vs mean vals for 256 graphs ");
gr3.at(j)->GetXaxis()->SetTitle("injected voltage");
gr3.at(j)->GetYaxis()->SetTitle("mean vals");
gr3.at(j)->Draw("A*");
std::ofstream slopes;
slopes.open("slopes.txt",std::ofstream::app);
slopes<<linear_fit->GetParameter(0)<<" ";
}
}
void slope_distribution(int y)
{
ifstream slopes("slopes.txt");
double slopeval;
TH1D* hist = new TH1D("slope","slope distribution",200,-2.0,10.0);
TH1D* hist = new TH1D("slope","slope distribution",200,-0.24540,-.24510);
if(slopes.is_open()){
while(!slopes.eof()){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment