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

all the histograms are globally defined.

parent 621efaf1
...@@ -4,9 +4,18 @@ const int namplitudes = 3; ...@@ -4,9 +4,18 @@ const int namplitudes = 3;
int nbins = 450; int nbins = 450;
double xmin=850.0,xmax = 1750.0; double xmin=850.0,xmax = 1750.0;
TH1D *hist_255[namplitudes]; TH1D *hist_255[namplitudes];
hist_255[0] = new TH1D("hist_255_amp03","Threshold gain measurement",nbins, xmin, xmax);
hist_255[1] = new TH1D("hist_255_amp02","Threshold gain measurement",nbins, xmin, xmax);
hist_255[2] = new TH1D("hist_255_amp01","Threshold gain measurement",nbins, xmin, xmax);
int colors[namplitudes]={kAzure,kRed,kViolet}; int colors[namplitudes]={kAzure,kRed,kViolet};
int markers[namplitudes]={2, 3, 5}; int markers[namplitudes]={2, 3, 5};
...@@ -20,20 +29,20 @@ double fitmax[namplitudes]={1700.,1420.,1240.}; ...@@ -20,20 +29,20 @@ double fitmax[namplitudes]={1700.,1420.,1240.};
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// The function fit_1d sets the cosmetics for the histograms/ // The function fit_1d sets the cosmetics for the histograms/
// and fits the histogram with modified erf function. / // and fits the histogram with modified erf function. /
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
//TH1D *fit_1d(TH1D *hist_255, int i,int j, double low_limit, double up_limit) //TH1D *fit_1d(TH1D *hist_255, int i,int j, double low_limit, double up_limit)
TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[namplitudes],int amp, double fitmin[namplitudes],double fitmax[namplitudes]) TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[namplitudes],int amp, double fitmin[namplitudes],double fitmax[namplitudes])
{ {
hist_255[namplitudes]->GetXaxis()->SetTitle("Threshold"); hist_255[namplitudes]->GetXaxis()->SetTitle("Threshold");
hist_255[namplitudes]->GetYaxis()->SetTitle("#signals above the threshold"); hist_255[namplitudes]->GetYaxis()->SetTitle("#signals above the threshold");
hist_255[namplitudes]->SetMarkerColor(namplitudes); hist_255[namplitudes]->SetMarkerColor(namplitudes);
hist_255[namplitudes]->SetMarkerStyle(namplitudes); hist_255[namplitudes]->SetMarkerStyle(namplitudes);
// hist_255->SetMarkerStyle(i+1); // hist_255->SetMarkerStyle(i+1);
// hist_255->SetMarkerColor(i+2); // hist_255->SetMarkerColor(i+2);
...@@ -43,7 +52,7 @@ TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[nam ...@@ -43,7 +52,7 @@ TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[nam
fitfunc->SetParNames("constant","mean","noise"); fitfunc->SetParNames("constant","mean","noise");
//Assigning Initial values to the parameters //Assigning Initial values to the parameters
fitfunc->SetParameter(0,200.0); fitfunc->SetParameter(0,200.0);
int lastbin1 = hist_255[namplitudes]->FindLastBinAbove(200); int lastbin1 = hist_255[namplitudes]->FindLastBinAbove(200);
...@@ -70,18 +79,6 @@ TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[nam ...@@ -70,18 +79,6 @@ TH1D *fit_1d(TH1D *hist_255[namplitudes],int colors[namplitudes],int markers[nam
void gain_measurement() void gain_measurement()
{ {
//Initialising the histograms.
hist_255[0] = new TH1D("hist_255_amp03","Threshold gain measurement",nbins, xmin, xmax);
hist_255[1] = new TH1D("hist_255_amp02","Threshold gain measurement",nbins, xmin, xmax);
hist_255[2] = new TH1D("hist_255_amp01","Threshold gain measurement",nbins, xmin, xmax);
cout<<"THe histograms initialised..."<<std::endl;
/*TH1D *hist_255_amp03 = new TH1D("hist_255_amp03"," Threshold gain measurement",500,850,1750);
TH1D *hist_255_amp02 = new TH1D("hist_255_amp02"," Threshold gain measurement",500,850,1750);
TH1D *hist_255_amp01 = new TH1D("hist_255_amp01"," Threshold gain measurement",500,850,1750);*/
//Initialising the trees. //Initialising the trees.
TTree *tree1 = new TTree("tree1", "tree1"); TTree *tree1 = new TTree("tree1", "tree1");
...@@ -94,22 +91,19 @@ void gain_measurement() ...@@ -94,22 +91,19 @@ void gain_measurement()
tree2->ReadFile("amp02_255_255.dat", "x/D:y/D"); tree2->ReadFile("amp02_255_255.dat", "x/D:y/D");
tree3->ReadFile("amp01_255_255.dat", "x/D:y/D"); tree3->ReadFile("amp01_255_255.dat", "x/D:y/D");
cout<<"The data is stored into the trees from the file..."<<std::endl; cout<<"The data is stored into the trees from the file..."<<std::endl;
tree1->Draw("x>>hist_255[0]","y","HIST P "); tree1->Draw("x>>hist_255[0]","y","HIST P ");
tree2->Draw("x>>hist_255[1]","y","HIST SAME P "); tree2->Draw("x>>hist_255[1]","y","HIST SAME P ");
tree3->Draw("x>>hist_255[2]","y","HIST SAME P "); tree3->Draw("x>>hist_255[2]","y","HIST SAME P ");
cout<<"The histograms are plotted.."<<std::endl; cout<<"The histograms are plotted.."<<std::endl;
for (int iamp=0; iamp<3;iamp++) for (int iamp=0; iamp<3;iamp++)
{ {
fit_1d(&hist_255[iamp],&colors[iamp],&markers[iamp],iamp, &fitmin[iamp], &fitmax[iamp]); fit_1d(&hist_255[iamp],&colors[iamp],&markers[iamp],iamp, &fitmin[iamp], &fitmax[iamp]);
} }
cout<<"The fiiting function is called three times..."<<std::endl; cout<<"The fiiting function is called three times..."<<std::endl;
/* fit_1d(hist_255_amp03,1,3,1220.0,1700.0);
fit_1d(hist_255_amp02,2,2,1200.0,1420.0);
fit_1d(hist_255_amp01,3,1,1150.0,1240.0);*/
//Drawing the legend //Drawing the legend
...@@ -129,6 +123,15 @@ void gain_measurement() ...@@ -129,6 +123,15 @@ void gain_measurement()
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