Module comparison now uses the most recent gain file.

This commit is contained in:
redford_s
2019-02-27 14:52:44 +01:00
parent 9e24a15bb6
commit fb1d930127

View File

@ -4,6 +4,7 @@
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
#include <fstream>
#include <stdexcept>
#include "TH1F.h"
#include "TCanvas.h"
@ -18,6 +19,22 @@ struct GainMaps
double hg0VALs[NCH];
};
std::string stdoutOfCommand(const char* cmd) {
char buffer[128];
std::string result = "";
FILE* pipe = popen(cmd, "r");
if (!pipe) throw std::runtime_error("popen() failed!");
try {
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
result += buffer;
}
} catch (...) {
pclose(pipe);
throw;
}
pclose(pipe);
return result;
}
int main(int argc, char* argv[]) {
@ -54,12 +71,16 @@ int main(int argc, char* argv[]) {
}
// get gain maps
sprintf(savename,"ls -1 data/M%3.3d/gainMaps_M%3.3d* | tail -1", j, j);
string mostRecentGainFile = stdoutOfCommand(savename);
mostRecentGainFile.erase(std::remove(mostRecentGainFile.begin(), mostRecentGainFile.end(), '\n'), mostRecentGainFile.end());
fstream infile;
sprintf(savename,"data/M%3.3d/gainMaps_M%3.3d.bin", j, j);
infile.open((char*)savename, ios::in | ios::binary);
infile.open(mostRecentGainFile.c_str(), ios::in | ios::binary);
if (not infile.is_open()) {
continue;
}
cout << "found " << mostRecentGainFile << endl;
infile.read((char*)mapsObject->g0VALs, sizeof(mapsObject->g0VALs));
infile.read((char*)mapsObject->g1VALs, sizeof(mapsObject->g1VALs));