diff --git a/slsDetectorCalibration/moench03Ctb10GbT1Data.h b/slsDetectorCalibration/moench03Ctb10GbT1Data.h index af344b987..b2939bda5 100644 --- a/slsDetectorCalibration/moench03Ctb10GbT1Data.h +++ b/slsDetectorCalibration/moench03Ctb10GbT1Data.h @@ -28,10 +28,12 @@ class moench03Ctb10GbT1Data : public slsReceiverData { // moench03Ctb10GbData(int ns=5000): slsDetectorData(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { moench03Ctb10GbT1Data(int ns=5000): slsReceiverData(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 { } - + //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 { /* }; */ - 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 { 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 { 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); - }; }; diff --git a/slsDetectorCalibration/moench03CtbData.h b/slsDetectorCalibration/moench03CtbData.h index 99a7fe92e..66ae0cbda 100644 --- a/slsDetectorCalibration/moench03CtbData.h +++ b/slsDetectorCalibration/moench03CtbData.h @@ -4,7 +4,7 @@ -class moench03TCtbData : public slsDetectorData { +class moench03CtbData : public slsDetectorData { private: @@ -25,21 +25,24 @@ class moench03TCtbData : public slsDetectorData { */ - moench03TCtbData(int ns=5000): slsDetectorData(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { + moench03CtbData(int ns=5000): slsDetectorData(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 //#include #include -#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 *filter=new singlePhotonDetector(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; ixgetEventType(buff, ix, iy,0); - } - } + // if (cmsub) { + // // cout << "cm" << endl; + // for (ix=xmin-1; ixgetEventType(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; ixgetEventType(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; diff --git a/slsDetectorCalibration/moench03TCtbData.h b/slsDetectorCalibration/moench03TCtbData.h index 6895078e1..5edbdd247 100644 --- a/slsDetectorCalibration/moench03TCtbData.h +++ b/slsDetectorCalibration/moench03TCtbData.h @@ -4,7 +4,7 @@ -class moench03CtbData : public slsDetectorData { +class moench03TCtbData : public slsDetectorData { private: @@ -25,13 +25,9 @@ class moench03CtbData : public slsDetectorData { */ - moench03CtbData(int ns=5000): slsDetectorData(400, 400, ns*2*32, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { + moench03TCtbData(int ns=5000): slsDetectorData(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 { + 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 { } } + int adc4; for (int i=0; i { } + /* for (int i=0; i=0 && ix=0 && iy=0 && dataMap[iy][ix]