Files
JFCalibration/JFMC_CalibWriter_wBP_sc.cpp

1035 lines
43 KiB
C++

// file to combine the four sets of results
// to write the calibration constants for the junfgrau module
#include "../sls_detector_calibration/jungfrauCommonHeader.h"
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TPaveText.h"
#include <fstream>
#include <iomanip>
#include <sys/stat.h>
struct GainMaps
{
static double g0VALs[NCH]; // declaration, incomplete type
static double g1VALs[NCH];
static double g2VALs[NCH];
static double hg0VALs[NCH];
static double hg1VALs[NCH];
static double hg2VALs[NCH];
};
double GainMaps::g0VALs[NCH]; // definition, complete type
double GainMaps::g1VALs[NCH];
double GainMaps::g2VALs[NCH];
double GainMaps::hg0VALs[NCH];
double GainMaps::hg1VALs[NCH];
double GainMaps::hg2VALs[NCH];
int main(int argc, char* argv[]) {
jungfrauStyle();
if (argc != 2) {
cout << "Correct usage:" << endl;
cout << "arg 1: specify module number" << endl;
cout << " " << endl;
exit(1);
}
string module_str = argv[1];
bool hasHGX = false;
//char savename[128];
char savename[256]; // VH 210902
// today's date
time_t rawtime;
tm* timeinfo;
char date[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(date,80,"%Y-%m-%d",timeinfo);
// create plot directory with permissions drwxrwxr-x
sprintf(savename,"plots/M%s/Calib_%s", module_str.c_str(), date);
mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
for (int sci = 0; sci < NSC; ++sci) {
// CuFluo HG0 dataset
sprintf( savename, "data/M%s/CuFluo_gain_sc%d_HG0_M%s.root", module_str.c_str(), sci, module_str.c_str() );
TFile* FL_HG0_file = new TFile((char*)savename,"READ");
TH2F* FL_HG0_gain_map = 0;
TH2F* FL_HG0_gainer_map = 0;
if (FL_HG0_file->IsZombie()) {
cout << "Did not find HG0 file for storage cell " << sci << endl;
} else {
sprintf( savename, "gain_ADUper1keV_2d_sc%d", sci );
FL_HG0_gain_map = (TH2F*)FL_HG0_file->Get( savename );
sprintf( savename, "gainerr_ADUper1keV_2d_sc%d", sci );
FL_HG0_gainer_map = (TH2F*)FL_HG0_file->Get( savename );
}
// CuFluo G0 dataset
sprintf( savename, "data/M%s/CuFluo_gain_sc%d_G0_M%s.root", module_str.c_str(), sci, module_str.c_str() );
TFile* FL_G0_file = new TFile((char*)savename,"READ");
TH2F* FL_G0_gain_map = 0;
TH2F* FL_G0_gainer_map = 0;
if (FL_G0_file->IsZombie()) {
cout << "Did not find G0 file for storage cell " << sci << endl;
} else {
sprintf( savename, "gain_ADUper1keV_2d_sc%d", sci );
FL_G0_gain_map = (TH2F*)FL_G0_file->Get( savename );
sprintf( savename, "gainerr_ADUper1keV_2d_sc%d", sci );
FL_G0_gainer_map = (TH2F*)FL_G0_file->Get( savename );
}
// Backplane pulsing dataset
sprintf( savename, "data/M%s/BP_ratio_M%s.root", module_str.c_str(), module_str.c_str() );
TFile* DB_file = new TFile((char*)savename,"READ");
TH2F* DB_ratio_map = 0;
TH2F* DB_ratioer_map = 0;
if ( DB_file->IsZombie() ) {
cout << "Did not find BP file" << endl;
// look for a direct beam dataset
sprintf( savename, "data/M%s/DB_ratio_M%s.root", module_str.c_str(), module_str.c_str() );
DB_file = new TFile((char*)savename,"READ");
if ( DB_file->IsZombie() ) {
cout << "Also did not find DB file" << endl;
} else {
cout << "loading G0/G1 from DB" << endl;
DB_ratio_map = (TH2F*)DB_file->Get("g0overg1map");
DB_ratioer_map = (TH2F*)DB_file->Get("g0overg1ermap");
}
} else {
cout << "loading G0/G1 from BP" << endl;
DB_ratio_map = (TH2F*)DB_file->Get("g0overg1_map");
DB_ratioer_map = (TH2F*)DB_file->Get("g0overg1er_map");
}
// Backplane pulsing dataset for HG0hg1hg2
sprintf( savename, "data/M%s/BP_ratio_M%s_HG0G1G2.root", module_str.c_str(), module_str.c_str() );
TFile* DB_HGX_file = new TFile((char*)savename,"READ");
TH2F* DB_HGX_ratio_map = 0;
TH2F* DB_HGX_ratioer_map = 0;
if ( DB_HGX_file->IsZombie() ) {
cout << "Did not find HG0 BP file" << endl; }
else {
cout << "loading G0/G1 from BP" << endl;
DB_HGX_ratio_map = (TH2F*)DB_HGX_file->Get("g0overg1_map");
DB_HGX_ratioer_map = (TH2F*)DB_HGX_file->Get("g0overg1er_map");
}
// Current source dataset
sprintf( savename, "data/M%s/CS_ratio_M%s.root", module_str.c_str(), module_str.c_str() );
TFile* CS_file = new TFile((char*)savename,"READ");
TH2F* CS_ratio_map = 0;
TH2F* CS_ratioer_map = 0;
if ( CS_file->IsZombie() ) {
cout << "Did not find CS file" << endl;
hasHGX=false;
} else {
hasHGX=true;
CS_ratio_map = (TH2F*)CS_file->Get("g1overg2map");
CS_ratioer_map = (TH2F*)CS_file->Get("g1overg2ermap");
}
// Current source dataset for HG0hg1hg2
sprintf( savename, "data/M%s/CS_ratio_M%s_HG0G1G2.root", module_str.c_str(), module_str.c_str() );
TFile* CS_HGX_file = new TFile((char*)savename,"READ");
TH2F* CS_HGX_ratio_map = 0;
TH2F* CS_HGX_ratioer_map = 0;
if ( CS_HGX_file->IsZombie() ) {
hasHGX=false;
cout << "Did not find HG0 CS file" << endl;
} else {
if (hasHGX) hasHGX=true;
CS_HGX_ratio_map = (TH2F*)CS_HGX_file->Get("g1overg2map");
CS_HGX_ratioer_map = (TH2F*)CS_HGX_file->Get("g1overg2ermap");
}
if (hasHGX) cout << "HG0HG1HG2 data present" <<endl;
// Now write binary maps
// units of ADU/keV
// one output file per module per storage cell with six maps in
GainMaps *mapsObject = new GainMaps;
// start out with all calibration constants zero
for (int i = 0; i < NCH; i++) {
mapsObject->hg0VALs[i] = 0.;
mapsObject->hg1VALs[i] = 0.;
mapsObject->hg2VALs[i] = 0.;
mapsObject->g0VALs[i] = 0.;
mapsObject->g1VALs[i] = 0.;
mapsObject->g2VALs[i] = 0.;
}
TH1F* hg0histall = new TH1F( "hg0histall", "", 160, 80, 160 );
TH1F* g0histall = new TH1F( "g0histall", "", 100, 20, 60 );
TH1F* g1histall = new TH1F( "g1histall", "", 100, -3, 0 );
TH1F* g2histall = new TH1F( "g2histall", "", 100, -0.2, 0 );
TH1F* hg1histall = new TH1F( "hg1histall", "", 100, -3, 0 );
TH1F* hg2histall = new TH1F( "hg2histall", "", 100, -0.2, 0 );
TH1F* hg0ferhistall = new TH1F( "hg0ferhistall", "", 100, 0, 0.005 );
TH1F* g0ferhistall = new TH1F( "g0ferhistall", "", 100, 0, 0.005 );
TH1F* g1ferhistall = new TH1F( "g1ferhistall", "", 100, 0, 0.01 );
TH1F* g2ferhistall = new TH1F( "g2ferhistall", "", 100, 0, 0.05 );
//TH1F* hg1ferhistall = new TH1F("hg1ferhistall","",100,0,0.01); //Not used
//TH1F* hg2ferhistall = new TH1F("hg2ferhistall","",100,0,0.05); //Not used
TH1F* hg0histcut = new TH1F( "hg0histcut", "", 160, 80, 160 );
TH1F* g0histcut = new TH1F( "g0histcut", "", 100, 20, 60 );
TH1F* g1histcut = new TH1F( "g1histcut", "", 100, -3, 0 );
TH1F* g2histcut = new TH1F( "g2histcut", "", 100, -0.2, 0 );
TH1F* hg1histcut = new TH1F( "hg1histcut", "", 100, -3, 0 );
TH1F* hg2histcut = new TH1F( "hg2histcut", "", 100, -0.2, 0 );
TH2F* hg0mapall = new TH2F( "hg0mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g0mapall = new TH2F( "g0mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g1mapall = new TH2F( "g1mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g2mapall = new TH2F( "g2mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* hg1mapall = new TH2F( "hg1mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* hg2mapall = new TH2F( "hg2mapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* hg0fermapall = new TH2F( "hg0fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g0fermapall = new TH2F( "g0fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g1fermapall = new TH2F( "g1fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g2fermapall = new TH2F( "g2fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
//TH2F* hg1fermapall = new TH2F( "hg1fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); //not used
//TH2F* hg2fermapall = new TH2F( "hg2fermapall", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 ); //not used
TH2F* hg0mapcut = new TH2F( "hg0mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g0mapcut = new TH2F( "g0mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g1mapcut = new TH2F( "g1mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* g2mapcut = new TH2F( "g2mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* hg1mapcut = new TH2F( "hg1mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* hg2mapcut = new TH2F( "hg2mapcut", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_hg0 = new TH2F( "defaultvalmap_hg0", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_g0 = new TH2F( "defaultvalmap_g0", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_g1 = new TH2F( "defaultvalmap_g1", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_g2 = new TH2F( "defaultvalmap_g2", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_hg1 = new TH2F( "defaultvalmap_hg1", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* defaultvalmap_hg2 = new TH2F( "defaultvalmap_hg2", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_hg0 = new TH2F( "missingvalmap_hg0", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_g0 = new TH2F( "missingvalmap_g0", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_g1 = new TH2F( "missingvalmap_g1", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_g2 = new TH2F( "missingvalmap_g2", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_hg1 = new TH2F( "missingvalmap_hg1", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
TH2F* missingvalmap_hg2 = new TH2F( "missingvalmap_hg2", "", NC, -0.5, NC-0.5, NR, -0.5, NR-0.5 );
sprintf( savename, "data/M%s/gainMaps_M%s_sc%d_%s.bin", module_str.c_str(), module_str.c_str(), sci, date );
fstream outfile;
outfile.open(savename, ios::binary | ios::out);
for ( int i = 0; i < NCH; ++i ) {
// load existing values into maps
// if the map doesn't exist, put the global default value
if (FL_HG0_gain_map) {
mapsObject->hg0VALs[i] = FL_HG0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
if ( FL_HG0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) == 0 ) {
missingvalmap_hg0->Fill(i%NC,i/NC,1);
}
} else {
mapsObject->hg0VALs[i] = 100.;
defaultvalmap_hg0->Fill( i%NC, i/NC, 1 );
missingvalmap_hg0->Fill( i%NC, i/NC, 1 );
}
if (FL_G0_gain_map) {
mapsObject->g0VALs[i] = FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
if ( FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) == 0 ) {
missingvalmap_g0->Fill( i%NC, i/NC, 1 );
}
} else {
mapsObject->g0VALs[i] = 42;
defaultvalmap_g0->Fill( i%NC, i/NC, 1 );
missingvalmap_g0->Fill( i%NC, i/NC, 1 );
}
if (DB_ratio_map) {
if ( DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
mapsObject->g1VALs[i] = mapsObject->g0VALs[i] / DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
} else {
missingvalmap_g1->Fill( i%NC, i/NC, 1 );
}
} else {
mapsObject->g1VALs[i] = -1.4;
defaultvalmap_g1->Fill( i%NC, i/NC, 1 );
missingvalmap_g1->Fill( i%NC, i/NC, 1 );
}
if (DB_HGX_ratio_map) {
if ( DB_HGX_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
mapsObject->hg1VALs[i] = mapsObject->hg0VALs[i] / DB_HGX_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
} else {
missingvalmap_hg1->Fill( i%NC, i/NC, 1 );
}
} else {
mapsObject->hg1VALs[i] = -1.41;
defaultvalmap_hg1->Fill( i%NC, i/NC, 1 );
missingvalmap_hg1->Fill( i%NC, i/NC, 1 );
}
if (CS_ratio_map) {
if (CS_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
mapsObject->g2VALs[i] = mapsObject->g1VALs[i] / CS_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
} else {
missingvalmap_g2->Fill( i%NC, i/NC, 1 );
}
} else {
mapsObject->g2VALs[i] = -0.1;
defaultvalmap_g2->Fill( i%NC, i/NC, 1 );
missingvalmap_g2->Fill( i%NC, i/NC, 1 );
}
if (CS_HGX_ratio_map) {
if ( CS_HGX_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
mapsObject->hg2VALs[i] = mapsObject->hg1VALs[i] / CS_HGX_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 );
} else {
missingvalmap_hg2->Fill( i%NC, i/NC, 1 );
}
} else {
mapsObject->hg2VALs[i] = -0.11;
defaultvalmap_hg2->Fill( i%NC, i/NC, 1 );
missingvalmap_hg2->Fill( i%NC, i/NC, 1 );
}
hg1histall->Fill( mapsObject->hg1VALs[i] );
hg2histall->Fill( mapsObject->hg2VALs[i] );
hg0histall->Fill( mapsObject->hg0VALs[i] );
g0histall->Fill( mapsObject->g0VALs[i] );
g1histall->Fill( mapsObject->g1VALs[i] );
g2histall->Fill( mapsObject->g2VALs[i] );
hg0mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg0VALs[i] );
hg1mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg1VALs[i] );
hg2mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg2VALs[i] );
g0mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g0VALs[i] );
g1mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g1VALs[i] );
g2mapall->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g2VALs[i] );
// uncertainties
if (FL_HG0_gain_map) {
if ( FL_HG0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
hg0fermapall->SetBinContent( (i%NC)+1, (i/NC)+1, FL_HG0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_HG0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1) );
hg0ferhistall->Fill( FL_HG0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_HG0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1) );
}
}
if (FL_G0_gain_map) {
if ( FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
g0fermapall->SetBinContent( (i%NC)+1, (i/NC)+1, FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) );
g0ferhistall->Fill( FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) );
}
}
if (FL_G0_gain_map && DB_ratio_map) {
if ( FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 && DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
g1fermapall->SetBinContent( (i%NC)+1, (i/NC)+1, sqrt( pow( ( FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1 ,(i/NC)+1) ), 2 ) + pow( ( DB_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1) ), 2 ) ) );
g1ferhistall->Fill( sqrt( pow( ( FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1) ), 2 ) + pow( ( DB_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) ) );
}
}
if (FL_G0_gain_map && DB_ratio_map && CS_ratio_map) {
if ( FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 &&
DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 &&
CS_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) != 0 ) {
g2fermapall->SetBinContent( (i%NC)+1, (i/NC)+1, sqrt( pow( ( FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) + pow( ( DB_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) + pow( ( CS_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/CS_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) ) );
g2ferhistall->Fill( sqrt( pow( ( FL_G0_gainer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/FL_G0_gain_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) + pow( ( DB_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/DB_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) + pow( ( CS_ratioer_map->GetBinContent( (i%NC)+1, (i/NC)+1 )/CS_ratio_map->GetBinContent( (i%NC)+1, (i/NC)+1 ) ), 2 ) ) );
}
}
// if (FL_HG0_gain_map && DB_HGX_ratio_map) { not generating the error distributions for HGOG1G2 at the moment.
} // end NCH for loop
float defaultHG0 = 0;
if (FL_HG0_gain_map) {
defaultHG0 = hg0histall->GetBinCenter( hg0histall->GetMaximumBin() );
}
float defaultG0 = 0;
if (FL_G0_gain_map) {
defaultG0 = g0histall->GetBinCenter( g0histall->GetMaximumBin() );
}
float defaultG1 = 0;
if (DB_ratio_map) {
defaultG1 = g1histall->GetBinCenter( g1histall->GetMaximumBin() );
}
float defaultG2 = 0;
if (CS_ratio_map) {
defaultG2 = g2histall->GetBinCenter( g2histall->GetMaximumBin() );
}
float defaultHG2 = 0;
if (CS_HGX_ratio_map) {
defaultHG2 = hg2histall->GetBinCenter( hg2histall->GetMaximumBin() );
}
float defaultHG1 = 0;
if (DB_HGX_ratio_map) {
defaultHG1 = hg1histall->GetBinCenter( hg1histall->GetMaximumBin() );
}
cout << setprecision(4) << fixed << "default/average values for module " << module_str << " storage cell " << sci << " " << defaultG0 << " " << defaultG1 << " " << defaultG2 <<" " << defaultHG0 << " " << defaultHG1 << " "<< defaultHG2 << " "<< endl;
for ( int i = 0; i < NCH; ++i ) {
// crazy and missing value check: replace with module default
// think of a way to get the limits better
if ( mapsObject->hg0VALs[i] < 80 || mapsObject->hg0VALs[i] > 200 || isnan( mapsObject->hg0VALs[i] ) ) {
mapsObject->hg0VALs[i] = defaultHG0;
defaultvalmap_hg0->Fill( i%NC, i/NC, 1 );
}
if ( mapsObject->hg1VALs[i] < -2.5 || mapsObject->hg1VALs[i] > -0.4 || isnan( mapsObject->hg1VALs[i] ) ) {
mapsObject->hg1VALs[i] = defaultHG1;
defaultvalmap_hg1->Fill( i%NC, i/NC, 1 );
}
if ( mapsObject->hg2VALs[i] < -0.3 || mapsObject->hg2VALs[i] > -0.015 || isnan( mapsObject->hg2VALs[i] ) ) {
mapsObject->hg2VALs[i] = defaultHG2;
defaultvalmap_hg2->Fill( i%NC, i/NC, 1 );
}
if ( mapsObject->g0VALs[i] < 22 || mapsObject->g0VALs[i] > 56 || isnan( mapsObject->g0VALs[i] ) ) { // had to change this from 30 to 22 (think about defaults!)
mapsObject->g0VALs[i] = defaultG0;
defaultvalmap_g0->Fill( i%NC, i/NC, 1 );
}
if ( mapsObject->g1VALs[i] < -2.5 || mapsObject->g1VALs[i] > -0.4 || isnan( mapsObject->g1VALs[i] ) ) {
mapsObject->g1VALs[i] = defaultG1;
defaultvalmap_g1->Fill( i%NC, i/NC, 1 );
}
if ( mapsObject->g2VALs[i] < -0.3 || mapsObject->g2VALs[i] > -0.015 || isnan( mapsObject->g2VALs[i] ) ) {
mapsObject->g2VALs[i] = defaultG2;
defaultvalmap_g2->Fill( i%NC, i/NC, 1 );
}
hg0histcut->Fill( mapsObject->hg0VALs[i] );
hg1histcut->Fill( mapsObject->hg1VALs[i] );
hg2histcut->Fill( mapsObject->hg2VALs[i] );
g0histcut->Fill( mapsObject->g0VALs[i] );
g1histcut->Fill( mapsObject->g1VALs[i] );
g2histcut->Fill( mapsObject->g2VALs[i] );
hg0mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg0VALs[i] );
hg1mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg1VALs[i] );
hg2mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->hg2VALs[i] );
g0mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g0VALs[i] );
g1mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g1VALs[i] );
g2mapcut->SetBinContent( (i%NC)+1, (i/NC)+1, mapsObject->g2VALs[i] );
}
outfile.write( (char*)mapsObject->g0VALs, sizeof(mapsObject->g0VALs) );
outfile.write( (char*)mapsObject->g1VALs, sizeof(mapsObject->g1VALs) );
outfile.write( (char*)mapsObject->g2VALs, sizeof(mapsObject->g2VALs) );
outfile.write( (char*)mapsObject->hg0VALs, sizeof(mapsObject->hg0VALs) );
outfile.write( (char*)mapsObject->hg1VALs, sizeof(mapsObject->hg1VALs) );
outfile.write( (char*)mapsObject->hg2VALs, sizeof(mapsObject->hg2VALs) );
outfile.close();
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);
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);
cout << setprecision(4) << fixed << "mean values for module " << module_str << " storage cell " << sci << " " << g0histcut->GetMean() << " " << g1histcut->GetMean() << " " << g2histcut->GetMean() << " " << hg0histcut->GetMean()<<" " << hg1histcut->GetMean()<<" " << hg2histcut->GetMean() <<endl;
hg0mapall->GetXaxis()->SetTitle("Column");
hg0mapall->GetYaxis()->SetTitle("Row");
hg0mapall->GetYaxis()->SetTitleOffset(0.7);
hg0mapall->Draw("colz");
pave->AddText("HG0 [ADU/keV]");
pave->Draw();
hg0mapall->GetZaxis()->SetRangeUser(90,150);
sprintf( savename, "plots/M%s/Calib_%s/hgain0_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg0mapall->Delete();
hg0fermapall->GetXaxis()->SetTitle("Column");
hg0fermapall->GetYaxis()->SetTitle("Row");
hg0fermapall->GetYaxis()->SetTitleOffset(0.7);
hg0fermapall->Draw("colz");
hg0fermapall->GetZaxis()->SetRangeUser(0.,0.005);
sprintf( savename, "plots/M%s/Calib_%s/hgain0fer_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg0fermapall->Delete();
g0mapall->GetXaxis()->SetTitle("Column");
g0mapall->GetYaxis()->SetTitle("Row");
g0mapall->GetYaxis()->SetTitleOffset(0.7);
g0mapall->Draw("colz");
pave->Clear();
pave->AddText("G0 [ADU/keV]");
pave->Draw();
g0mapall->GetZaxis()->SetRangeUser(27,37); // was 38,46
sprintf( savename, "plots/M%s/Calib_%s/gain0_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g0mapall->Delete();
g0fermapall->GetXaxis()->SetTitle("Column");
g0fermapall->GetYaxis()->SetTitle("Row");
g0fermapall->GetYaxis()->SetTitleOffset(0.7);
g0fermapall->Draw("colz");
g0fermapall->GetZaxis()->SetRangeUser(0.,0.005);
sprintf( savename, "plots/M%s/Calib_%s/gain0fer_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g0fermapall->Delete();
g1mapall->GetXaxis()->SetTitle("Column");
g1mapall->GetYaxis()->SetTitle("Row");
g1mapall->GetYaxis()->SetTitleOffset(0.7);
g1mapall->Draw("colz");
pave->Clear();
pave->AddText("G1 [ADU/keV]");
pave->Draw();
//g1mapall->GetZaxis()->SetRangeUser(-1.56,-1.36);
//g1mapall->GetZaxis()->SetRangeUser(-1.56,-1.16); // VH 2022-04-26
g1mapall->GetZaxis()->SetRangeUser(-1.26,-0.96); // VH 2022-05-20
sprintf( savename, "plots/M%s/Calib_%s/gain1_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g1mapall->Delete();
hg1mapall->GetXaxis()->SetTitle("Column");
hg1mapall->GetYaxis()->SetTitle("Row");
hg1mapall->GetYaxis()->SetTitleOffset(0.7);
hg1mapall->Draw("colz");
pave->Clear();
pave->AddText("HG1 [ADU/keV]");
pave->Draw();
hg1mapall->GetZaxis()->SetRangeUser(-1.66,-1.26);
sprintf( savename, "plots/M%s/Calib_%s/hgain1_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg1mapall->Delete();
g1fermapall->GetXaxis()->SetTitle("Column");
g1fermapall->GetYaxis()->SetTitle("Row");
g1fermapall->GetYaxis()->SetTitleOffset(0.7);
g1fermapall->Draw("colz");
g1fermapall->GetZaxis()->SetRangeUser(0,0.005);
sprintf( savename, "plots/M%s/Calib_%s/gain1fer_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g1fermapall->Delete();
g2mapall->GetXaxis()->SetTitle("Column");
g2mapall->GetYaxis()->SetTitle("Row");
g2mapall->GetYaxis()->SetTitleOffset(0.7);
g2mapall->Draw("colz");
pave->Clear();
pave->AddText("G2 [ADU/keV]");
pave->Draw();
//g2mapall->GetZaxis()->SetRangeUser(-0.122,-0.108);
//g2mapall->GetZaxis()->SetRangeUser(-0.122,-0.088); // VH 2022-04-26
g2mapall->GetZaxis()->SetRangeUser(-0.098,-0.076); // VH 2022-05-20
sprintf( savename, "plots/M%s/Calib_%s/gain2_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g2mapall->Delete();
hg2mapall->GetXaxis()->SetTitle("Column");
hg2mapall->GetYaxis()->SetTitle("Row");
hg2mapall->GetYaxis()->SetTitleOffset(0.7);
hg2mapall->Draw("colz");
pave->Clear();
pave->AddText("HG2 [ADU/keV]");
pave->Draw();
hg2mapall->GetZaxis()->SetRangeUser(-0.14,-0.10);
sprintf( savename, "plots/M%s/Calib_%s/hgain2_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg2mapall->Delete();
g2fermapall->GetXaxis()->SetTitle("Column");
g2fermapall->GetYaxis()->SetTitle("Row");
g2fermapall->GetYaxis()->SetTitleOffset(0.7);
g2fermapall->Draw("colz");
g2fermapall->GetZaxis()->SetRangeUser(0,0.1);
sprintf( savename, "plots/M%s/Calib_%s/gain2fer_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g2fermapall->Delete();
hg0mapcut->GetXaxis()->SetTitle("Column");
hg0mapcut->GetYaxis()->SetTitle("Row");
hg0mapcut->GetYaxis()->SetTitleOffset(0.7);
hg0mapcut->Draw("colz");
pave->Clear();
pave->AddText("HG0 [ADU/keV]");
pave->Draw();
hg0mapcut->GetZaxis()->SetRangeUser(90,110);
sprintf( savename, "plots/M%s/Calib_%s/hgain0_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg0mapcut->Delete();
g0mapcut->GetXaxis()->SetTitle("Column");
g0mapcut->GetYaxis()->SetTitle("Row");
g0mapcut->GetYaxis()->SetTitleOffset(0.7);
g0mapcut->Draw("colz");
pave->Clear();
pave->AddText("G0 [ADU/keV]");
pave->Draw();
g0mapcut->GetZaxis()->SetRangeUser(27,37); // was 38,46
sprintf( savename, "plots/M%s/Calib_%s/gain0_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g0mapcut->Delete();
g1mapcut->GetXaxis()->SetTitle("Column");
g1mapcut->GetYaxis()->SetTitle("Row");
g1mapcut->GetYaxis()->SetTitleOffset(0.7);
g1mapcut->Draw("colz");
pave->Clear();
pave->AddText("G1 [ADU/keV]");
pave->Draw();
//g1mapcut->GetZaxis()->SetRangeUser(-1.56,-1.36);
//g1mapcut->GetZaxis()->SetRangeUser(-1.56,-1.16); // VH 2022-04-26
g1mapcut->GetZaxis()->SetRangeUser(-1.26,-0.96); // VH 2022-05-20
sprintf( savename, "plots/M%s/Calib_%s/gain1_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g1mapcut->Delete();
hg1mapcut->GetXaxis()->SetTitle("Column");
hg1mapcut->GetYaxis()->SetTitle("Row");
hg1mapcut->GetYaxis()->SetTitleOffset(0.7);
hg1mapcut->Draw("colz");
pave->Clear();
pave->AddText("HG1 [ADU/keV]");
pave->Draw();
hg1mapcut->GetZaxis()->SetRangeUser(-1.56,-1.36);
sprintf( savename, "plots/M%s/Calib_%s/hgain1_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg1mapcut->Delete();
g2mapcut->GetXaxis()->SetTitle("Column");
g2mapcut->GetYaxis()->SetTitle("Row");
g2mapcut->GetYaxis()->SetTitleOffset(0.7);
g2mapcut->Draw("colz");
pave->Clear();
pave->AddText("G2 [ADU/keV]");
pave->Draw();
//g2mapcut->GetZaxis()->SetRangeUser(-0.122,-0.108);
//g2mapcut->GetZaxis()->SetRangeUser(-0.122,-0.088); // VH 2022-04-26
g2mapcut->GetZaxis()->SetRangeUser(-0.098,-0.076); // VH 2022-05-20
sprintf( savename, "plots/M%s/Calib_%s/gain2_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
g2mapcut->Delete();
hg2mapcut->GetXaxis()->SetTitle("Column");
hg2mapcut->GetYaxis()->SetTitle("Row");
hg2mapcut->GetYaxis()->SetTitleOffset(0.7);
hg2mapcut->Draw("colz");
pave->Clear();
pave->AddText("HG2 [ADU/keV]");
pave->Draw();
hg2mapcut->GetZaxis()->SetRangeUser(-0.122,-0.108);
sprintf( savename, "plots/M%s/Calib_%s/hgain2_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
hg2mapcut->Delete();
defaultvalmap_hg0->GetXaxis()->SetTitle("Column");
defaultvalmap_hg0->GetYaxis()->SetTitle("Row");
defaultvalmap_hg0->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_hg0->Draw("colz");
pave->Clear();
sprintf(savename,"%d pixels default", int(defaultvalmap_hg0->GetEntries()));
pave->AddText(savename);
pave->Draw();
defaultvalmap_hg0->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_hg0_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_hg0->Delete();
defaultvalmap_g0->GetXaxis()->SetTitle("Column");
defaultvalmap_g0->GetYaxis()->SetTitle("Row");
defaultvalmap_g0->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_g0->Draw("colz");
pave->Clear();
sprintf( savename,"%d pixels default", int( defaultvalmap_g0->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
defaultvalmap_g0->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_g0_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_g0->Delete();
defaultvalmap_g1->GetXaxis()->SetTitle("Column");
defaultvalmap_g1->GetYaxis()->SetTitle("Row");
defaultvalmap_g1->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_g1->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels default", int( defaultvalmap_g1->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
defaultvalmap_g1->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_g1_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_g1->Delete();
defaultvalmap_hg1->GetXaxis()->SetTitle("Column");
defaultvalmap_hg1->GetYaxis()->SetTitle("Row");
defaultvalmap_hg1->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_hg1->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels default", int( defaultvalmap_hg1->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
defaultvalmap_hg1->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_hg1_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_hg1->Delete();
defaultvalmap_g2->GetXaxis()->SetTitle("Column");
defaultvalmap_g2->GetYaxis()->SetTitle("Row");
defaultvalmap_g2->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_g2->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels default", int( defaultvalmap_g2->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
defaultvalmap_g2->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_g2_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_g2->Delete();
defaultvalmap_hg2->GetXaxis()->SetTitle("Column");
defaultvalmap_hg2->GetYaxis()->SetTitle("Row");
defaultvalmap_hg2->GetYaxis()->SetTitleOffset(0.7);
defaultvalmap_hg2->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels default", int( defaultvalmap_hg2->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
defaultvalmap_hg2->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/defaultvalmap_hg2_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
defaultvalmap_hg2->Delete();
missingvalmap_hg0->GetXaxis()->SetTitle("Column");
missingvalmap_hg0->GetYaxis()->SetTitle("Row");
missingvalmap_hg0->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_hg0->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels missing", int( missingvalmap_hg0->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
missingvalmap_hg0->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_hg0_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
missingvalmap_hg0->Delete();
missingvalmap_g0->GetXaxis()->SetTitle("Column");
missingvalmap_g0->GetYaxis()->SetTitle("Row");
missingvalmap_g0->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_g0->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels missing", int( missingvalmap_g0->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
missingvalmap_g0->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_g0_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
missingvalmap_g0->Delete();
missingvalmap_g1->GetXaxis()->SetTitle("Column");
missingvalmap_g1->GetYaxis()->SetTitle("Row");
missingvalmap_g1->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_g1->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels missing", int( missingvalmap_g1->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
missingvalmap_g1->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_g1_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci);
mapcanvas->SaveAs( (const char *)(savename) );
missingvalmap_g1->Delete();
missingvalmap_g2->GetXaxis()->SetTitle("Column");
missingvalmap_g2->GetYaxis()->SetTitle("Row");
missingvalmap_g2->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_g2->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels missing", int( missingvalmap_g2->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
missingvalmap_g2->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_g2_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
missingvalmap_g2->Delete();
missingvalmap_hg1->GetXaxis()->SetTitle("Column");
missingvalmap_hg1->GetYaxis()->SetTitle("Row");
missingvalmap_hg1->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_hg1->Draw("colz");
pave->Clear();
sprintf(savename,"%d pixels missing", int(missingvalmap_hg1->GetEntries()));
pave->AddText(savename);
pave->Draw();
missingvalmap_hg1->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_hg1_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs((const char *)(savename));
missingvalmap_hg1->Delete();
missingvalmap_hg2->GetXaxis()->SetTitle("Column");
missingvalmap_hg2->GetYaxis()->SetTitle("Row");
missingvalmap_hg2->GetYaxis()->SetTitleOffset(0.7);
missingvalmap_hg2->Draw("colz");
pave->Clear();
sprintf( savename, "%d pixels missing", int( missingvalmap_hg2->GetEntries() ) );
pave->AddText(savename);
pave->Draw();
missingvalmap_hg2->GetZaxis()->SetRangeUser(0,1);
sprintf( savename, "plots/M%s/Calib_%s/missingvalmap_hg2_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
mapcanvas->SaveAs( (const char *)(savename) );
missingvalmap_hg2->Delete();
TCanvas* c1 = new TCanvas("c1","");
hg0histcut->SetLineColor(kRed);
g0histcut->SetLineColor(kRed);
g1histcut->SetLineColor(kRed);
g2histcut->SetLineColor(kRed);
hg0histall->GetXaxis()->SetTitle("Gain HG0 [ADU / keV]");
hg0histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg0hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg0histall->Delete();
hg0histcut->GetXaxis()->SetTitle("Gain HG0 [ADU / keV]");
hg0histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg0hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg0histcut->Delete();
hg0histcut->Draw();
hg0histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/hg0hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf( savename, "plots/M%s/Calib_%s/hg0hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
hg0histall->Delete();
hg0histcut->Delete();
g0histall->GetXaxis()->SetTitle("Gain G0 [ADU / keV]");
g0histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g0hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g0histall->Delete();
g0histcut->GetXaxis()->SetTitle("Gain G0 [ADU / keV]");
g0histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g0hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g0histcut->Delete();
g0histcut->Draw();
g0histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/g0hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf(savename,"plots/M%s/Calib_%s/g0hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
g0histall->Delete();
g0histcut->Delete();
g1histall->GetXaxis()->SetTitle("Gain G1 [ADU / keV]");
g1histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g1hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g1histall->Delete();
g1histcut->GetXaxis()->SetTitle("Gain G1 [ADU / keV]");
g1histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g1hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g1histcut->Delete();
g1histcut->Draw();
g1histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/g1hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf( savename, "plots/M%s/Calib_%s/g1hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
g1histcut->Delete();
g1histall->Delete();
hg1histall->GetXaxis()->SetTitle("Gain HG1 [ADU / keV]");
hg1histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg1hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg1histall->Delete();
hg1histcut->GetXaxis()->SetTitle("Gain HG1 [ADU / keV]");
hg1histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg1hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg1histcut->Delete();
hg1histcut->Draw();
hg1histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/hg1hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf( savename, "plots/M%s/Calib_%s/hg1hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
hg1histall->Delete();
hg1histcut->Delete();
g2histall->GetXaxis()->SetTitle("Gain G2 [ADU / keV]");
g2histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g2hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g2histall->Delete();
g2histcut->GetXaxis()->SetTitle("Gain G2 [ADU / keV]");
g2histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g2hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//g2histcut->Delete();
g2histcut->Draw();
g2histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/g2hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf( savename, "plots/M%s/Calib_%s/g2hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
g2histall->Delete();
g2histcut->Delete();
hg2histall->GetXaxis()->SetTitle("Gain HG2 [ADU / keV]");
hg2histall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg2hist_all_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg2histall->Delete();
hg2histcut->GetXaxis()->SetTitle("Gain HG2 [ADU / keV]");
hg2histcut->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg2hist_cut_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
//hg2histcut->Delete();
hg2histcut->Draw();
hg2histall->Draw("same");
sprintf( savename, "plots/M%s/Calib_%s/hg2hist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy();
sprintf( savename, "plots/M%s/Calib_%s/hg2hist_log_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
c1->SetLogy(0);
hg2histall->Delete();
hg2histcut->Delete();
hg0ferhistall->GetXaxis()->SetTitle("Gain HG0 frac uncert");
hg0ferhistall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/hg0ferhist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
hg0ferhistall->Delete();
g0ferhistall->GetXaxis()->SetTitle("Gain G0 frac uncert");
g0ferhistall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g0ferhist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
g0ferhistall->Delete();
g1ferhistall->GetXaxis()->SetTitle("Gain G1 frac uncert");
g1ferhistall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g1ferhist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
g1ferhistall->Delete();
g2ferhistall->GetXaxis()->SetTitle("Gain G2 frac uncert");
g2ferhistall->Draw();
sprintf( savename, "plots/M%s/Calib_%s/g2ferhist_M%s_sc%d.png", module_str.c_str(), date, module_str.c_str(), sci );
c1->SaveAs( (const char *)(savename) );
g2ferhistall->Delete();
} // end of SC for loop
}