Files
JFCalibration/Default_pixels_arrays.cpp
carulla_m_ 427b525022 BP_analysis.cpp add comments on the script
BP_analysis_M431 modified
BP_analysis_M431.cpp modified
BP_scan.sh must declare module number as argument and readout speed (full_speed or half_speed) Modified the communication interface and commands to the pulser
BP_scan_both_speeds.sh Added Vb_comp 1220 at the end of the script and Modified the communication interface and commands to the pulser
CS_analysis.cpp add list of new modules for analysis
CS_analysis_JF11 modified
CS_analysis_M431.cpp modified
CS_fit.cpp add new modules in the list
CS_scan.sh must declare module number as argument and readout speed (full_speed or half_speed)
CS_scan_both_speeds.sh Added Vb_comp 1220 at the end of the script
CuFluo_exposure.sh Change HV to 60V and I to 40mA instead of 40V and 60mV+ must declare module number as argument and readout speed (full_speed or half_speed)
CuFluo_exposure_JF11.s Change HV to 60V and I to 40mA instead of 40V and 60mV
CuFluo_exposure_both_speeds.sh Change HV to 60V and I to 40mA instead of 40V and 60m
CuFluo_exposure_sc.sh Change HV to 60V and I to 40mA instead of 40V and 60m. Adjust the period to avoid losing packets
CuFluo_fit_sc.cpp Create a new file to fit Cu and noise peak fit for the storage cells data
Default_pixels_arrays.cpp Creates a default pixels system map given the module numbers of the system
Fluo_analysis_Ti_In.cpp Analysis the data for Fluorecensce target: Ti, Fe, Cu, Se, Mo, or In. The target needs to be passed as an argument.
Fluo_exposure_Ti_In.sh Fluorescence exposure with targets: Ti, Fe, Cu, Se, Mo, or In.
Fluo_fit.cpp Function to fit the fluorescence peaks for the different targets: Ti, Fe, Cu, Se, Mo, or In. The target needs to be passed as an argument.
JFMC_CalibWriter_wBP_sc.cpp change the range of the g0cutmap
Multi_filename_creator.sh Bash file to create 6 different receivers, one for each JFcalib readout board
filename_creator.sh add comments
makefile Add new objects:Fluo_analysis_Ti_In, Fluo_fit, CuFluo_fit_sc, CS_fit, BP_fit, etc...
2026-02-20 16:38:10 +01:00

249 lines
8.7 KiB
C++

// file to create the hg0, g0, g1,and g2 bin files of default pixels for a list of modules past as an argument
// Each file contains the default pixels map for the list of modules past as an argument
// It save 4 files. One for each gain stage.
#include "../sls_detector_calibration/jungfrauCommonHeader.h"
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
#include <fstream>
#include <dirent.h>
#include "TCanvas.h"
#include "TFile.h"
#include "TH2F.h"
#include "TGraph.h"
#include "TF1.h"
int main(int argc, char* argv[]) {
jungfrauStyle();
if (argc == 1) {
cout << "Correct usage:" << endl;
cout << "arg 1: specify module number" << endl;
cout << "Number of arguments "<< argc << endl;
cout << " " << endl;
exit(1);
} else {
char savename[256];
char savename_hg0[256];
char savename_g0[256];
char savename_g1[256];
char savename_g2[256];
// today's date
time_t rawtime;
tm* timeinfo;
char date[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(date,80,"%Y-%m-%d",timeinfo);
sprintf(savename_hg0,"/afs/psi.ch/user/c/carulla_m/JFProjects/defaultMaps_HG0_%s.bin", date);
fstream outfile_hg0;
outfile_hg0.open(savename_hg0, ios::binary | ios::out);
sprintf(savename_g0,"/afs/psi.ch/user/c/carulla_m/JFProjects/defaultMaps_G0_%s.bin", date);
fstream outfile_g0;
outfile_g0.open(savename_g0, ios::binary | ios::out);
sprintf(savename_g1,"/afs/psi.ch/user/c/carulla_m/JFProjects/defaultMaps_G1_%s.bin", date);
fstream outfile_g1;
outfile_g1.open(savename_g1, ios::binary | ios::out);
sprintf(savename_g2,"/afs/psi.ch/user/c/carulla_m/JFProjects/defaultMaps_G2_%s.bin", date);
fstream outfile_g2;
outfile_g2.open(savename_g2, ios::binary | ios::out);
for (int j=1; j<argc; j++) {
cout << j << endl;
string this_module = argv[j];
cout << "Processing module "<< this_module << endl;
std::vector<short> this_g0_default_pixels(NCH,0);
std::vector<short> this_g1_default_pixels(NCH,0);
std::vector<short> this_g2_default_pixels(NCH,0);
std::vector<short> this_hg0_default_pixels(NCH,0);
// // CuFluo HG0 dataset
sprintf(savename,"data/M%s/CuFluo_gain_HG0_M%s.root", this_module.c_str(), this_module.c_str());
TFile* FL_HG0_file = new TFile((char*)savename,"READ");
TH2F* FL_HG0_gain_map = 0;
if (FL_HG0_file->IsZombie()) {
cout << "didn't find HG0 file" << endl;
} else {
FL_HG0_gain_map = (TH2F*)FL_HG0_file->Get("gain_ADUper1keV_2d");
cout << "The HG0 map is loaded" << endl;
}
// CuFluo G0 dataset
sprintf(savename,"data/M%s/CuFluo_gain_G0_M%s.root", this_module.c_str(), this_module.c_str());
TFile* FL_G0_file = new TFile((char*)savename,"READ");
TH2F* FL_G0_gain_map = 0;
if (FL_G0_file->IsZombie()) {
cout << "didn't find G0 file" << endl;
} else {
FL_G0_gain_map = (TH2F*)FL_G0_file->Get("gain_ADUper1keV_2d");
}
// Backplane pulsing dataset
sprintf(savename,"data/M%s/BP_ratio_M%s.root", this_module.c_str(), this_module.c_str());
TFile* DB_file = new TFile((char*)savename,"READ");
TH2F* DB_ratio_map = 0;
if (DB_file->IsZombie()) {
cout << "didn't find BP file" << endl;
// look for a direct beam dataset
sprintf(savename,"data/M%s/DB_ratio_M%s.root", this_module.c_str(), this_module.c_str());
DB_file = new TFile((char*)savename,"READ");
if (DB_file->IsZombie()) {
cout << "also didn't find DB file" << endl;
} else {
cout << "loading G0/G1 from DB" << endl;
DB_ratio_map = (TH2F*)DB_file->Get("g0overg1map");
}
} else {
cout << "loading G0/G1 from BP" << endl;
DB_ratio_map = (TH2F*)DB_file->Get("g0overg1_map");
}
// Current source dataset
sprintf(savename,"data/M%s/CS_ratio_M%s.root", this_module.c_str(), this_module.c_str());
TFile* CS_file = new TFile((char*)savename,"READ");
TH2F* CS_ratio_map = 0;
if (CS_file->IsZombie()) {
cout << "didn't find CS file" << endl;
} else {
CS_ratio_map = (TH2F*)CS_file->Get("g1overg2map");
cout << "loading G1/G2 map" << endl;
}
for (int i=0; i<NCH; i++) {
double this_hg0 = 0;
double this_g0 = 0;
double this_g0overg1 = 0;
double this_g1 = 0;
double this_g1_2 = 0;
double this_g1overg2 = 0;
double this_g2 = 0;
double this_g2_2 =0;
// HG0
if (FL_HG0_gain_map) {
this_hg0 = FL_HG0_gain_map->GetBinContent((i%NC)+1,(i/NC)+1);
//cout << "Gain value is " << this_hg0 << endl;
//this_hg0_default_pixels[i] = 0;
if (this_hg0 == 0) {
this_hg0_default_pixels[i] = 1;
} else if (this_hg0 < 80 || this_hg0 > 200) {
this_hg0_default_pixels[i] = 1;
}
} else {
this_hg0_default_pixels[i] = 1;
}
// G0
if (FL_G0_gain_map) {
this_g0 = FL_G0_gain_map->GetBinContent((i%NC)+1,(i/NC)+1);
//this_g0_default_pixels[i] = 0;
if (this_g0 == 0) {
this_g0_default_pixels[i] = 1;
} else if (this_g0 < 30 || this_g0 > 56) {
this_g0_default_pixels[i] = 1;
}
} else {
this_g0_default_pixels[i] = 1;
}
// G1
if (DB_ratio_map) {
this_g0overg1 = DB_ratio_map->GetBinContent((i%NC)+1,(i/NC)+1);
this_g1 = this_g0 / this_g0overg1;
this_g1_2 = this_g0_default_pixels[i];
this_g1_default_pixels[i] = 0;
if (this_g0overg1 == 0) {
this_g1_default_pixels[i] = 1;
} else if (this_g0 != 0 && (this_g1 < -2.5 || this_g1 > -0.4)) {
this_g1_default_pixels[i] = 1;
} else if (this_g1_2 == 1) {
this_g1_default_pixels[i] =1;
}
} else {
this_g1_default_pixels[i] = 1;
}
// G2
if (CS_ratio_map) {
this_g1overg2 = CS_ratio_map->GetBinContent((i%NC)+1,(i/NC)+1);
this_g2 = this_g1 / this_g1overg2;
this_g2_2 = this_g1_default_pixels[i];
this_g2_default_pixels[i] = 0;
if (this_g1overg2 == 0) {
this_g2_default_pixels[i] = 1;
} else if (this_g0 != 0 && this_g1 != 0 && (this_g2 < -0.3 || this_g2 > -0.015)) {
this_g2_default_pixels[i] = 1;
} else if (this_g2_2 == 1) {
this_g2_default_pixels[i] =1;
}
} else {
this_g2_default_pixels[i] = 1;
}
if (this_module == "586") {
if ( (i/NC) > 0 && (i/NC)<256 && (i%NC)> 768 && (i%NC)<1024 ) {
this_g2_default_pixels[i]=1;
this_g1_default_pixels[i]=1;
}
}
if (this_module == "454") {
if ( (i/NC) > 0 && (i/NC)<256 && (i%NC)> 768 && (i%NC)<1024 ) {
this_g2_default_pixels[i]=1;
}
}
//hg0_default_pixels.push_back(this_hg0_default_pixels[i]);
outfile_hg0.write(reinterpret_cast<const char *>(&this_hg0_default_pixels[i]), sizeof(short));
// g0_default_pixels.push_back(this_g0_default_pixels[i]);
outfile_g0.write(reinterpret_cast<const char *>(&this_g0_default_pixels[i]), sizeof(short));
// g1_default_pixels.push_back(this_g1_default_pixels[i]);
outfile_g1.write(reinterpret_cast<const char *>(&this_g1_default_pixels[i]), sizeof(short));
// g2_default_pixels.push_back(this_g2_default_pixels[i]);
outfile_g2.write(reinterpret_cast<const char *>(&this_g2_default_pixels[i]), sizeof(short));
}
// //Modules_d.push_back(this_module);
// cout << "Module loop after push_back" << endl;
// cout << j << endl;
cout << "Pixels number " << this_hg0_default_pixels.size() << endl;
}
outfile_hg0.close();
outfile_g0.close();
outfile_g1.close();
outfile_g2.close();
cout << "Files closed" << endl;
// outfile_g0.close();
// outfile_g1.close();
// outfile_g2.close();
// cout<< "Number of words "<< sizeof(hg0_default_pixels)<< endl;
// cout<< "Size of HG0 map"<< hg0_default_pixels.size() * sizeof(int)<< endl;
}
}