diff --git a/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder b/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder new file mode 100644 index 000000000..f0de740fc --- /dev/null +++ b/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package +#module add CBFlib/0.9.5 +INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../tiffio/include + +LDFLAG= ../tiffio/src/tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11 + +MAIN=jungfrauClusterFinder.cpp + + +all: jungfrauRawDataProcess + +jungfrauRawDataProcess: jungfrauRawDataProcess.cpp $(INCS) clean + g++ -o jungfrauRawDataProcess jungfrauRawDataProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL + + +jungfrauClusterFinder: jungfrauClusterFinder.cpp $(INCS) clean + g++ -o jungfrauClusterFinder jungfrauClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL + + +jungfrauClusterFinderHighZ: jungfrauClusterFinder.cpp $(INCS) clean + g++ -o jungfrauClusterFinderHighZ jungfrauClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DHIGHZ + + +jungfrauClusterFinderStrx: jungfrauClusterFinder.cpp $(INCS) clean + g++ -o jungfrauClusterFinderStrx jungfrauClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DJFSTRX + + + + +jungfrauMakeEta: jungfrauInterpolation.cpp $(INCS) clean + g++ -o jungfrauMakeEta jungfrauInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF + +jungfrauInterpolation: jungfrauInterpolation.cpp $(INCS) clean + g++ -o jungfrauInterpolation jungfrauInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) + +jungfrauNoInterpolation: jungfrauNoInterpolation.cpp $(INCS) clean + g++ -o jungfrauNoInterpolation jungfrauNoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) + +jungfrauPhotonCounter: jungfrauPhotonCounter.cpp $(INCS) clean + g++ -o jungfrauPhotonCounter jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER + +jungfrauAnalog: jungfrauPhotonCounter.cpp $(INCS) clean + g++ -o jungfrauAnalog jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG + +jungfrauPhotonCounterHighZ: jungfrauPhotonCounter.cpp $(INCS) clean + g++ -o jungfrauPhotonCounterHighZ jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ + +jungfrauAnalogHighZ: jungfrauPhotonCounter.cpp $(INCS) clean + g++ -o jungfrauAnalogHighZ jungfrauPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ + +clean: + rm -f jungfrauClusterFinder jungfrauMakeEta jungfrauInterpolation jungfrauNoInterpolation jungfrauPhotonCounter jungfrauAnalog + + diff --git a/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder~ b/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder~ deleted file mode 100644 index f452a020f..000000000 --- a/slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder~ +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -#module add CBFlib/0.9.5 -INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ - -LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11 - -MAIN=moench03ClusterFinder.cpp - - -all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog - - - -moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean - g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER - - -moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean - g++ -o moenchClusterFinderHighZ moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DHIGHZ - - - - -moenchMakeEta: moench03Interpolation.cpp $(INCS) clean - g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF - -moenchInterpolation: moench03Interpolation.cpp $(INCS) clean - g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) - -moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean - g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) - -moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER - -moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG - -moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchPhotonCounterHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ - -moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean - g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ - -clean: - rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog - - diff --git a/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp b/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp new file mode 100644 index 000000000..228af1d87 --- /dev/null +++ b/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +//#include "sls/ansi.h" +#include + +//#include "moench03T1ZmqData.h" +#ifndef JFSTRX +#include "jungfrauHighZSingleChipData.h" +#endif +#ifdef JFSTRX +#include "jungfrauLGADStrixelsData.h" +#endif + +#include "multiThreadedAnalogDetector.h" +#include "singlePhotonDetector.h" + +#include +#include +#include +#include + +#include +using namespace std; + +int main(int argc, char *argv[]) { + + if (argc < 6) { + cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " + << endl; + return 1; + } + int p = 10000; + int fifosize = 1000; + int nthreads = 1; + int nsubpix = 25; + int etabins = nsubpix * 10; + double etamin = -1, etamax = 2; + int csize = 3; + int nx = 400, ny = 400; + int save = 1; + int nsigma = 5; + int nped = 1000; + int ndark = 100; + int ok; + int iprog = 0; +#ifndef JFSTRX + jungfrauHighZSingleChipData *decoder = new jungfrauHighZSingleChipData(); +#endif +#ifdef JFSTRX + cout << "bbb" << endl; + jungfrauLGADStrixelsData *decoder = new jungfrauLGADStrixelsData(); +#endif + + decoder->getDetectorSize(nx, ny); + cout << "nx " << nx << " ny " << ny << endl; + + // moench03T1ZmqData *decoder=new moench03T1ZmqData(); + singlePhotonDetector *filter = + new singlePhotonDetector(decoder, csize, nsigma, 1, 0, nped, 200); + // char tit[10000]; + cout << "filter " << endl; + + int *image; + filter->newDataSet(); + + int ff, np; + int dsize = decoder->getDataSize(); + cout << " data size is " << dsize; + + char data[dsize]; + + ifstream filebin; + char *indir = argv[1]; + char *outdir = argv[2]; + char *fformat = argv[3]; + int runmin = atoi(argv[4]); + int runmax = atoi(argv[5]); + + char fname[10000]; + char outfname[10000]; + char imgfname[10000]; + char pedfname[10000]; + char fn[10000]; + + std::time_t end_time; + + FILE *of = NULL; + cout << "input directory is " << indir << endl; + cout << "output directory is " << outdir << endl; + cout << "fileformat is " << fformat << endl; + + std::time(&end_time); + cout << std::ctime(&end_time) << endl; + + char *buff; + multiThreadedAnalogDetector *mt = + new multiThreadedAnalogDetector(filter, nthreads, fifosize); + + mt->setDetectorMode(ePhotonCounting); + mt->setFrameMode(eFrame); + mt->StartThreads(); + mt->popFree(buff); + + cout << "mt " << endl; + + int ifr = 0; + + for (int irun = runmin; irun < runmax; irun++) { + sprintf(fn, fformat, irun); + sprintf(fname, "%s/%s.dat", indir, fn); + sprintf(outfname, "%s/%s.clust", outdir, fn); + sprintf(imgfname, "%s/%s.tiff", outdir, fn); + std::time(&end_time); + cout << std::ctime(&end_time) << endl; + cout << fname << " " << outfname << " " << imgfname << endl; + filebin.open((const char *)(fname), ios::in | ios::binary); + // //open file + if (filebin.is_open()) { + of = fopen(outfname, "w"); + if (of) { + mt->setFilePointer(of); + // cout << "file pointer set " << endl; + } else { + cout << "Could not open " << outfname << " for writing " + << endl; + mt->setFilePointer(NULL); + return 1; + } + // //while read frame + ff = -1; + while (decoder->readNextFrame(filebin, ff, np, buff)) { + + mt->pushData(buff); + mt->nextThread(); + mt->popFree(buff); + ifr++; + if (ifr % 10000 == 0) + cout << ifr << " " << ff << endl; + ff = -1; + } + cout << "--" << endl; + filebin.close(); + while (mt->isBusy()) { + ; + } // wait until all data are processed from the queues + if (of) + fclose(of); + + mt->writeImage(imgfname); + mt->clearImage(); + + std::time(&end_time); + cout << std::ctime(&end_time) << endl; + + } else + cout << "Could not open " << fname << " for reading " << endl; + } + + return 0; +} diff --git a/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp~ b/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp~ deleted file mode 100644 index 36a6675af..000000000 --- a/slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp~ +++ /dev/null @@ -1,237 +0,0 @@ -//#include "sls/ansi.h" -#include - - -//#include "moench03T1ZmqData.h" -#ifdef NEWRECEIVER -#ifndef RECT -#include "moench03T1ReceiverDataNew.h" -#endif - -#ifdef RECT -#include "moench03T1ReceiverDataNewRect.h" -#endif - -#endif - - -#ifdef CSAXS_FP -#include "moench03T1ReceiverData.h" -#endif -#ifdef OLDDATA -#include "moench03Ctb10GbT1Data.h" -#endif - -#ifdef REORDERED -#include "moench03T1ReorderedData.h" -#endif - -// #include "interpolatingDetector.h" -//#include "etaInterpolationPosXY.h" -// #include "linearInterpolation.h" -// #include "noInterpolation.h" -#include "multiThreadedAnalogDetector.h" -#include "singlePhotonDetector.h" -//#include "interpolatingDetector.h" - -#include -#include -#include -#include - -#include -using namespace std; - - -int main(int argc, char *argv[]) { - - - if (argc<6) { - cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl; - return 1; - } - int p=10000; - int fifosize=1000; - int nthreads=1; - int nsubpix=25; - int etabins=nsubpix*10; - double etamin=-1, etamax=2; - int csize=3; - int nx=400, ny=400; - int save=1; - int nsigma=5; - int nped=1000; - int ndark=100; - int ok; - int iprog=0; - - - - - -#ifdef NEWRECEIVER -#ifdef RECT - cout << "Should be rectangular!" <getDetectorSize(nx,ny); - cout << "nx " << nx << " ny " << ny << endl; - - //moench03T1ZmqData *decoder=new moench03T1ZmqData(); - singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200); - // char tit[10000]; - cout << "filter " << endl; - - - - // filter->readPedestals("/scratch/ped_100.tiff"); - // interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax); - // cout << "filter "<< endl; - - - int size = 327680;////atoi(argv[3]); - - int* image; - //int* image =new int[327680/sizeof(int)]; - filter->newDataSet(); - - - int ff, np; - int dsize=decoder->getDataSize(); - cout << " data size is " << dsize; - - - char data[dsize]; - - ifstream filebin; - char *indir=argv[1]; - char *outdir=argv[2]; - char *fformat=argv[3]; - int runmin=atoi(argv[4]); - int runmax=atoi(argv[5]); - - char fname[10000]; - char outfname[10000]; - char imgfname[10000]; - char pedfname[10000]; - // strcpy(pedfname,argv[6]); - char fn[10000]; - - std::time_t end_time; - - FILE *of=NULL; - cout << "input directory is " << indir << endl; - cout << "output directory is " << outdir << endl; - cout << "fileformat is " << fformat << endl; - - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - - - - - - - - char* buff; - multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); - - - mt->setDetectorMode(ePhotonCounting); - mt->setFrameMode(eFrame); - mt->StartThreads(); - mt->popFree(buff); - - - cout << "mt " << endl; - - int ifr=0; - - - for (int irun=runmin; irunsetFilePointer(of); - // cout << "file pointer set " << endl; - } else { - cout << "Could not open "<< outfname << " for writing " << endl; - mt->setFilePointer(NULL); - return 1; - } - // //while read frame - ff=-1; - while (decoder->readNextFrame(filebin, ff, np,buff)) { - // cout << "*"<getChannel(buff, ix, iy)<3000 || decoder->getChannel(buff, ix, iy)>8000) { - // cout << ifr << " " << ff << " " << ix << " " << iy << " " << decoder->getChannel(buff, ix, iy) << endl ; - // } - // } - - mt->pushData(buff); - // // //pop - mt->nextThread(); - // // // cout << " " << (void*)buff; - mt->popFree(buff); - ifr++; - if (ifr%10000==0) cout << ifr << " " << ff << endl; - ff=-1; - } - cout << "--" << endl; - filebin.close(); - // //close file - // //join threads - while (mt->isBusy()) {;}//wait until all data are processed from the queues - if (of) - fclose(of); - - mt->writeImage(imgfname); - mt->clearImage(); - - std::time(&end_time); - cout << std::ctime(&end_time) << endl; - - } else - cout << "Could not open "<< fname << " for reading " << endl; - - - } - - - return 0; -} -