Commit 99eced95 authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

codes for gain measurement. The fitting doesnt work properly.

parents
void gain_measurement()
{
ifstream file_255;
file_255.open("255_255.dat");
cout<<"The data file 255_255 is opened..."<<std::endl;
TCanvas *c1 = new TCanvas();
TTree *tree = new TTree("tree", "tree");
TH1D *hist_255 = new TH1D("hist_255"," Threshold gain measurement",100,900,1300);
tree->ReadFile("255_255.dat", "x/D:y/D");
tree->SetEstimate(-1);//Set the #entries to estimate variable limits. n=-1, estimate is set to current maximum of the tree.
tree->Draw("x>>hist_255","y","HIST");
hist_255->GetXaxis()->SetTitle("Threshold");
hist_255->GetYaxis()->SetTitle("# signals above the threshold");
//fitting the histogram with modified error function
TF1 *modified_erf = new TF1("modified_erf","[0]*(1-TMath::Erf((x-[1])/(sqrt(2)*[2])))",1000,1250);//Not sure how to give the fit range
modified_erf->SetParameter(0,100);
modified_erf->SetParameter(1,1115);
modified_erf->SetParameter(2,0);//Not sure how to give the initial value
modified_erf->SetParNames("constant","mean","noise");
hist_255->Fit("modified_erf");
hist_255->Draw();
//file_255.close();
cout<<"Code succesfull..."<<std::endl;
}
Supports Markdown
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