From 985b4d71b409c021a60eab8fdf987e7f72a5f069 Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Thu, 5 Mar 2015 13:04:31 +0100 Subject: [PATCH] Added jungfrau1.0 data structure (bad) and added xmap, ymap and getPixel method to the slsDetectorData base class --- slsDetectorCalibration/jungfrau10ModuleData.h | 154 ++++++++++++++++++ slsDetectorCalibration/moench02CtbData.h | 4 +- slsDetectorCalibration/moench03CtbData.h | 7 +- slsDetectorCalibration/moench03ReadData.C | 57 +++---- slsDetectorCalibration/readMoench03Data.C | 36 ++-- slsDetectorCalibration/slsDetectorData.h | 30 +++- 6 files changed, 230 insertions(+), 58 deletions(-) create mode 100644 slsDetectorCalibration/jungfrau10ModuleData.h diff --git a/slsDetectorCalibration/jungfrau10ModuleData.h b/slsDetectorCalibration/jungfrau10ModuleData.h new file mode 100644 index 000000000..a107f5058 --- /dev/null +++ b/slsDetectorCalibration/jungfrau10ModuleData.h @@ -0,0 +1,154 @@ +#ifndef JUNGFRAU10MODULEDATA_H +#define JUNGFRAU10MODULEBDATA_H +#include "slsDetectorData.h" + + + +class jungfrau10ModuleData : public slsDetectorData { + + private: + + int iframe; + int nadc; + int sc_width; + int sc_height; + public: + + + + + /** + Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver + (160x160 pixels, 40 packets 1286 large etc.) + \param c crosstalk parameter for the output buffer + + */ + + + jungfrau10ModuleData(int ns=16384): slsDetectorData(256*4, 256*2, ns*2*32, NULL, NULL) , nadc(32), sc_width(64), sc_height(256) { + + + + int row, col; + + int isample; + int iadc; + int ix, iy; + + + + cout << nx << " " << ny << " " << dataSize << endl; + + for (iadc=0; iadc=dataSize) + cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; + + } + + } + for (int i=0; i0) { + iframe++; + // cout << ib << "-" << endl; + return (char*)afifo_cont; + } else { + delete [] afifo_cont; + return NULL; + } + } + return NULL; + }; + + + + +}; + + + +#endif diff --git a/slsDetectorCalibration/moench02CtbData.h b/slsDetectorCalibration/moench02CtbData.h index 03ffd4ac5..37bf8304d 100644 --- a/slsDetectorCalibration/moench02CtbData.h +++ b/slsDetectorCalibration/moench02CtbData.h @@ -47,9 +47,11 @@ class moench02CtbData : public slsDetectorData { col=adc_nr[iadc]+(i%sc_width); row=i/sc_width; dataMap[row][col]=(32*i+iadc)*2; - if (dataMap[row][col]<0 || dataMap[row][col]>=2*160*160) + if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) { cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; + } + } } for (int i=0; i { private: int iframe; - int *xmap, *ymap; int nadc; int sc_width; int sc_height; @@ -39,8 +38,6 @@ class moench03CtbData : public slsDetectorData { int iadc; int ix, iy; - xmap=new int[nx*ny]; - ymap=new int[nx*ny]; @@ -83,8 +80,6 @@ class moench03CtbData : public slsDetectorData { // cout << "data struct created" << endl; }; - void getPixel(int ip, int &x, int &y) {if (ip>=0 && ip { } if (ib>0) { iframe++; - cout << ib << "-" << endl; + // cout << ib << "-" << endl; return (char*)afifo_cont; } else { delete [] afifo_cont; diff --git a/slsDetectorCalibration/moench03ReadData.C b/slsDetectorCalibration/moench03ReadData.C index a2f268aff..c54a7655e 100644 --- a/slsDetectorCalibration/moench03ReadData.C +++ b/slsDetectorCalibration/moench03ReadData.C @@ -27,7 +27,7 @@ using namespace std; #define NR 400 -#define MY_DEBUG 1 +//#define MY_DEBUG 1 #ifdef MY_DEBUG #include @@ -47,7 +47,7 @@ TH2F *readImage(ifstream &filebin, TH2F *h2=NULL, TH2F *hped=NULL) { h2=new TH2F("h2","",400,0,400,400,0,400); h2->SetStats(kFALSE); } - cout << "." << endl; + // cout << "." << endl; for (int ix=0; ix<400; ix++) { for (int iy=0; iy<400; iy++) { // cout << decoder->getDataSize() << " " << decoder->getValue(buff,ix,iy)<< endl; @@ -77,7 +77,7 @@ TH2F *readImage(char *fname, int iframe=0, TH2F *hped=NULL) { if (hh==NULL) break; hh=readImage(filebin, h2, hped ); if (hh) - cout << "="<< endl; + ;// cout << "="<< endl; else { delete h2; return NULL; @@ -114,7 +114,7 @@ TH2F *calcPedestal(char *fformat, int runmin, int runmax){ } } delete [] buff; - cout << "="<< endl; + //cout << "="<< endl; ii++; } if (filebin.is_open()) @@ -146,8 +146,6 @@ Loops over data file to find single photons, fills the tree (and writes it to fi \param nbins number of bins for spectrum hists \param hmin histo minimum for spectrum hists \param hmax histo maximum for spectrum hists - \param sign sign of the spectrum to find hits - \param hc readout correlation coefficient with previous pixel \param xmin minimum x coordinate \param xmax maximum x coordinate \param ymin minimum y coordinate @@ -156,8 +154,10 @@ Loops over data file to find single photons, fills the tree (and writes it to fi \returns pointer to histo stack with cluster spectra */ -THStack *moench03ReadData(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 *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int nbins=1500, int hmin=-500, int hmax=1000, int xmin=1, int xmax=NC-1, int ymin=1, int ymax=NR-1, int cmsub=0, int hitfinder=1) { + double hc=0; + int sign=1; + moench03CtbData *decoder=new moench03CtbData(); cout << "decoder allocated " << endl; @@ -173,7 +173,7 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int int iev=0; int nph=0; - singlePhotonDetector *filter=new singlePhotonDetector(decoder, 3, 5, sign, cmSub, 10, 100); + singlePhotonDetector *filter=new singlePhotonDetector(decoder, 3, 5, sign, cmSub, 100, 10); cout << "filter allocated " << endl; char *buff; @@ -270,11 +270,8 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int nph=0; while ((buff=decoder->readNextFrame(filebin))) { + filter->newFrame(); - if (hitfinder) { - filter->newFrame(); - - //calculate pedestals and common modes if (cmsub) { // cout << "cm" << endl; for (ix=xmin-1; ixgetEventType(buff, ix, iy,0); } } - } + // if (hitfinder) { + + // //calculate pedestals and common modes + // } // cout << "new frame " << endl; for (ix=xmin-1; ixgetEventType(buff, ix, iy, cmsub); - -#ifdef MY_DEBUG - if (hitfinder) { - // if (iev%10==0) - he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent); - } -#endif - + thisEvent=filter->getEventType(buff, ix, iy, cmsub); // if (nf>10) { h1->Fill(filter->getClusterTotal(1), iy+NR*ix); - if (hitfinder) { + +#ifdef MY_DEBUG + // if (iev%10==0) + he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent); +#endif + + if (hitfinder) { if (thisEvent==PHOTON_MAX ) { nph++; @@ -315,7 +313,10 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int } - } + } // else { + // filter->addToPedestal(decoder->getValue(buff,ix,iy, cmsub)); + + // } // } @@ -323,7 +324,7 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int ////////////////////////////////////////////////////////// #ifdef MY_DEBUG - cout << iev << " " << h1->GetEntries() << " " << h2->GetEntries() << endl; + // cout << iev << " " << h1->GetEntries() << " " << h2->GetEntries() << endl; // if (iev%10==0) { // myC->Modified(); // myC->Update(); @@ -338,10 +339,10 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int #endif nf++; - cout << "=" ; + // cout << "=" ; delete [] buff; } - cout << nph << endl; + // cout << nph << endl; if (filebin.is_open()) filebin.close(); else diff --git a/slsDetectorCalibration/readMoench03Data.C b/slsDetectorCalibration/readMoench03Data.C index 2bf22e111..8bbee83b3 100644 --- a/slsDetectorCalibration/readMoench03Data.C +++ b/slsDetectorCalibration/readMoench03Data.C @@ -12,31 +12,31 @@ void readMoench03Data(char *tit, int sign=1){ TFile *fout; THStack *hs; - sprintf(fname,"/scratch/roberto/photons.root"); + sprintf(fname,"/mnt/moenchnas/big_moench_xbox_20150223/Mo.root"); fout=new TFile(fname,"RECREATE"); - sprintf(fname,"/scratch/roberto/run_%%d.raw"); + sprintf(fname,"/mnt/moenchnas/big_moench_xbox_20150223/Mo_f0_%%d.raw"); - hs=moench03ReadData(fname,"photons",136,1135,1500,-500,2500,1,0.,1,399,1,399, 0,1); -// cout << "returned" << endl; -// hs->SetName(tit); -// hs->SetTitle(tit); -// cout << "name/title set" << endl; + hs=moench03ReadData(fname,"Mo",25133,25187,1500,-500,2500,1,399,1,399, 0,1); + cout << "returned" << endl; + hs->SetName(tit); + hs->SetTitle(tit); + cout << "name/title set" << endl; -// if (hs->GetHists()) { -// for (int i=0; i<3; i++) { -// if (hs->GetHists()->At(i)) { -// cout << i << " " ; -// (TH2F*)(hs->GetHists()->At(i))->Write(); -// } -// } -// cout << " histos written " << endl; -// } else -// cout << "no hists in stack " << endl; + if (hs->GetHists()) { + for (int i=0; i<3; i++) { + if (hs->GetHists()->At(i)) { + cout << i << " " ; + (TH2F*)(hs->GetHists()->At(i))->Write(); + } + } + cout << " histos written " << endl; + } else + cout << "no hists in stack " << endl; -// fout->Close(); + fout->Close(); diff --git a/slsDetectorCalibration/slsDetectorData.h b/slsDetectorCalibration/slsDetectorData.h index 8240a7484..b433960f3 100644 --- a/slsDetectorCalibration/slsDetectorData.h +++ b/slsDetectorCalibration/slsDetectorData.h @@ -19,6 +19,8 @@ class slsDetectorData { dataType **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) */ + int *xmap; + int *ymap; public: @@ -56,6 +58,16 @@ class slsDetectorData { dataROIMask[i][j]=1; } + + + xmap=new int[dataSize/sizeof(dataType)]; + ymap=new int[dataSize/sizeof(dataType)]; + + for (int i=0 ; i=0 && ip