mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 17:18:00 +02:00
more debugging with moench
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@20 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
@ -26,7 +26,7 @@ using namespace std;
|
||||
#define NR 160
|
||||
|
||||
|
||||
//#define MY_DEBUG 1
|
||||
#define MY_DEBUG 1
|
||||
#ifdef MY_DEBUG
|
||||
#include <TCanvas.h>
|
||||
#endif
|
||||
@ -53,7 +53,7 @@ Loops over data file to find single photons, fills the tree (and writes it to fi
|
||||
*/
|
||||
|
||||
|
||||
THStack *moenchReadData(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=0, int xmax=NC, int ymin=0, int ymax=NR, int cmsub=0) {
|
||||
THStack *moenchReadData(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=0, int xmax=NC, int ymin=0, int ymax=NR, int cmsub=0, int hitfinder=1) {
|
||||
|
||||
moench02ModuleData *decoder=new moench02ModuleData(hc);
|
||||
moenchCommonMode *cmSub=NULL;
|
||||
@ -88,15 +88,16 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
TH2F *h1=new TH2F("h1",tit,nbins,hmin-0.5,hmax-0.5,NC*NR,-0.5,NC*NR-0.5);
|
||||
hs->Add(h1);
|
||||
|
||||
|
||||
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);
|
||||
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 (hitfinder) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -107,27 +108,37 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
|
||||
|
||||
Int_t iFrame;
|
||||
TTree *tall=filter->initEventTree(tit, &iFrame);
|
||||
TTree *tall;
|
||||
if (hitfinder)
|
||||
tall=filter->initEventTree(tit, &iFrame);
|
||||
|
||||
|
||||
double tot, tl, tr, bl, br, v;
|
||||
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
TCanvas *myC=new TCanvas();
|
||||
TH2F *he=new TH2F("he","Event Mask",xmax-xmin, xmin, xmax, ymax-ymin, ymin, ymax);
|
||||
he->SetStats(kFALSE);
|
||||
he->Draw("colz");
|
||||
TCanvas *cH1=new TCanvas();
|
||||
cH1->SetLogz();
|
||||
h1->Draw("colz");
|
||||
TCanvas *cH2=new TCanvas();
|
||||
cH2->SetLogz();
|
||||
h2->Draw("colz");
|
||||
TCanvas *cH3=new TCanvas();
|
||||
cH3->SetLogz();
|
||||
h3->Draw("colz");
|
||||
|
||||
TCanvas *myC;
|
||||
TH2F *he;
|
||||
TCanvas *cH1;
|
||||
TCanvas *cH2;
|
||||
TCanvas *cH3;
|
||||
|
||||
if (hitfinder) {
|
||||
myC=new TCanvas();
|
||||
he=new TH2F("he","Event Mask",xmax-xmin, xmin, xmax, ymax-ymin, ymin, ymax);
|
||||
he->SetStats(kFALSE);
|
||||
he->Draw("colz");
|
||||
cH1=new TCanvas();
|
||||
cH1->SetLogz();
|
||||
h1->Draw("colz");
|
||||
cH2=new TCanvas();
|
||||
cH2->SetLogz();
|
||||
h2->Draw("colz");
|
||||
cH3=new TCanvas();
|
||||
cH3->SetLogz();
|
||||
h3->Draw("colz");
|
||||
}
|
||||
#endif
|
||||
filter->newDataSet();
|
||||
|
||||
@ -160,89 +171,92 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
thisEvent=filter->getEventType(buff, ix, iy, cmsub);
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
if (iev%1000==0)
|
||||
he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent);
|
||||
if (hitfinder) {
|
||||
if (iev%1000==0)
|
||||
he->SetBinContent(ix+1-xmin, iy+1-ymin, (int)thisEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nf>1000) {
|
||||
tot=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
h1->Fill(filter->getClusterElement(0,0), iy+NR*ix);
|
||||
|
||||
// if (nf%1000==0 && ix==20 && iy==20) cout << " val="<< decoder->getClusterElement(0,0)<< endl;
|
||||
if (hitfinder) {
|
||||
tot=0;
|
||||
tl=0;
|
||||
tr=0;
|
||||
bl=0;
|
||||
br=0;
|
||||
|
||||
// if (nf%1000==0 && ix==20 && iy==20) cout << " val="<< decoder->getClusterElement(0,0)<< endl;
|
||||
|
||||
if (thisEvent==PHOTON_MAX ) {
|
||||
nph++;
|
||||
for (ir=-1; ir<2; ir++) {
|
||||
for (ic=-1; ic<2; ic++) {
|
||||
v=filter->getClusterElement(ic,ir);
|
||||
// data[ic+1][ir+1]=v;
|
||||
if (thisEvent==PHOTON_MAX ) {
|
||||
nph++;
|
||||
for (ir=-1; ir<2; ir++) {
|
||||
for (ic=-1; ic<2; ic++) {
|
||||
v=filter->getClusterElement(ic,ir);
|
||||
// data[ic+1][ir+1]=v;
|
||||
|
||||
|
||||
|
||||
tot+=v;
|
||||
if (ir<1) {
|
||||
|
||||
if (ic<1) {
|
||||
bl+=v;
|
||||
|
||||
tot+=v;
|
||||
if (ir<1) {
|
||||
|
||||
if (ic<1) {
|
||||
bl+=v;
|
||||
|
||||
}
|
||||
if (ic>-1) {
|
||||
br+=v;
|
||||
}
|
||||
}
|
||||
|
||||
if (ir>-1) {
|
||||
if (ic<1) {
|
||||
tl+=v;
|
||||
}
|
||||
if (ic>-1) {
|
||||
tr+=v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (ic>-1) {
|
||||
br+=v;
|
||||
}
|
||||
if (bl>br && bl>tl && bl>tr) {
|
||||
h2->Fill(bl, iy+NR*ix);
|
||||
if (bl>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/bl,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/bl,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/bl,iy+NR*(ix-1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/bl,(iy-1)+NR*ix);
|
||||
}
|
||||
} else if (br>bl && br>tl && br>tr) {
|
||||
h2->Fill(br, iy+NR*ix);
|
||||
if (br>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/br,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/br,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/br,iy+NR*(ix+1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/br,iy-1+NR*ix);
|
||||
}
|
||||
} else if (tl>br && tl>bl && tl>tr) {
|
||||
h2->Fill(tl, iy+NR*ix);
|
||||
if (tl>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tl,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/tl,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tl,iy+NR*(ix-1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/tl,iy+1+NR*ix);
|
||||
}
|
||||
} else if (tr>bl && tr>tl && tr>br) {
|
||||
h2->Fill(tr, iy+NR*ix);
|
||||
if (tr>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tr,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/tr,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tr,iy+NR*(ix+1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/tr,iy+1+NR*ix);
|
||||
}
|
||||
|
||||
if (ir>-1) {
|
||||
if (ic<1) {
|
||||
tl+=v;
|
||||
}
|
||||
if (ic>-1) {
|
||||
tr+=v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bl>br && bl>tl && bl>tr) {
|
||||
h2->Fill(bl, iy+NR*ix);
|
||||
if (bl>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/bl,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/bl,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/bl,iy+NR*(ix-1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/bl,(iy-1)+NR*ix);
|
||||
|
||||
}
|
||||
} else if (br>bl && br>tl && br>tr) {
|
||||
h2->Fill(br, iy+NR*ix);
|
||||
if (br>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/br,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/br,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/br,iy+NR*(ix+1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/br,iy-1+NR*ix);
|
||||
}
|
||||
} else if (tl>br && tl>bl && tl>tr) {
|
||||
h2->Fill(tl, iy+NR*ix);
|
||||
if (tl>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tl,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/tl,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tl,iy+NR*(ix-1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/tl,iy+1+NR*ix);
|
||||
}
|
||||
} else if (tr>bl && tr>tl && tr>br) {
|
||||
h2->Fill(tr, iy+NR*ix);
|
||||
if (tr>0) {
|
||||
hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tr,iy+NR*ix);
|
||||
hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/tr,iy+NR*ix);
|
||||
hetaX->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(0,1))/tr,iy+NR*(ix+1));
|
||||
hetaY->Fill(1.-(filter->getClusterElement(0,0)+filter->getClusterElement(1,0))/tr,iy+1+NR*ix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
h3->Fill(tot, iy+NR*ix);
|
||||
iFrame=decoder->getFrameNumber(buff);
|
||||
@ -250,45 +264,47 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
tall->Fill();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
if (iev%1000==0) {
|
||||
myC->Modified();
|
||||
myC->Update();
|
||||
cH1->Modified();
|
||||
cH1->Update();
|
||||
cH2->Modified();
|
||||
cH2->Update();
|
||||
cH3->Modified();
|
||||
cH3->Update();
|
||||
}
|
||||
iev++;
|
||||
#endif
|
||||
|
||||
cout << "=" ;
|
||||
if (iev%1000==0) {
|
||||
myC->Modified();
|
||||
myC->Update();
|
||||
cH1->Modified();
|
||||
cH1->Update();
|
||||
cH2->Modified();
|
||||
cH2->Update();
|
||||
cH3->Modified();
|
||||
cH3->Update();
|
||||
}
|
||||
iev++;
|
||||
#endif
|
||||
nf++;
|
||||
|
||||
cout << "=" ;
|
||||
delete [] buff;
|
||||
}
|
||||
cout << nph << endl;
|
||||
if (filebin.is_open())
|
||||
filebin.close();
|
||||
filebin.close();
|
||||
else
|
||||
cout << "could not open file " << fname << endl;
|
||||
}
|
||||
tall->Write(tall->GetName(),TObject::kOverwrite);
|
||||
|
||||
}
|
||||
if (hitfinder)
|
||||
tall->Write(tall->GetName(),TObject::kOverwrite);
|
||||
|
||||
|
||||
|
||||
delete decoder;
|
||||
cout << "Read " << nf << " frames" << endl;
|
||||
return hs;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user