T1 data structure fixed

This commit is contained in:
bergamaschi 2017-09-01 10:08:07 +02:00
parent 5dbfbdb82b
commit 1510fa71d3
5 changed files with 141 additions and 79 deletions

View File

@ -28,10 +28,12 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
// moench03Ctb10GbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
moench03Ctb10GbT1Data(int ns=5000): slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={200,225,250,275,300,325,350,375,\
0,25,50,75,100,125,150,175,\
175,150,125,100,75,50,25,0,\
375,350,325,300,275,250,225,200};
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
@ -94,10 +96,10 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
}
//cout << dataMap[0][0] << endl;
iframe=0;
// cout << "data struct created" << endl;
cout << "data struct created" << endl;
};
@ -174,24 +176,38 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
/* }; */
virtual char *readNextFrame(ifstream &filebin, int& fnum) {
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[packetSize*nPackets];
char *retval=0;
int np=0, nd;
fnum = -1;
int nd;
int fnum = -1;
np=0;
int pn;
char aa[8224];
char *packet=(char *)aa;
// cout << packetSize*nPackets << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
while(filebin.read((char*)packet, 8208) && np<nPackets){
while(filebin.read((char*)packet, 8208) ){
pn=getPacketNumber(packet);
if (pn==1 && fnum<0)
if (fnum<0)
fnum= getFrameNumber(packet);
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
@ -202,12 +218,22 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
delete [] data;
return NULL;
} else
filebin.seekg(-8208,ios_base::cur);
return data;
}
if (pn>nPackets) {
cout << "Bad packet number " << pn << endl;
}
memcpy(data+(pn-1)*packetSize, packet, packetSize);
np++;
if (np==nPackets)
break;
if (pn==nPackets)
break;
}
}
@ -218,14 +244,13 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
return NULL;
}
ff=fnum;
return data;
};
int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
virtual char *readNextFrame(ifstream &filebin) {
int fnum;
return readNextFrame(filebin, fnum);
};
};

View File

@ -4,7 +4,7 @@
class moench03TCtbData : public slsDetectorData<uint16_t> {
class moench03CtbData : public slsDetectorData<uint16_t> {
private:
@ -25,21 +25,24 @@ class moench03TCtbData : public slsDetectorData<uint16_t> {
*/
moench03TCtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
moench03CtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={200,225,250,275,300,325,350,375,\
0,25,50,75,100,125,150,175,\
175,150,125,100,75,50,25,0,\
375,350,325,300,275,250,225,200};
int row, col;
int isample;
int iadc;
int ix, iy;
int adc_nr[32]={200,225,250,275,300,325,350,375,\
0,25,50,75,100,125,150,175,\
175,150,125,100,75,50,25,0,\
375,350,325,300,275,250,225,200};
/* int adc_nr[32]={300,325,350,375,300,325,350,375, \ */
/* 200,225,250,275,200,225,250,275,\ */
/* 100,125,150,175,100,125,150,175,\ */
/* 0,25,50,75,0,25,50,75}; */
for (iadc=0; iadc<nadc; iadc++) {

View File

@ -15,7 +15,7 @@
//#include <list>
//#include <queue>
#include <fstream>
#include "moench03Ctb10GbData.h"
#include "moench03Ctb10GbT1Data.h"
#include "moench03CommonMode.h"
#define MYROOT1
#include "singlePhotonDetector.h"
@ -37,7 +37,7 @@ using namespace std;
TH2F *readImage(ifstream &filebin, TH2F *h2=NULL, TH2F *hped=NULL) {
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
char *buff=decoder->readNextFrame(filebin);
@ -96,7 +96,7 @@ TH2F *readImage(char *fname, int iframe=0, TH2F *hped=NULL) {
TH2F *calcPedestal(char *fformat, int runmin, int runmax){
ifstream filebin;
char fname[10000];
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
singlePhotonDetector<uint16_t> *filter=new singlePhotonDetector<uint16_t>(decoder, 3, 5, 1, NULL);
char *buff;
int ix,iy;
@ -142,7 +142,7 @@ TH2F *calcPedestal(char *fformat, int runmin, int runmax){
TH1D *calcSpectrum(char *fformat, int runmin, int runmax, TH2F *hped=NULL){
ifstream filebin;
char fname[10000];
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
TH1D *hspectrum=new TH1D("hsp","hsp",2500,-500,10000);
char *buff;
int ix,iy;
@ -180,7 +180,7 @@ TH1D *calcSpectrum(char *fformat, int runmin, int runmax, TH2F *hped=NULL){
TH2F *drawImage(char *fformat, int runmin, int runmax, TH2F *hped=NULL){
ifstream filebin;
char fname[10000];
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
TH2F *hspectrum=new TH2F("hsp","hsp",400,0,400,400,0,400);
char *buff;
int ix,iy;
@ -243,7 +243,7 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
double hc=0;
int sign=1;
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
cout << "decoder allocated " << endl;
moench03CommonMode *cmSub=NULL;
@ -278,30 +278,30 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
cout << "hstack allocated " << endl;
TH2F *h1=new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
hs->Add(h1);
cout << "h1 allocated " << endl;
TH2F *h1=NULL;//new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
// hs->Add(h1);
// cout << "h1 allocated " << endl;
TH2F *h2;
TH2F *h3;
if (hitfinder) {
h2=new TH2F("h2",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
cout << "h2 allocated " << endl;
h3=new TH2F("h3",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
cout << "h3 allocated " << endl;
// hetaX=new TH2F("hetaX",tit,nbins,-1,2,NC*NR,-0.5,NC*NR-0.5);
// hetaY=new TH2F("hetaY",tit,nbins,-1,2,NC*NR,-0.5,NC*NR-0.5);
hs->Add(h2);
hs->Add(h3);
// hs->Add(hetaX);
// hs->Add(hetaY);
}
if (hs->GetHists()) {
for (int i=0; i<3; i++)
if (hs->GetHists()->At(1)) cout << i << " " ;
cout << " histos allocated " << endl;
} else
cout << "no hists in stack " << endl;
TH2F *h2=NULL;
TH2F *h3=NULL;
// if (hitfinder) {
// h2=new TH2F("h2",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
// cout << "h2 allocated " << endl;
// h3=new TH2F("h3",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
// cout << "h3 allocated " << endl;
// // hetaX=new TH2F("hetaX",tit,nbins,-1,2,NC*NR,-0.5,NC*NR-0.5);
// // hetaY=new TH2F("hetaY",tit,nbins,-1,2,NC*NR,-0.5,NC*NR-0.5);
// hs->Add(h2);
// hs->Add(h3);
// // hs->Add(hetaX);
// // hs->Add(hetaY);
// }
// if (hs->GetHists()) {
// for (int i=0; i<3; i++)
// if (hs->GetHists()->At(1)) cout << i << " " ;
// cout << " histos allocated " << endl;
// } else
// cout << "no hists in stack " << endl;
ifstream filebin;
@ -310,7 +310,8 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
int ix=20, iy=20, ir, ic;
Int_t iFrame;
Int_t iFrame=-1;
Int_t np=-1;
TTree *tall;
if (hitfinder)
tall=filter->initEventTree(tit, &iFrame);
@ -353,17 +354,21 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
cout << "file name " << fname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
nph=0;
while ((buff=decoder->readNextFrame(filebin))) {
if (filebin.is_open())
;
else
cout << "Could not open file " << fname<< endl;
while ((buff=decoder->readNextFrame(filebin, iFrame))) {
//cout << (void*)buff << endl;
filter->newFrame();
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);
}
}
// 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);
// }
// }
// if (hitfinder) {
// //calculate pedestals and common modes
@ -373,10 +378,10 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
for (ix=xmin-1; ix<xmax+1; ix++)
for (iy=ymin-1; iy<ymax+1; iy++) {
// cout << ix << " " << iy << endl;
// cout << buff << " " << iFrame << " " << ix << " " << iy << endl;
thisEvent=filter->getEventType(buff, ix, iy, cmsub);
// if (nf>10) {
h1->Fill(filter->getClusterTotal(1), iy+NR*ix);
// h1->Fill(filter->getClusterTotal(1), iy+NR*ix);
#ifdef MY_DEBUG
// if (iev%10==0)
@ -388,9 +393,9 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
if (thisEvent==PHOTON_MAX ) {
nph++;
h2->Fill(filter->getClusterTotal(2), iy+NR*ix);
h3->Fill(filter->getClusterTotal(3), iy+NR*ix);
iFrame=decoder->getFrameNumber(buff);
// h2->Fill(filter->getClusterTotal(2), iy+NR*ix);
// h3->Fill(filter->getClusterTotal(3), iy+NR*ix);
// iFrame=decoder->getFrameNumber(buff);
tall->Fill();
@ -403,7 +408,8 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
// }
iFrame=-1;
np=-1;
// }
}
//////////////////////////////////////////////////////////
@ -457,7 +463,7 @@ THStack *moench03ReadData(char *fformat, char *tit, int runmin, int runmax, int
TGraph* checkFrameNumber(char *fformat, int runmin, int runmax, int ix, int iy){
ifstream filebin;
char fname[10000];
moench03Ctb10GbData *decoder=new moench03Ctb10GbData();
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
char *buff;
int ii=0;

View File

@ -4,7 +4,7 @@
class moench03CtbData : public slsDetectorData<uint16_t> {
class moench03TCtbData : public slsDetectorData<uint16_t> {
private:
@ -25,13 +25,9 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
*/
moench03CtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
moench03TCtbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
int row, col;
int isample;
@ -40,6 +36,17 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
int adc_nr[32]={300,325,350,375,300,325,350,375, \
200,225,250,275,200,225,250,275,\
100,125,150,175,100,125,150,175,\
0,25,50,75,0,25,50,75};
/* int adc_nr[32]={200,225,250,275,300,325,350,375,\ */
/* 0,25,50,75,100,125,150,175,\ */
/* 175,150,125,100,75,50,25,0,\ */
/* 375,350,325,300,275,250,225,200}; */
for (iadc=0; iadc<nadc; iadc++) {
@ -56,12 +63,15 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
}
}
int adc4;
for (int i=0; i<nx*ny; i++) {
isample=i/nadc;
iadc=i%nadc;
ix=isample%sc_width;
iy=isample/sc_width;
if (iadc<(nadc/2)) {
adc4 = (int)iadc/4;
// if (iadc<(nadc/2)) {
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
@ -72,6 +82,22 @@ class moench03CtbData : public slsDetectorData<uint16_t> {
}
/* for (int i=0; i<nx*ny; i++) { */
/* isample=i/nadc; */
/* iadc=i%nadc; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (iadc<(nadc/2)) { */
/* xmap[i]=adc_nr[iadc]+ix; */
/* ymap[i]=ny/2-1-iy; */
/* } else { */
/* xmap[i]=adc_nr[iadc]+ix; */
/* ymap[i]=ny/2+iy; */
/* } */
/* } */

View File

@ -220,6 +220,8 @@ class slsDetectorData {
virtual dataType getChannel(char *data, int ix, int iy=0) {
dataType m=0, d=0;
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
// cout << ix << " " << iy << " " ;
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
m=dataMask[iy][ix];
d=*((dataType*)(data+dataMap[iy][ix]));
}