diff --git a/CuFluo_analysis_sc.cpp b/CuFluo_analysis_sc.cpp index a19384c..a57498f 100644 --- a/CuFluo_analysis_sc.cpp +++ b/CuFluo_analysis_sc.cpp @@ -23,6 +23,7 @@ #include "TPaveText.h" #include +#include int main(int argc, char* argv[]) { @@ -109,6 +110,11 @@ int main(int argc, char* argv[]) { TCanvas* c1 = new TCanvas("c1",""); + /****************************************************************************************************************/ + /* NOTE: Since arrays, as they were used before, tend to cause memory leaks if they grow too large on the heap, */ + /* it might be smarter to realize all array objects with std::vector instead. */ + /****************************************************************************************************************/ + if (createHistoFile) { jungfrauFile *thisfile = new jungfrauFile(); @@ -120,34 +126,34 @@ int main(int argc, char* argv[]) { pedestalObject_SC[sci] = new jungfrauPedestal(); pedestalObject_SC[sci]->pedestalSetNFrames(100); - Char_t *pedhistoname = new Char_t[50]; + Char_t *pedehistoname = new Char_t[50]; snprintf( pedehistoname, 50, "pedestalsG0_sc%d", sci ); - pedestalsG0[sci] = new TH2F(pedehistoname,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + pedestalsG0[sci] = new TH2F( pedehistoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); snprintf( pedehistoname, 50, "pedeRMSG0_sc%d", sci ); - pedeRMSG0[sci] = = new TH2F(pedehistoname,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5); + pedeRMSG0[sci] = new TH2F( pedehistoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); } - static uint16_t pedestals16_G0_start[16][NCH]{}; //I suppose, this is to track pedestal shifting over the course of data taking - static double pedeRMS16_G0[16][NCH]{}; + static uint16_t pedestals16_G0_start[16][NCH]; //I suppose, this is to track pedestal shifting over the course of data taking + static double pedeRMS16_G0[16][NCH]; - for (int pedefilei = 0; filei < pedefilen; ++pedefilei) { + for (int pedefilei = 0; pedefilei < pedefilen; ++pedefilei) { // open pede file - sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), pede_file.c_str()); //VH: note, this adds a double slash in the filepath - thisfile->open((char*)savename, pedefilei); + sprintf( savename, "%s/%s_%%6.6d.dat", data_loc.c_str(), pede_file.c_str() ); //VH: note, this adds a double slash in the filepath + thisfile->open( (char*)savename, pedefilei ); //count events in file int nevents = 0; - while (thisfile->readNextFrame()) { + while ( thisfile->readNextFrame() ) { nevents++; } thisfile->rewind(); cout << "read " << nevents << " events" << endl; - while (thisfile->readNextFrame()) { + while ( thisfile->readNextFrame() ) { // calculate pixel mask - pixelMaskObject->maskIfGainNot(0, thisfile->getFrameDataHandle(), pixel_mask); + pixelMaskObject->maskIfGainNot( 0, thisfile->getFrameDataHandle(), pixel_mask ); // caluclate pedestals - pedestalObject[thisfile->currentSCnumber()]->addFrameToPedestalCalculation(thisfile->getFrameDataHandle()); + pedestalObject_SC[ thisfile->currentSCnumber() ]->addFrameToPedestalCalculation( thisfile->getFrameDataHandle() ); } thisfile->close(); @@ -157,18 +163,18 @@ int main(int argc, char* argv[]) { for (int sci = 0; sci < 16; ++sci) { for (int i = 0; i < NCH; ++i) { if (pixel_mask[i] == true) { - pedestalsG0[sci]->Fill(i%NC,i/NC,pedestalObject[sci]->pedestalOfChannel(i)); - pedeRMSG0[sci]->Fill(i%NC,i/NC,pedestalObject[sci]->rmsOfChannel(i)); + pedestalsG0[sci]->Fill( i%NC, i/NC, pedestalObject_SC[sci]->pedestalOfChannel(i) ); + pedeRMSG0[sci]->Fill( i%NC, i/NC, pedestalObject_SC[sci]->rmsOfChannel(i) ); } } - pedestalObject[sci]->pedestalData((uint16_t*)(&pedestals16_G0_start[sci])); //this loads the pedestal data into the array pedestals16_G0_start - pedestalObject[sci]->pedestalRMSData(pedeRMS16_G0[sci]); //same here - pedestalObject[sci]->pedestalResetUpdates(); + pedestalObject_SC[sci]->pedestalData((uint16_t*)(&pedestals16_G0_start[sci])); //this loads the pedestal data into the array pedestals16_G0_start + pedestalObject_SC[sci]->pedestalRMSData(pedeRMS16_G0[sci]); //same here + pedestalObject_SC[sci]->pedestalResetUpdates(); //pedestalObject[sci]->pedestalClear(); //I don't need to clear if I only calculate pedestal once. } - sprintf(savename,"plots/M%s/CuFluo/%s/pixelmask_%s_M%s.png", module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - pixelMaskObject->plotPixelMask(pixel_mask,savename); + sprintf( savename, "plots/M%s/CuFluo/%s/pixelmask_%s_M%s.png", module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str() ); + pixelMaskObject->plotPixelMask( pixel_mask, savename ); cout << "after chip mask, n masked pixels is " << pixelMaskObject->getNMasked(pixel_mask) << endl; mapcanvas->cd(); @@ -182,11 +188,11 @@ int main(int argc, char* argv[]) { sprintf(savename,"plots/M%s/CuFluo/%s/pedeG0_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); mapcanvas->SaveAs((const char *)(savename)); - pedeRMSG0->GetXaxis()->SetTitle("Column"); - pedeRMSG0->GetYaxis()->SetTitle("Row"); - pedeRMSG0->GetYaxis()->SetTitleOffset(0.7); - pedeRMSG0->GetZaxis()->SetRangeUser(0,30); - pedeRMSG0->Draw("colz"); + pedeRMSG0[sci]->GetXaxis()->SetTitle("Column"); + pedeRMSG0[sci]->GetYaxis()->SetTitle("Row"); + pedeRMSG0[sci]->GetYaxis()->SetTitleOffset(0.7); + pedeRMSG0[sci]->GetZaxis()->SetRangeUser(0,30); + pedeRMSG0[sci]->Draw("colz"); sprintf(savename,"plots/M%s/CuFluo/%s/pedeRMSG0_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); mapcanvas->SaveAs((const char *)(savename)); @@ -214,15 +220,15 @@ int main(int argc, char* argv[]) { Char_t *_histoname = new Char_t[50]; for ( int adci = 0; adci < 8; ++adci ) { snprintf( _histoname, 50, "adc2d_%d_sc%d", (adci+1), sci ); - adc2d[adci][sci] = new TH2I( _histoname,"",adc2d_nbin,-200-0.5,adc2d_nbin-200-0.5,65536,( 65536*adci-0.5 ),( 65536*( adci+1 )-0.5 ) ); + adc2d[adci][sci] = new TH2I( _histoname, "", adc2d_nbin, -200-0.5, adc2d_nbin-200-0.5, 65536, ( 65536*adci-0.5 ), ( 65536*( adci+1 )-0.5 ) ); } snprintf( _histoname, 50, "adcpc_spec_sc%d", sci ); adcpc_spec[sci] = new TH1D( _histoname,"",300,0,3000 ); //spectrum for every sc, every 10000 frames snprintf( _histoname, 50, "pede_updates_sc%d", sci ); - pede_updates[sci] = new TH2F( _histoname,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5 ); + pede_updates[sci] = new TH2F( _histoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); snprintf( _histoname, 50, "pede_diff_sc%d", sci ); - pede_diff[sci] = new TH2F( _histoname,"",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5 ); + pede_diff[sci] = new TH2F( _histoname, "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); } for (int filei = 0; filei < filen; filei++) { @@ -236,7 +242,7 @@ int main(int argc, char* argv[]) { uint16_t* imagedptr = thisfile->getFrameDataHandle(); uint64_t scnumber = thisfile->currentSCnumber(); - pedestalObject[scnumber]->addG0FrameToPedestalCalculationWThreshold(imagedptr, pedestalObject[scnumber], pedeRMS16_G0[scnumber]); + pedestalObject_SC[scnumber]->addG0FrameToPedestalCalculationWThreshold( imagedptr, pedestalObject_SC[scnumber], pedeRMS16_G0[scnumber] ); for (int i = 0; i < NCH; i++) { @@ -244,8 +250,8 @@ int main(int argc, char* argv[]) { if (gain == 0) { - int adcpc = (imagedptr[i]&0x3fff) - pedestalObject[scnumber]->pedestalOfChannel(i); - adcpc_spec->Fill(adcpc); + int adcpc = (imagedptr[i]&0x3fff) - pedestalObject_SC[scnumber]->pedestalOfChannel(i); + adcpc_spec[scnumber]->Fill(adcpc); if (i < (65536*1)) { adc2d[0][scnumber]->Fill(adcpc,i); @@ -269,7 +275,7 @@ int main(int argc, char* argv[]) { } thisfile->close(); - if ( filei%16 == 0 ) { + if ( filei%16 == 0 ) { // every 16th file equals every 10000 frames for each storage cell for ( int sci = 0; sci < 16; ++sci ) { @@ -284,9 +290,9 @@ int main(int argc, char* argv[]) { pede_updates[sci]->Reset(); pede_diff[sci]->Reset(); for (int i = 0; i < NCH; i++) { - pede_updates[sci]->Fill(i%NC,i/NC,pedestalObject[sci]->pedestalUpdates(i)); - pede_diff[sci]->Fill(i%NC,i/NC,pedestalObject[sci]->pedestalOfChannel(i) - pedestals16_G0_start[sci][i]); - pedestals16_G0_start[sci][i] = pedestalObject[sci]->pedestalOfChannel(i); + pede_updates[sci]->Fill(i%NC,i/NC,pedestalObject_SC[sci]->pedestalUpdates(i)); + pede_diff[sci]->Fill(i%NC,i/NC,pedestalObject_SC[sci]->pedestalOfChannel(i) - pedestals16_G0_start[sci][i]); + pedestals16_G0_start[sci][i] = pedestalObject_SC[sci]->pedestalOfChannel(i); } pede_updates[sci]->GetXaxis()->SetTitle("Column"); @@ -305,7 +311,7 @@ int main(int argc, char* argv[]) { sprintf(savename,"plots/M%s/CuFluo/%s/pede_diff_sc%d_slice%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, ( filei/16 ), gain_str.c_str(), module_str.c_str()); mapcanvas->SaveAs((const char *)(savename)); - pedestalObject[sci]->pedestalResetUpdates(); + pedestalObject_SC[sci]->pedestalResetUpdates(); } //end of storage cell loop @@ -490,9 +496,7 @@ int main(int argc, char* argv[]) { adc2d_j->Draw("colz"); c1->Update(); - //HERE!!!!! - - for (int i=(65536*(j-1)); i<(65536*(j)); i++) { + for (int i=(65536*(j-1)); i<(65536*(j)); ++i) { if (i%10000==0){cout << "another 10k" << endl;} @@ -507,10 +511,10 @@ int main(int argc, char* argv[]) { proj_noise->Fit("gaus","Q"); TF1 *fit = proj_noise->GetFunction("gaus"); - noise_fit_pos->Fill(fit->GetParameter(1)); - noise_fit_pos_2d->Fill(i%NC,i/NC,fit->GetParameter(1)); - noise_fit_poserr->Fill(fit->GetParError(1)); - noise_fit_poserr_2d->Fill(i%NC,i/NC,fit->GetParError(1)); + noise_fit_pos[sci]->Fill(fit->GetParameter(1)); + noise_fit_pos_2d[sci]->Fill(i%NC,i/NC,fit->GetParameter(1)); + noise_fit_poserr[sci]->Fill(fit->GetParError(1)); + noise_fit_poserr_2d[sci]->Fill(i%NC,i/NC,fit->GetParError(1)); // peak TH1D *proj_peak = dynamic_cast(proj->Rebin(4,"proj_peak")); @@ -547,22 +551,22 @@ int main(int argc, char* argv[]) { thiscalibration->fixParameter(1,0.); TF1* fittedfun = thiscalibration->fitSpectrumKb(proj_peak,mypar,emypar); - fit_par3->Fill(mypar[3]); - fit_par4->Fill(mypar[4]); - fit_par5->Fill(mypar[5]); - fit_par6->Fill(mypar[6]); - fit_par7->Fill(mypar[7]); + fit_par3[sci]->Fill(mypar[3]); + fit_par4[sci]->Fill(mypar[4]); + fit_par5[sci]->Fill(mypar[5]); + fit_par6[sci]->Fill(mypar[6]); + fit_par7[sci]->Fill(mypar[7]); - fit_par3_2d->Fill(i%NC,i/NC,mypar[3]); - fit_par4_2d->Fill(i%NC,i/NC,mypar[4]); - fit_par5_2d->Fill(i%NC,i/NC,mypar[5]); - fit_par6_2d->Fill(i%NC,i/NC,mypar[6]); - fit_par7_2d->Fill(i%NC,i/NC,mypar[7]); + fit_par3_2d[sci]->Fill(i%NC,i/NC,mypar[3]); + fit_par4_2d[sci]->Fill(i%NC,i/NC,mypar[4]); + fit_par5_2d[sci]->Fill(i%NC,i/NC,mypar[5]); + fit_par6_2d[sci]->Fill(i%NC,i/NC,mypar[6]); + fit_par7_2d[sci]->Fill(i%NC,i/NC,mypar[7]); - peak_fit_pos->Fill(mypar[2]); - peak_fit_poserr->Fill(emypar[2]); - peak_fit_pos_2d->Fill(i%NC,i/NC,mypar[2]); - peak_fit_poserr_2d->Fill(i%NC,i/NC,emypar[2]); + peak_fit_pos[sci]->Fill(mypar[2]); + peak_fit_poserr[sci]->Fill(emypar[2]); + peak_fit_pos_2d[sci]->Fill(i%NC,i/NC,mypar[2]); + peak_fit_poserr_2d[sci]->Fill(i%NC,i/NC,emypar[2]); if ((i >= 58000 && i < 58000+10) || // bulk (i >= 10 && i < 10+10) || // edge @@ -599,7 +603,7 @@ int main(int argc, char* argv[]) { st0->SetY2NDC(0.94); st0->SetBorderSize(0); st0->SetTextSize(0.04); - sprintf(savename,"plots/M%s/CuFluo/%s/noise_%s_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), i, gain_str.c_str(), module_str.c_str()); + sprintf(savename,"plots/M%s/CuFluo/%s/noise_%s_sc%d_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), sci, i, gain_str.c_str(), module_str.c_str()); c1->SaveAs((const char *)(savename)); TF1 *gaus_Ka = new TF1("gaus_Ka","gaus",proj->GetBinLowEdge(low_bin_peak),proj->GetBinLowEdge(high_bin_peak+1)); @@ -634,35 +638,35 @@ int main(int argc, char* argv[]) { st->SetY2NDC(0.94); st->SetBorderSize(0); st->SetTextSize(0.04); - sprintf(savename,"plots/M%s/CuFluo/%s/peak_%s_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), i, gain_str.c_str(), module_str.c_str()); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_%s_sc%d_%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), pixel_type.c_str(), sci, i, gain_str.c_str(), module_str.c_str()); c1->SaveAs((const char *)(savename)); } // gain - gain_fit->Fill(mypar[2] - fit->GetParameter(1)); - gain_fiterr->Fill(sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); - gain_fit_2d->Fill(i%NC,i/NC,mypar[2] - fit->GetParameter(1)); - gain_fiterr_2d->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); - gain_ADUper1keV_2d->Fill(i%NC,i/NC,(mypar[2] - fit->GetParameter(1)) / 8.0); - gainerr_ADUper1keV_2d->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2)) / 8.0); + gain_fit[sci]->Fill(mypar[2] - fit->GetParameter(1)); + gain_fiterr[sci]->Fill(sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); + gain_fit_2d[sci]->Fill(i%NC,i/NC,mypar[2] - fit->GetParameter(1)); + gain_fiterr_2d[sci]->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2))); + gain_ADUper1keV_2d[sci]->Fill(i%NC,i/NC,(mypar[2] - fit->GetParameter(1)) / 8.0); + gainerr_ADUper1keV_2d[sci]->Fill(i%NC,i/NC,sqrt(pow(emypar[2],2) + pow(fit->GetParError(1),2)) / 8.0); if (isEdge(i)) { - gain_fit_isEdge->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isEdge[sci]->Fill(mypar[2] - fit->GetParameter(1)); } if (isInnerEdge(i)) { - gain_fit_isInnerEdge->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isInnerEdge[sci]->Fill(mypar[2] - fit->GetParameter(1)); } if (isDouble(i)) { - gain_fit_isDouble->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isDouble[sci]->Fill(mypar[2] - fit->GetParameter(1)); } if (isNextToDouble(i)) { - gain_fit_isNextToDouble->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isNextToDouble[sci]->Fill(mypar[2] - fit->GetParameter(1)); } if (isQuad(i)) { - gain_fit_isQuad->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isQuad[sci]->Fill(mypar[2] - fit->GetParameter(1)); } if (isBulk(i)) { - gain_fit_isBulk->Fill(mypar[2] - fit->GetParameter(1)); + gain_fit_isBulk[sci]->Fill(mypar[2] - fit->GetParameter(1)); } delete thiscalibration; @@ -672,256 +676,260 @@ int main(int argc, char* argv[]) { } else { pixel_mask[i] = false; - } - } + } //end if can be fitted + + } // end for loop pixel numbers (i) + + } // end for loop sensor slices (j) + + sprintf(savename,"plots/M%s/CuFluo/%s/pixelmask_afterfit_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + pixelMaskObject->plotPixelMask(pixel_mask,savename); + + 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); + + mapcanvas->cd(); + + fit_par3_2d[sci]->GetXaxis()->SetTitle("Column"); + fit_par3_2d[sci]->GetYaxis()->SetTitle("Row"); + fit_par3_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + fit_par3_2d[sci]->Draw("colz"); + fit_par3_2d[sci]->GetZaxis()->SetRangeUser(0,50); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par3_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par4_2d[sci]->GetXaxis()->SetTitle("Column"); + fit_par4_2d[sci]->GetYaxis()->SetTitle("Row"); + fit_par4_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + fit_par4_2d[sci]->Draw("colz"); + fit_par4_2d[sci]->GetZaxis()->SetRangeUser(0,500); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par4_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par5_2d[sci]->GetXaxis()->SetTitle("Column"); + fit_par5_2d[sci]->GetYaxis()->SetTitle("Row"); + fit_par5_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + fit_par5_2d[sci]->Draw("colz"); + fit_par5_2d[sci]->GetZaxis()->SetRangeUser(0,0.5); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par5_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par6_2d[sci]->GetXaxis()->SetTitle("Column"); + fit_par6_2d[sci]->GetYaxis()->SetTitle("Row"); + fit_par6_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + fit_par6_2d[sci]->Draw("colz"); + fit_par6_2d[sci]->GetZaxis()->SetRangeUser(1.0,1.25); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par6_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + fit_par7_2d[sci]->GetXaxis()->SetTitle("Column"); + fit_par7_2d[sci]->GetYaxis()->SetTitle("Row"); + fit_par7_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + fit_par7_2d[sci]->Draw("colz"); + fit_par7_2d[sci]->GetZaxis()->SetRangeUser(0.,0.4); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par7_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + peak_fit_pos_2d[sci]->GetXaxis()->SetTitle("Column"); + peak_fit_pos_2d[sci]->GetYaxis()->SetTitle("Row"); + peak_fit_pos_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + peak_fit_pos_2d[sci]->Draw("colz"); + peak_fit_pos_2d[sci]->GetZaxis()->SetRangeUser( low_ADU_peak, high_ADU_peak ); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_pos_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + peak_fit_poserr_2d[sci]->GetXaxis()->SetTitle("Column"); + peak_fit_poserr_2d[sci]->GetYaxis()->SetTitle("Row"); + peak_fit_poserr_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + peak_fit_poserr_2d[sci]->Draw("colz"); + peak_fit_poserr_2d[sci]->GetZaxis()->SetRangeUser(0,2); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_poserr_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + noise_fit_pos_2d[sci]->GetXaxis()->SetTitle("Column"); + noise_fit_pos_2d[sci]->GetYaxis()->SetTitle("Row"); + noise_fit_pos_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + noise_fit_pos_2d[sci]->Draw("colz"); + noise_fit_pos_2d[sci]->GetZaxis()->SetRangeUser(-5,5); + sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_pos_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + noise_fit_poserr_2d[sci]->GetXaxis()->SetTitle("Column"); + noise_fit_poserr_2d[sci]->GetYaxis()->SetTitle("Row"); + noise_fit_poserr_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + noise_fit_poserr_2d[sci]->Draw("colz"); + if (gain_str == "HG0") { + noise_fit_poserr_2d[sci]->GetZaxis()->SetRangeUser(0,0.1); + } else if (gain_str == "G0") { + noise_fit_poserr_2d[sci]->GetZaxis()->SetRangeUser(0,0.05); } + sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_poserr_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); - sprintf(savename,"plots/M%s/CuFluo/%s/pixelmask_afterfit_%s_M%s.png", module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - pixelMaskObject->plotPixelMask(pixel_mask,savename); + gain_fit_2d[sci]->GetXaxis()->SetTitle("Column"); + gain_fit_2d[sci]->GetYaxis()->SetTitle("Row"); + gain_fit_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + gain_fit_2d[sci]->Draw("colz"); + sprintf(savename,"%s [ADU/8 keV]", gain_str.c_str()); + pave->AddText((const char *)(savename)); + pave->Draw(); + gain_fit_2d[sci]->GetZaxis()->SetRangeUser( low_ADU_peak, high_ADU_peak ); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); - 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); + gain_fiterr_2d[sci]->GetXaxis()->SetTitle("Column"); + gain_fiterr_2d[sci]->GetYaxis()->SetTitle("Row"); + gain_fiterr_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + gain_fiterr_2d[sci]->Draw("colz"); + gain_fiterr_2d[sci]->GetZaxis()->SetRangeUser(0,2); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fiterr_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); - mapcanvas->cd(); + gain_ADUper1keV_2d[sci]->GetXaxis()->SetTitle("Column"); + gain_ADUper1keV_2d[sci]->GetYaxis()->SetTitle("Row"); + gain_ADUper1keV_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + gain_ADUper1keV_2d[sci]->Draw("colz"); + if (gain_str == "HG0") { + gain_ADUper1keV_2d[sci]->GetZaxis()->SetRangeUser(80,120); + } else if (gain_str == "G0") { + gain_ADUper1keV_2d[sci]->GetZaxis()->SetRangeUser(35,50); + } + sprintf(savename,"plots/M%s/CuFluo/%s/gain_ADUper1keV_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); - fit_par3_2d->GetXaxis()->SetTitle("Column"); - fit_par3_2d->GetYaxis()->SetTitle("Row"); - fit_par3_2d->GetYaxis()->SetTitleOffset(0.7); - fit_par3_2d->Draw("colz"); - fit_par3_2d->GetZaxis()->SetRangeUser(0,50); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par3_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + gainerr_ADUper1keV_2d[sci]->GetXaxis()->SetTitle("Column"); + gainerr_ADUper1keV_2d[sci]->GetYaxis()->SetTitle("Row"); + gainerr_ADUper1keV_2d[sci]->GetYaxis()->SetTitleOffset(0.7); + gainerr_ADUper1keV_2d[sci]->Draw("colz"); + if (gain_str == "HG0") { + gainerr_ADUper1keV_2d[sci]->GetZaxis()->SetRangeUser(0,0.5); + } else if (gain_str == "G0") { + gainerr_ADUper1keV_2d[sci]->GetZaxis()->SetRangeUser(0,0.25); + } + sprintf(savename,"plots/M%s/CuFluo/%s/gainerr_ADUper1keV_2d_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + mapcanvas->SaveAs((const char *)(savename)); + + c1->cd(); + + fit_par3[sci]->GetXaxis()->SetTitle("Fit par 3"); + fit_par3[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par3_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - fit_par4_2d->GetXaxis()->SetTitle("Column"); - fit_par4_2d->GetYaxis()->SetTitle("Row"); - fit_par4_2d->GetYaxis()->SetTitleOffset(0.7); - fit_par4_2d->Draw("colz"); - fit_par4_2d->GetZaxis()->SetRangeUser(0,500); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par4_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + fit_par4[sci]->GetXaxis()->SetTitle("Fit par 4"); + fit_par4[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par4_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - fit_par5_2d->GetXaxis()->SetTitle("Column"); - fit_par5_2d->GetYaxis()->SetTitle("Row"); - fit_par5_2d->GetYaxis()->SetTitleOffset(0.7); - fit_par5_2d->Draw("colz"); - fit_par5_2d->GetZaxis()->SetRangeUser(0,0.5); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par5_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + fit_par5[sci]->GetXaxis()->SetTitle("Fit par 5"); + fit_par5[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par5_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - fit_par6_2d->GetXaxis()->SetTitle("Column"); - fit_par6_2d->GetYaxis()->SetTitle("Row"); - fit_par6_2d->GetYaxis()->SetTitleOffset(0.7); - fit_par6_2d->Draw("colz"); - fit_par6_2d->GetZaxis()->SetRangeUser(1.0,1.25); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par6_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + fit_par6[sci]->GetXaxis()->SetTitle("Fit par 6"); + fit_par6[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par6_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - fit_par7_2d->GetXaxis()->SetTitle("Column"); - fit_par7_2d->GetYaxis()->SetTitle("Row"); - fit_par7_2d->GetYaxis()->SetTitleOffset(0.7); - fit_par7_2d->Draw("colz"); - fit_par7_2d->GetZaxis()->SetRangeUser(0.,0.4); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par7_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + fit_par7[sci]->GetXaxis()->SetTitle("Fit par 7"); + fit_par7[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/fit_par7_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - peak_fit_pos_2d->GetXaxis()->SetTitle("Column"); - peak_fit_pos_2d->GetYaxis()->SetTitle("Row"); - peak_fit_pos_2d->GetYaxis()->SetTitleOffset(0.7); - peak_fit_pos_2d->Draw("colz"); - peak_fit_pos_2d->GetZaxis()->SetRangeUser(low_ADU_peak,high_ADU_peak); - sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_pos_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + peak_fit_pos[sci]->GetXaxis()->SetTitle("Peak position [ADU]"); + peak_fit_pos[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_pos_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - peak_fit_poserr_2d->GetXaxis()->SetTitle("Column"); - peak_fit_poserr_2d->GetYaxis()->SetTitle("Row"); - peak_fit_poserr_2d->GetYaxis()->SetTitleOffset(0.7); - peak_fit_poserr_2d->Draw("colz"); - peak_fit_poserr_2d->GetZaxis()->SetRangeUser(0,2); - sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_poserr_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + peak_fit_poserr[sci]->GetXaxis()->SetTitle("Peak position uncert [ADU]"); + peak_fit_poserr[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_poserr_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - noise_fit_pos_2d->GetXaxis()->SetTitle("Column"); - noise_fit_pos_2d->GetYaxis()->SetTitle("Row"); - noise_fit_pos_2d->GetYaxis()->SetTitleOffset(0.7); - noise_fit_pos_2d->Draw("colz"); - noise_fit_pos_2d->GetZaxis()->SetRangeUser(-5,5); - sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_pos_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + noise_fit_pos[sci]->GetXaxis()->SetTitle("Noise position [ADU]"); + noise_fit_pos[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_pos_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - noise_fit_poserr_2d->GetXaxis()->SetTitle("Column"); - noise_fit_poserr_2d->GetYaxis()->SetTitle("Row"); - noise_fit_poserr_2d->GetYaxis()->SetTitleOffset(0.7); - noise_fit_poserr_2d->Draw("colz"); - if (gain_str == "HG0") { - noise_fit_poserr_2d->GetZaxis()->SetRangeUser(0,0.1); - } else if (gain_str == "G0") { - noise_fit_poserr_2d->GetZaxis()->SetRangeUser(0,0.05); - } - sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_poserr_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + noise_fit_poserr[sci]->GetXaxis()->SetTitle("Noise position uncert [ADU]"); + noise_fit_poserr[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_poserr_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - gain_fit_2d->GetXaxis()->SetTitle("Column"); - gain_fit_2d->GetYaxis()->SetTitle("Row"); - gain_fit_2d->GetYaxis()->SetTitleOffset(0.7); - gain_fit_2d->Draw("colz"); - sprintf(savename,"%s [ADU/8 keV]", gain_str.c_str()); - pave->AddText((const char *)(savename)); - pave->Draw(); - gain_fit_2d->GetZaxis()->SetRangeUser(low_ADU_peak,high_ADU_peak); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); + gain_fit[sci]->GetXaxis()->SetTitle((const char *)(savename)); + gain_fit[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - gain_fiterr_2d->GetXaxis()->SetTitle("Column"); - gain_fiterr_2d->GetYaxis()->SetTitle("Row"); - gain_fiterr_2d->GetYaxis()->SetTitleOffset(0.7); - gain_fiterr_2d->Draw("colz"); - gain_fiterr_2d->GetZaxis()->SetRangeUser(0,2); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fiterr_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + gain_fit[sci]->GetXaxis()->SetRangeUser(low_ADU_peak+30, high_ADU_peak); + gain_fit[sci]->Fit("gaus"); + gain_fit[sci]->Draw(); + c1->Update(); + TPaveText *pave2 = new TPaveText(0.6,0.8,0.94,0.94,"blNDC"); + pave2->SetBorderSize(0); + pave2->SetFillStyle(0); + pave2->SetTextSize(0.04); + pave2->SetTextAlign(32); + TF1* gain_fit_gaus = gain_fit[sci]->GetFunction("gaus"); + sprintf(savename,"Mean %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(1), gain_fit_gaus->GetParError(1)); + pave2->AddText((const char *)(savename)); + sprintf(savename,"Sigma %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(2), gain_fit_gaus->GetParError(2)); + pave2->AddText((const char *)(savename)); + pave2->Draw(); + gain_fit[sci]->SetStats(kFALSE); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_fit_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - gain_ADUper1keV_2d->GetXaxis()->SetTitle("Column"); - gain_ADUper1keV_2d->GetYaxis()->SetTitle("Row"); - gain_ADUper1keV_2d->GetYaxis()->SetTitleOffset(0.7); - gain_ADUper1keV_2d->Draw("colz"); - if (gain_str == "HG0") { - gain_ADUper1keV_2d->GetZaxis()->SetRangeUser(80,120); - } else if (gain_str == "G0") { - gain_ADUper1keV_2d->GetZaxis()->SetRangeUser(35,50); - } - sprintf(savename,"plots/M%s/CuFluo/%s/gain_ADUper1keV_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + gain_fiterr[sci]->GetXaxis()->SetTitle("Gain uncert [ADU / 8 keV]"); + gain_fiterr[sci]->Draw(); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fiterr_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - gainerr_ADUper1keV_2d->GetXaxis()->SetTitle("Column"); - gainerr_ADUper1keV_2d->GetYaxis()->SetTitle("Row"); - gainerr_ADUper1keV_2d->GetYaxis()->SetTitleOffset(0.7); - gainerr_ADUper1keV_2d->Draw("colz"); - if (gain_str == "HG0") { - gainerr_ADUper1keV_2d->GetZaxis()->SetRangeUser(0,0.5); - } else if (gain_str == "G0") { - gainerr_ADUper1keV_2d->GetZaxis()->SetRangeUser(0,0.25); - } - sprintf(savename,"plots/M%s/CuFluo/%s/gainerr_ADUper1keV_2d_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - mapcanvas->SaveAs((const char *)(savename)); + gain_fit_isEdge[sci]->SetLineColor(kBlue); + gain_fit_isInnerEdge[sci]->SetLineColor(kCyan); + gain_fit_isDouble[sci]->SetLineColor(kGreen+2); + gain_fit_isNextToDouble[sci]->SetLineColor(kRed); + gain_fit_isQuad[sci]->SetLineColor(kOrange); - c1->cd(); + gain_fit_isEdge[sci]->Scale(1./gain_fit_isEdge[sci]->GetEntries()); + gain_fit_isInnerEdge[sci]->Scale(1./gain_fit_isInnerEdge[sci]->GetEntries()); + gain_fit_isDouble[sci]->Scale(1./gain_fit_isDouble[sci]->GetEntries()); + gain_fit_isNextToDouble[sci]->Scale(1./gain_fit_isNextToDouble[sci]->GetEntries()); + gain_fit_isQuad[sci]->Scale(1./gain_fit_isQuad[sci]->GetEntries()); + gain_fit_isBulk[sci]->Scale(1./gain_fit_isBulk[sci]->GetEntries()); - fit_par3->GetXaxis()->SetTitle("Fit par 3"); - fit_par3->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par3_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); + TLegend *leg = new TLegend(0.62,0.6,0.93,0.93); + leg->AddEntry(gain_fit_isBulk[sci], "Normal", "l"); + leg->AddEntry(gain_fit_isDouble[sci], "Double", "l"); + leg->AddEntry(gain_fit_isNextToDouble[sci], "Next to D", "l"); + leg->AddEntry(gain_fit_isEdge[sci], "Edge", "l"); + leg->AddEntry(gain_fit_isInnerEdge[sci], "Inner E", "l"); - fit_par4->GetXaxis()->SetTitle("Fit par 4"); - fit_par4->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par4_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); + sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); + gain_fit_isDouble[sci]->GetXaxis()->SetTitle((const char *)(savename)); + gain_fit_isDouble[sci]->GetYaxis()->SetTitle("Normalised"); + gain_fit_isDouble[sci]->GetYaxis()->SetTitleOffset(1.3); + gain_fit_isDouble[sci]->SetMinimum(0.0); + gain_fit_isDouble[sci]->SetMaximum(0.16); + gain_fit_isDouble[sci]->Draw(); + gain_fit_isEdge[sci]->Draw("same"); + gain_fit_isInnerEdge[sci]->Draw("same"); + gain_fit_isNextToDouble[sci]->Draw("same"); + gain_fit_isBulk[sci]->Draw("same"); + leg->Draw("same"); + sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_perType_sc%d_%s_M%s.png", module_str.c_str(), gain_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + c1->SaveAs((const char *)(savename)); - fit_par5->GetXaxis()->SetTitle("Fit par 5"); - fit_par5->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par5_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - fit_par6->GetXaxis()->SetTitle("Fit par 6"); - fit_par6->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par6_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - fit_par7->GetXaxis()->SetTitle("Fit par 7"); - fit_par7->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/fit_par7_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - peak_fit_pos->GetXaxis()->SetTitle("Peak position [ADU]"); - peak_fit_pos->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_pos_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - peak_fit_poserr->GetXaxis()->SetTitle("Peak position uncert [ADU]"); - peak_fit_poserr->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/peak_fit_poserr_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - noise_fit_pos->GetXaxis()->SetTitle("Noise position [ADU]"); - noise_fit_pos->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_pos_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - noise_fit_poserr->GetXaxis()->SetTitle("Noise position uncert [ADU]"); - noise_fit_poserr->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/noise_fit_poserr_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); - gain_fit->GetXaxis()->SetTitle((const char *)(savename)); - gain_fit->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - gain_fit->GetXaxis()->SetRangeUser(low_ADU_peak+30, high_ADU_peak); - gain_fit->Fit("gaus"); - gain_fit->Draw(); - c1->Update(); - TPaveText *pave2 = new TPaveText(0.6,0.8,0.94,0.94,"blNDC"); - pave2->SetBorderSize(0); - pave2->SetFillStyle(0); - pave2->SetTextSize(0.04); - pave2->SetTextAlign(32); - TF1* gain_fit_gaus = gain_fit->GetFunction("gaus"); - sprintf(savename,"Mean %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(1), gain_fit_gaus->GetParError(1)); - pave2->AddText((const char *)(savename)); - sprintf(savename,"Sigma %0.2f #pm %0.2f", gain_fit_gaus->GetParameter(2), gain_fit_gaus->GetParError(2)); - pave2->AddText((const char *)(savename)); - pave2->Draw(); - gain_fit->SetStats(kFALSE); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_fit_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - gain_fiterr->GetXaxis()->SetTitle("Gain uncert [ADU / 8 keV]"); - gain_fiterr->Draw(); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fiterr_%s_M%s.png",module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - gain_fit_isEdge->SetLineColor(kBlue); - gain_fit_isInnerEdge->SetLineColor(kCyan); - gain_fit_isDouble->SetLineColor(kGreen+2); - gain_fit_isNextToDouble->SetLineColor(kRed); - gain_fit_isQuad->SetLineColor(kOrange); - - gain_fit_isEdge->Scale(1./gain_fit_isEdge->GetEntries()); - gain_fit_isInnerEdge->Scale(1./gain_fit_isInnerEdge->GetEntries()); - gain_fit_isDouble->Scale(1./gain_fit_isDouble->GetEntries()); - gain_fit_isNextToDouble->Scale(1./gain_fit_isNextToDouble->GetEntries()); - gain_fit_isQuad->Scale(1./gain_fit_isQuad->GetEntries()); - gain_fit_isBulk->Scale(1./gain_fit_isBulk->GetEntries()); - - TLegend *leg = new TLegend(0.62,0.6,0.93,0.93); - leg->AddEntry(gain_fit_isBulk, "Normal", "l"); - leg->AddEntry(gain_fit_isDouble, "Double", "l"); - leg->AddEntry(gain_fit_isNextToDouble, "Next to D", "l"); - leg->AddEntry(gain_fit_isEdge, "Edge", "l"); - leg->AddEntry(gain_fit_isInnerEdge, "Inner E", "l"); - - sprintf(savename,"Gain %s [ADU / 8 keV]", gain_str.c_str()); - gain_fit_isDouble->GetXaxis()->SetTitle((const char *)(savename)); - gain_fit_isDouble->GetYaxis()->SetTitle("Normalised"); - gain_fit_isDouble->GetYaxis()->SetTitleOffset(1.3); - gain_fit_isDouble->SetMinimum(0.0); - gain_fit_isDouble->SetMaximum(0.16); - gain_fit_isDouble->Draw(); - gain_fit_isEdge->Draw("same"); - gain_fit_isInnerEdge->Draw("same"); - gain_fit_isNextToDouble->Draw("same"); - gain_fit_isBulk->Draw("same"); - leg->Draw("same"); - sprintf(savename,"plots/M%s/CuFluo/%s/gain_fit_perType_%s_M%s.png", module_str.c_str(), gain_str.c_str(), gain_str.c_str(), module_str.c_str()); - c1->SaveAs((const char *)(savename)); - - sprintf(savename,"data/M%s/CuFluo_gain_%s_M%s.root", module_str.c_str(), gain_str.c_str(), module_str.c_str()); - TFile* saved_file = new TFile((const char *)(savename),"RECREATE"); - gain_ADUper1keV_2d->Write(); - gainerr_ADUper1keV_2d->Write(); - saved_file->Close(); + sprintf(savename,"data/M%s/CuFluo_gain_sc%d_%s_M%s.root", module_str.c_str(), sci, gain_str.c_str(), module_str.c_str()); + TFile* saved_file = new TFile((const char *)(savename),"RECREATE"); + gain_ADUper1keV_2d[sci]->Write(); + gainerr_ADUper1keV_2d[sci]->Write(); + saved_file->Close(); + + } // end of sc loop } diff --git a/makefile b/makefile index cf983db..d4660ee 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,9 @@ CuFluo_analysis: CuFluo_analysis.cpp g++ -Wall -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic CuFluo_analysis.cpp -o CuFluo_analysis +CuFluo_analysis_sc: CuFluo_analysis_sc.cpp + g++ -Wall -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic CuFluo_analysis_sc.cpp -o CuFluo_analysis_sc + DB_analysis: DB_analysis.cpp g++ -Wall -O3 -m64 -I$(ROOTSYS)/include -L$(ROOTSYS)/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic DB_analysis.cpp -o DB_analysis