mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
fixed CM corrections
This commit is contained in:
parent
f3c669f193
commit
ef9e769c4b
@ -866,7 +866,7 @@ template <class dataType> class analogDetector {
|
|||||||
for (ix = xmin; ix < xmax; ++ix) {
|
for (ix = xmin; ix < xmax; ++ix) {
|
||||||
if (det->isGood(ix, iy)) {
|
if (det->isGood(ix, iy)) {
|
||||||
// addToPedestal(data,ix,iy,1);
|
// addToPedestal(data,ix,iy,1);
|
||||||
addToPedestal(data, ix, iy, cm);
|
addToPedestal(data, ix, iy, 0);
|
||||||
/* if (ix==50 && iy==50) */
|
/* if (ix==50 && iy==50) */
|
||||||
/* cout<< "*ped* " << id << " " << ix << " " << iy << " "
|
/* cout<< "*ped* " << id << " " << ix << " " << iy << " "
|
||||||
* << det->getChannel(data,ix,iy) << " " <<
|
* << det->getChannel(data,ix,iy) << " " <<
|
||||||
@ -1097,8 +1097,7 @@ template <class dataType> class analogDetector {
|
|||||||
return thr;
|
return thr;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual int setClusterSize(int n = -1) {
|
virtual int setClusterSize(int n = -1) { return 0; };
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
gets threshold value for conversion into number of photons
|
gets threshold value for conversion into number of photons
|
||||||
|
@ -100,7 +100,10 @@ class commonModeSubtraction {
|
|||||||
if (iroi >= 0 && iroi < nROI) {
|
if (iroi >= 0 && iroi < nROI) {
|
||||||
if (nCm[iroi] > 0)
|
if (nCm[iroi] > 0)
|
||||||
return mean[iroi] / nCm[iroi];
|
return mean[iroi] / nCm[iroi];
|
||||||
}
|
else
|
||||||
|
std::cout << ix << " " << iy << " no data in cm " << iroi << std::endl;
|
||||||
|
} else
|
||||||
|
std::cout << ix << " " << iy << " bad roi " << iroi << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -117,6 +120,8 @@ class commonModeSubtraction {
|
|||||||
return sqrt(mean2[iroi] / nCm[iroi] -
|
return sqrt(mean2[iroi] / nCm[iroi] -
|
||||||
(mean[iroi] / nCm[iroi]) *
|
(mean[iroi] / nCm[iroi]) *
|
||||||
(mean[iroi] / nCm[iroi]));
|
(mean[iroi] / nCm[iroi]));
|
||||||
|
else
|
||||||
|
std::cout << ix << " " << iy << " no data in cm " << iroi << std::endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
@ -27,6 +27,8 @@ enum quadrant {
|
|||||||
//#ifdef MYROOT1
|
//#ifdef MYROOT1
|
||||||
//: public TObject
|
//: public TObject
|
||||||
//#endif
|
//#endif
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class slsInterpolation {
|
class slsInterpolation {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -30,4 +30,29 @@ class commonModeSubtractionSuperColumnJF : public commonModeSubtraction {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class commonModeSubtractionChip : public commonModeSubtraction {
|
||||||
|
public:
|
||||||
|
commonModeSubtractionChip()
|
||||||
|
: commonModeSubtraction(8){};
|
||||||
|
virtual int getROI(int ix, int iy) { int top=iy/256; int sc=ix/256; return sc+top*4; };
|
||||||
|
/*
|
||||||
|
virtual void addToCommonMode(double val, int ix = 0, int iy = 0) {
|
||||||
|
int iroi = getROI(ix, iy);
|
||||||
|
// cout << iy << " " << ix << " " << iroi ;
|
||||||
|
if (iroi >= 0 && iroi < nROI) {
|
||||||
|
mean[iroi] += val;
|
||||||
|
mean2[iroi] += val * val;
|
||||||
|
nCm[iroi]++;
|
||||||
|
if (nCm[iroi] > 64*256)
|
||||||
|
std::cout << "Too many pixels added " << nCm[iroi] << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
virtual commonModeSubtractionChip *Clone() {
|
||||||
|
return new commonModeSubtractionChip();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//enable common mode subtraction
|
//enable common mode subtraction
|
||||||
//#define CMS
|
#define CMS
|
||||||
//disable common mode subtraction
|
//disable common mode subtraction
|
||||||
#undef CMS
|
//#undef CMS
|
||||||
#undef CORR
|
#undef CORR
|
||||||
#define C_GHOST 0.0004
|
#define C_GHOST 0.0004
|
||||||
|
|
||||||
@ -40,7 +40,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
//#include "jungfrauCommonMode.h"
|
//#include "commonModeSubtractionNew.h"
|
||||||
|
#include "jungfrauCommonMode.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -63,7 +64,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int fifosize = 1000;
|
int fifosize = 1000;
|
||||||
int nthreads = 10;
|
int nthreads = 1;
|
||||||
int csize = 3; //3
|
int csize = 3; //3
|
||||||
int nsigma = 5;
|
int nsigma = 5;
|
||||||
int nped = 10000;
|
int nped = 10000;
|
||||||
@ -73,10 +74,12 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && !defined JFSTRXCHIP6
|
#if !defined JFSTRX && !defined JFSTRXOLD && !defined JFSTRXCHIP1 && !defined JFSTRXCHIP6
|
||||||
#ifndef MODULE
|
#ifndef MODULE
|
||||||
|
cout << "This is a JF single chip!" <<endl;
|
||||||
jungfrauHighZSingleChipData *decoder = new jungfrauHighZSingleChipData();
|
jungfrauHighZSingleChipData *decoder = new jungfrauHighZSingleChipData();
|
||||||
int nx = 256, ny = 256;
|
int nx = 256, ny = 256;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE
|
#ifdef MODULE
|
||||||
|
cout << "This is a JF module!" <<endl;
|
||||||
jungfrauModuleData *decoder = new jungfrauModuleData();
|
jungfrauModuleData *decoder = new jungfrauModuleData();
|
||||||
int nx = 1024, ny = 512;
|
int nx = 1024, ny = 512;
|
||||||
#endif
|
#endif
|
||||||
@ -186,7 +189,7 @@ int main(int argc, char *argv[]) {
|
|||||||
uint32_t nnx, nny;
|
uint32_t nnx, nny;
|
||||||
commonModeSubtraction *cm = NULL;
|
commonModeSubtraction *cm = NULL;
|
||||||
#ifdef CMS
|
#ifdef CMS
|
||||||
cm = new commonModeSubtractionSuperColumnJF();
|
cm = new commonModeSubtractionChip();//commonModeSubtraction(1,5);//commonModeSubtractionSuperColumnJF();
|
||||||
std::cout << "Enabled common mode subtraction" << std::endl;
|
std::cout << "Enabled common mode subtraction" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
singlePhotonDetector *filter = new singlePhotonDetector(
|
singlePhotonDetector *filter = new singlePhotonDetector(
|
||||||
@ -250,6 +253,7 @@ int main(int argc, char *argv[]) {
|
|||||||
double *ped=new double[nx * ny];//, *ped1;
|
double *ped=new double[nx * ny];//, *ped1;
|
||||||
|
|
||||||
int pos,pos1;
|
int pos,pos1;
|
||||||
|
int ipixX=351, ipixY=331;
|
||||||
|
|
||||||
if (pedfile) {
|
if (pedfile) {
|
||||||
|
|
||||||
@ -277,19 +281,43 @@ int main(int argc, char *argv[]) {
|
|||||||
ff = -1;
|
ff = -1;
|
||||||
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
||||||
// if (np == 40) {
|
// if (np == 40) {
|
||||||
if ((ifr+1) % 100 == 0) {
|
// if ((ifr+1) % 100 == 0) {
|
||||||
cout << " ****" << decoder->getValue(buff,20,20);// << endl;
|
// cout << " ****" << decoder->getValue(buff,20,20);// << endl;
|
||||||
}
|
// }
|
||||||
mt->pushData(buff);
|
mt->pushData(buff);
|
||||||
|
|
||||||
|
|
||||||
|
// while (mt->isBusy())
|
||||||
|
// ;
|
||||||
|
//if ((ifr+1) % 100 == 0)
|
||||||
|
|
||||||
|
// double pix=0,ped=0,sub=0,cmp=0, sub0=0;
|
||||||
|
|
||||||
|
// for (int ix=-1; ix<2; ix++) {
|
||||||
|
// for (int iy=-1; iy<2; iy++) {
|
||||||
|
// pix+=decoder->getValue(buff, ipixX+ix, ipixY+iy);
|
||||||
|
// sub+=filter->subtractPedestal(buff, ipixX+ix, ipixY+iy, 1);
|
||||||
|
// sub0+=filter->subtractPedestal(buff, ipixX+ix, ipixY+iy, 0);
|
||||||
|
// ped+=filter->getPedestal(ipixX+ix, ipixY+iy);
|
||||||
|
// cmp+=filter->getCommonMode(ipixX+ix, ipixY+iy);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cout << pix << " " << sub << " " sub0 << " " << ped << " " << cmp << endl;
|
||||||
|
|
||||||
|
|
||||||
mt->nextThread();
|
mt->nextThread();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
ifr++;
|
ifr++;
|
||||||
if (ifr % 100 == 0) {
|
// if (ifr % 100 == 0) {
|
||||||
cout << " ****" << ifr << " " << ff << " " << np << endl;
|
// cout << " ****" << ifr << " " << ff << " " << np << endl;
|
||||||
} //else
|
// }
|
||||||
|
|
||||||
|
//else
|
||||||
//cout << ifr << " " << ff << " " << np << endl;
|
//cout << ifr << " " << ff << " " << np << endl;
|
||||||
if (ifr>=1000)
|
// if (ifr>=1000)
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
ff = -1;
|
ff = -1;
|
||||||
}
|
}
|
||||||
filebin.close();
|
filebin.close();
|
||||||
@ -370,7 +398,25 @@ int main(int argc, char *argv[]) {
|
|||||||
if ((ifr+1) % 100 == 0) {
|
if ((ifr+1) % 100 == 0) {
|
||||||
cout << " ****" << decoder->getValue(buff,20,20);// << endl;
|
cout << " ****" << decoder->getValue(buff,20,20);// << endl;
|
||||||
}
|
}
|
||||||
mt->pushData(buff);
|
mt->pushData(buff);
|
||||||
|
|
||||||
|
|
||||||
|
// while (mt->isBusy())
|
||||||
|
|
||||||
|
// double pix=0,ped=0,sub=0,cmp=0, sub0=0;
|
||||||
|
|
||||||
|
// for (int ix=-1; ix<2; ix++) {
|
||||||
|
// for (int iy=-1; iy<2; iy++) {
|
||||||
|
// pix+=decoder->getValue(buff, ipixX+ix, ipixY+iy);
|
||||||
|
// sub+=filter->subtractPedestal(buff, ipixX+ix, ipixY+iy, 1);
|
||||||
|
// sub0+=filter->subtractPedestal(buff, ipixX+ix, ipixY+iy, 0);
|
||||||
|
// ped+=filter->getPedestal(ipixX+ix, ipixY+iy);
|
||||||
|
// cmp+=filter->getCommonMode(ipixX+ix, ipixY+iy);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cout << pix << " " << sub << " " sub0 << " " << ped << " " << cmp << endl;
|
||||||
|
|
||||||
// // //pop
|
// // //pop
|
||||||
mt->nextThread();
|
mt->nextThread();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
|
@ -396,14 +396,14 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
newFrame(data);
|
newFrame(data);
|
||||||
|
/*
|
||||||
if (cmSub) {
|
if (cmSub) {
|
||||||
addToCommonMode(data);
|
addToCommonMode(data);
|
||||||
cm = 1;
|
cm = 1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
double *val = new double[ny * nx];
|
double *val = new double[ny * nx];
|
||||||
|
cm=0;
|
||||||
for (iy = ymin; iy < ymax; ++iy) {
|
for (iy = ymin; iy < ymax; ++iy) {
|
||||||
for (ix = xmin; ix < xmax; ++ix) {
|
for (ix = xmin; ix < xmax; ++ix) {
|
||||||
if (det->isGood(ix, iy) == 0)
|
if (det->isGood(ix, iy) == 0)
|
||||||
@ -547,12 +547,50 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
|||||||
|
|
||||||
} else if (ee == PEDESTAL) {
|
} else if (ee == PEDESTAL) {
|
||||||
addToPedestal(data, ix, iy, cm);
|
addToPedestal(data, ix, iy, cm);
|
||||||
|
if (cmSub) {
|
||||||
|
addToCommonMode(data, ix, iy);
|
||||||
|
}
|
||||||
} /*else {
|
} /*else {
|
||||||
eventMask[iy][ix]=PHOTON;
|
eventMask[iy][ix]=PHOTON;
|
||||||
}*/
|
}*/
|
||||||
// eventMask[iy][ix]=ee;
|
// eventMask[iy][ix]=ee;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmSub) {
|
||||||
|
|
||||||
|
double cmv=0;
|
||||||
|
for (int iph=0; iph<nph; iph++) {
|
||||||
|
ix=(clusters + iph)->x ;
|
||||||
|
iy=(clusters + nph)->y;
|
||||||
|
|
||||||
|
for (ir = -(clusterSizeY / 2); ir < (clusterSizeY / 2) + 1;
|
||||||
|
ir++) {
|
||||||
|
for (ic = -(clusterSize / 2);
|
||||||
|
ic < (clusterSize / 2) + 1; ic++) {
|
||||||
|
if ((iy + ir) >= 0 && (iy + ir) < ny &&
|
||||||
|
(ix + ic) >= 0 && (ix + ic) < nx) {
|
||||||
|
|
||||||
|
cmv=getCommonMode(ix+ic, iy+ir);
|
||||||
|
//if (ir==0 && ic==0)
|
||||||
|
//cout << cmv << endl;
|
||||||
|
(clusters + iph)
|
||||||
|
->set_data((clusters + iph)
|
||||||
|
->get_data(ic,ir)-cmv, ic,ir);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nphFrame = nph;
|
nphFrame = nph;
|
||||||
nphTot += nph;
|
nphTot += nph;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user