changes from pcmoench01

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@46 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
l_msdetect 2014-03-19 17:02:17 +00:00
parent 98c0bd163e
commit fb40e2236e
9 changed files with 192 additions and 23 deletions

View File

@ -12,7 +12,7 @@
fout=new TFile("/scratch/outfile.root","RECREATE");
hs2N=moenchReadData("/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_cds_g4_f00000%%04d000_0.raw",0,20,1500,-500,2500,1,0.,1,159,1,159, 0,1);
hs2N=moenchReadData("/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_12us_120V_cds_g4_f00000%04d000_0.raw","dum",0,20,1500,-500,2500,1,0.,1,159,1,159, 0,1);
hs2N->SetName("cds_g4");
hs2N->SetTitle("cds_g4");
(TH2F*)(hs2N->GetHists()->At(0))->Write();

View File

@ -1,11 +1,19 @@
{
void gMap(char *tit, float g=1) {
//.L energyCalibration.cpp+
//.L gainMap.C+
TFile fin("/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_cds_g4.root");
char fname[1000];
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s.root",tit);
TFile fin(fname);
TH2F *h2=fin.Get("h2");
TH2F *gMap=gainMap(h2,4);
TH2F *gMap=(TH2F*)gainMap(h2,g);
gMap->Draw("colz");
sprintf(fname,"/data/moench_xbox_20140113/gain_map_%s.root",tit);
TFile fout(fname,"RECREATE");
gMap->Write();
fout.Close();
}

View File

@ -137,7 +137,7 @@ TH2F *gainMap(TH2F *h2, float g) {
}
TH2F *noiseMap(TH2F *h2) {
TH2F *noiseMap(TH2F *h2, TH2F *gMap=NULL) {
// int npx, npy;
int npx=160, npy=160;
// det->getDetectorSize(npx, npy);
@ -150,8 +150,8 @@ TH2F *noiseMap(TH2F *h2) {
for (int ix=0; ix<npx; ix++) {
for (int iy=0; iy<npy; iy++) {
cout << ix << " " << iy << " " << ibin << endl;
ibin=ix*npy+iy;
px=h2->ProjectionX("px",ibin+1,ibin+1);
ibin=h2->GetYaxis()->FindBin(ix*npy+iy);
px=h2->ProjectionX("px",ibin,ibin);
px->Fit("gaus", FOPT);
if (px->GetFunction("gaus")) {
nMap->SetBinContent(ix+1,iy+1,px->GetFunction("gaus")->GetParameter(2));
@ -159,6 +159,10 @@ TH2F *noiseMap(TH2F *h2) {
// delete px;
}
}
if (gMap) {
nMap->Divide(gMap);
nMap->Scale(1000./3.6);
}
return nMap;
}
@ -167,7 +171,7 @@ TH2F *noiseMap(TH2F *h2) {
THStack *noiseHistos(char *tit) {
char fname[10000];
sprintf(fname,"/data/moench_xbox_20140116/noise_map_%s.root",tit);
sprintf(fname,"/data/moench_xbox_201401_trees/noise_map_%s.root",tit);
TFile *fn=new TFile(fname);
TH2F *nmap=(TH2F*)fn->Get("nmap");
@ -177,7 +181,7 @@ THStack *noiseHistos(char *tit) {
return NULL;
}
sprintf(fname,"/data/moench_xbox_20140113/gain_map_%s.root",tit);
sprintf(fname,"/data/moench_xbox_201401_trees/gain_map_%s.root",tit);
TFile *fg=new TFile(fname);
TH2F *gmap=(TH2F*)fg->Get("gmap");
@ -226,3 +230,44 @@ THStack *noiseHistos(char *tit) {
}
THStack *noiseHistos(TH2F *nmap) {
char tit[1000];
strcpy(tit,nmap->GetTitle());
THStack *hs=new THStack(tit,tit);
hs->SetTitle(tit);
TH1F *h;
char hname[100];
cout << tit << endl;
for (int is=0; is<4; is++) {
sprintf(hname,"h%ds",is+1);
h=new TH1F(hname,tit,500,0,500);
hs->Add(h);
// cout << hs->GetHists()->GetEntries() << endl;
for (int ix=40*is+2; ix<40*(is+1)-2; ix++) {
for (int iy=2; iy<158; iy++) {
if (ix<100 || ix>120)
h->Fill(nmap->GetBinContent(ix+1,iy+1));
}
}
cout << is+1 << "SC: " << "" << h->GetMean() << "+-" << h->GetRMS();
h->Fit("gaus","0Q");
h->SetLineColor(is+1);
if (h->GetFunction("gaus")) {
h->GetFunction("gaus")->SetLineColor(is+1);
cout << " or " << h->GetFunction("gaus")->GetParameter(1) << "+-" << h->GetFunction("gaus")->GetParError(1);
}
cout << endl;
}
// cout << hs->GetHists()->GetEntries() << endl;
return hs;
}

View File

@ -129,6 +129,45 @@ class moench02ModuleData : public slsReceiverData<uint16_t> {
};
class moench02OversampledData : public moench02ModuleData {
public:
moench02OversampledData(int nos, int off=0): moench02ModuleData(), nSamples(nos), offset(off){};
/**
returns the pixel value as double correcting for the output buffer crosstalk
\param data pointer to the memory
\param ix coordinate in the x direction
\param iy coordinate in the y direction
\returns channel value as double
*/
double getValue(char *data, int ix, int iy=0) {
double v=0, is=0;
int ix1, iy1, isc=ix/40, ip=ix%40, ip1=iy*nSamples*40+ix;
if (iy*nSamples<160) {
for (int i=offset; i<nSamples; i++) {
ip1=iy*nSamples*40+ip*nSamples+i-1;
iy1=ip1/40;
ix1=ip1%40+isc*40;
if (ix1>=0 && iy1>=0 && ix1<160 && iy1<160) {
v+=moench02ModuleData::getValue(data,ix1,iy1);
is++;
}
}
if (is>0)
v/=is;
}
return v;
};
private:
int nSamples;
int offset;
};
#endif

View File

@ -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
@ -102,14 +102,16 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
ifstream filebin;
int iev;
int ix=20, iy=20, ir, ic;
Int_t iFrame;
TTree *tall;
cout << "init tree " << tit << endl;
if (hitfinder)
tall=filter->initEventTree(tit, &iFrame);
cout << "done" << endl;

View File

@ -50,3 +50,22 @@ void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runo
//to compile: g++ -DMYROOT -DMYROOT1 -g `root-config --cflags --glibs` -o moenchReadDataMT moenchReadDataMT.C
int main(int argc, char **argv){
if(argc != 8){
cout << "Usage: " << argv[0] << " fformat tit tdir runmin runoffset nThreads treeIndexStart" << endl;
exit(-1);
}
char *fformat = argv[1];
char *tit = argv[2];
char *tdir = argv[3];
int runmin = atoi(argv[4]);
int runoffset = atoi(argv[5]);
int nThreads = atoi(argv[6]);
int treeIndexStart = atoi(argv[7]);
moenchReadDataMT(fformat, tit, tdir,runmin,runoffset,nThreads,treeIndexStart);
}

View File

@ -1,4 +1,5 @@
#include "moenchReadData.C"
#include "moenchReadOversampledData.C"
@ -13,12 +14,12 @@ void raedNoiseData(char *tit, int sign=1){
TFile *fout;
THStack *hs2N;
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s_0.root",tit);
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s.root",tit);
fout=new TFile(fname,"RECREATE");
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s_f00000%%04d000_0.raw",tit);
hs2N=moenchReadData(fname,0,3000,1500,-500,2500,1,0.,1,159,1,159, 0,1);
hs2N=moenchReadData(fname,tit,0,3000,1500,-500,2500,sign,0.,1,159,1,159, 0,1);
hs2N->SetName(tit);
hs2N->SetTitle(tit);
(TH2F*)(hs2N->GetHists()->At(0))->Write();
@ -36,6 +37,59 @@ void raedNoiseData(char *tit, int sign=1){
}
void raedOsNoiseData(){
THStack *hs[10];
char fname[1000];
char f[1000];
TFile *fout;
strcpy(fname,"/data/moench_xbox_201401_trees/noise_cds_g1_os10_2ndsample.root");
fout=new TFile(fname,"RECREATE");
for (int ir=0; ir<10; ir++) {
sprintf(fname,"/data/moench_xbox_201401/moench_xbox_20140116/noise_os10_16rows_f00000%%04d000_%d.raw",ir);
hs[ir]=moenchReadOversampledData(fname,"cds_g1_os10",0,1000,1000,-500,500,1,10,0,160,0,16,0);
}
TH2F *h;
int ii=0, ii1=0;
h=(TH2F*)(hs[0]->GetHists()->At(0));
TH2F *hn=(TH2F*)h->Clone();
for (int ir=1; ir<10; ir++) {
h=(TH2F*)(hs[ir]->GetHists()->At(0));
for (int iy=0; iy<16; iy++)
for (int ix=0; ix<160; ix++)
for (int ib=0; ib<hn->GetNbinsX(); ib++) {
ii=h->GetYaxis()->FindBin(iy+ix*160);
ii1= hn->GetYaxis()->FindBin(iy+ir*16+ix*160);
hn->SetBinContent(ib+1,ii1,h->GetBinContent(ib+1,ii));
}
}
hn->Write();
// (TH2F*)(hs2N->GetHists()->At(1))->Write();
// (TH2F*)(hs2N->GetHists()->At(2))->Write();
// (TH2F*)(hs2N->GetHists()->At(3))->Write();
// (TH2F*)(hs2N->GetHists()->At(4))->Write();
fout->Close();
}
void raedNoiseDataN(char *tit, int sign=1){
@ -74,7 +128,7 @@ void g4() {
raedNoiseData("cds_g4_low_gain");
raedNoiseData("cds_g4_sto1_only");
raedNoiseData("cds_g4_no sto");
raedNoiseData("cds_g4_no_sto");
@ -84,7 +138,7 @@ void no_cds() {
raedNoiseData("cds_disable_low_gain",-1);
raedNoiseData("cds_disable_sto1_only",-1);
raedNoiseData("cds_disable_no sto",-1);
raedNoiseData("cds_disable_no_sto",-1);

View File

@ -335,20 +335,22 @@ class singlePhotonDetector {
\returns returns pointer to the TTree
*/
TTree *initEventTree(char *tname, int *iFrame=NULL) {
cout << tname << endl;
TTree* tall=new TTree(tname,tname);
cout << "tree instantiated" << endl;
if (iFrame)
tall->Branch("iFrame",iFrame,"iframe/I");
else
tall->Branch("iFrame",&(cluster->iframe),"iframe/I");
cout << "iframe" << endl;
char tit[100];
tall->Branch("x",&(cluster->x),"x/I");
tall->Branch("y",&(cluster->y),"y/I");
char tit[100];
sprintf(tit,"data[%d]/D",clusterSize*clusterSizeY);
tall->Branch("data",cluster->data,tit);
// tall->Branch("pedestal",&(cluster->ped),"pedestal/D");
// tall->Branch("rms",&(cluster->rms),"rms/D");
tall->Branch("pedestal",&(cluster->ped),"pedestal/D");
tall->Branch("rms",&(cluster->rms),"rms/D");
cout << "Cluster" << endl;
return tall;
};
#else

View File

@ -203,7 +203,7 @@ class slsDetectorData {
virtual int getFrameNumber(char *buff)=0;
/**
/*
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset