Adapt analysis code to avoid hardcoded absolute paths (add additional argv), add paths only in filename_creator
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
// file to take current source scan files, analyse and plot them.
|
||||
// changes by VH 210906: to eliminate hardcoded absolute paths, uses location of the analysis root files as additional input argument (accordingly changed in filename_creator.sh)
|
||||
|
||||
|
||||
#include "../sls_detector_calibration/jungfrauCommonHeader.h"
|
||||
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
|
||||
@ -30,12 +32,15 @@ double checkRangeMinForRCEffect(double range_min) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
jungfrauStyle();
|
||||
gROOT->SetBatch(1);
|
||||
gStyle->SetOptFit(11);
|
||||
|
||||
/*
|
||||
if (argc != 4) {
|
||||
cout << "Correct usage:" << endl;
|
||||
cout << "arg 1: specify module number" << endl;
|
||||
@ -44,10 +49,31 @@ int main(int argc, char* argv[]) {
|
||||
cout << " " << endl;
|
||||
exit(1);
|
||||
}
|
||||
*/ //uncomment for SR
|
||||
|
||||
if (argc != 5) {
|
||||
cout << "Correct usage:" << endl;
|
||||
cout << "arg 1: specify module number" << endl;
|
||||
cout << "arg 2: specify data location folder" << endl;
|
||||
cout << "arg 3: specify data file prefix" << endl;
|
||||
cout << "arg 4: specify location of analysis root files" << endl;
|
||||
cout << " " << endl;
|
||||
exit(1);
|
||||
} //uncomment for VH 210906
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string module_str = argv[1];
|
||||
string data_loc = argv[2];
|
||||
string data_file = argv[3];
|
||||
string anadata_loc = argv[4]; //uncomment for VH 210906
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vector<string> scan_v1;
|
||||
scan_v1.push_back("002");
|
||||
@ -252,6 +278,39 @@ int main(int argc, char* argv[]) {
|
||||
scan_v6.push_back("355");
|
||||
scan_v6.push_back("364");
|
||||
scan_v6.push_back("366");
|
||||
scan_v6.push_back("243");
|
||||
scan_v6.push_back("339");
|
||||
scan_v6.push_back("341");
|
||||
scan_v6.push_back("368");
|
||||
scan_v6.push_back("376");
|
||||
scan_v6.push_back("379");
|
||||
|
||||
scan_v6.push_back("359");
|
||||
scan_v6.push_back("363");
|
||||
scan_v6.push_back("365");
|
||||
scan_v6.push_back("347");
|
||||
scan_v6.push_back("366");
|
||||
|
||||
|
||||
scan_v6.push_back("268");
|
||||
scan_v6.push_back("300");
|
||||
scan_v6.push_back("302");
|
||||
scan_v6.push_back("303");
|
||||
scan_v6.push_back("309");
|
||||
scan_v6.push_back("326");
|
||||
|
||||
scan_v6.push_back("308");
|
||||
scan_v6.push_back("322");
|
||||
scan_v6.push_back("328");
|
||||
scan_v6.push_back("332");
|
||||
scan_v6.push_back("335");
|
||||
scan_v6.push_back("353");
|
||||
scan_v6.push_back("335_FW2_2");
|
||||
scan_v6.push_back("353_FW2_2");
|
||||
|
||||
scan_v6.push_back("262_FWcheck_1_1_1");
|
||||
scan_v6.push_back("262_FWcheck_1_1_1_test");
|
||||
scan_v6.push_back("262_FWcheck_1_2_rc210831");
|
||||
|
||||
|
||||
jungfrauFile *thisfile = new jungfrauFile();
|
||||
@ -274,7 +333,8 @@ int main(int argc, char* argv[]) {
|
||||
TH2F* no_g0g1_calib_map = new TH2F("no_g0g1_calib_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
||||
TH2F* no_g1g2_calib_map = new TH2F("no_g1g2_calib_map","",NC,-0.5,NC-0.5,NR,-0.5,NR-0.5);
|
||||
|
||||
char savename[128];
|
||||
//char savename[128];
|
||||
char savename[256]; // VH 210902
|
||||
|
||||
int createHistoFile = 1; //set 0 for a fit-only run
|
||||
int createPerStepHistos = 0; //debug
|
||||
@ -294,11 +354,12 @@ int main(int argc, char* argv[]) {
|
||||
sprintf(savename,"plots/M%s/CurrentSource", module_str.c_str());
|
||||
mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
// /mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/Mxxx_CalibAna
|
||||
sprintf(savename,"/mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/M%s_CalibAna", module_str.c_str());
|
||||
//sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna", module_str.c_str()); //uncomment for SR
|
||||
sprintf(savename,"%s", anadata_loc.c_str()); //uncomment for VH 210906
|
||||
mkdir(savename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
|
||||
// open first file
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str());
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str()); //VH: note, this adds a double slash in the filepath
|
||||
thisfile->open((char*)savename, 0);
|
||||
|
||||
// calculate pixel mask
|
||||
@ -312,7 +373,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
for (int i = 0; i < 640; i++) {
|
||||
thisfile->readNextFrame();
|
||||
pixelMaskObject->maskIfGainNot(1, thisfile->getFrameDataHandle(), pixel_mask);
|
||||
pixelMaskObject->maskIfGainNot(1, thisfile->getFrameDataHandle(), pixel_mask); // change to Not(2 to fix FW error during JF11 FW develop. needed for modules 243-379
|
||||
}
|
||||
cout << "after G1, n masked pixels is " << pixelMaskObject->getNMasked(pixel_mask) << endl;
|
||||
|
||||
@ -504,7 +565,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
for (int filei = 0; filei < nfiles; filei++) {
|
||||
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str());
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str()); //VH: note, this adds a double slash in the filepath
|
||||
thisfile->open((char*)savename, filei);
|
||||
|
||||
while(thisfile->readNextFrame()) {
|
||||
@ -525,7 +586,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
for (int filei = 0; filei < nfiles; filei++) {
|
||||
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str());
|
||||
sprintf(savename,"%s/%s_%%6.6d.dat", data_loc.c_str(), data_file.c_str()); //VH: note, this adds a double slash in the filepath
|
||||
thisfile->open((char*)savename, filei);
|
||||
|
||||
if (filei == 0) {
|
||||
@ -560,7 +621,7 @@ int main(int argc, char* argv[]) {
|
||||
gain_histos[i]->Fill(gain);
|
||||
if (gain == 0) {
|
||||
adc_histos_g0[i]->Fill(adc);
|
||||
} else if (gain == 1) {
|
||||
} else if ((gain == 1)||(gain == 2)) { //(gain == 2) to fix FW error during JF11 FW develop. needed for modules 243-379
|
||||
adc_histos_g1[i]->Fill(adc);
|
||||
} else if (gain == 3) {
|
||||
adc_histos_g2[i]->Fill(adc);
|
||||
@ -764,7 +825,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// save histograms
|
||||
sprintf(savename,"/mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/M%s_CalibAna/CS_histos_M%s.root", module_str.c_str(), module_str.c_str());
|
||||
//sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CS_histos_M%s.root", module_str.c_str(), module_str.c_str()); //uncomment for SR
|
||||
sprintf(savename,"%s/CS_histos_M%s.root", anadata_loc.c_str(), module_str.c_str()); //uncomment for VH 210906
|
||||
TFile* saved_file = new TFile((const char *)(savename),"RECREATE");
|
||||
|
||||
for (int i = 0; i < 97; i++) {
|
||||
@ -779,7 +841,8 @@ int main(int argc, char* argv[]) {
|
||||
} else {
|
||||
// load histos
|
||||
cout << "LOADING HISTOS" << endl;
|
||||
sprintf(savename,"/mnt/pcmoench_jungfrau_data/jungfrau_ana_sophie/M%s_CalibAna/CS_histos_M%s.root", module_str.c_str(), module_str.c_str());
|
||||
//sprintf(savename,"/mnt/sls_det_storage/jungfrau_data1/jungfrau_ana_sophie/M%s_CalibAna/CS_histos_M%s.root", module_str.c_str(), module_str.c_str()); //uncomment for SR
|
||||
sprintf(savename,"%s/CS_histos_M%s.root", anadata_loc.c_str(), module_str.c_str()); //uncomment for VH 210906
|
||||
TFile* saved_file = new TFile((const char *)(savename),"READ");
|
||||
|
||||
for (int i = 0; i < 97; i++) {
|
||||
|
Reference in New Issue
Block a user