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

Codes for gain measurements when test pulses with low,mid and high amplitudes...

Codes for gain measurements when test pulses with low,mid and high amplitudes are injected to the pixel frontend. The noise data is yet to be incorporated
parent 524ef7ec
......@@ -7,8 +7,8 @@ double xmin=850.0,xmax = 1750.0,nbins=450.0;
void fit_1d(TH1D* hist_255,int colors,int markers,int amplitude,double fitmin,double fitmax)
{
hist_255->GetXaxis()->SetTitle("Threshold");
hist_255->GetYaxis()->SetTitle("# signals above the threshold");
// hist_255->GetXaxis()->SetTitle("Threshold");
// hist_255->GetYaxis()->SetTitle("# signals above the threshold");
hist_255->SetMarkerColor(colors);
hist_255->SetMarkerStyle(markers);
......@@ -51,11 +51,12 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
//double xmin=850.0,xmax = 1750.0;
std::vector<int>colors={kAzure,kTeal+3,kViolet+3};
std::vector<int>markers={2,3,5};
std::vector<int>markers={1,1,1};
std::vector<double>fitmin ={1220.,1200.,1150.};
std::vector<double>fitmax={1700.,1420.,1240.};
std::vector<TH1D*> hist_255;
//The data files are named as following : 000_000.dat to 256_256.dat
stringstream sfilename;
sfilename << std::setw(3) << std::setfill('0') << i << "_"
<< std::setw(3) << std::setfill('0') << j <<".dat";
......@@ -69,14 +70,14 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
for(int amp = 0; amp < 3; amp++) {
std::ifstream amplitude_file(filenames.at(amp).c_str());
if(amplitude_file.is_open()) {
cout<<"The data file " << filenames.at(amp)<< " is opened..."<<std::endl;
std::string hist_name = "h" + std::to_string(amp) + "_" + std::to_string(j);
TH1D* h1 = new TH1D(hist_name.c_str(),"Threshold gain measurement",nbins,xmin,xmax);
std::string line;
while(!amplitude_file.eof()) {
std::getline(amplitude_file, line);
......@@ -88,7 +89,7 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
s >> x >> y;
h1->Fill(x,y);
}
hist_255.push_back(h1);
} else {
......@@ -96,15 +97,6 @@ std::vector<TH1D*> gain_measurement_pixel(int i, int j)
}
fit_1d(hist_255.at(amp),colors.at(amp),markers.at(amp),amp,fitmin.at(amp),fitmax.at(amp));
}
TLegend *leg = new TLegend(0.7,0.7,0.9,0.9);
leg->AddEntry(hist_255.at(0), "high amplitude","p");
leg->AddEntry(hist_255.at(1),"mid amplitude","p");
leg->AddEntry(hist_255.at(2),"low amplitude","p");
leg->Draw();
cout<<"Done..."<<std::endl;
return hist_255;
}
......@@ -112,37 +104,50 @@ void gain_measurement()
{
int row,col;
THStack* hs = new THStack("hs", "Gain measurements");
std::vector<std::vector<TH1D*>>histograms;
// std::vector<TH1D*>histograms;
std::vector<TH1D*>pixel_histograms;
for(row=0;row<256;row++) {
for(col=0;col<256;col++) {
if(row==col) {
histograms.push_back(gain_measurement_pixel(row,col));
//cout<<"the size of histogram vector is "<<histograms.size()<<std::endl;
}
}
}
// cout<<"the size of gain measurement vector is "<<gain_measurement_pixel<<std::endl;
cout<<"the size of histogram vector is "<<histograms.size()<<std::endl;
for(int i = 0; i < histograms.size(); i++)
{
auto pixel_histograms = histograms.at(i);
cout<<"Trying to stack the histograms for pixel " << i << "..."<<std::endl;
for(int j = 0; j < pixel_histograms.size(); j++)
{
hs->Add(pixel_histograms.at(j));
}
for(int i = 0; i < histograms.size(); i++) {
pixel_histograms = histograms.at(i);
cout<<"Trying to stack the histograms for pixel " << i << "..."<<std::endl;
for(int j = 0; j < pixel_histograms.size(); j++) {
hs->Add(pixel_histograms.at(j));
}
// cout<<"The size of pixel_histogram vector is"<<pixel_histograms.size()<<std::endl;
}
cout<<"The histograms are added to the stack..."<<std::endl;
//cout<<"the size of histogram vector is "<<histograms.size()<<std::endl;
hs->Draw("HIST P nostack");
hs->Draw("HIST P nostack");
hs->GetXaxis()->SetTitle("Threshold");
hs->GetYaxis()->SetTitle("# signals above the threshold");
TLegend *leg = new TLegend(0.7,0.7,0.9,0.9);
// leg->SetBorderSize(0);
if(pixel_histograms.at(0)){
leg->AddEntry(pixel_histograms.at(0),"high amplitude","p");
}
if(pixel_histograms.at(1)){
leg->AddEntry(pixel_histograms.at(1),"mid amplitude","p");
}
if(pixel_histograms.at(2)){
leg->AddEntry(pixel_histograms.at(2),"low amplitude","p");
}
leg->Draw("SAME");
}
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