From 38501f775036ca6db40262b3df9cbfba9b26f0ad Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Mar 2026 17:12:55 +0100 Subject: [PATCH] 1001/jungfrau 1M root display support (#1363) * Aldo Mozzanica added support for 2 modules in 1M configuration for root display * deleted the wrong files --- .../Makefile.cluster_finder~ | 49 ---- .../jungfrauExecutables/Makefile.zmqrootdisp | 17 +- .../jungfrauClusterFinder.cpp~ | 237 ------------------ .../jungfrauExecutables/onlinedisp_zmq.cpp | 161 +++++++++--- .../jungfrauExecutables/onlinedisp_zmq.h | 9 +- 5 files changed, 143 insertions(+), 330 deletions(-) delete mode 100644 slsDetectorCalibration/jungfrauExecutables/Makefile.cluster_finder~ delete mode 100644 slsDetectorCalibration/jungfrauExecutables/jungfrauClusterFinder.cpp~ 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/Makefile.zmqrootdisp b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp index 5734535fd..a03e851db 100644 --- a/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp +++ b/slsDetectorCalibration/jungfrauExecutables/Makefile.zmqrootdisp @@ -1,17 +1,22 @@ -ROOTSYS=/opt/cern/v6/root +#ROOTSYS=/opt/cern/v6/root +ROOTSYS=/opt/cern/v6_RHEL8_from_src/build #/afs/psi.ch/project/sls_det_sof/roottware/root_v5.34.23_sl6_64bit LIBZMQDIR = $(PWD) LIBZMQ = -L$(LIBZMQDIR) -lzmq -SHLIB_PATH=/opt/cern/v6/root/lib -CMAKE_PREFIX_PATH=/opt/cern/v6/root -DYLD_LIBRARY_PATH=/opt/cern/v6/root/lib - +#SHLIB_PATH=/opt/cern/v6/root/lib +SHLIB_PATH=/opt/cern/v6_RHEL8_from_src/build/lib +#CMAKE_PREFIX_PATH=/opt/cern/v6/root +CMAKE_PREFIX_PATH=/opt/cern/v6_RHEL8_from_src/build +#DYLD_LIBRARY_PATH=/opt/cern/v6/root/lib +DYLD_LIBRARY_PATH=/opt/cern/v6_RHEL8_from_src/build/lib +LD_LIBRARY_PATH=/home/l_msdetect/sls_det_package_9_2_0/slsDetectorPackage/build/bin INCDIR= -I. -I../dataStructures ../tiffio/src/tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ -I../tiffio/include -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport +#LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport +LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++17 -Wall -L../../build/bin/ -lSlsSupport #-L../../bin -lhdf5 -L. 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; -} - diff --git a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp index f649200a2..6a6993dbc 100644 --- a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp +++ b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.cpp @@ -3,11 +3,16 @@ bool hasallpede; TH1F * his102;TH1F * his101; int processedf; sls::zmqHeader zHeader; +sls::zmqHeader zHeader2; #define PEDEFNAME "current_pede.dat" #define NPRO 50 #define NPRI 50 -#define JFSTRX +#include "sls/sls_detector_defs.h" +#include "slsDetectorData.h" +//#define JFSTRX // comment for JF +#define JF1M + #ifdef JFSTRX #include "jungfrauLGADStrixelsData_new.h" #include "sls/sls_detector_defs.h" @@ -59,8 +64,14 @@ int main(int argc, char* argv[]) #else - nx = 1024; ny= 512; - + nx = 1024; +#ifdef JF1M + scaler=2 ; + ny= 1024; +#else + scaler=1; + ny=512; +#endif #endif @@ -73,10 +84,10 @@ int main(int argc, char* argv[]) HDraw_every=20; fixranges=false; - int group; - + hchptr = (short*) malloc(NCH*sizeof(short)); + startsocket(); //create and connect ZMQ for (ipx=0;ipxGetZaxis()->SetRangeUser(0,4); if (dophotonmap) { - his3000= new TH2F("his3000"," photon map ",1024,-0.5,1024-0.5,512,-0.5,512-0.5); + his3000= new TH2F("his3000"," photon map ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5); + his1000->SetOption("colz"); } else { - his3000= new TH2F("his3000"," raw adc ",1024,-0.5,1024-0.5,512,-0.5,512-0.5); + his3000= new TH2F("his3000"," raw adc ",nx,-0.5,nx-0.5,ny,-0.5,ny-0.5); + his1000->SetOption("colz"); + } - his4500= new TH2F("his4500","T vs B",101,-500,MAX_POS,101,-500,MAX_POS); - hchip=new TH1I*[8]; + his4500= new TH2F("his4500","T vs B",101,-300,MAX_POS/2,101,-300,MAX_POS/2); + hchip=new TH1I*[16]; #ifdef JFSTRX - for (i=0;i<8;i++) { + for (i=0;i<16;i++) { if(i<3) sprintf(hname,"%d_hchip1group%d",i,i+1); else if (i>4) @@ -142,14 +156,14 @@ int main(int argc, char* argv[]) hchip[i] = new TH1I(hname,hname,NBIN,MIN_POS,MAX_POS); } #else - for (i=0;i<8;i++) { + for (i=0;i<16;i++) { sprintf(hname,"hchip%d",i); hchip[i] = new TH1I(hname,hname,NBIN,MIN_POS,MAX_POS); } #endif cout <<"end of histo booking" <cd(6); // g->SetCanvasSize( g->GetWw(), 2*g->GetWw()); #else - A3 = new TCanvas("A3","Plotting Canvas ADC",150,360,1200,550); + A3 = new TCanvas("A3","Plotting Canvas ADC",150,360,1200,550*scaler); #endif } - if (A4==NULL) A4 = new TCanvas("A4","Plotting Canvas PHs",750,300,1000,800); + if (A4==NULL) A4 = new TCanvas("A4","Plotting Canvas PHs",750,300,1000,800*scaler); A4->Clear(); +#ifdef JF1M + A4->Divide(4,4,0.005,0.005); +#else A4->Divide(4,2,0.005,0.005); - if (A5==NULL) A5 = new TCanvas("A5","Plotting Canvas Photon Map",750,300,1000,600); +#endif + + if (A5==NULL) A5 = new TCanvas("A5","Plotting Canvas Photon Map",750,300,1000,600*scaler); if (A6==NULL) A6 = new TCanvas("A6","Plotting Canvas LvsR",650,250,650,660); gSystem->ProcessEvents(); @@ -198,8 +217,14 @@ int main(int argc, char* argv[]) else { // if (((icount++)%10)==0) cout <<"recived frameindex "<ReceiveData(0, (char *)(&image_data), NCH*2); + + zmqSocket->ReceiveData(0, (char *)(&image_data), NCH ); //(NCH/2*2) + #ifdef JF1M + zmqSocket2->ReceiveHeader(0,zHeader2, SLS_DETECTOR_JSON_HEADER_VERSION); + zmqSocket2->ReceiveData(0, (char *)(&image_data)+ NCH, NCH );//(NCH/2*2) + #endif + + } { @@ -210,14 +235,14 @@ int main(int argc, char* argv[]) ROIxmax=croi.xmax; ROIymin=croi.ymin; ROIymax=croi.ymax; - cout<<" ROIymin "<< ROIymin<0) cout<<" ROIymin "<< ROIymin<>14) & 0x3;} else {gain=0;} @@ -299,7 +324,7 @@ int main(int argc, char* argv[]) hchip[ichip]->Fill(adcpedecorr,1); #endif - // if (((i%256)<253)&&((i%256)>2)) his4500->Fill(adcpedecorrold,adcpedecorr,1); + if (ichip<8) if (((i%256)<253)&&((i%256)>2)) his4500->Fill(adcpedecorrold,adcpedecorr,1); adcpedecorrold=adcpedecorr; @@ -335,6 +360,8 @@ int main(int argc, char* argv[]) value= ((image_data[i]) & 0x3fff) -fpeded[i]; + gain = (image_data[i]>>14) & 0x3; + #ifndef JFSTRX if ((i%256==0)||(i%256==255)) value=int(value/factor); if ((i/1024==255)||(i/1024==256)||(i/1024==767)||(i/1024==768)) value=int(value/factor); @@ -375,15 +402,27 @@ int main(int argc, char* argv[]) #else - his1000->Fill(float(ipx),float(ipy),value); - + + if (ipy>512) { + his1000->Fill(float(ipx),float(ipy+36),value); + + } + else { + his1000->Fill(float(ipx),float(ipy),value); + } #endif + if (ipy>512) { + his2000->Fill(float(ipx),float(ipy+36) ,gain); + } + else { + his2000->Fill(float(ipx),float(ipy) ,gain); + + } - his2000->Fill(float(ipx),float(ipy) ,gain); // if (!dophotonmap)his3000->Fill(float(ipx),float(ipy) ,value); // value=(int)(hchptr[i]); @@ -393,12 +432,18 @@ int main(int argc, char* argv[]) } //for ipy for (ipx=0;ipx<1024;ipx++){ +#ifdef JF1M + for (ipy=0;ipy<1024;ipy++){ +#else for (ipy=0;ipy<512;ipy++){ +#endif + i=ipx+ipy*1024; value= ((image_data[i]) & 0x3fff) -fpeded[i]; if (!dophotonmap)his3000->Fill(float(ipx),float(ipy) ,value); value=(int)(hchptr[i]); - if (dophotonmap) his3000->Fill(float(ipx),float(ipy),float(value)); + if (ipy>512) { if (dophotonmap) his3000->Fill(float(ipx),float(ipy+36),float(value)); } + else {if (dophotonmap) his3000->Fill(float(ipx),float(ipy),float(value)); } } } @@ -518,7 +563,12 @@ void loadpede(void){ cout <<"received frameindex "<ReceiveData(0, (char *)(&image_data), NCH*2); + zmqSocket->ReceiveData(0, (char *)(&image_data), NCH); +#ifdef JF1M + zmqSocket2->ReceiveHeader(0,zHeader2, SLS_DETECTOR_JSON_HEADER_VERSION); + zmqSocket2->ReceiveData(0, (char *)(&image_data)+NCH, NCH); +#endif + framesinstream++;nframes++; for (ipx=0;ipxReset(); his3000->Reset(); - for (i=0;i<8;i++) { + for (i=0;i<16;i++) { hchip[i]->Reset(); } @@ -635,7 +685,7 @@ void axisreset(){ his3000->GetZaxis()->UnZoom(); - for (i=0;i<8;i++) { + for (i=0;i<16;i++) { hchip[i]->GetXaxis()->UnZoom(); hchip[i]->GetYaxis()->UnZoom(); } @@ -725,21 +775,29 @@ void Plot1DHistos(void){ if (hchip[0]->GetXaxis()->GetLast()!=oldh0xlast){ oldh0xlast=hchip[0]->GetXaxis()->GetLast(); + cout << oldh0xlast << endl; oldh0xfirst=hchip[0]->GetXaxis()->GetFirst(); - for (int ipad=1; ipad<8;ipad++) { + for (int ipad=1; ipad<16;ipad++) { hchip[ipad]->GetXaxis()->SetRange(oldh0xfirst,oldh0xlast); } } +#ifdef JF1M + for (int ipad=0; ipad<16;ipad++) { +#else + for (int ipad=0; ipad<8;ipad++) { +#endif - for (int ipad=0; ipad<8;ipad++) { A4->cd(ipad+1); gStyle->SetOptStat(1); gPad->SetLogy(); +#ifdef JF1M + hchip[ipad%4+(3-int(ipad/4))*4]->Draw(); +#else hchip[ipad%4+(1-int(ipad/4))*4]->Draw(); - - } +#endif + } A4->cd(); A4->Update(); } @@ -801,6 +859,7 @@ void Plot2DHistos(void){ A6->cd(); his4500->Draw("colz"); + gPad->SetLogz(); A6->Update(); @@ -816,6 +875,9 @@ void startsocket(void) { try { zmqSocket = new sls::ZmqSocket(serverip, portnum); + + + } catch (...) { cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", @@ -824,12 +886,37 @@ void startsocket(void) { return; } zmqSocket->SetReceiveHighWaterMark(3); - zmqSocket->SetReceiveBuffer(1024*1024); + zmqSocket->SetReceiveBuffer(1024*5012*2); zmqSocket->Connect(); cout<<"Zmq Client[] "<< zmqSocket->GetZmqServerAddress()<SetReceiveHighWaterMark(3); + zmqSocket2->SetReceiveBuffer(1024*5012*2); + zmqSocket2->Connect(); + + + cout<<"Zmq Client[] "<< zmqSocket2->GetZmqServerAddress()<~ZmqSocket (); +#ifdef JF1M + delete zmqSocket2; + zmqSocket2=0; + +#endif + haveconnection=false; diff --git a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h index e53b8f8cb..80cf3a0c8 100644 --- a/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h +++ b/slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h @@ -80,12 +80,12 @@ using namespace sls; #define FALSE 0 #define OFFSET 0 -#define NBIN 500 +#define NBIN 250 #define MIN_POS -500.5 // 400.5 -#define MAX_POS 8499.5 //-100.5 +#define MAX_POS 3500.5 //-100.5 -#define NCH 524288 +#define NCH 2*524288 // #define NCH 262144 in case of half_frames char serverip[256]; @@ -220,6 +220,7 @@ int ix,iy; int adcmin,adcmax; int pmmin,pmmax; //min/mnx for the photon map bool fixranges; - +int scaler; sls::ZmqSocket *zmqSocket= NULL; +sls::ZmqSocket *zmqSocket2= NULL;