mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
Jf rawdataprocess txtfile (#732)
* Fix ROI mapping * Formatting * Minor edit * intial draft of cmake for jungfrau executables Makefile.rawdataprocess * added the cmake file * missed Makefile * added libfmt * Fix some compiler warnings * Fix some compiler warnings * Create filename usining fmt::format * Rewrite command line parsing with std::string and fmt::format * Fix file reading * Fix root string extraction * Fix ifstream file reading * Clean up comments * Add version of rawdataprocess with bash wildcards * Add version of rawdataprocess that reads inputs from txt-file, still buggy * intermediate * fix file loop * fix const * Circumevent bug with stuck threads * Fix mutex bug * cleanup --------- Co-authored-by: vhinger182 <hinger_v@hv_home_lt1.localdomain> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch> Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
This commit is contained in:
parent
74acbb15f5
commit
4c6be26846
@ -14,7 +14,7 @@ target_compile_definitions(jungfrauRawDataProcess PRIVATE MODULE)
|
|||||||
list(APPEND JUNGFRAU_EXECUTABLES jungfrauRawDataProcess)
|
list(APPEND JUNGFRAU_EXECUTABLES jungfrauRawDataProcess)
|
||||||
|
|
||||||
# jungfrauRawDataProcessStrx
|
# jungfrauRawDataProcessStrx
|
||||||
add_executable(jungfrauRawDataProcessStrx jungfrauRawDataProcess.cpp)
|
add_executable(jungfrauRawDataProcessStrx jungfrauRawDataProcess_filetxt.cpp)
|
||||||
target_compile_definitions(jungfrauRawDataProcessStrx PRIVATE JFSTRX)
|
target_compile_definitions(jungfrauRawDataProcessStrx PRIVATE JFSTRX)
|
||||||
list(APPEND JUNGFRAU_EXECUTABLES jungfrauRawDataProcessStrx)
|
list(APPEND JUNGFRAU_EXECUTABLES jungfrauRawDataProcessStrx)
|
||||||
|
|
||||||
|
@ -59,14 +59,12 @@ std::string getRootString( const std::string& filepath ) {
|
|||||||
// aindex: acquisition index (i.e. "run number")
|
// aindex: acquisition index (i.e. "run number")
|
||||||
|
|
||||||
std::string createFileName( const std::string& dir, const std::string& fprefix="run", const std::string& fsuffix="", const std::string& fext="raw", int aindex=0, int mindex=0, int findex=0, int outfilecounter=-1 ) {
|
std::string createFileName( const std::string& dir, const std::string& fprefix="run", const std::string& fsuffix="", const std::string& fext="raw", int aindex=0, int mindex=0, int findex=0, int outfilecounter=-1 ) {
|
||||||
std::string filename{};
|
|
||||||
if (outfilecounter >= 0)
|
if (outfilecounter >= 0)
|
||||||
filename = fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}_f{:05d}.{:s}", dir, fprefix, mindex, findex, aindex, outfilecounter, fext);
|
return fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}_f{:05d}.{:s}", dir, fprefix, mindex, findex, aindex, outfilecounter, fext);
|
||||||
else if (fsuffix.length()!=0)
|
else if (fsuffix.length()!=0)
|
||||||
filename = fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
|
return fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
|
||||||
else
|
else
|
||||||
filename = fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}.{:s}", dir, fprefix, mindex, findex, aindex, fext);
|
return fmt::format("{:s}/{:s}_d{:d}_f{:d}_{:d}.{:s}", dir, fprefix, mindex, findex, aindex, fext);
|
||||||
return filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
std::string getRootString( const std::string filepath ) {
|
|
||||||
|
std::string getRootString( const std::string& filepath ) {
|
||||||
size_t pos1;
|
size_t pos1;
|
||||||
if (filepath.find("/") == std::string::npos )
|
if (filepath.find("/") == std::string::npos )
|
||||||
pos1 = 0;
|
pos1 = 0;
|
||||||
@ -57,15 +58,13 @@ std::string getRootString( const std::string filepath ) {
|
|||||||
// fprefix: fileprefix (without extension)
|
// fprefix: fileprefix (without extension)
|
||||||
// fsuffix: filesuffix (for output files, e.g. "ped")
|
// fsuffix: filesuffix (for output files, e.g. "ped")
|
||||||
// fext: file extension (e.g. "raw")
|
// fext: file extension (e.g. "raw")
|
||||||
std::string createFileName( const std::string dir, std::string fprefix="run", std::string fsuffix="", std::string fext="raw", int outfilecounter=-1 ) {
|
std::string createFileName( const std::string& dir, const std::string& fprefix="run", const std::string& fsuffix="", const std::string& fext="raw", int outfilecounter=-1 ) {
|
||||||
std::string filename{};
|
|
||||||
if (outfilecounter >= 0)
|
if (outfilecounter >= 0)
|
||||||
filename = fmt::format("{:s}/{:s}_{:s}_f{:05d}.{:s}", dir, fprefix, fsuffix, outfilecounter, fext);
|
return fmt::format("{:s}/{:s}_{:s}_f{:05d}.{:s}", dir, fprefix, fsuffix, outfilecounter, fext);
|
||||||
else if (fsuffix.length()!=0)
|
else if (fsuffix.length()!=0)
|
||||||
filename = fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
|
return fmt::format("{:s}/{:s}_{:s}.{:s}", dir, fprefix, fsuffix, fext);
|
||||||
else
|
else
|
||||||
filename = fmt::format("{:s}/{:s}.{:s}", dir, fprefix, fext);
|
return fmt::format("{:s}/{:s}.{:s}", dir, fprefix, fext);
|
||||||
return filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -104,9 +103,9 @@ int main(int argc, char *argv[]) {
|
|||||||
int ff, np;
|
int ff, np;
|
||||||
// cout << " data size is " << dsize;
|
// cout << " data size is " << dsize;
|
||||||
|
|
||||||
std::string txtfilename(argv[1]);
|
const std::string txtfilename(argv[1]);
|
||||||
std::string outdir(argv[2]);
|
const std::string outdir(argv[2]);
|
||||||
std::string pedfilename(argv[3]);
|
const std::string pedfilename(argv[3]);
|
||||||
|
|
||||||
int xmin = atoi(argv[4]);
|
int xmin = atoi(argv[4]);
|
||||||
int xmax = atoi(argv[5]);
|
int xmax = atoi(argv[5]);
|
||||||
@ -122,16 +121,21 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
//Get vector of filenames from input txt-file
|
//Get vector of filenames from input txt-file
|
||||||
std::vector<std::string> filenames{};
|
std::vector<std::string> filenames{};
|
||||||
|
//filenames.reserve(512);
|
||||||
{ //Safety scope for ifstream
|
{ //Safety scope for ifstream
|
||||||
ifstream inputs( txtfilename, std::ios::in );
|
ifstream inputs( txtfilename, std::ios::in );
|
||||||
if (inputs.is_open()) {
|
if (inputs.is_open()) {
|
||||||
std::cout << "Reading imput filenames from txt-file ..." << std::endl;
|
std::cout << "Reading imput filenames from txt-file ..." << std::endl;
|
||||||
while (!inputs.eof()) {
|
|
||||||
std::string line{};
|
std::string line{};
|
||||||
|
while (!inputs.eof()) {
|
||||||
std::getline(inputs, line);
|
std::getline(inputs, line);
|
||||||
filenames.push_back(line);
|
filenames.emplace_back(line);
|
||||||
|
std::cout << line << " line.max_size() " << line.max_size() << " filenames.capacity() " << filenames.capacity() << '\n';
|
||||||
}
|
}
|
||||||
|
inputs.close();
|
||||||
std::cout << "---- Reached end of txt-file. ----" << std::endl;
|
std::cout << "---- Reached end of txt-file. ----" << std::endl;
|
||||||
|
} else
|
||||||
|
std::cout << "Could not open " << txtfilename << std::endl;
|
||||||
if (filenames.size()>0) {
|
if (filenames.size()>0) {
|
||||||
std::cout << filenames.size() << " filenames found in " << txtfilename << std::endl;
|
std::cout << filenames.size() << " filenames found in " << txtfilename << std::endl;
|
||||||
std::cout << "The files will be processed in the same order as found in the txt-file." << std::endl;
|
std::cout << "The files will be processed in the same order as found in the txt-file." << std::endl;
|
||||||
@ -139,10 +143,10 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout << "No files found in txt-file!" << std::endl;
|
std::cout << "No files found in txt-file!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
std::cout << "Could not open " << txtfilename << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "###############" << std::endl;
|
||||||
|
|
||||||
// Define decoders...
|
// Define decoders...
|
||||||
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && \
|
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && \
|
||||||
!defined JFSTRXCHIP6
|
!defined JFSTRXCHIP6
|
||||||
@ -319,14 +323,14 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout << "PEDESTAL " << std::endl;
|
std::cout << "PEDESTAL " << std::endl;
|
||||||
|
|
||||||
if (pedfilename.find(".tif") == std::string::npos) {
|
if (pedfilename.find(".tif") == std::string::npos) {
|
||||||
std::string fname = pedfilename;
|
const std::string fname(pedfilename);
|
||||||
std::cout << fname << std::endl;
|
std::cout << fname << std::endl;
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
std::cout << "aaa " << std::ctime(&end_time) << std::endl;
|
std::cout << "aaa " << std::ctime(&end_time) << std::endl;
|
||||||
|
|
||||||
mt->setFrameMode(ePedestal);
|
mt->setFrameMode(ePedestal);
|
||||||
|
|
||||||
ifstream pedefile(fname, ios::in | ios::binary);
|
std::ifstream pedefile(fname, ios::in | ios::binary);
|
||||||
// //open file
|
// //open file
|
||||||
if (pedefile.is_open()) {
|
if (pedefile.is_open()) {
|
||||||
std::cout << "bbbb " << std::ctime(&end_time) << std::endl;
|
std::cout << "bbbb " << std::ctime(&end_time) << std::endl;
|
||||||
@ -392,15 +396,15 @@ int main(int argc, char *argv[]) {
|
|||||||
mt->setFrameMode(eFrame);
|
mt->setFrameMode(eFrame);
|
||||||
|
|
||||||
FILE *of = NULL;
|
FILE *of = NULL;
|
||||||
|
std::ifstream filebin{};
|
||||||
|
|
||||||
//NOTE THAT THE DATA FILES HAVE TO BE IN THE RIGHT ORDER SO THAT PEDESTAL TRACKING WORKS!
|
//NOTE THAT THE DATA FILES HAVE TO BE IN THE RIGHT ORDER SO THAT PEDESTAL TRACKING WORKS!
|
||||||
for (unsigned int ifile = 0; ifile != filenames.size(); ++ifile) {
|
for (unsigned int ifile = 0; ifile != filenames.size(); ++ifile) {
|
||||||
std::cout << "DATA ";
|
std::cout << "DATA ";
|
||||||
//std::string fname(argv[iargc]);
|
|
||||||
std::string fsuffix{};
|
std::string fsuffix{};
|
||||||
std::string fprefix = getRootString(filenames[ifile]);
|
const std::string fprefix( getRootString(filenames[ifile]) );
|
||||||
std::string imgfname = createFileName( outdir, fprefix, fsuffix, "tiff" );
|
std::string imgfname( createFileName( outdir, fprefix, fsuffix, "tiff" ) );
|
||||||
std::string cfname = createFileName( outdir, fprefix, fsuffix, "clust" );
|
const std::string cfname( createFileName( outdir, fprefix, fsuffix, "clust" ) );
|
||||||
std::cout << filenames[ifile] << " ";
|
std::cout << filenames[ifile] << " ";
|
||||||
std::cout << imgfname << std::endl;
|
std::cout << imgfname << std::endl;
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
@ -408,7 +412,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
ifstream filebin(filenames[ifile], ios::in | ios::binary);
|
ifstream filebin(filenames[ifile], ios::in | ios::binary);
|
||||||
// //open file
|
// //open file
|
||||||
ifile = 0;
|
ioutfile = 0;
|
||||||
if (filebin.is_open()) {
|
if (filebin.is_open()) {
|
||||||
if (thr <= 0 && cf != 0) { // cluster finder
|
if (thr <= 0 && cf != 0) { // cluster finder
|
||||||
if (of == NULL) {
|
if (of == NULL) {
|
||||||
@ -448,21 +452,23 @@ int main(int argc, char *argv[]) {
|
|||||||
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", ioutfile );
|
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", ioutfile );
|
||||||
mt->writeImage(imgfname.c_str(), thr1);
|
mt->writeImage(imgfname.c_str(), thr1);
|
||||||
mt->clearImage();
|
mt->clearImage();
|
||||||
ioutfile++;
|
++ioutfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// } else
|
// } else
|
||||||
//std::cout << ifr << " " << ff << " " << np << std::endl;
|
//std::cout << ifr << " " << ff << " " << np << std::endl;
|
||||||
ff = -1;
|
ff = -1;
|
||||||
}
|
}
|
||||||
std::cout << "--" << std::endl;
|
std::cout << "aa --" << std::endl;
|
||||||
filebin.close();
|
filebin.close();
|
||||||
|
std::cout << "bb --" << std::endl;
|
||||||
while (mt->isBusy()) {
|
while (mt->isBusy()) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
std::cout << "cc --" << std::endl;
|
||||||
if (nframes >= 0) {
|
if (nframes >= 0) {
|
||||||
if (nframes > 0)
|
if (nframes > 0)
|
||||||
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", ifile );
|
imgfname = createFileName( outdir, fprefix, fsuffix, "tiff", ioutfile );
|
||||||
std::cout << "Writing tiff to " << imgfname << " " << thr1
|
std::cout << "Writing tiff to " << imgfname << " " << thr1
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
mt->writeImage(imgfname.c_str(), thr1);
|
mt->writeImage(imgfname.c_str(), thr1);
|
||||||
@ -481,8 +487,8 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
if (nframes < 0) {
|
if (nframes < 0) {
|
||||||
//std::string fname(argv[10]);
|
//std::string fname(argv[10]);
|
||||||
auto fprefix = getRootString(filenames[0]); //This might by a non-ideal name choice for that file
|
std::string fprefix( getRootString(filenames[0]) ); //This might by a non-ideal name choice for that file
|
||||||
auto imgfname = createFileName( outdir, fprefix, "sum", "tiff" );
|
std::string imgfname( createFileName( outdir, fprefix, "sum", "tiff" ) );
|
||||||
std::cout << "Writing tiff to " << imgfname << " " << thr1 << std::endl;
|
std::cout << "Writing tiff to " << imgfname << " " << thr1 << std::endl;
|
||||||
mt->writeImage(imgfname.c_str(), thr1);
|
mt->writeImage(imgfname.c_str(), thr1);
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@ class threadedAnalogDetector {
|
|||||||
// return 1;}
|
// return 1;}
|
||||||
|
|
||||||
virtual int isBusy() {
|
virtual int isBusy() {
|
||||||
|
//std::cout << busy << " " << fifoData->isEmpty() << " " << fifoData->getDataValue() << " " << fifoData->getFreeValue() << std::endl;
|
||||||
if (busy == 0) {
|
if (busy == 0) {
|
||||||
usleep(100);
|
usleep(100);
|
||||||
if (busy == 0) {
|
if (busy == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user