#include "TCanvas.h" #include "TGraph.h" #include "TF1.h" #include "TFile.h" #include "TH1.h" #include "TStyle.h" #include "TROOT.h" #include "TStyle.h" #include "TAxis.h" #include "TMath.h" #include "TAxis.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TPad.h" #include "TLatex.h" #include "TApplication.h" double mean_rms(double* input_array, int n, double& rms) { double mean = 0; rms = 0; for(int i = 0; iSetOptStat(1); char data_dir[512]; int input_offset = 2; sprintf(data_dir,"./results/%s",gApplication->Argv(input_offset)); int correction_flag = atoi(gApplication->Argv(1+input_offset)); int save_flag = atoi(gApplication->Argv(2+input_offset)); cout<<"Reading data in "<Divide(2,3); // light intensity: 12.78 photons/mm^2, for each tile 9 mm^2 => 115 photon/tile, // percentage double l_input[5] = {0., 0.0160,0.0269,0.0528,0.0778}; for(int i = 0; iSetMarkerStyle(20+i); gr[i]->SetMarkerColor(col[i]); gr[i]->SetLineColor(col[i]); gr[i]->GetXaxis()->SetLimits(-1,10); sprintf(grtitle,"%s; Number of Photons; %s",title[i],ytitle[i]); gr[i]->SetTitle(grtitle); c1->cd(i+1); gPad->SetGridx(1); gPad->SetGridy(1); gr[i]->Draw("AP"); if(i == 0) { gr[i]->Fit("pol1","Q"); gr[i]->GetFunction("pol1")->SetLineColor(col[i]); gr[i]->GetFunction("pol1")->SetLineWidth(2); } else { gr[i]->Fit("pol0","Q"); gr[i]->GetFunction("pol0")->SetLineColor(col[i]); gr[i]->GetFunction("pol0")->SetLineWidth(2); } } // Fit Uniformity Variables TCanvas* c2 = new TCanvas("c2","",1200,800); c2->Divide(4,4); // get parameters for each channels TGraph* tmp_gr[16]; double tmp_rms; for(int i = 0; icd(i+1); // dark noise and PDE tmp_gr[i] = new TGraph(nf, l_input, data[i][0]); sprintf(grtitle,"Ch#%02d; Number of photons; Number of Pixels",i); tmp_gr[i]->SetTitle(grtitle); tmp_gr[i]->GetXaxis()->SetLimits(-1,10); tmp_gr[i]->SetMarkerStyle(4); tmp_gr[i]->SetMarkerColor(2); tmp_gr[i]->Fit("pol1","Q"); tmp_gr[i]->GetFunction("pol1")->SetLineWidth(1); // Chage hits to rate by dividing gate uniformity[0][i] = tmp_gr[i]->GetFunction("pol1")->GetParameter(0)*1000./condition[4][0]; uniformity[1][i] = tmp_gr[i]->GetFunction("pol1")->GetParameter(1); // PDE uniformity[2][i] = mean_rms(data[i][1],nf,tmp_rms); // gain uniformity[3][i] = mean_rms(data[i][3],nf,tmp_rms); // x-talk tmp_gr[i]->Draw("AP"); } for(int i = 0; i<4; i++) uni_mean[i] = mean_rms(uniformity[i],nc,uni_rms[i]); // Plot Uniformities TCanvas* c3 = new TCanvas("c3","",800,600); c3->Divide(2,2); TGraph* bar_gr[4]; double channel[16]; double norm_uni[16]; for(int i = 0; icd(i+1); gPad->SetGridy(1); // for(int j = 0; jSetTitle(grtitle); bar_gr[i]->SetFillColor(col_bar[i]); bar_gr[i]->GetXaxis()->SetLimits(-1,nc); bar_gr[i]->Draw("AB"); if(i == 1||i ==2) { bar_gr[i]->SetMinimum(-0.15); bar_gr[i]->SetMaximum(0.15); } else { bar_gr[i]->SetMinimum(-0.4); bar_gr[i]->SetMaximum(0.4); } sprintf(grtitle,"%.3f #pm %.1f%% %s",uni_mean[i],uni_rms[i]*100/uni_mean[i],bar_unit[i]); if(i == 1||i ==2) { ltext.DrawLatex(nc*.2, 0.12, grtitle); } else ltext.DrawLatex(nc*.2, 0.32, grtitle); c3->Update(); } // Save data char tale[2][20] = {"_nc",""}; if(save_flag) { char fname[512]; sprintf(fname,"%s/Parameters%s.png",data_dir,tale[correction_flag]); c1->Print(fname); sprintf(fname,"%s/PDE_Fit%s.png",data_dir,tale[correction_flag]); c2->Print(fname); sprintf(fname,"%s/Uniformity%s.png",data_dir,tale[correction_flag]); c3->Print(fname); sprintf(fname,"%s/Summary%s.txt",data_dir,tale[correction_flag]); FILE* summary = fopen(fname,"w"); fprintf(summary,"PhotonInput\t npe\t npe_e\t gain(x10^5)\t gain_e\t pedestal\t ped_e\t xtalk\t xtalk_e\t sigma\t sig_e\t sigma_p\t sig_p_e\n"); for(int i = 0; i