Some fixes to use moench

This commit is contained in:
bergamaschi 2020-02-18 10:45:53 +01:00
parent 4cce0aee62
commit 6b0bf02a85
8 changed files with 210 additions and 79 deletions

View File

@ -45,6 +45,7 @@
#include "deserializer.h" #include "deserializer.h"
#include "detectorData.h" #include "detectorData.h"
#include "imageZmq16bit.h" #include "imageZmq16bit.h"
#include "imageZmq32bit.h"
using namespace std; using namespace std;
@ -236,6 +237,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
cbDetType->AddEntry("MOENCH04", MOENCH04); cbDetType->AddEntry("MOENCH04", MOENCH04);
// cbDetType->AddEntry("JUNGFRAU1.0", 2); // cbDetType->AddEntry("JUNGFRAU1.0", 2);
cbDetType->AddEntry("MOENCH03",MOENCH03); cbDetType->AddEntry("MOENCH03",MOENCH03);
cbDetType->AddEntry("IMAGE32BIT",IMAGE32B);
cbDetType->AddEntry("IMAGE16BIT",IMAGE16B); cbDetType->AddEntry("IMAGE16BIT",IMAGE16B);
//cbDetType->AddEntry("MOENCH03", iiii++); //cbDetType->AddEntry("MOENCH03", iiii++);
@ -365,7 +367,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
TGNumberFormat::kNELLimitMinMax,0,16535); TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixX,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1)); hframe->AddFrame(ePixX,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixX->MapWindow(); ePixX->MapWindow();
ePixX->SetNumber(0); ePixX->SetNumber(400);
e= ePixX->TGNumberEntry::GetNumberEntry(); e= ePixX->TGNumberEntry::GetNumberEntry();
ePixX->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)"); ePixX->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()"); e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
@ -383,7 +385,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
TGNumberFormat::kNELLimitMinMax,0,16535); TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(ePixY,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1)); hframe->AddFrame(ePixY,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
ePixY->MapWindow(); ePixY->MapWindow();
ePixY->SetNumber(0); ePixY->SetNumber(400);
e= ePixY->TGNumberEntry::GetNumberEntry(); e= ePixY->TGNumberEntry::GetNumberEntry();
ePixY->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)"); ePixY->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeImagePixels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()"); e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeImagePixels()");
@ -911,10 +913,10 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
nx=eNumCount->GetIntNumber(); nx=eNumCount->GetIntNumber();
dr=eDynRange->GetIntNumber(); dr=eDynRange->GetIntNumber();
soff=eSerOff->GetIntNumber(); soff=eSerOff->GetIntNumber();
cout <<"deserializer: " << endl; // cout <<"deserializer: " << endl;
cout << "Number of chans:\t" << nx << endl; // cout << "Number of chans:\t" << nx << endl;
cout << "Serial Offset:\t" << soff << endl; // cout << "Serial Offset:\t" << soff << endl;
cout << "Dynamic range:\t" << dr << endl; // cout << "Dynamic range:\t" << dr << endl;
} }
@ -980,7 +982,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
for (int y=0; y<ny; y++) { for (int y=0; y<ny; y++) {
ped=0; ped=0;
aval=dataStructure->getValue(data->data,x,y); aval=dataStructure->getValue(data->data,x,y);
// cout << x << " " <<y << " "<< aval << endl;
if (cbGetPedestal->IsOn()) { if (cbGetPedestal->IsOn()) {
if (photonFinder) { if (photonFinder) {
photonFinder->addToPedestal(aval,x,y); photonFinder->addToPedestal(aval,x,y);
@ -1295,21 +1297,39 @@ void ctbAcquisition::changeDetector(){
cout << "MOENCH 0.3! USE JUNGFRAU MODULE!" << endl; cout << "MOENCH 0.3! USE JUNGFRAU MODULE!" << endl;
commonMode=new moench03CommonMode(); commonMode=new moench03CommonMode();
break; break;
case IMAGE32B:
//try {
// auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) {
// if (deserializer) {
ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE);
// }
dataStructure=new imageZmq32bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image 32bit, no channel shuffling" << endl;
commonMode=NULL;
break;
case IMAGE16B: case IMAGE16B:
//try { //try {
// auto retval = myDet->getTenGiga().tsquash("Different values"); // auto retval = myDet->getTenGiga().tsquash("Different values");
// if (retval) { // if (retval) {
if (deserializer) { // if (deserializer) {
ePixX->SetState(kTRUE); ePixX->SetState(kTRUE);
ePixY->SetState(kTRUE); ePixY->SetState(kTRUE);
} // }
dataStructure=new imageZmq16bit(ePixX->GetIntNumber(),ePixY->GetIntNumber()); dataStructure=new imageZmq16bit(ePixX->GetIntNumber(),ePixY->GetIntNumber());
// } else { // } else {
// dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples); // dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
// } // }
//} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector") //} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "Image, no channel shuffling" << endl; cout << "Image 16bit, no channel shuffling" << endl;
commonMode=NULL; commonMode=NULL;
break; break;
@ -1375,6 +1395,7 @@ void ctbAcquisition::changeDetector(){
photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
//photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode //photonFinder=new singlePhotonDetector(dataStructure,csize,nsigma,1,cm); //sign is positive - should correct with ADC mask, no common mode
dataStructure->getDetectorSize(nx,ny); dataStructure->getDetectorSize(nx,ny);
} }
if (deserializer) { if (deserializer) {
ny=1; ny=1;

View File

@ -42,7 +42,7 @@ using namespace std;
class ctbAcquisition : public TGGroupFrame { class ctbAcquisition : public TGGroupFrame {
enum {DESERIALIZER, MOENCH04, MOENCH02, MOENCH03, IMAGE16B, ADCSAR2, MYTHEN301, MYTHEN302}; enum {DESERIALIZER, MOENCH04, MOENCH02, MOENCH03, IMAGE32B, IMAGE16B, ADCSAR2, MYTHEN301, MYTHEN302};
private: private:

View File

@ -423,7 +423,7 @@ template <class dataType> class analogDetector {
if (g==0) g=-1.; if (g==0) g=-1.;
} }
return stat[iy][ix].getPedestalRMS()/g;//divide by gain? return stat[iy][ix].getPedestalRMS();//divide by gain?
} }
return -1; return -1;
}; };

View File

@ -29,7 +29,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
*/ */
// moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) { // moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) {
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(0), xtalk(0.00021) { moench03T1ZmqDataNew(int ns=5000, int oo=0): slsDetectorData<uint16_t>(400, 400, ns*32*2+oo), nSamples(ns), offset(oo), xtalk(0.00021) {
int nadc=32; int nadc=32;
int sc_width=25; int sc_width=25;

View File

@ -5,11 +5,15 @@ LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3
#DESTDIR?=../bin #DESTDIR?=../bin
all: moenchZmqProcess all: moenchZmqProcess moenchZmqProcessCtbGui
moenchZmqProcess: moenchZmqProcess.cpp clean moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean: clean:
rm -f moenchZmqProcess rm -f moenchZmqProcess

View File

@ -74,6 +74,14 @@ int main(int argc, char *argv[]) {
// high_resolution_clock::time_point t1; // high_resolution_clock::time_point t1;
// high_resolution_clock::time_point t2 ; // high_resolution_clock::time_point t2 ;
time_t begin,end,finished; time_t begin,end,finished;
int rms=0;
int nped=1000, nped0=100;
#ifdef PTC
nped=10000;
nped0=10000;
#endif
if (argc > 4) { if (argc > 4) {
@ -111,7 +119,7 @@ int main(int argc, char *argv[]) {
} }
//slsDetectorData *det=new moench03T1ZmqDataNew(); //slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int));
cout << endl << " det" <<endl; cout << endl << " det" <<endl;
int npx, npy; int npx, npy;
det->getDetectorSize(npx, npy); det->getDetectorSize(npx, npy);
@ -129,8 +137,15 @@ int main(int argc, char *argv[]) {
int ncol_cm=CM_ROWS; int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST; double xt_ghost=C_GHOST;
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
moench03CommonMode *cm=NULL;
moench03GhostSummation *gs=NULL;
#ifdef CORR
cm=new moench03CommonMode(ncol_cm);
gs=new moench03GhostSummation(det, xt_ghost);
#endif
double *gainmap=NULL; double *gainmap=NULL;
float *gm; float *gm;
double *gmap=NULL; double *gmap=NULL;
@ -158,7 +173,7 @@ int main(int argc, char *argv[]) {
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000); //analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
#ifndef INTERP #ifndef INTERP
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize); multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
@ -169,7 +184,7 @@ int main(int argc, char *argv[]) {
if (etafname) interp->readFlatField(etafname); if (etafname) interp->readFlatField(etafname);
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize); multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
#endif #endif
@ -357,6 +372,11 @@ int main(int argc, char *argv[]) {
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex); sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
mt->writePedestal(ofname); mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl; cout << "Writing pedestal to " << ofname << endl;
if (rms) {
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex);
mt->writePedestalRMS(ofname);
cout << "Writing pedestal variance to " << ofname << endl;
}
} }
#ifdef INTERP #ifdef INTERP
else if (fMode==eFlat) { else if (fMode==eFlat) {
@ -389,7 +409,7 @@ int main(int argc, char *argv[]) {
dout[ix]=ped[ix]; dout[ix]=ped[ix];
// if (ix<100*400) // if (ix<100*400)
// cout << ix << " " << ped[ix] << endl; // cout << ix << " " << ped[ix] << " "<< dout[ix] << endl;
} }
} }
@ -429,7 +449,7 @@ int main(int argc, char *argv[]) {
// } // }
dout[ix]=detimage[ix]; dout[ix]=detimage[ix];
if (dout[ix]<0) dout[ix]=0; if (dout[ix]<0) dout[ix]=0;
// cout << ix << " " << dout[ix] << endl; //cout << ix << " " << dout[ix] << endl;
// } // }
} }
} }
@ -449,42 +469,48 @@ int main(int argc, char *argv[]) {
// cout << "Sending image size " << nnx << " " << nny << endl; // cout << "Sending image size " << nnx << " " << nny << endl;
#ifndef DEVELOPER // #ifndef DEVELOPER
#ifndef MOENCH_BRANCH // #ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader); // zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif // #endif
#endif // #endif
#ifdef DEVELOPER
// #ifdef DEVELOPER
#ifdef CTBGUI
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader); zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif #endif
#ifdef MOENCH_BRANCH #ifndef CTBGUI
/* zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,1,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) {
int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*)
*/
//zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version);//, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
/* old
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
*/
/*
new
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,additionalJsonHeader);
*/
#endif #endif
// #endif
// #ifdef MOENCH_BRANCH
// /*
// int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
// uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
// uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
// uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
// uint64_t bunchId = 0, uint64_t timestamp = 0,
// uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
// uint32_t debug = 0, uint16_t roundRNumber = 0,
// uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
// char* additionalJsonHeader = 0) {
// int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*)
// */
// //zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version);//, 0,additionalJsonHeader);
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
// /* old
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
// */
// /*
// new
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,additionalJsonHeader);
// */
// #endif
@ -578,6 +604,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
/* Analog detector commands */ /* Analog detector commands */
//isPedestal=0; //isPedestal=0;
//isFlat=0; //isFlat=0;
rms=0;
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: "); cprintf(MAGENTA, "Frame mode: ");
@ -587,11 +614,17 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
if (frameMode_s == "pedestal"){ if (frameMode_s == "pedestal"){
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; //isPedestal=1;
} else if (frameMode_s == "newPedestal"){ } else if (frameMode_s == "newpedestal"){
mt->newDataSet(); //resets pedestal mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n"); // cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; //isPedestal=1;
} else if (frameMode_s == "variance"){
mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal;
rms=1;
//isPedestal=1;
} }
#ifdef INTERP #ifdef INTERP
else if (frameMode_s == "flatfield") { else if (frameMode_s == "flatfield") {
@ -612,11 +645,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
frameMode_s="frame"; frameMode_s="frame";
} }
} }
}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str()); cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setFrameMode(fMode); mt->setFrameMode(fMode);
// threshold=0; threshold=0;
cprintf(MAGENTA, "Threshold: "); cprintf(MAGENTA, "Threshold: ");
if (doc.HasMember("threshold")) { if (doc.HasMember("threshold")) {
if (doc["threshold"].IsInt()) { if (doc["threshold"].IsInt()) {
@ -684,10 +719,11 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
} }
} }
} cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setDetectorMode(dMode); mt->setDetectorMode(dMode);
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
// cout << "done " << endl; // cout << "done " << endl;
@ -738,7 +774,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// cout << "file" << endl; // cout << "file" << endl;
// cout << "data " << endl; // cout << "data " << endl;
if (of==NULL) { if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) {
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex); sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
#endif #endif
@ -779,9 +815,6 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
zmqsocket->ReceiveData(0, dummybuff, size); zmqsocket->ReceiveData(0, dummybuff, size);
} }
iframe++; iframe++;
} // exiting infinite loop } // exiting infinite loop

View File

@ -462,6 +462,50 @@ public:
}; };
virtual double *getPedestalRMS(){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
// if (ped) delete [] ped;
double *rms=new double[nx*ny];
double *p0=new double[nx*ny];
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestalRMS(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]+=p0[ib]*p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;
/* for (int ib=0; ib<nx*ny; ib++) { */
/* if (rms[ib]>0) */
/* rms[ib]=sqrt(ped[ib]); */
/* else */
/* rms[ib]=0; */
/* } */
return rms;
};
virtual double *setPedestal(double *h=NULL){ virtual double *setPedestal(double *h=NULL){
//int nb=0; //int nb=0;
@ -498,6 +542,27 @@ public:
}; };
virtual void *writePedestalRMS(const char * imgname){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=getPedestalRMS();
float *gm=new float[nx*ny];
if (gm) {
for (int ix=0; ix<nx*ny; ix++) {
gm[ix]=rms[ix];
}
WriteToTiff(gm,imgname ,nx, ny);
delete [] gm;
delete [] rms;
} else cout << "Could not allocate float image " << endl;
return NULL;
};
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){ virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
int nx, ny; int nx, ny;

View File

@ -561,16 +561,19 @@ void multiSlsDetector::readFrameFromReceiver() {
if (image == nullptr) { if (image == nullptr) {
// allocate // allocate
size = doc["size"].GetUint(); size = doc["size"].GetUint();
//std::cout << "SIZE: "<< size << std::endl;
multisize = size * zmqSocket.size(); multisize = size * zmqSocket.size();
image = new char[size]; image = new char[size];
multiframe = new char[multisize]; multiframe = new char[multisize];
memset(multiframe, 0xFF, multisize); memset(multiframe, 0xFF, multisize);
// dynamic range // dynamic range
dynamicRange = doc["bitmode"].GetUint(); // dynamicRange = doc["bitmode"].GetUint();
bytesPerPixel = (float)dynamicRange / 8; bytesPerPixel = (float)dynamicRange / 8;
// std::cout << "DR: "<< dynamicRange << std::endl;
// shape // shape
nPixelsX = doc["shape"][0].GetUint(); nPixelsX = doc["shape"][0].GetUint();
nPixelsY = doc["shape"][1].GetUint(); nPixelsY = doc["shape"][1].GetUint();
// std::cout << "shape: "<< nPixelsX << " "<< nPixelsY << std::endl;
// detector shape // detector shape
nX = doc["detshape"][0].GetUint(); nX = doc["detshape"][0].GetUint();
nY = doc["detshape"][1].GetUint(); nY = doc["detshape"][1].GetUint();
@ -626,7 +629,6 @@ void multiSlsDetector::readFrameFromReceiver() {
// DATA // DATA
data = true; data = true;
zmqSocket[isocket]->ReceiveData(isocket, image, size); zmqSocket[isocket]->ReceiveData(isocket, image, size);
// creating multi image // creating multi image
{ {
uint32_t xoffset = coordX * nPixelsX * bytesPerPixel; uint32_t xoffset = coordX * nPixelsX * bytesPerPixel;
@ -635,7 +637,11 @@ void multiSlsDetector::readFrameFromReceiver() {
uint32_t rowoffset = nX * singledetrowoffset; uint32_t rowoffset = nX * singledetrowoffset;
if (multi_shm()->multiDetectorType == CHIPTESTBOARD) { if (multi_shm()->multiDetectorType == CHIPTESTBOARD) {
singledetrowoffset = size; singledetrowoffset = size;
nPixelsY=1;
} }
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1)
<< "Multi Image Info:" << "Multi Image Info:"
"\n\txoffset: " "\n\txoffset: "
@ -654,6 +660,7 @@ void multiSlsDetector::readFrameFromReceiver() {
} }
} else { } else {
for (uint32_t i = 0; i < nPixelsY; ++i) { for (uint32_t i = 0; i < nPixelsY; ++i) {
std::cout << i << " " << std::endl;
memcpy(((char *)multiframe) + memcpy(((char *)multiframe) +
((yoffset + i) * rowoffset) + xoffset, ((yoffset + i) * rowoffset) + xoffset,
(char *)image + (i * singledetrowoffset), (char *)image + (i * singledetrowoffset),
@ -663,11 +670,11 @@ void multiSlsDetector::readFrameFromReceiver() {
} }
} }
} }
FILE_LOG(logDEBUG) << "Call Back Info:" FILE_LOG(logDEBUG)<< "Call Back Info:"
<< "\n\t nDetPixelsX: " << nDetPixelsX << "\n\t nDetPixelsX: " << nDetPixelsX
<< "\n\t nDetPixelsY: " << nDetPixelsY << "\n\t nDetPixelsY: " << nDetPixelsY
<< "\n\t databytes: " << multisize << "\n\t databytes: " << multisize
<< "\n\t dynamicRange: " << dynamicRange; << "\n\t dynamicRange: " << dynamicRange ;
// send data to callback // send data to callback
if (data) { if (data) {
@ -683,7 +690,8 @@ void multiSlsDetector::readFrameFromReceiver() {
} }
int n = processImageWithGapPixels(multiframe, multigappixels, int n = processImageWithGapPixels(multiframe, multigappixels,
quadEnable); quadEnable);
FILE_LOG(logDEBUG) << "Call Back Info Recalculated:" FILE_LOG(logDEBUG)
<< "Call Back Info Recalculated:"
<< "\n\t nDetPixelsX: " << nDetPixelsX << "\n\t nDetPixelsX: " << nDetPixelsX
<< "\n\t nDetPixelsY: " << nDetPixelsY << "\n\t nDetPixelsY: " << nDetPixelsY
<< "\n\t databytes: " << n; << "\n\t databytes: " << n;