789 lines
30 KiB
C++
789 lines
30 KiB
C++
// to analyse the backplane pulsing data per module
|
|
|
|
#include "/afs/psi.ch/project/mythen/sophie/sls_detector_calibration/jungfrauCommonHeader.h"
|
|
#include "/afs/psi.ch/project/mythen/sophie/sls_detector_calibration/jungfrauCommonFunctions.h"
|
|
|
|
#include "/afs/psi.ch/project/mythen/sophie/sls_detector_calibration/jungfrauFile.C"
|
|
#include "/afs/psi.ch/project/mythen/sophie/sls_detector_calibration/jungfrauPedestal.C"
|
|
#include "/afs/psi.ch/project/mythen/sophie/sls_detector_calibration/jungfrauPixelMask.C"
|
|
|
|
#include "TGraphErrors.h"
|
|
#include "TF1.h"
|
|
#include "TPaveStats.h"
|
|
#include "TFile.h"
|
|
#include "TLegend.h"
|
|
#include "TPaveText.h"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
jungfrauStyle();
|
|
gROOT->SetBatch(1);
|
|
gStyle->SetOptFit(11);
|
|
|
|
if (argc != 2) {
|
|
cout << "Correct usage:" << endl;
|
|
cout << "arg 1: specify module number" << endl;
|
|
exit(1);
|
|
}
|
|
|
|
string module_str = argv[1];
|
|
|
|
int createHistos = 0;
|
|
|
|
jungfrauFile *thisfile = new jungfrauFile();
|
|
|
|
jungfrauPixelMask *pixelMaskObject = new jungfrauPixelMask();
|
|
static int pixel_mask[NCH];
|
|
pixelMaskObject->initialisePixelMask(pixel_mask);
|
|
if (module_str == "006") {
|
|
pixelMaskObject->maskChip(6, pixel_mask);
|
|
pixelMaskObject->maskSupercolumn(4,1, pixel_mask);
|
|
pixelMaskObject->maskSupercolumn(4,2, pixel_mask);
|
|
} else if (module_str == "040") {
|
|
pixelMaskObject->maskSupercolumn(4,2, pixel_mask);
|
|
} else if (module_str == "065") {
|
|
pixelMaskObject->maskChip(5,pixel_mask);
|
|
}
|
|
|
|
jungfrauPedestal *pedestalObjectG0 = new jungfrauPedestal();
|
|
pedestalObjectG0->pedestalSetNFrames(100); // using 100 frames, rolling window
|
|
jungfrauPedestal *pedestalObjectG1 = new jungfrauPedestal();
|
|
pedestalObjectG1->pedestalSetNFrames(100); // using 100 frames, rolling window
|
|
|
|
TH2F* avg_adcG0_map [220];
|
|
TH2F* avg_adcG0er_map [220];
|
|
TH2F* avg_adcG1_map [220];
|
|
TH2F* avg_adcG1er_map [220];
|
|
|
|
char savename[128];
|
|
char filename[128];
|
|
|
|
double xs[220];
|
|
for (int i = 0; i < 100; i++) {
|
|
xs[i] = (i+1)*10.;
|
|
}
|
|
for (int i = 0; i < 120; i++) {
|
|
xs[i+100] = 1000+((i+1)*50);
|
|
}
|
|
|
|
TCanvas *mapcanvas = new TCanvas("mapcanvas","",150,10,800,400);
|
|
mapcanvas->SetLeftMargin(0.1);
|
|
mapcanvas->SetRightMargin(0.13);
|
|
mapcanvas->SetTopMargin(0.08);
|
|
mapcanvas->SetBottomMargin(0.15);
|
|
|
|
TH1F* g0_grad_hist = new TH1F("g0_grad_hist","",100,5,10);
|
|
TH1F* g0_grader_hist = new TH1F("g0_grader_hist","",100,0,0.002);
|
|
|
|
TH1F* g1_grad_hist = new TH1F("g1_grad_hist","",100,-0.3,-0.15);
|
|
TH1F* g1_grader_hist = 0;
|
|
if (module_str == "006") {
|
|
g1_grader_hist = new TH1F("g1_grader_hist","",100,0,0.001);
|
|
} else {
|
|
g1_grader_hist = new TH1F("g1_grader_hist","",100,0,0.0001);
|
|
}
|
|
|
|
TH2F* pixelmask_map = new TH2F("pixelmask_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
TH2F* g0_grad_map = new TH2F("g0_grad_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
TH2F* g0_grader_map = new TH2F("g0_grader_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
TH2F* g1_grad_map = new TH2F("g1_grad_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
TH2F* g1_grader_map = new TH2F("g1_grader_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
TH1F* g0_const_hist = new TH1F("g0_const_hist","",100,1000,4000);
|
|
TH1F* g0_conster_hist = new TH1F("g0_conster_hist","",100,0,0.5);
|
|
|
|
TH1F* g1_const_hist = new TH1F("g1_const_hist","",100,10000,15000);
|
|
TH1F* g1_conster_hist = 0;
|
|
if (module_str == "006") {
|
|
g1_conster_hist = new TH1F("g1_conster_hist","",100,0,10);
|
|
} else {
|
|
g1_conster_hist = new TH1F("g1_conster_hist","",100,0,1);
|
|
}
|
|
|
|
TH2F* g0_const_map = new TH2F("g0_const_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
TH2F* g0_conster_map = new TH2F("g0_conster_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
TH2F* g1_const_map = new TH2F("g1_const_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
TH2F* g1_conster_map = new TH2F("g1_conster_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
if (createHistos == 1) {
|
|
|
|
for (int j = 0; j < 220; j++) {
|
|
sprintf(savename,"avg_adcG0_map_%d", j);
|
|
avg_adcG0_map[j] = new TH2F(savename,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
sprintf(savename,"avg_adcG0er_map_%d", j);
|
|
avg_adcG0er_map[j] = new TH2F(savename,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
sprintf(savename,"avg_adcG1_map_%d", j);
|
|
avg_adcG1_map[j] = new TH2F(savename,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
sprintf(savename,"avg_adcG1er_map_%d", j);
|
|
avg_adcG1er_map[j] = new TH2F(savename,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
}
|
|
|
|
// data file
|
|
if (module_str == "006") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_006_vbackpulse/scan4_170217_%%6.6d.dat");
|
|
} else if (module_str == "021") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_021_vbackpulse/bpp_scan1_20170303_%%6.6d.dat");
|
|
} else if (module_str == "022") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_022_vbackpulse/bpp_scan1_20170303_%%6.6d.dat");
|
|
} else if (module_str == "027") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_027_Calib/BP_180322_scan4_%%6.6d.dat");
|
|
} else if (module_str == "040") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_040_Calib/BP_240322_scan_%%6.6d.dat");
|
|
} else if (module_str == "044") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_044_vbackpulse/bpp_scan2_20170303_%%6.6d.dat");
|
|
} else if (module_str == "045") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data/Module_045_Calib/BP_HS_NF_500Hz_scan3_%%6.6d.dat");
|
|
} else if (module_str == "055") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_055_2017-09-21_Calib/VbackplanePulsing_scan1_%%6.6d.dat");
|
|
} else if (module_str == "065") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_065_2017-08-29_Calib/Vbackplane_scan1%%6.6d.dat");
|
|
} else if (module_str == "069") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_069_2017-09-18_Calib/vbackpulse_scan1_%%6.6d.dat");
|
|
} else if (module_str == "079") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_079_2017-09-18_Calib/vbackpulse_scan1_%%6.6d.dat");
|
|
} else if (module_str == "068") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_068_2017-09-19_Calib/VbackplanePulsing_scan1_%%6.6d.dat");
|
|
} else if (module_str == "088") {
|
|
sprintf(filename,"/mnt/pcmoench_jungfrau_data1_ib/Module_088_2017-09-19_Calib/VbackplanePulsing_scan1_%%6.6d.dat");
|
|
}
|
|
|
|
int framecounter = 0;
|
|
|
|
for (int filei = 0; filei < 3; filei++) {
|
|
|
|
thisfile->open((char*)filename, filei);
|
|
|
|
while(thisfile->readNextFrame()) {
|
|
framecounter++;
|
|
}
|
|
|
|
thisfile->close();
|
|
}
|
|
|
|
cout << "framecounter " << framecounter << endl;
|
|
// ok for 006 021 022 044
|
|
// 027: 21799, 040: 21899
|
|
if (framecounter != 21999) {
|
|
cout << "WARNING unexpected number of frames" << endl;
|
|
cout << "WARNING code expected 21999 frames" << endl;
|
|
}
|
|
|
|
framecounter = 0;
|
|
|
|
for (int filei = 0; filei < 3; filei++) {
|
|
|
|
thisfile->open((char*)filename, filei);
|
|
|
|
while(thisfile->readNextFrame()) {
|
|
|
|
pedestalObjectG0->addG0FrameToPedestalCalculation(thisfile->getFrameDataHandle());
|
|
pedestalObjectG1->addG1FrameToPedestalCalculation(thisfile->getFrameDataHandle());
|
|
|
|
if (((framecounter+1)%100 == 0) || (framecounter == 21998)) {
|
|
if (framecounter == 21998) {
|
|
framecounter++;
|
|
}
|
|
|
|
for (int i = 0; i < NCH; i++) {
|
|
if (pixel_mask[i] == 1) {
|
|
|
|
avg_adcG0_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG0->pedestalOfChannel(i));
|
|
avg_adcG0er_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG0->semOfChannel(i));
|
|
|
|
avg_adcG1_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG1->pedestalOfChannel(i));
|
|
avg_adcG1er_map[framecounter/100]->SetBinContent((i%NC)+1,(i/NC)+1,pedestalObjectG1->semOfChannel(i));
|
|
|
|
}
|
|
}
|
|
|
|
pedestalObjectG0->pedestalClear();
|
|
pedestalObjectG1->pedestalClear();
|
|
|
|
avg_adcG0_map[framecounter/100]->GetXaxis()->SetTitle("Column");
|
|
avg_adcG0_map[framecounter/100]->GetYaxis()->SetTitle("Row");
|
|
avg_adcG0_map[framecounter/100]->GetYaxis()->SetTitleOffset(0.7);
|
|
avg_adcG0_map[framecounter/100]->GetZaxis()->SetRangeUser(0,17000);
|
|
avg_adcG0_map[framecounter/100]->Draw("colz");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/perStep/adc_g0_map_%d.png", module_str.c_str(), framecounter/100);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
avg_adcG0er_map[framecounter/100]->GetXaxis()->SetTitle("Column");
|
|
avg_adcG0er_map[framecounter/100]->GetYaxis()->SetTitle("Row");
|
|
avg_adcG0er_map[framecounter/100]->GetYaxis()->SetTitleOffset(0.7);
|
|
avg_adcG0er_map[framecounter/100]->GetZaxis()->SetRangeUser(0,5);
|
|
avg_adcG0er_map[framecounter/100]->Draw("colz");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/perStep/adcer_g0_map_%d.png", module_str.c_str(), framecounter/100);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
avg_adcG1_map[framecounter/100]->GetXaxis()->SetTitle("Column");
|
|
avg_adcG1_map[framecounter/100]->GetYaxis()->SetTitle("Row");
|
|
avg_adcG1_map[framecounter/100]->GetYaxis()->SetTitleOffset(0.7);
|
|
avg_adcG1_map[framecounter/100]->GetZaxis()->SetRangeUser(0,17000);
|
|
avg_adcG1_map[framecounter/100]->Draw("colz");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/perStep/adc_g1_map_%d.png", module_str.c_str(), framecounter/100);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
avg_adcG1er_map[framecounter/100]->GetXaxis()->SetTitle("Column");
|
|
avg_adcG1er_map[framecounter/100]->GetYaxis()->SetTitle("Row");
|
|
avg_adcG1er_map[framecounter/100]->GetYaxis()->SetTitleOffset(0.7);
|
|
avg_adcG1er_map[framecounter/100]->GetZaxis()->SetRangeUser(0,20);
|
|
avg_adcG1er_map[framecounter/100]->Draw("colz");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/perStep/adcer_g1_map_%d.png", module_str.c_str(), framecounter/100);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
}
|
|
|
|
framecounter++;
|
|
}
|
|
thisfile->close();
|
|
} // end of files
|
|
|
|
// save histograms
|
|
sprintf(savename,"/mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/M%s_CalibAna/BP_histos_M%s.root", module_str.c_str(), module_str.c_str());
|
|
TFile* saved_file = new TFile((const char *)(savename),"RECREATE");
|
|
|
|
for (int i = 0; i < 220; i++) {
|
|
avg_adcG0_map[i]->Write();
|
|
avg_adcG1_map[i]->Write();
|
|
avg_adcG0er_map[i]->Write();
|
|
avg_adcG1er_map[i]->Write();
|
|
}
|
|
saved_file->Close();
|
|
|
|
} else {
|
|
// load histos
|
|
cout << "LOADING HISTOS" << endl;
|
|
sprintf(savename,"/mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/M%s_CalibAna/BP_histos_M%s.root", module_str.c_str(), module_str.c_str());
|
|
TFile* saved_file = new TFile((const char *)(savename),"READ");
|
|
|
|
for (int i = 0; i < 220; i++) {
|
|
sprintf(savename,"avg_adcG0_map_%d", i);
|
|
avg_adcG0_map[i] = (TH2F*)saved_file->Get((const char *)(savename));
|
|
sprintf(savename,"avg_adcG1_map_%d", i);
|
|
avg_adcG1_map[i] = (TH2F*)saved_file->Get((const char *)(savename));
|
|
|
|
sprintf(savename,"avg_adcG0er_map_%d", i);
|
|
avg_adcG0er_map[i] = (TH2F*)saved_file->Get((const char *)(savename));
|
|
sprintf(savename,"avg_adcG1er_map_%d", i);
|
|
avg_adcG1er_map[i] = (TH2F*)saved_file->Get((const char *)(savename));
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < NCH; i++) {
|
|
|
|
if (i%100000==0) {cout << "another 100k" << endl;}
|
|
|
|
if (pixel_mask[i] == 1) {
|
|
|
|
vector<double> r0_adc;
|
|
vector<double> r0_filter;
|
|
vector<double> r0_adcerr;
|
|
vector<double> r0_ferr;
|
|
|
|
vector<double> r1_adc;
|
|
vector<double> r1_filter;
|
|
vector<double> r1_adcerr;
|
|
vector<double> r1_ferr;
|
|
|
|
for (int j = 0; j < 220; j++) {
|
|
|
|
double this_avgG0 = avg_adcG0_map[j]->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
double this_avgG0er = avg_adcG0er_map[j]->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
|
|
if (this_avgG0 != 0 && this_avgG0er > 0) {
|
|
r0_adc.push_back(this_avgG0);
|
|
r0_filter.push_back(xs[j]);
|
|
r0_adcerr.push_back(this_avgG0er);
|
|
r0_ferr.push_back(0.);
|
|
}
|
|
|
|
double this_avgG1 = avg_adcG1_map[j]->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
double this_avgG1er = avg_adcG1er_map[j]->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
|
|
if (this_avgG1 != 0 && this_avgG1er > 0) {
|
|
r1_adc.push_back(this_avgG1);
|
|
r1_filter.push_back(xs[j]);
|
|
r1_adcerr.push_back(this_avgG1er);
|
|
r1_ferr.push_back(0.);
|
|
}
|
|
}
|
|
|
|
if (r0_adc.size() > 1 && r1_adc.size() > 1) {
|
|
|
|
double g0max = 0.9 * (*max_element(r0_filter.begin(),r0_filter.end()));
|
|
double g1min = 1.5 * (*min_element(r1_filter.begin(),r1_filter.end()));
|
|
|
|
int data_in_range_g0 = 0;
|
|
for (size_t j = 0; j < r0_filter.size(); j++) {
|
|
if (r0_filter[j] >= 0 && r0_filter[j] <= g0max) {
|
|
data_in_range_g0++;
|
|
}
|
|
}
|
|
int data_in_range_g1 = 0;
|
|
for (size_t j = 0; j < r1_filter.size(); j++) {
|
|
if (r1_filter[j] >= g1min && r1_filter[j] <= 7000) {
|
|
data_in_range_g1++;
|
|
}
|
|
}
|
|
|
|
if (data_in_range_g0 > 1 && data_in_range_g1 > 1) {
|
|
|
|
TGraphErrors *grap0 = new TGraphErrors(r0_adc.size(),&(r0_filter[0]),&(r0_adc[0]),&(r0_ferr[0]),&(r0_adcerr[0]));
|
|
TGraphErrors *grap1 = new TGraphErrors(r1_adc.size(),&(r1_filter[0]),&(r1_adc[0]),&(r1_ferr[0]),&(r1_adcerr[0]));
|
|
|
|
grap0->Fit("pol1","QRC","",0,g0max);
|
|
TF1 *g0_fit = (TF1*) grap0->GetFunction("pol1");
|
|
|
|
grap1->Fit("pol1","QRC","",g1min,7000);
|
|
TF1 *g1_fit = (TF1*) grap1->GetFunction("pol1");
|
|
|
|
g0_grad_hist->Fill(g0_fit->GetParameter(1));
|
|
g0_grader_hist->Fill(g0_fit->GetParError(1));
|
|
g0_grad_map->Fill(i%NC,i/NC,g0_fit->GetParameter(1));
|
|
g0_grader_map->Fill(i%NC,i/NC,g0_fit->GetParError(1));
|
|
g0_const_hist->Fill(g0_fit->GetParameter(0));
|
|
g0_conster_hist->Fill(g0_fit->GetParError(0));
|
|
g0_const_map->Fill(i%NC,i/NC,g0_fit->GetParameter(0));
|
|
g0_conster_map->Fill(i%NC,i/NC,g0_fit->GetParError(0));
|
|
|
|
g1_grad_hist->Fill(g1_fit->GetParameter(1));
|
|
g1_grader_hist->Fill(g1_fit->GetParError(1));
|
|
g1_grad_map->Fill(i%NC,i/NC,g1_fit->GetParameter(1));
|
|
g1_grader_map->Fill(i%NC,i/NC,g1_fit->GetParError(1));
|
|
g1_const_hist->Fill(g1_fit->GetParameter(0));
|
|
g1_conster_hist->Fill(g1_fit->GetParError(0));
|
|
g1_const_map->Fill(i%NC,i/NC,g1_fit->GetParameter(0));
|
|
g1_conster_map->Fill(i%NC,i/NC,g1_fit->GetParError(0));
|
|
|
|
if ((i >= 58000 && i < 58000+10) || // bulk
|
|
(i >= 10 && i < 10+10) || // edge
|
|
(i >= 1024+10 && i < 1024+10+10) || // inner edge
|
|
(i >= (256*1024)+10 && i < (256*1024)+10+10) || // double
|
|
(i >= (257*1024)+10 && i < (257*1024)+10+10) || // next to double
|
|
(i == (255*1024)+255) // quad
|
|
) {
|
|
|
|
string pixel_type = "x";
|
|
if (i >= 58000 && i < 58000+10) {
|
|
pixel_type = "b";
|
|
} else if (i >= 10 && i < 10+10) {
|
|
pixel_type = "e";
|
|
} else if (i >= 1024+10 && i < 1024+10+10) {
|
|
pixel_type = "ie";
|
|
} else if (i >= (256*1024)+10 && i < (256*1024)+10+10) {
|
|
pixel_type = "d";
|
|
} else if (i >= (257*1024)+10 && i < (257*1024)+10+10) {
|
|
pixel_type = "ntd";
|
|
} else if (i == (255*1024)+255) {
|
|
pixel_type = "q";
|
|
}
|
|
|
|
mapcanvas->SetLeftMargin(0.13);
|
|
mapcanvas->SetRightMargin(0.05);
|
|
|
|
g0_fit->SetParName(0,"G0 const");
|
|
g0_fit->SetParName(1,"G0 grad");
|
|
g1_fit->SetParName(0,"G1 const");
|
|
g1_fit->SetParName(1,"G1 grad");
|
|
|
|
grap0->SetMarkerStyle(20);
|
|
grap0->SetMarkerColor(kBlue);
|
|
grap0->GetXaxis()->SetTitle("Pulsar voltage [mV]");
|
|
grap0->GetYaxis()->SetTitle("ADC [ADU]");
|
|
grap0->GetYaxis()->SetTitleOffset(0.9);
|
|
grap0->SetMinimum(1000);
|
|
grap0->SetMaximum(15000);
|
|
grap0->GetXaxis()->SetLimits(0,7200);
|
|
grap0->Draw("AP");
|
|
g0_fit->Draw("same");
|
|
mapcanvas->Update();
|
|
TPaveStats *st0 = (TPaveStats*)grap0->FindObject("stats");
|
|
st0->SetX1NDC(0.2);
|
|
st0->SetX2NDC(0.54);
|
|
st0->SetY1NDC(0.18);
|
|
st0->SetY2NDC(0.37);
|
|
st0->SetBorderSize(0);
|
|
st0->SetTextColor(kBlue);
|
|
|
|
grap1->SetMarkerStyle(20);
|
|
grap1->SetMarkerColor(kGreen+2);
|
|
grap1->Draw("P");
|
|
g1_fit->Draw("same");
|
|
mapcanvas->Update();
|
|
TPaveStats *st1 = (TPaveStats*)grap1->FindObject("stats");
|
|
st1->SetX1NDC(0.6);
|
|
st1->SetX2NDC(0.94);
|
|
st1->SetY1NDC(0.18);
|
|
st1->SetY2NDC(0.37);
|
|
st1->SetBorderSize(0);
|
|
st1->SetTextColor(kGreen+2);
|
|
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/pixel_%s_%d.png", module_str.c_str(), pixel_type.c_str(), i);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
// normalise
|
|
vector<double> r0_adc_norm;
|
|
vector<double> r1_adc_norm;
|
|
for (size_t j = 0; j < r0_adc.size(); j++) {
|
|
r0_adc_norm.push_back(r0_adc[j] - g0_fit->Eval(r0_filter[j]));
|
|
}
|
|
for (size_t j = 0; j < r1_adc.size(); j++) {
|
|
r1_adc_norm.push_back(r1_adc[j] - g1_fit->Eval(r1_filter[j]));
|
|
}
|
|
TGraphErrors *grap0_norm = new TGraphErrors(r0_adc.size(),&(r0_filter[0]),&(r0_adc_norm[0]),&(r0_ferr[0]),&(r0_adcerr[0]));
|
|
TGraphErrors *grap1_norm = new TGraphErrors(r1_adc.size(),&(r1_filter[0]),&(r1_adc_norm[0]),&(r1_ferr[0]),&(r1_adcerr[0]));
|
|
|
|
TF1* flat_g0 = new TF1("flat_g0","0",0,g0max);
|
|
TF1* flat_g1 = new TF1("flat_gi","0",g1min,7000);
|
|
|
|
grap0_norm->SetMarkerColor(kBlue);
|
|
grap0_norm->SetLineColor(kBlue);
|
|
flat_g0->SetLineColor(kBlue);
|
|
grap0_norm->GetXaxis()->SetTitle("Pulsar voltage [mV]");
|
|
grap0_norm->GetYaxis()->SetTitle("Normalised ADC [ADU]");
|
|
grap0_norm->GetYaxis()->SetTitleOffset(0.9);
|
|
grap0_norm->SetMinimum(-50);
|
|
grap0_norm->SetMaximum(50);
|
|
grap0_norm->Draw("AP");
|
|
flat_g0->Draw("same");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/pixel_%s_%d_g0norm.png", module_str.c_str(), pixel_type.c_str(), i);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
grap1_norm->SetMarkerColor(kGreen+2);
|
|
grap1_norm->SetLineColor(kGreen+2);
|
|
flat_g1->SetLineColor(kGreen+2);
|
|
grap1_norm->GetXaxis()->SetTitle("Pulsar voltage [mV]");
|
|
grap1_norm->GetYaxis()->SetTitle("Normalised ADC [ADU]");
|
|
grap1_norm->GetYaxis()->SetTitleOffset(0.9);
|
|
grap1_norm->SetMinimum(-30);
|
|
grap1_norm->SetMaximum(30);
|
|
grap1_norm->Draw("AP");
|
|
flat_g1->Draw("same");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/pixel_%s_%d_g1norm.png", module_str.c_str(), pixel_type.c_str(), i);
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
mapcanvas->SetLeftMargin(0.1);
|
|
mapcanvas->SetRightMargin(0.13);
|
|
delete grap0_norm;
|
|
delete grap1_norm;
|
|
}
|
|
|
|
delete grap0;
|
|
delete grap1;
|
|
|
|
} else {
|
|
pixelmask_map->Fill(i%NC,i/NC,1);
|
|
pixel_mask[i] = 0;
|
|
}
|
|
|
|
} else {
|
|
pixelmask_map->Fill(i%NC,i/NC,1);
|
|
pixel_mask[i] = 0;
|
|
}
|
|
|
|
} else {
|
|
pixelmask_map->Fill(i%NC,i/NC,1);
|
|
pixel_mask[i] = 0;
|
|
}
|
|
|
|
}
|
|
|
|
TCanvas* c1 = new TCanvas("c1","");
|
|
|
|
g0_grad_hist->GetXaxis()->SetTitle("G0 gradient");
|
|
g0_grad_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_grad_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g0_grader_hist->GetXaxis()->SetTitle("#sigma_{G0 gradient}");
|
|
g0_grader_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_grader_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g1_grad_hist->GetXaxis()->SetTitle("G1 gradient");
|
|
g1_grad_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_grad_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g1_grader_hist->GetXaxis()->SetTitle("#sigma_{G1 gradient}");
|
|
g1_grader_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_grader_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g0_const_hist->GetXaxis()->SetTitle("G0 intercept");
|
|
g0_const_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_const_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g0_conster_hist->GetXaxis()->SetTitle("#sigma_{G0 intercept}");
|
|
g0_conster_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_conster_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g1_const_hist->GetXaxis()->SetTitle("G1 intercept");
|
|
g1_const_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_const_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g1_conster_hist->GetXaxis()->SetTitle("#sigma_{G1 intercept}");
|
|
g1_conster_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_conster_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
mapcanvas->cd();
|
|
|
|
TPaveText *pave = new TPaveText(0.86,0.95,0.91,0.98,"blNDC");
|
|
pave->SetBorderSize(0);
|
|
pave->SetFillStyle(0);
|
|
pave->SetTextSize(0.06);
|
|
pave->SetTextAlign(32);
|
|
|
|
g0_grad_map->GetXaxis()->SetTitle("Column");
|
|
g0_grad_map->GetYaxis()->SetTitle("Row");
|
|
g0_grad_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0_grad_map->Draw("colz");
|
|
pave->AddText("G0 [ADU/mV]");
|
|
pave->Draw();
|
|
g0_grad_map->GetZaxis()->SetRangeUser(5,10);
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_grad_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g0_grader_map->GetXaxis()->SetTitle("Column");
|
|
g0_grader_map->GetYaxis()->SetTitle("Row");
|
|
g0_grader_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0_grader_map->Draw("colz");
|
|
pave->Clear();
|
|
pave->AddText("#sigma_{G0}");
|
|
pave->Draw();
|
|
g0_grader_map->GetZaxis()->SetRangeUser(0.0,0.001);
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_grader_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g1_grad_map->GetXaxis()->SetTitle("Column");
|
|
g1_grad_map->GetYaxis()->SetTitle("Row");
|
|
g1_grad_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g1_grad_map->Draw("colz");
|
|
pave->Clear();
|
|
pave->AddText("G1 [ADU/mV]");
|
|
pave->Draw();
|
|
if (module_str == "006") {
|
|
g1_grad_map->GetZaxis()->SetRangeUser(-0.3,-0.15);
|
|
} else {
|
|
g1_grad_map->GetZaxis()->SetRangeUser(-0.3,-0.23);
|
|
}
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_grad_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g1_grader_map->GetXaxis()->SetTitle("Column");
|
|
g1_grader_map->GetYaxis()->SetTitle("Row");
|
|
g1_grader_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g1_grader_map->Draw("colz");
|
|
pave->Clear();
|
|
pave->AddText("#sigma_{G1}");
|
|
pave->Draw();
|
|
if (module_str == "006") {
|
|
g1_grader_map->GetZaxis()->SetRangeUser(0.0,0.002);
|
|
} else {
|
|
g1_grader_map->GetZaxis()->SetRangeUser(0.0,0.0002);
|
|
}
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_grader_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g0_const_map->GetXaxis()->SetTitle("Column");
|
|
g0_const_map->GetYaxis()->SetTitle("Row");
|
|
g0_const_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0_const_map->Draw("colz");
|
|
g0_const_map->GetZaxis()->SetRangeUser(1500,3500);
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_const_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g0_conster_map->GetXaxis()->SetTitle("Column");
|
|
g0_conster_map->GetYaxis()->SetTitle("Row");
|
|
g0_conster_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0_conster_map->Draw("colz");
|
|
g0_conster_map->GetZaxis()->SetRangeUser(0.0,0.5);
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0_conster_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g1_const_map->GetXaxis()->SetTitle("Column");
|
|
g1_const_map->GetYaxis()->SetTitle("Row");
|
|
g1_const_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g1_const_map->Draw("colz");
|
|
if (module_str == "006") {
|
|
g1_const_map->GetZaxis()->SetRangeUser(10000,15000);
|
|
} else {
|
|
g1_const_map->GetZaxis()->SetRangeUser(13000,15000);
|
|
}
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_const_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g1_conster_map->GetXaxis()->SetTitle("Column");
|
|
g1_conster_map->GetYaxis()->SetTitle("Row");
|
|
g1_conster_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g1_conster_map->Draw("colz");
|
|
if (module_str == "006") {
|
|
g1_conster_map->GetZaxis()->SetRangeUser(0.0,10.);
|
|
} else {
|
|
g1_conster_map->GetZaxis()->SetRangeUser(0.0,1.);
|
|
}
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g1_conster_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
TH1F* g0overg1_hist = new TH1F("g0overg1_hist","",100,-34,-24);
|
|
TH1F* g0overg1er_hist = 0;
|
|
if (module_str == "006") {
|
|
g0overg1er_hist = new TH1F("g0overg1er_hist","",100,0,0.01);
|
|
} else {
|
|
g0overg1er_hist = new TH1F("g0overg1er_hist","",100,0,0.001);
|
|
}
|
|
|
|
TH1F* g0overg1_hist_isEdge = new TH1F("g0overg1_hist_isEdge","",100,-34,-24);
|
|
TH1F* g0overg1_hist_isInnerEdge = new TH1F("g0overg1_hist_isInnerEdge","",100,-34,-24);
|
|
TH1F* g0overg1_hist_isDouble = new TH1F("g0overg1_hist_isDouble","",100,-34,-24);
|
|
TH1F* g0overg1_hist_isNextToDouble = new TH1F("g0overg1_hist_isNextToDouble","",100,-34,-24);
|
|
TH1F* g0overg1_hist_isQuad = new TH1F("g0overg1_hist_isQuad","",100,-34,-24);
|
|
TH1F* g0overg1_hist_isBulk = new TH1F("g0overg1_hist_isBulk","",100,-34,-24);
|
|
|
|
TH2F* g0overg1_map = new TH2F("g0overg1_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
TH2F* g0overg1er_map = new TH2F("g0overg1er_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
|
|
|
double this_g0 = 0;
|
|
double this_g1 = 0;
|
|
|
|
for (int i = 0; i < NCH; i ++) {
|
|
if (pixel_mask[i] == 1) {
|
|
|
|
this_g0 = g0_grad_map->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
this_g1 = g1_grad_map->GetBinContent((i%NC)+1,(i/NC)+1);
|
|
|
|
g0overg1_hist->Fill(this_g0 / this_g1);
|
|
g0overg1_map->Fill(i%NC,i/NC,this_g0 / this_g1);
|
|
|
|
g0overg1er_hist->Fill(sqrt(pow(g0_grader_map->GetBinContent((i%NC)+1,(i/NC)+1)/this_g0,2) + pow(g1_grader_map->GetBinContent((i%NC)+1,(i/NC)+1)/this_g1,2)));
|
|
g0overg1er_map->Fill(i%NC,i/NC,sqrt(pow(g0_grader_map->GetBinContent((i%NC)+1,(i/NC)+1)/this_g0,2) + pow(g1_grader_map->GetBinContent((i%NC)+1,(i/NC)+1)/this_g1,2)));
|
|
|
|
if (isEdge(i)) {
|
|
g0overg1_hist_isEdge->Fill(this_g0 / this_g1);
|
|
}
|
|
if (isInnerEdge(i)) {
|
|
g0overg1_hist_isInnerEdge->Fill(this_g0 / this_g1);
|
|
}
|
|
if (isDouble(i)) {
|
|
g0overg1_hist_isDouble->Fill(this_g0 / this_g1);
|
|
}
|
|
if (isNextToDouble(i)) {
|
|
g0overg1_hist_isNextToDouble->Fill(this_g0 / this_g1);
|
|
}
|
|
if (isQuad(i)) {
|
|
g0overg1_hist_isQuad->Fill(this_g0 / this_g1);
|
|
}
|
|
if (isBulk(i)) {
|
|
g0overg1_hist_isBulk->Fill(this_g0 / this_g1);
|
|
}
|
|
}
|
|
}
|
|
|
|
c1->cd();
|
|
|
|
g0overg1_hist->GetXaxis()->SetTitle("G0 / G1");
|
|
g0overg1_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
g0overg1_hist->Fit("gaus");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1_histfit.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g0overg1er_hist->GetXaxis()->SetTitle("#sigma_{G0 / G1}");
|
|
g0overg1er_hist->Draw();
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1er_hist.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
g0overg1_hist_isEdge->SetLineColor(kBlue);
|
|
g0overg1_hist_isInnerEdge->SetLineColor(kCyan);
|
|
g0overg1_hist_isDouble->SetLineColor(kGreen+2);
|
|
g0overg1_hist_isNextToDouble->SetLineColor(kRed);
|
|
g0overg1_hist_isQuad->SetLineColor(kOrange);
|
|
|
|
g0overg1_hist_isEdge->Scale(1./g0overg1_hist_isEdge->GetEntries());
|
|
g0overg1_hist_isInnerEdge->Scale(1./g0overg1_hist_isInnerEdge->GetEntries());
|
|
g0overg1_hist_isDouble->Scale(1./g0overg1_hist_isDouble->GetEntries());
|
|
g0overg1_hist_isNextToDouble->Scale(1./g0overg1_hist_isNextToDouble->GetEntries());
|
|
g0overg1_hist_isQuad->Scale(1./g0overg1_hist_isQuad->GetEntries());
|
|
g0overg1_hist_isBulk->Scale(1./g0overg1_hist_isBulk->GetEntries());
|
|
|
|
TLegend *leg = new TLegend(0.62,0.6,0.93,0.93);
|
|
leg->AddEntry(g0overg1_hist_isBulk, "Normal", "l");
|
|
leg->AddEntry(g0overg1_hist_isDouble, "Double", "l");
|
|
leg->AddEntry(g0overg1_hist_isNextToDouble, "Next to D", "l");
|
|
leg->AddEntry(g0overg1_hist_isEdge, "Edge", "l");
|
|
leg->AddEntry(g0overg1_hist_isInnerEdge, "Inner E", "l");
|
|
|
|
if (module_str == "006") {
|
|
g0overg1_hist_isEdge->GetXaxis()->SetTitle("G0 / G1");
|
|
g0overg1_hist_isEdge->GetYaxis()->SetTitle("Normalised");
|
|
g0overg1_hist_isEdge->GetYaxis()->SetTitleOffset(1.3);
|
|
g0overg1_hist_isEdge->Draw();
|
|
g0overg1_hist_isDouble->Draw("same");
|
|
} else {
|
|
g0overg1_hist_isDouble->GetXaxis()->SetTitle("G0 / G1");
|
|
g0overg1_hist_isDouble->GetYaxis()->SetTitle("Normalised");
|
|
g0overg1_hist_isDouble->GetYaxis()->SetTitleOffset(1.3);
|
|
g0overg1_hist_isDouble->Draw();
|
|
g0overg1_hist_isEdge->Draw("same");
|
|
}
|
|
g0overg1_hist_isInnerEdge->Draw("same");
|
|
g0overg1_hist_isNextToDouble->Draw("same");
|
|
g0overg1_hist_isBulk->Draw("same");
|
|
leg->Draw("same");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1_hist_perType.png", module_str.c_str());
|
|
c1->SaveAs((const char *)(savename));
|
|
|
|
mapcanvas->cd();
|
|
|
|
g0overg1_map->GetXaxis()->SetTitle("Column");
|
|
g0overg1_map->GetYaxis()->SetTitle("Row");
|
|
g0overg1_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0overg1_map->Draw("colz");
|
|
pave->Clear();
|
|
pave->AddText("G0/G1");
|
|
pave->Draw();
|
|
g0overg1_map->GetZaxis()->SetRangeUser(-32,-25);
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
g0overg1er_map->GetXaxis()->SetTitle("Column");
|
|
g0overg1er_map->GetYaxis()->SetTitle("Row");
|
|
g0overg1er_map->GetYaxis()->SetTitleOffset(0.7);
|
|
g0overg1er_map->Draw("colz");
|
|
pave->Clear();
|
|
pave->AddText("#sigma_{G0/G1}");
|
|
pave->Draw();
|
|
if (module_str == "006") {
|
|
g0overg1er_map->GetZaxis()->SetRangeUser(0,0.01);
|
|
} else {
|
|
g0overg1er_map->GetZaxis()->SetRangeUser(0,0.001);
|
|
}
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/g0overg1er_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
pixelmask_map->GetXaxis()->SetTitle("Column");
|
|
pixelmask_map->GetYaxis()->SetTitle("Row");
|
|
pixelmask_map->GetYaxis()->SetTitleOffset(0.7);
|
|
pixelmask_map->Draw("colz");
|
|
sprintf(savename,"plots/M%s/BackplanePulsing/pixelmask_map.png", module_str.c_str());
|
|
mapcanvas->SaveAs((const char *)(savename));
|
|
|
|
sprintf(savename,"data/M%s/BP_ratio_M%s.root", module_str.c_str(), module_str.c_str());
|
|
TFile* saved_file2 = new TFile((const char *)(savename),"RECREATE");
|
|
g0overg1_map->Write();
|
|
g0overg1er_map->Write();
|
|
g0_grad_map->Write();
|
|
g1_grad_map->Write();
|
|
saved_file2->Close();
|
|
|
|
}
|