Commit 76fb2d50 authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

Codes for plotting 2d distribution of bl, rms. The profile histogram and...

Codes for plotting 2d distribution of bl, rms. The profile histogram and projections are also plotted together
parent 30bd3c0b
void profilehist(){
double row, col;
TCanvas* c1 = new TCanvas("c1");
// std::string hist_name = "h" + std::to_string(row) + "_" + std::to_string(col);
TH2D* histo_bl = new TH2D("histo_bl", "Baseline distribution",256,0.,256.,256,0.,256.);
TH2D* histo_rms = new TH2D("histo_rms", "Noise distribution",256,0.,256.,256,0.,256.);
for (row = 0; row < 256; row++){
for(col = 0; col < 256; col++){
stringstream foldername, filename;
foldername << std::setw(3) << std::setfill('0') << row;
// std::cout << " Foldername : " << foldername.str()<< std::endl;
filename << std::setw(3) << std::setfill('0') << row << "_"
<< std::setw(3) << std::setfill('0') << col << ".dat";
//cout << "Filename : " << filename.str() << std::endl;
std::ifstream infile(foldername.str()+"/"+filename.str());
if(infile.is_open()){
// std::cout<<"The data file is opened..."<<std::endl;
std::string line;
double avr=0.,rms=0.;
while(!infile.eof()){
std::getline(infile,line);
if(line.rfind("#",0)!=0){
continue;
}
// cout<<"original line : " <<line<<std::endl;
std::string newline = " ";
for(int i=0;i<line.length();i++){
if(line[i]!=':'){
newline=newline+line[i];
}
else{
newline=newline+line[i]+" ";
}
}
// cout<<"The new line with spaces " <<newline<<std::endl;
std::stringstream s;
s<<newline;
//cout<<"The line is stored in the stringstream object..."<<std::endl;
string temp;
double num=0.;
double arr[2]={ };
int i=0;
while(!s.eof()){
s>>temp;
if(std::stringstream(temp)>>num){
//cout<<num<<std::endl;
arr[i] =num;
i++;
}
temp = " ";
}
avr = arr[0];
rms = arr[1];
}
// cout << " avr : " << avr << " " << " rms : " << rms << std::endl;
if(avr >= 0 && rms >=0){
histo_bl->Fill(row,col,avr);
histo_rms->Fill(row,col,rms);
}
/* else{
cout<< " Foldername : " << foldername.str() << " " << " filename : " << filename.str() << " "
<< " avr : " << avr << " " << " rms : " << rms << std::endl;
}*/
}
else{
cout<<"Error..."<<std::endl;
}
}
}
c1->Divide(2,3);
c1->cd(1);
histo_bl->SetStats(0);
// gStyle->SetOptStat(111100);
histo_bl->Draw("COLZ");
histo_bl->GetXaxis()->SetTitle("Row");
histo_bl->GetYaxis()->SetTitle("Column");
histo_bl->GetZaxis()->SetTitle("Baseline");
histo_bl->GetZaxis()->SetRangeUser(1000,1200);
c1->cd(2);
histo_rms->SetStats(0);
// gStyle->SetOptStat(111100);
histo_rms->Draw("COLZ");
histo_rms->GetXaxis()->SetTitle("Row");
histo_rms->GetYaxis()->SetTitle("Column");
histo_rms->GetZaxis()->SetTitle("Noise");
histo_rms->GetZaxis()->SetRangeUser(5,25);
c1->cd(3);
TProfile *px = histo_rms->ProfileX("px",0.,256.);
px->Draw("HIST");
c1->cd(4);
TProfile *py = histo_rms->ProfileY("py",0.,256.);
py->Draw("HIST");
c1->cd(5);
TH1D *projx = histo_rms->ProjectionX("projx", 0., 256.);
projx->Draw("HIST");
c1->cd(6);
TH1D *projy = histo_rms->ProjectionY("projy", 0., 256.);
projy->Draw("HIST");
}
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