Module comparison now uses the most recent gain file.
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
|
#include "../sls_detector_calibration/jungfrauCommonFunctions.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "TH1F.h"
|
#include "TH1F.h"
|
||||||
#include "TCanvas.h"
|
#include "TCanvas.h"
|
||||||
@ -18,6 +19,22 @@ struct GainMaps
|
|||||||
double hg0VALs[NCH];
|
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[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
@ -54,12 +71,16 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get gain maps
|
// 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;
|
fstream infile;
|
||||||
sprintf(savename,"data/M%3.3d/gainMaps_M%3.3d.bin", j, j);
|
infile.open(mostRecentGainFile.c_str(), ios::in | ios::binary);
|
||||||
infile.open((char*)savename, ios::in | ios::binary);
|
|
||||||
if (not infile.is_open()) {
|
if (not infile.is_open()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
cout << "found " << mostRecentGainFile << endl;
|
||||||
|
|
||||||
infile.read((char*)mapsObject->g0VALs, sizeof(mapsObject->g0VALs));
|
infile.read((char*)mapsObject->g0VALs, sizeof(mapsObject->g0VALs));
|
||||||
infile.read((char*)mapsObject->g1VALs, sizeof(mapsObject->g1VALs));
|
infile.read((char*)mapsObject->g1VALs, sizeof(mapsObject->g1VALs));
|
||||||
|
Reference in New Issue
Block a user