mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
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:
parent
574f9cf566
commit
facbce62cf
@ -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) {
|
||||
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
|
||||
if (xtalk==0 || ix%40==0)
|
||||
return (double)getValue(data, ix, iy);
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
|
||||
else
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
|
||||
};
|
||||
|
@ -134,6 +134,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
|
||||
//calculate pedestals and common modes
|
||||
if (cmsub) {
|
||||
// cout << "cm" << endl;
|
||||
for (ix=xmin-1; ix<xmax+1; ix++)
|
||||
for (iy=ymin-1; iy<ymax+1; iy++) {
|
||||
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 (iy=ymin-1; iy<ymax+1; iy++) {
|
||||
// cout << ix << " " << iy << endl;
|
||||
thisEvent=filter->getEventType(buff, ix, iy, cmsub);
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
|
@ -118,7 +118,15 @@ class singlePhotonDetector {
|
||||
\param ix pixel x 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)
|
||||
@ -177,10 +185,14 @@ class singlePhotonDetector {
|
||||
|
||||
// eventType ret=PEDESTAL;
|
||||
double tot=0, max=0;
|
||||
|
||||
// cout << iframe << endl;
|
||||
|
||||
if (iframe<nDark) {
|
||||
if (cm==0)
|
||||
if (cm==0) {
|
||||
// cout << "=" << endl;
|
||||
addToPedestal(det->getValue(data, ix, iy),ix,iy);
|
||||
// cout << "=" << endl;
|
||||
}
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@ class slsReceiverData : public slsDetectorData<dataType> {
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
|
||||
slsReceiver data structure. Works for data acquired using the slsDetectorReceiver subdivided in different packets with headers and footers.
|
||||
Inherits and implements slsDetectorData.
|
||||
|
||||
@ -69,12 +67,13 @@ class slsReceiverData : public slsDetectorData<dataType> {
|
||||
while (dd<=(dsize-packetSize)) {
|
||||
pnum=getPacketNumber(p);
|
||||
fn=getFrameNumber(p);
|
||||
if (pnum<0 || pnum>=nPackets) {
|
||||
|
||||
|
||||
if (pnum<1 || pnum>nPackets) {
|
||||
cout << "Bad packet number " << pnum << " frame "<< fn << endl;
|
||||
retval=NULL;
|
||||
continue;
|
||||
}
|
||||
if (pnum==1) {
|
||||
np=0;
|
||||
} else if (pnum==1) {
|
||||
fnum=fn;
|
||||
retval=p;
|
||||
if (np>0)
|
||||
@ -90,21 +89,23 @@ class slsReceiverData : public slsDetectorData<dataType> {
|
||||
p+=packetSize;
|
||||
dd+=packetSize;
|
||||
np++;
|
||||
// cout << pnum << " " << fn << " " << np << " " << dd << " " << dsize << endl;
|
||||
if (np==nPackets)
|
||||
if (pnum==nPackets)
|
||||
if (pnum==nPackets) {
|
||||
// cout << "Frame found!" << endl;
|
||||
break;
|
||||
else {
|
||||
} else {
|
||||
cout << "Too many packets for this frame! "<< fnum << " " << pnum << endl;
|
||||
retval=NULL;
|
||||
}
|
||||
}
|
||||
if (np<40) {
|
||||
if (np<nPackets) {
|
||||
if (np>0)
|
||||
cout << "Too few packets for this frame! "<< fnum << " " << pnum << endl;
|
||||
}
|
||||
|
||||
ndata=np*packetSize;
|
||||
|
||||
// cout << "return " << ndata << endl;
|
||||
return retval;
|
||||
};
|
||||
|
||||
@ -128,14 +129,19 @@ class slsReceiverData : public slsDetectorData<dataType> {
|
||||
|
||||
retval=findNextFrame(data,nd,packetSize*nPackets);
|
||||
np=nd/packetSize;
|
||||
// cout << np << endl;
|
||||
|
||||
if (retval==data && np==nPackets)
|
||||
|
||||
if (retval==data && np==nPackets) {
|
||||
// cout << "-" << endl;
|
||||
return data;
|
||||
else if (np>nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
|
||||
} else if (np>nPackets) {
|
||||
cout << "too many packets!!!!!!!!!!" << endl;
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else {
|
||||
} else if (retval!=NULL) {
|
||||
// cout << "+" << endl;;
|
||||
for (int ip=0; ip<np; ip++)
|
||||
memcpy(data+ip*packetSize,retval+ip*packetSize,packetSize);
|
||||
}
|
||||
@ -145,6 +151,7 @@ class slsReceiverData : public slsDetectorData<dataType> {
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else {
|
||||
// cout << "." << endl;;
|
||||
np++;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user