mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
some fixes in the cluster finder
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
|
||||
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
@ -17,17 +16,18 @@ all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
|
||||
|
||||
|
||||
moenchClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA
|
||||
|
||||
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
|
||||
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB) -lzmq
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
@ -18,7 +18,7 @@ all: tiff_to_th2f
|
||||
|
||||
tiff_to_th2f: $(MAIN) $(INCS)
|
||||
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) ../tiffIO.cpp
|
||||
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
@ -1,8 +1,18 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
@ -24,12 +34,13 @@ using namespace std;
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax pedfname" << endl;
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nthreads=8;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -42,11 +53,30 @@ int main(int argc, char *argv[]) {
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
|
||||
cout << "filter " << endl;
|
||||
|
||||
|
||||
|
||||
@ -80,7 +110,7 @@ int main(int argc, char *argv[]) {
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
strcpy(pedfname,argv[6]);
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
@ -89,52 +119,52 @@ int main(int argc, char *argv[]) {
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
cout << "pedestal file is " << fformat << endl;
|
||||
// cout << "pedestal file is " << fformat << endl;
|
||||
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
filter->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
cout << pedfname<< endl;
|
||||
// filter->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
// cout << pedfname<< endl;
|
||||
|
||||
filebin.open((const char *)(pedfname), ios::in | ios::binary);
|
||||
//filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// filebin.open((const char *)(pedfname), ios::in | ios::binary);
|
||||
// //filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
// //while read frame
|
||||
cout << "pedestal file " << endl;
|
||||
while (decoder->readNextFrame(filebin, ff, np,data)) {
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
// mt->pushData(buff);
|
||||
// // //pop
|
||||
//mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
//mt->popFree(buff);
|
||||
filter->processData(data);
|
||||
}
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// cout << outfname << endl;
|
||||
// filter->writePedestals(outfname);
|
||||
// sprintf(outfname,"%s/%s_pedimg.tiff",outdir,fn);
|
||||
// // //open file
|
||||
// if (filebin.is_open()){
|
||||
// // //while read frame
|
||||
// cout << "pedestal file " << endl;
|
||||
// while (decoder->readNextFrame(filebin, ff, np,data)) {
|
||||
// // cout << ff << " " << np << endl;
|
||||
// // //push
|
||||
// // mt->pushData(buff);
|
||||
// // // //pop
|
||||
// //mt->nextThread();
|
||||
// // // // cout << " " << (void*)buff;
|
||||
// //mt->popFree(buff);
|
||||
// filter->processData(data);
|
||||
// }
|
||||
// filebin.close();
|
||||
// // //close file
|
||||
// // //join threads
|
||||
// // while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// // cout << outfname << endl;
|
||||
// // filter->writePedestals(outfname);
|
||||
// // sprintf(outfname,"%s/%s_pedimg.tiff",outdir,fn);
|
||||
|
||||
// cout << outfname << endl;
|
||||
// // cout << outfname << endl;
|
||||
|
||||
// filter->writeImage(outfname);
|
||||
// //mt->clearImage();
|
||||
} else
|
||||
cout << "Could not open "<< pedfname << " for reading " << endl;
|
||||
// // filter->writeImage(outfname);
|
||||
// // //mt->clearImage();
|
||||
// } else
|
||||
// cout << "Could not open "<< pedfname << " for reading " << endl;
|
||||
|
||||
|
||||
|
||||
// for (int ix=0; ix<400; ix++)
|
||||
// for (int iy=0; iy<400; iy++)
|
||||
// cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
|
||||
// // for (int ix=0; ix<400; ix++)
|
||||
// // for (int iy=0; iy<400; iy++)
|
||||
// // cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
|
||||
|
||||
|
||||
|
||||
@ -149,11 +179,12 @@ filter->setFrameMode(eFrame);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
// //loop on files
|
||||
@ -165,37 +196,37 @@ filter->setFrameMode(eFrame);
|
||||
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmin+5; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
// for (int irun=runmin; irun<runmin+5; irun++) {
|
||||
// sprintf(fn,fformat,irun);
|
||||
// sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
|
||||
|
||||
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
// //while read frame
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
// filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// // //open file
|
||||
// if (filebin.is_open()){
|
||||
// // //while read frame
|
||||
// while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// // cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// // cout << ff << " " << np << endl;
|
||||
// // //push
|
||||
// mt->pushData(buff);
|
||||
// // // //pop
|
||||
// mt->nextThread();
|
||||
// // // // cout << " " << (void*)buff;
|
||||
// mt->popFree(buff);
|
||||
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
filebin.close();
|
||||
// }
|
||||
// // cout << "--" << endl;
|
||||
// filebin.close();
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
mt->clearImage();
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// mt->clearImage();
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
@ -218,18 +249,19 @@ filter->setFrameMode(eFrame);
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
mt->popFree(buff);
|
||||
ff=-1;
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
// #include "etaInterpolationPosXY.h"
|
||||
#include "etaInterpolationAdaptiveBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
@ -43,9 +43,13 @@ int main(int argc, char *argv[]) {
|
||||
FILE *f=NULL;
|
||||
|
||||
single_photon_hit cl(3,3);
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
// etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//#ifndef FF
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
interp->readFlatField(argv[2]);
|
||||
interp->prepareInterpolation(ok);
|
||||
//#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
@ -133,7 +137,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cout << "writing eta!" << endl;
|
||||
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
#include "../single_photon_hit.h"
|
||||
//#include "etaVEL/etaInterpolationPosXY.h"
|
||||
#include <TH1F.h>
|
||||
#include <TH2F.h>
|
||||
#include <TCanvas.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
FILE *f=fopen(fname,"r");
|
||||
@ -13,21 +18,21 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
h2=new TH2F("h2",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
|
||||
//h2mult=new TH2F("h2mult",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
|
||||
// TH2F *hint=new TH2F("hint",fname,nx*ns, -0.5, nx-0.5, ny*ns, -0.5, ny-0.5);
|
||||
TH1F *hf=new TH1F("hf","hf",1000,0,3000000);
|
||||
TH1F *hf=new TH1F("hf","hf",1000,0,10E6);
|
||||
//TH2F *hff=new TH2F("hff","hff",ns, -0.5, 0.5, ns, -0.5, +0.5);
|
||||
TH1F *hsp=new TH1F("hsp",fname,500,0,2000);
|
||||
TH1F *hsp1=new TH1F("hsp1",fname,500,0,2000);
|
||||
TH1F *hsp=new TH1F("hsp",fname,500,0,10000);
|
||||
// TH1F *hsp1=new TH1F("hsp1",fname,500,0,10000);
|
||||
// TH1F *hsp2=new TH1F("hsp2",fname,500,0,1000);
|
||||
// TH1F *hsp3=new TH1F("hsp3",fname,500,0,1000);
|
||||
hsp1->SetLineColor(2);
|
||||
// hsp1->SetLineColor(2);
|
||||
// hsp2->SetLineColor(3);
|
||||
// hsp3->SetLineColor(4);
|
||||
TCanvas *c=new TCanvas();
|
||||
c->SetLogz(kTRUE);
|
||||
h2->Draw("colz");
|
||||
TCanvas *c1=new TCanvas();
|
||||
hsp->Draw();
|
||||
hsp1->Draw("same");
|
||||
c1->SetLogy(kTRUE);
|
||||
// hsp1->Draw("same");
|
||||
// hsp2->Draw("same");
|
||||
// hsp3->Draw("same");
|
||||
TCanvas *c2=new TCanvas();
|
||||
@ -40,6 +45,8 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
double phw=340, phs=62;
|
||||
int f0=-1;
|
||||
double tl, bl, tr, br, qt;
|
||||
int iimage=0;
|
||||
|
||||
while (cl.read(f)) {
|
||||
//cl.get_pixel(x1, y1);
|
||||
//cout << cl.iframe << " " << cl.x << " " << cl.y << endl;
|
||||
@ -64,7 +71,6 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
// if (iy>0) top+=cl.get_data(ix,iy);
|
||||
|
||||
}
|
||||
|
||||
qt=bl;
|
||||
if (br>qt) qt=br;
|
||||
if (tl>qt) qt=tl;
|
||||
@ -75,22 +81,22 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
//max at 340
|
||||
//if (tot>200) {
|
||||
w=1;
|
||||
|
||||
if (qt>1000) {
|
||||
if (qt/tot>0.8 && qt/tot<1.2){
|
||||
if (f0<0)
|
||||
f0=cl.iframe;
|
||||
hf->Fill(cl.iframe-f0);
|
||||
if (qt>540) w++;
|
||||
if (qt>820) w++;
|
||||
// if (qt>540) w++;
|
||||
// if (qt>820) w++;
|
||||
//(tot+3.5*phs)/phw;
|
||||
//} else
|
||||
//w=0;
|
||||
// if (w) {
|
||||
// if (cl.y<350) {
|
||||
// if (cl.y<100 || cl.y>300) {
|
||||
if (cl.x>150 && cl.x<250 && cl.y>200 && cl.y<250)
|
||||
hsp1->Fill(qt);
|
||||
else
|
||||
// if (cl.x>150 && cl.x<250 && cl.y>200 && cl.y<250)
|
||||
// hsp1->Fill(qt);
|
||||
// else
|
||||
hsp->Fill(qt);
|
||||
|
||||
// hsp2->Fill(cl.get_data(0,0));
|
||||
@ -122,10 +128,11 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
c2->Modified();;
|
||||
c2->Update();
|
||||
}
|
||||
|
||||
// if (iph>1E7)
|
||||
// break;
|
||||
//}
|
||||
// if (iph>0.5E7) break;
|
||||
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
// hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
|
||||
|
Reference in New Issue
Block a user