mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-27 00:30:03 +02:00
Jungfrau stuff updated
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@48 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
parent
0f881677d2
commit
9297b14500
@ -62,7 +62,7 @@ class chiptestBoardData : public slsDetectorData<uint16_t> {
|
|||||||
if (filebin.is_open()) {
|
if (filebin.is_open()) {
|
||||||
if (filebin.read((char*)&afifo_length,sizeof(uint32_t))) {
|
if (filebin.read((char*)&afifo_length,sizeof(uint32_t))) {
|
||||||
setDataSize(afifo_length*nAdc*sizeof(uint16_t));
|
setDataSize(afifo_length*nAdc*sizeof(uint16_t));
|
||||||
afifo_cont=new uint16_t[afifo_length];
|
afifo_cont=new uint16_t[afifo_length*nAdc];
|
||||||
if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) {
|
if (filebin.read((char*)afifo_cont,afifo_length*sizeof(uint16_t)*nAdc)) {
|
||||||
iframe++;
|
iframe++;
|
||||||
return (char*)afifo_cont;
|
return (char*)afifo_cont;
|
||||||
|
@ -31,7 +31,7 @@ class commonModeSubtraction {
|
|||||||
cmPed[i]=0;
|
cmPed[i]=0;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/** adds the average of pedestals to the moving average and reienitialize the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||||
virtual void newFrame(){
|
virtual void newFrame(){
|
||||||
for (int i=0; i<nROI; i++) {
|
for (int i=0; i<nROI; i++) {
|
||||||
if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||||
|
@ -235,7 +235,7 @@ energyCalibration::energyCalibration() :
|
|||||||
fspectrum(NULL),
|
fspectrum(NULL),
|
||||||
#endif
|
#endif
|
||||||
funcs(NULL),
|
funcs(NULL),
|
||||||
plot_flag(1),
|
plot_flag(1), // fit parameters output to screen
|
||||||
cs_flag(1)
|
cs_flag(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t
|
|||||||
strcpy(fname, fun->GetName());
|
strcpy(fname, fun->GetName());
|
||||||
|
|
||||||
if (plot_flag) {
|
if (plot_flag) {
|
||||||
h1->Fit(fname,"R");
|
h1->Fit(fname,"R0Q");
|
||||||
} else
|
} else
|
||||||
h1->Fit(fname,"R0Q");
|
h1->Fit(fname,"R0Q");
|
||||||
|
|
||||||
@ -526,4 +526,4 @@ TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *ee
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Fit data is empty
|
||||||
|
@ -41,19 +41,22 @@ class jungfrau02Data : public chiptestBoardData {
|
|||||||
for (int iy=0; iy<48; iy++) {
|
for (int iy=0; iy<48; iy++) {
|
||||||
for (int ix=0; ix<48; ix++) {
|
for (int ix=0; ix<48; ix++) {
|
||||||
|
|
||||||
dMap[iy][ix]=offset+(iy*48+ix)*nAdc;
|
dMap[ix][iy]=offset+(iy*48+ix)*nAdc;//dMap[iy][ix]=offset+(iy*48+ix)*nAdc;
|
||||||
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
|
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << (0,0) << " " << dMap[0][0] << endl;
|
||||||
|
cout << (47,47) << " " << dMap[47][47] << endl;
|
||||||
|
|
||||||
|
|
||||||
for (int ix=0; ix<48; ix++) {
|
for (int ix=0; ix<48; ix++) {
|
||||||
for (int iy=0; iy<48; iy++)
|
for (int iy=0; iy<48; iy++)
|
||||||
dMask[iy][ix]=0x0;
|
dMask[iy][ix]=0x0;
|
||||||
}
|
|
||||||
|
|
||||||
setDataMap(dMap);
|
setDataMap(dMap);
|
||||||
setDataMask(dMask);
|
setDataMask(dMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -76,11 +79,11 @@ class jungfrau02Data : public chiptestBoardData {
|
|||||||
d=*(((uint16_t*)(data))+dataMap[iy][ix]);
|
d=*(((uint16_t*)(data))+dataMap[iy][ix]);
|
||||||
// cout << ix << " " << iy << " " << (uint16_t*)data << " " << ((uint16_t*)(data))+dataMap[iy][ix] << " " << d << endl;
|
// cout << ix << " " << iy << " " << (uint16_t*)data << " " << ((uint16_t*)(data))+dataMap[iy][ix] << " " << d << endl;
|
||||||
if (nAdc==3) {
|
if (nAdc==3) {
|
||||||
cout << "Gain bit!" << endl;
|
//cout << "Gain bit!" << endl;
|
||||||
if (*((uint16_t*)(data)+dataMap[iy][ix]+1)>8000)
|
if (*((uint16_t*)(data)+dataMap[iy][ix]+2)>8000) //exchange if gainBits==2 is returned!
|
||||||
d|=(1<<14); // set gain bit 0
|
d|=(1<<14); // gain bit 1
|
||||||
if (*((uint16_t*)(data)+dataMap[iy][ix]+2)>8000)
|
if (*((uint16_t*)(data)+dataMap[iy][ix]+1)>8000) //exchange if gainBits==2 is returned!
|
||||||
d|=(1<<15); // set gain bit 1
|
d|=(1<<15); // gain bit 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +109,20 @@ class jungfrau02Data : public chiptestBoardData {
|
|||||||
return (double)(getChannel(data, ix, iy)&0x3fff)-xtalk* (double)(getChannel(data, ix, iy)&0x3fff);
|
return (double)(getChannel(data, ix, iy)&0x3fff)-xtalk* (double)(getChannel(data, ix, iy)&0x3fff);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
returns the gain bit value, i.e. returns 0 if(GB0==0 && GB1==0), returns 1 if(GB0==1 && GB1==0), returns 3 if(GB0==1 && GB1==1), if it returns 2 -> the gain bits are read out the wrong way around (i.e. GB0 and GB1 have to be reversed!)
|
||||||
|
\param data pointer to the memory
|
||||||
|
\param ix coordinate in the x direction
|
||||||
|
\param iy coordinate in the y direction
|
||||||
|
\returns gain bits as int
|
||||||
|
*/
|
||||||
|
int getGainBits(char *data, int ix, int iy=0) {
|
||||||
|
uint16_t d=getChannel(data, ix, iy);
|
||||||
|
return ((d&0xc000)>>14);
|
||||||
|
};
|
||||||
|
//*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** sets the output buffer crosstalk correction parameter
|
/** sets the output buffer crosstalk correction parameter
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
//#include <queue>
|
//#include <queue>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "jungfrau02Data.h"
|
#include "jungfrau02Data.h"
|
||||||
#include "moenchCommonMode.h"
|
|
||||||
#include "jungfrau02CommonMode.h"
|
#include "jungfrau02CommonMode.h"
|
||||||
#include "singlePhotonDetector.h"
|
#include "singlePhotonDetector.h"
|
||||||
|
|
||||||
//#include "MovingStat.h"
|
//#include "MovingStat.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define NC 48
|
#define NC 48
|
||||||
@ -49,18 +49,37 @@ Loops over data file to find single photons, fills the tree (and writes it to fi
|
|||||||
\param xmax maximum x coordinate
|
\param xmax maximum x coordinate
|
||||||
\param ymin minimum y coordinate
|
\param ymin minimum y coordinate
|
||||||
\param ymax maximum y coordinate
|
\param ymax maximum y coordinate
|
||||||
\param cmsub enable commonmode subtraction -> Currently, CM subtraction is not implemented for Jungfrau!
|
\param cmsub enable commonmode subtraction
|
||||||
\param hitfinder if 0: performs pedestal subtraction, not hit finding; if 1: performs both pedestal subtraction and hit finding
|
\param hitfinder if 0: performs pedestal subtraction, not hit finding; if 1: performs both pedestal subtraction and hit finding
|
||||||
|
\param fcal -> calibration file, which contains 7 columns per pixel; 1) pixel #, 2) cal. offset G0, 3) cal. slope G0, 4) cal. offset G1, 5) cal. slope G1, 6) cal. offset G2, 7) cal. slope G2
|
||||||
\returns pointer to histo stack with cluster spectra
|
\returns pointer to histo stack with cluster spectra
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int nbins=1500, int hmin=-500, int hmax=1000, int sign=1, double hc=0, int xmin=1, int xmax=NC-1, int ymin=1, int ymax=NR-1, int cmsub=0, int hitfinder=1) {
|
THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int nbins=1500, int hmin=-500, int hmax=1000, int sign=1, double hc=0, int xmin=1, int xmax=NC-1, int ymin=1, int ymax=NR-1, int cmsub=0, int hitfinder=1){
|
||||||
|
|
||||||
jungfrau02Data *decoder=new jungfrau02Data(1,0,0);
|
// read in calibration file
|
||||||
jungfrau02CommonMode *cmSub=NULL;//moenchCommonMode *cmSub=NULL; //
|
ifstream calfile("/mnt/slitnas/datadir_jungfrau02/analysis_tests/CalibrationParametersTest_fake.txt");
|
||||||
// if (cmsub)
|
if (calfile.is_open()==0){cout << "Unable to open calibration file!" << endl;}
|
||||||
// cmSub=new moenchCommonMode();
|
int pix;
|
||||||
|
double of0,sl0,of1,sl1,of2,sl2;
|
||||||
|
double of_0[NC*NR], of_1[NC*NR], of_2[NC*NR], sl_0[NC*NR], sl_1[NC*NR], sl_2[NC*NR];
|
||||||
|
while (calfile >> pix >> of0 >> sl0 >> of1 >> sl1 >> of2 >> sl2){
|
||||||
|
of_0[pix]=of0;
|
||||||
|
sl_0[pix]=sl0;
|
||||||
|
of_1[pix]=of1;
|
||||||
|
sl_1[pix]=sl1;
|
||||||
|
of_2[pix]=of2;
|
||||||
|
sl_2[pix]=sl2; //if(pix==200) cout << "sl_2[200] " << sl_2[200] << endl;
|
||||||
|
}
|
||||||
|
calfile.close();
|
||||||
|
|
||||||
|
double adc_value, num_photon;
|
||||||
|
|
||||||
|
jungfrau02Data *decoder=new jungfrau02Data(1,0,0);//(3,0,0); // (adc,offset,crosstalk) //(1,0,0) //(3,0,0) for readout of GB
|
||||||
|
jungfrau02CommonMode *cmSub=NULL;
|
||||||
|
if (cmsub)
|
||||||
|
cmSub=new jungfrau02CommonMode();
|
||||||
|
|
||||||
int nph=0;
|
int nph=0;
|
||||||
int iev=0;
|
int iev=0;
|
||||||
@ -85,10 +104,12 @@ THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int
|
|||||||
THStack *hs=new THStack("hs",fformat);
|
THStack *hs=new THStack("hs",fformat);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TH2F *h1=new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
TH2F *h1=new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
||||||
hs->Add(h1);
|
hs->Add(h1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (hitfinder) {
|
if (hitfinder) {
|
||||||
h2=new TH2F("h2",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
h2=new TH2F("h2",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
||||||
h3=new TH2F("h3",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
h3=new TH2F("h3",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
||||||
@ -101,7 +122,6 @@ THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ifstream filebin;
|
ifstream filebin;
|
||||||
|
|
||||||
|
|
||||||
@ -143,7 +163,7 @@ THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int
|
|||||||
filter->newDataSet();
|
filter->newDataSet();
|
||||||
|
|
||||||
|
|
||||||
for (int irun=runmin; irun<=runmax; irun++){ //{for (int irun=runmin; irun<runmax; irun++) {
|
for (int irun=runmin; irun<=runmax; irun++){
|
||||||
sprintf(fname,fformat,irun);
|
sprintf(fname,fformat,irun);
|
||||||
cout << "file name " << fname << endl;
|
cout << "file name " << fname << endl;
|
||||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
@ -173,19 +193,25 @@ THStack *jungfrauReadData(char *fformat, char *tit, int runmin, int runmax, int
|
|||||||
|
|
||||||
|
|
||||||
thisEvent=filter->getEventType(buff, ix, iy, cmsub);
|
thisEvent=filter->getEventType(buff, ix, iy, cmsub);
|
||||||
|
int gainBits=decoder->getGainBits(buff,ix,iy); // get gain bits
|
||||||
|
|
||||||
#ifdef MY_DEBUG
|
#ifdef MY_DEBUG
|
||||||
if (hitfinder) {
|
if (hitfinder) {
|
||||||
if (iev%1000==0)
|
if (iev%1000==0)
|
||||||
he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent);
|
//he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent); // show single photon hits // original
|
||||||
|
//he->SetBinContent(ix+1-xmin, iy+1-ymin, cmSub->getCommonMode(ix,iy)); //show common mode!
|
||||||
|
he->SetBinContent(iy+1-ymin, ix+1-xmin, (int)gainBits); //show gain bits
|
||||||
|
//he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)gainBits); // rows and columns reversed!!!
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nf>1000) {
|
if (nf>1000) { // only start filing data after 1000 frames
|
||||||
|
|
||||||
// h1->Fill(decoder->getValue(buff,ix,iy), iy+NR*ix);
|
// h1->Fill(decoder->getValue(buff,ix,iy), iy+NR*ix);
|
||||||
h1->Fill(filter->getClusterTotal(1), iy+NR*ix);
|
h1->Fill(filter->getClusterTotal(1), iy+NR*ix);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (hitfinder) {
|
if (hitfinder) {
|
||||||
|
|
||||||
if (thisEvent==PHOTON_MAX ) {
|
if (thisEvent==PHOTON_MAX ) {
|
||||||
|
@ -21,7 +21,7 @@ class pedestalSubtraction {
|
|||||||
/** adds the element to the moving average
|
/** adds the element to the moving average
|
||||||
\param val value to be added
|
\param val value to be added
|
||||||
*/
|
*/
|
||||||
virtual void addToPedestal(double val){ stat.Calc(val);};
|
virtual void addToPedestal(double val){stat.Calc(val);};
|
||||||
|
|
||||||
/** returns the average value of the pedestal
|
/** returns the average value of the pedestal
|
||||||
\returns mean of the moving average
|
\returns mean of the moving average
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
{ // script to run Jungfrau data analysis
|
{ // script to run Jungfrau data analysis
|
||||||
|
|
||||||
gROOT->ProcessLine(".L jungfrauReadData.C+");
|
gROOT->ProcessLine(".L jungfrauReadData.C++");//");
|
||||||
|
|
||||||
TFile *fout; // output file
|
TFile *fout; // output file
|
||||||
THStack *hs2N; // collection of objects
|
THStack *hs2N; // collection of objects
|
||||||
|
|
||||||
fout=new TFile("/mnt/slitnas/datadir_jungfrau02/20140131_analysis/test/outfile.root","RECREATE"); // careful "RECREATE" will OVERWRITE!
|
fout=new TFile("/mnt/slitnas/datadir_jungfrau02/jungfrau_Trieste_2014/TriesteBeam2014/Analysis/D4_M1_HG_2000clk_CD986_CMsub.root","RECREATE"); //
|
||||||
|
|
||||||
|
//hs2N=jungfrauReadData("/mnt/slitnas/datadir_jungfrau02/20140131_BeamSLS/datadir_310114/21keV_10us_HIGHG0_CDS550_%d.bin","tit",0,75,1500,-500,2500,1,0.,1,47,1,47,1,1); //1,1);
|
||||||
|
|
||||||
|
//hs2N=jungfrauReadData("/mnt/slitnas/datadir_jungfrau02/20140228_GainBits/GSdata_laser_%d.bin","tit",0,5,1500,-500,2500,1,0.,1,47,1,47,0,1);//,"/mnt/slitnas/datadir_jungfrau02/analysis_tests/CalibrationParametersTest_fake.txt"); //1,1); // data set test GB -> set (3,0,0) in junfrauReadData.C
|
||||||
|
|
||||||
|
hs2N=jungfrauReadData("/mnt/slitnas/datadir_jungfrau02/jungfrau_Trieste_2014/Trieste_20140314/HG_20keV_CDS986_2000clk_%d.bin","tit",0,201,3000,-499.5,2500.5,1,0.,1,47,1,47,1,1);
|
||||||
|
//,"/mnt/slitnas/datadir_jungfrau02/analysis_tests/CalibrationParametersTest_fake.txt"); //1,1); // data set test GB -> set (3,0,0) in junfrauReadData.C
|
||||||
|
|
||||||
hs2N=jungfrauReadData("/mnt/slitnas/datadir_jungfrau02/20140131_BeamSLS/datadir_310114/18keV_10us_HIGHG0_CDS550_%d.bin","tit",0,10,1500,-500,2500,1,0.,1,47,1,47,1,1); //0,1);
|
|
||||||
//hs2N->SetName("cds_g4");
|
//hs2N->SetName("cds_g4");
|
||||||
//hs2N->SetTitle("cds_g4");
|
//hs2N->SetTitle("cds_g4");
|
||||||
|
|
||||||
@ -16,11 +22,10 @@
|
|||||||
(TH2F*)(hs2N->GetHists()->At(2))->Write();
|
(TH2F*)(hs2N->GetHists()->At(2))->Write();
|
||||||
(TH2F*)(hs2N->GetHists()->At(3))->Write();
|
(TH2F*)(hs2N->GetHists()->At(3))->Write();
|
||||||
(TH2F*)(hs2N->GetHists()->At(4))->Write();
|
(TH2F*)(hs2N->GetHists()->At(4))->Write();
|
||||||
|
//(TH2F*)(hs2N->GetHists()->At(5))->Write();
|
||||||
|
//(TH2F*)(hs2N->GetHists()->At(6))->Write();
|
||||||
|
|
||||||
|
//fout->Close(); // uncomment
|
||||||
fout->Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ class slsDetectorData {
|
|||||||
dataROIMask=new int*[ny];
|
dataROIMask=new int*[ny];
|
||||||
for(int i = 0; i < ny; i++) {
|
for(int i = 0; i < ny; i++) {
|
||||||
dataROIMask[i] = new int[nx];
|
dataROIMask[i] = new int[nx];
|
||||||
|
for (int j=0; j<nx; j++)
|
||||||
|
dataROIMask[i][j]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDataMap(dMap);
|
setDataMap(dMap);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user