Some bug fixes to slsReceiverData

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@17 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
bergamaschi 2014-01-14 13:46:21 +00:00
parent 574f9cf566
commit facbce62cf
4 changed files with 43 additions and 20 deletions

View File

@ -18,7 +18,8 @@ class moench02ModuleData : public slsReceiverData<uint16_t> {
*/ */
moench02ModuleData(double c=0): slsReceiverData<uint16_t>(160, 160, 40, 1286), xtalk(c) { moench02ModuleData(double c=0): slsReceiverData<uint16_t>(160, 160, 40, 1286),
xtalk(c) {
@ -96,8 +97,9 @@ class moench02ModuleData : public slsReceiverData<uint16_t> {
*/ */
double getValue(char *data, int ix, int iy=0) { double getValue(char *data, int ix, int iy=0) {
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
if (xtalk==0 || ix%40==0) if (xtalk==0 || ix%40==0)
return (double)getValue(data, ix, iy); return slsDetectorData<uint16_t>::getValue(data, ix, iy);
else else
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy); return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
}; };

View File

@ -134,6 +134,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
//calculate pedestals and common modes //calculate pedestals and common modes
if (cmsub) { if (cmsub) {
// cout << "cm" << endl;
for (ix=xmin-1; ix<xmax+1; ix++) for (ix=xmin-1; ix<xmax+1; ix++)
for (iy=ymin-1; iy<ymax+1; iy++) { for (iy=ymin-1; iy<ymax+1; iy++) {
thisEvent=filter->getEventType(buff, ix, iy,0); thisEvent=filter->getEventType(buff, ix, iy,0);
@ -141,10 +142,11 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
} }
// cout << "new frame " << endl;
for (ix=xmin-1; ix<xmax+1; ix++) for (ix=xmin-1; ix<xmax+1; ix++)
for (iy=ymin-1; iy<ymax+1; iy++) { for (iy=ymin-1; iy<ymax+1; iy++) {
// cout << ix << " " << iy << endl;
thisEvent=filter->getEventType(buff, ix, iy, cmsub); thisEvent=filter->getEventType(buff, ix, iy, cmsub);
#ifdef MY_DEBUG #ifdef MY_DEBUG

View File

@ -118,7 +118,15 @@ class singlePhotonDetector {
\param ix pixel x coordinate \param ix pixel x coordinate
\param iy pixel y coordinate \param iy pixel y coordinate
*/ */
virtual void addToPedestal(double val, int ix, int iy){ if (ix>=0 && ix<nx && iy>=0 && iy<ny) { stat[iy][ix].addToPedestal(val); if (cmSub && det->isGood(ix, iy) ) cmSub->addToCommonMode(val, ix, iy);}}; virtual void addToPedestal(double val, int ix, int iy){
// cout << "*"<< ix << " " << iy << " " << val << endl;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
// cout << ix << " " << iy << " " << val << endl;
stat[iy][ix].addToPedestal(val);
if (cmSub && det->isGood(ix, iy) )
cmSub->addToCommonMode(val, ix, iy);
};
};
/** /**
gets pedestal (and common mode) gets pedestal (and common mode)
@ -177,10 +185,14 @@ class singlePhotonDetector {
// eventType ret=PEDESTAL; // eventType ret=PEDESTAL;
double tot=0, max=0; double tot=0, max=0;
// cout << iframe << endl;
if (iframe<nDark) { if (iframe<nDark) {
if (cm==0) if (cm==0) {
// cout << "=" << endl;
addToPedestal(det->getValue(data, ix, iy),ix,iy); addToPedestal(det->getValue(data, ix, iy),ix,iy);
// cout << "=" << endl;
}
return UNDEFINED; return UNDEFINED;
} }

View File

@ -10,8 +10,6 @@ class slsReceiverData : public slsDetectorData<dataType> {
public: public:
/** /**
slsReceiver data structure. Works for data acquired using the slsDetectorReceiver subdivided in different packets with headers and footers. slsReceiver data structure. Works for data acquired using the slsDetectorReceiver subdivided in different packets with headers and footers.
Inherits and implements slsDetectorData. Inherits and implements slsDetectorData.
@ -69,12 +67,13 @@ class slsReceiverData : public slsDetectorData<dataType> {
while (dd<=(dsize-packetSize)) { while (dd<=(dsize-packetSize)) {
pnum=getPacketNumber(p); pnum=getPacketNumber(p);
fn=getFrameNumber(p); fn=getFrameNumber(p);
if (pnum<0 || pnum>=nPackets) {
if (pnum<1 || pnum>nPackets) {
cout << "Bad packet number " << pnum << " frame "<< fn << endl; cout << "Bad packet number " << pnum << " frame "<< fn << endl;
retval=NULL; retval=NULL;
continue; np=0;
} } else if (pnum==1) {
if (pnum==1) {
fnum=fn; fnum=fn;
retval=p; retval=p;
if (np>0) if (np>0)
@ -90,21 +89,23 @@ class slsReceiverData : public slsDetectorData<dataType> {
p+=packetSize; p+=packetSize;
dd+=packetSize; dd+=packetSize;
np++; np++;
// cout << pnum << " " << fn << " " << np << " " << dd << " " << dsize << endl;
if (np==nPackets) if (np==nPackets)
if (pnum==nPackets) if (pnum==nPackets) {
// cout << "Frame found!" << endl;
break; break;
else { } else {
cout << "Too many packets for this frame! "<< fnum << " " << pnum << endl; cout << "Too many packets for this frame! "<< fnum << " " << pnum << endl;
retval=NULL; retval=NULL;
} }
} }
if (np<40) { if (np<nPackets) {
if (np>0) if (np>0)
cout << "Too few packets for this frame! "<< fnum << " " << pnum << endl; cout << "Too few packets for this frame! "<< fnum << " " << pnum << endl;
} }
ndata=np*packetSize; ndata=np*packetSize;
// cout << "return " << ndata << endl;
return retval; return retval;
}; };
@ -128,14 +129,19 @@ class slsReceiverData : public slsDetectorData<dataType> {
retval=findNextFrame(data,nd,packetSize*nPackets); retval=findNextFrame(data,nd,packetSize*nPackets);
np=nd/packetSize; np=nd/packetSize;
// cout << np << endl;
if (retval==data && np==nPackets)
if (retval==data && np==nPackets) {
// cout << "-" << endl;
return data; return data;
else if (np>nPackets) {
} else if (np>nPackets) {
cout << "too many packets!!!!!!!!!!" << endl; cout << "too many packets!!!!!!!!!!" << endl;
delete [] data; delete [] data;
return NULL; return NULL;
} else { } else if (retval!=NULL) {
// cout << "+" << endl;;
for (int ip=0; ip<np; ip++) for (int ip=0; ip<np; ip++)
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize); memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
} }
@ -145,6 +151,7 @@ class slsReceiverData : public slsDetectorData<dataType> {
delete [] data; delete [] data;
return NULL; return NULL;
} else { } else {
// cout << "." << endl;;
np++; np++;
} }
} }