mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
common mode subtraction now works for moench - bad channel mask added to the data structure
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@10 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
class MovingStat
|
||||
{
|
||||
public:
|
||||
MovingStat() : m_n(0), n(0) {}
|
||||
MovingStat() : m_n(0), n(1000) {}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
|
@ -126,31 +126,42 @@ class moench02ModuleData : public slsDetectorData {
|
||||
for (ix=xmin-1; ix<xmax+1; ix++) {
|
||||
isc=ix/40;
|
||||
for (iy=ymin-1; iy<ymax+1; iy++) {
|
||||
|
||||
if (getEventType(ix, iy, hc, tc, 1)==PEDESTAL) {
|
||||
cmPed[isc]+=getChannelShort(ix, iy, hc, tc);
|
||||
nCm[isc]++;
|
||||
if (isGood(ix,iy)) {
|
||||
if (getEventType(ix, iy, hc, tc, 1,0)==PEDESTAL) {
|
||||
cmPed[isc]+=getChannelShort(ix, iy, hc, tc);
|
||||
nCm[isc]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (isc=scmin; isc<scmax; isc++) {
|
||||
|
||||
if (nCm[isc]>0)
|
||||
cmStat[isc].Calc(cmPed[isc]/nCm[isc]);
|
||||
}
|
||||
|
||||
// cout << "SC " << isc << nCm[isc] << " " << cmPed[isc]/nCm[isc] << " " << cmStat[isc].Mean() << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
double getCommonMode(int ix, int iy) {
|
||||
int isc=ix/40;
|
||||
if (nCm[isc]>0)
|
||||
if (nCm[isc]>0) {
|
||||
/* if (ix==20 && iy==20) */
|
||||
/* cout << cmPed[isc] << " " << nCm[isc] << " " << cmStat[isc].Mean() << " " << cmPed[isc]/nCm[isc]-cmStat[isc].Mean() << endl; */
|
||||
return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
|
||||
else
|
||||
} else {
|
||||
/* if (ix==20 && iy==20) */
|
||||
/* cout << "No common mode!" << endl; */
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -221,7 +232,7 @@ class moench02ModuleData : public slsDetectorData {
|
||||
char *getBuff(){return buff;}
|
||||
char *getOldBuff(){return oldbuff;}
|
||||
|
||||
int setPedestalSubstraction(int i=-1){if (i==0) pedSub=0; if (i==1) pedSub=1; return pedSub;};
|
||||
int setPedestalSubstraction(int i=-1){if (i>=0) pedSub=i; return pedSub;};
|
||||
|
||||
|
||||
double getChannelShort(int ix, int iy, double hc=0, double tc=0) {
|
||||
@ -240,7 +251,7 @@ class moench02ModuleData : public slsDetectorData {
|
||||
|
||||
|
||||
|
||||
eventType getEventType(int ix, int iy, double hcorr=0, double tcorr=0, int sign=1) {
|
||||
eventType getEventType(int ix, int iy, double hcorr=0, double tcorr=0, int sign=1, int cm=0) {
|
||||
|
||||
/* PEDESTAL, */
|
||||
/* NEIGHBOUR, */
|
||||
@ -256,9 +267,11 @@ class moench02ModuleData : public slsDetectorData {
|
||||
for (int ir=-1; ir<2; ir++) {
|
||||
for (int ic=-1; ic<2; ic ++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<160 && (ix+ic)>=0 && (ix+ic)<160) {
|
||||
v=getChannelShort(ix+ic, iy+ir, hcorr, tcorr);
|
||||
v=sign*getChannelShort(ix+ic, iy+ir, hcorr, tcorr);
|
||||
if (pedSub)
|
||||
v=sign*(v-getPedestal(ix+ic,iy+ir));
|
||||
v-=sign*getPedestal(ix+ic,iy+ir);
|
||||
if (cm)
|
||||
v-=sign*getCommonMode(ix+ic, iy+ic);
|
||||
cluster[ic+1][ir+1]=v;
|
||||
tot+=v;
|
||||
if (v>max) {
|
||||
@ -290,10 +303,7 @@ class moench02ModuleData : public slsDetectorData {
|
||||
};
|
||||
|
||||
|
||||
double getClusterElement(int ic, int ir, int cm=0){
|
||||
if (cm) cluster[ic+1][ir+1]-getCommonMode(cx,cy);
|
||||
else return cluster[ic+1][ir+1];
|
||||
};
|
||||
double getClusterElement(int ic, int ir, int cmsub=0){return cluster[ic+1][ir+1];};
|
||||
|
||||
double *getCluster(){return &cluster[0][0];};
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include <THStack.h>
|
||||
#include <TCanvas.h>
|
||||
#include <stdio.h>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <queue>
|
||||
//#include <deque>
|
||||
//#include <list>
|
||||
//#include <queue>
|
||||
#include <fstream>
|
||||
#include "moench02ModuleData.h"
|
||||
|
||||
@ -23,7 +23,14 @@ using namespace std;
|
||||
#define NC 160
|
||||
#define NR 160
|
||||
|
||||
|
||||
#define MY_DEBUG 1
|
||||
#ifdef MY_DEBUG
|
||||
#include <TCanvas.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
char *fformat, file name format
|
||||
char *tit, title of the tree etc.
|
||||
int runmin, minimum run number
|
||||
@ -67,6 +74,9 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
|
||||
THStack *hs=new THStack("hs",fformat);
|
||||
|
||||
|
||||
int iev=0;
|
||||
|
||||
TH2F *h1=new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
||||
hs->Add(h1);
|
||||
|
||||
@ -106,6 +116,14 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
// 6% x-talk from previous pixel
|
||||
// 12% x-talk from previous frame
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
TCanvas *myC=new TCanvas();
|
||||
TH2F *he=new TH2F("he","Event",3,-1.5,1.5,3,-1.5,1.5);
|
||||
he->SetStats(kFALSE);
|
||||
he->Draw("colz");
|
||||
he->SetMinimum(0);
|
||||
he->SetMaximum(0.5*hmax);
|
||||
#endif
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fname,fformat,irun);
|
||||
@ -119,9 +137,13 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
if (nf>100) {
|
||||
if (cmsub) {
|
||||
for (int isc=scmin; isc<scmax; isc++) {
|
||||
decoder->calculateCommonMode(3+isc*40, 40*(isc-1)-3, 3, NR-3, hc, tc);
|
||||
decoder->calculateCommonMode(3+isc*40, 40*(isc+1)-3, 3, NR-3, hc, tc);
|
||||
#ifdef MY_DEBUG
|
||||
if (nf%1000==0) cout << "sc=" << isc << " CM="<< decoder->getCommonMode(3+isc*40, NR/2)<< endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +156,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
|
||||
|
||||
if (nf>100) {
|
||||
thisEvent= decoder->getEventType(ix, iy, hc, tc, 1);
|
||||
thisEvent= decoder->getEventType(ix, iy, hc, tc, 1,1);
|
||||
}
|
||||
|
||||
|
||||
@ -142,10 +164,11 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
|
||||
if (thisEvent==moench02ModuleData::PEDESTAL) {
|
||||
if (cmsub && nf>1000)
|
||||
decoder->addToPedestal( decoder->getChannelShort(ix, iy, hc, tc)- decoder->getCommonMode(ix,iy), ix, iy);
|
||||
decoder->addToPedestal(decoder->getChannelShort(ix, iy, hc, tc)-decoder->getCommonMode(ix,iy), ix, iy);
|
||||
else
|
||||
decoder->addToPedestal( decoder->getChannelShort(ix, iy, hc, tc), ix, iy);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -159,15 +182,30 @@ Add here the function that you want to call: fill histos, make trees etc.
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
h1->Fill(decoder->getClusterElement(0,0, cmsub), iy+NR*ix);
|
||||
h1->Fill(decoder->getClusterElement(0,0), iy+NR*ix);
|
||||
|
||||
// if (nf%1000==0 && ix==20 && iy==20) cout << " val="<< decoder->getClusterElement(0,0)<< endl;
|
||||
|
||||
if (thisEvent==moench02ModuleData::PHOTON_MAX ) {
|
||||
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
if (iev%100000==0) {
|
||||
cout << "Event " << iev << " Frame "<< nf << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
for (ir=-1; ir<2; ir++) {
|
||||
for (ic=-1; ic<2; ic++) {
|
||||
v=decoder->getClusterElement(ic,ir,cmsub);
|
||||
data[ic+1][ir+1]=v;
|
||||
#ifdef MY_DEBUG
|
||||
if (iev%100000==0) {
|
||||
he->SetBinContent(ic+2,ir+2,v);
|
||||
cout << "Histo("<< ix+ic << ","<< iy+ir <<")" << v << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
tot+=v;
|
||||
if (ir<1) {
|
||||
|
||||
@ -237,7 +275,16 @@ Add here the function that you want to call: fill histos, make trees etc.
|
||||
y=iy;
|
||||
|
||||
tall->Fill();
|
||||
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
if (iev%100000==0) {
|
||||
myC->Modified();
|
||||
myC->Update();
|
||||
}
|
||||
#endif
|
||||
|
||||
iev++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,9 +19,7 @@ class slsDetectorData {
|
||||
|
||||
|
||||
*/
|
||||
slsDetectorData(int npx, int npy=1, int ds=-1, int **dMap=NULL, int **dMask=NULL) {
|
||||
nx=npx;
|
||||
ny=npy;
|
||||
slsDetectorData(int npx, int npy=1, int ds=-1, int **dMap=NULL, int **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy) {
|
||||
|
||||
if (ds<=0)
|
||||
dataSize=nx*ny;
|
||||
@ -37,8 +35,14 @@ class slsDetectorData {
|
||||
dataMap[i] = new int[nx];
|
||||
}
|
||||
|
||||
dataROIMask=new int*[ny];
|
||||
for(int i = 0; i < ny; i++) {
|
||||
dataROIMask[i] = new int[nx];
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
setDataROIMask(dROI);
|
||||
|
||||
};
|
||||
|
||||
@ -46,9 +50,11 @@ class slsDetectorData {
|
||||
for(int i = 0; i < ny; i++) {
|
||||
delete [] dataMap[i];
|
||||
delete [] dataMask[i];
|
||||
delete [] dataROIMask[i];
|
||||
}
|
||||
delete [] dataMap;
|
||||
delete [] dataMask;
|
||||
delete [] dataROIMask;
|
||||
}
|
||||
|
||||
void setDataMap(int **dMap=NULL) {
|
||||
@ -76,8 +82,27 @@ class slsDetectorData {
|
||||
}
|
||||
|
||||
};
|
||||
void setDataROIMask(int **dROI=NULL){
|
||||
|
||||
if (dROI!=NULL) {
|
||||
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataROIMask[iy][ix]=dROI[iy][ix];
|
||||
} else {
|
||||
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
dataROIMask[iy][ix]=1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
int setBad(int ix, int iy, int i=1) {dataROIMask[iy][ix]=i; return isGood(ix,iy);};
|
||||
|
||||
int isGood(int ix, int iy) {return dataROIMask[iy][ix];};
|
||||
|
||||
|
||||
/**
|
||||
@ -117,11 +142,12 @@ class slsDetectorData {
|
||||
|
||||
|
||||
private:
|
||||
int nx; /**< Number of pixels in the x direction */
|
||||
int ny; /**< Number of pixels in the y direction */
|
||||
const int nx; /**< Number of pixels in the x direction */
|
||||
const int ny; /**< Number of pixels in the y direction */
|
||||
int dataSize; /**< Size of a dataset */
|
||||
int **dataMap; /**< Array of size nx*ny storing the pointers to the data in the dataset (as offset)*/
|
||||
int **dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required */
|
||||
int **dataMask; /**< Array of size nx*ny storing the polarity of the data in the dataset (should be 0 if no inversion is required, 0xffffffff is inversion is required) */
|
||||
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user