Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 300 → Rev 301

/drs/DrsChannel.h
7,6 → 7,7
float adcgate[2];
float vcut[2];
int edge;
float offset;
} DrsChannel;
 
#endif
/drs/drs.C
1,5 → 1,7
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TFile.h"
#include "TGraph.h"
#include "TCanvas.h"
#include "TStyle.h"
19,53 → 21,61
ClassImp (drs)
 
 
TH1F *h1_chmax[NCH];
TH1F *h1_chmaxt[NCH];
TH1F *h1_chmin[NCH];
TH1F *h1_chmint[NCH];
TH1F *h1_letime[NCH];
TH1F *h1_cftime[NCH];
TH1F *h1_cftdif[NCH];
TH1F *h1_qdc[NCH];
TH2F *h2_dpo[NCH];
TH2F *h2_tdcadc[NCH];
TH2F *h2_ctdcadc[NCH];
TH2F *h2_ctalk;
TGraph *gr_wfm[NCH];
TLegend *leg;
TCanvas *c_wfm;
TFile *froot;
 
TFile *froot;
TH1F *h1_chmax[NCH];
TH1F *h1_chmaxt[NCH];
TH1F *h1_chmin[NCH];
TH1F *h1_chmint[NCH];
TH1F *h1_letime[NCH];
TH1F *h1_cftime[NCH];
TH1F *h1_cftdif[NCH];
TH1F *h1_qdc[NCH];
TH2F *h2_dpo[NCH];
TH2F *h2_tdcadc[NCH];
TH2F *h2_ctdcadc[NCH];
TH2F *h2_ctalk;
TH2F *h2_pos;
TH1F *h1_qsumx;
TH1F *h1_qsumy;
TGraph *gr_wfm[NCH];
TLegend *leg;
 
int drs::histoinit( int nch, DrsChannel* d, int trgch){
int drs::histoinit( int nch, DrsChannel* d, int trgch, double ymin, double ymax){
char histname[128];
leg = new TLegend(0.8, 0.8, 1, 1);
for (int i=0; i<nch; i++) {
c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700);
c_wfm->Divide(1,1);
c_wfm->cd(1);
const double maxt=1800;
leg = new TLegend(0.8, 0.8, 1, 1);
for (int i=0; i<nch; i++) {
sprintf(histname,"chmax_%02d",i);
h1_chmax[i]=new TH1F(histname,histname,1100,-0.88,0.88);
h1_chmax[i]=new TH1F(histname,histname,1500,ymin,ymax);
sprintf(histname,"chmaxt_%02d",i);
h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7);
h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt);
sprintf(histname,"chmin_%02d",i);
h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55);
h1_chmin[i]=new TH1F(histname,histname,1500,ymin,ymax);
sprintf(histname,"chmint_%02d",i);
h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7);
h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt);
sprintf(histname,"letime_%02d",i);
h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]);
sprintf(histname,"cftime_%02d",i);
h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]);
sprintf(histname,"cftdif_%02d",i);
h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]);
h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0]-40,d[i].twin[1]-d[trgch].twin[0]+20);
sprintf(histname,"qdc_%02d",i);
h1_qdc[i]=new TH1F(histname,histname,500,-0.5,4.5);
h1_qdc[i]=new TH1F(histname,histname,500,-4.5,4.5);
sprintf(histname,"dpo_%02d",i);
h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,200.7,3000,-0.9,0.9);
h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,maxt,1500,ymin,ymax);
sprintf(histname,"tdcadc_%02d",i);
h2_tdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]);
h2_tdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]);
sprintf(histname,"ctdcadc_%02d",i);
h2_ctdcadc[i]=new TH2F(histname,histname,250,-0.1,0.5,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]);
h2_ctdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]);
gr_wfm[i]=new TGraph(DWIDTH);
gr_wfm[i]->SetMinimum(-0.9);
gr_wfm[i]->SetMaximum(0.9);
gr_wfm[i]->SetMinimum(ymin);
gr_wfm[i]->SetMaximum(ymax);
gr_wfm[i]->SetLineColor(i+1);
gr_wfm[i]->SetMarkerColor(i+1);
sprintf(histname,"ch %d",i);
72,14 → 82,19
leg->AddEntry(gr_wfm[i], histname, "l");
if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP");
gr_wfm[i]->GetHistogram()->SetTitle("WaveForms");
gr_wfm[i]->GetHistogram()->SetDirectory(0);
}
 
leg->Draw();
h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5);
h2_pos=new TH2F("cpos","cpos",40,-1,1,40,-1,1);
h1_qsumx=new TH1F("qsumx","qsumx",100,-1,6);
h1_qsumy=new TH1F("qsumy","qsumy",100,-1,6);
return 0;
}
 
drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch, int first, int neve, int updfrq)
drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch,int first, int neve, int updfrq,double ymin, double ymax)
 
{
int debug=0;
int i,ich,iev;
122,19 → 137,13
 
gStyle->SetOptStat(1111111);
// gStyle->SetPalette(52);
 
char rootname[0xFF];
sprintf(rootname, "%s_x%d_y%d.root", FileName, 0,0);
TFile *froot = new TFile(rootname,"RECREATE");
histoinit(nch, d, trgch);
leg->Draw();
TCanvas *c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700);
c_wfm->Divide(1,1);
c_wfm->cd(1);
histoinit(nch, d, trgch, ymin,ymax);
char rootname[0xff];
sprintf(rootname, "%s_x%d_y%d.root", FileName, 0, 0);
froot = new TFile(rootname,"RECREATE");
 
fin=fopen(FileName,"rb");
if (fin==NULL) {
printf("Error opening file %s\n",FileName);
158,7 → 167,7
told=t0-1;
int posrec[9];
while(!feof(fin)) {
if (iev>=nev) break;
if (iev==nev) break;
stat=fread(recid,1,4,fin);
if (debug) {
if (recid[1]=='#') printf("%c%c%u\n",recid[0],recid[1],srecid[1]);
177,7 → 186,7
froot->Close();
sprintf(rootname, "%s_x%d_y%d.root", FileName, posrec[3], posrec[4]);
froot = new TFile(rootname,"RECREATE");
histoinit(nch,d, trgch);
histoinit(nch,d, trgch, ymin,ymax);
}
printf("Position len=%d x=%d y=%d ix=%d iy=%d\n", len, posrec[0], posrec[1], posrec[3], posrec[4]);
} else
244,6 → 253,13
//if (i==1) printf("ph=%f %f\n", pulseheight, letime[i]-cftime[trgch]);
}
double qsumx=qdc[0]+qdc[1];
double qsumy=qdc[2]+qdc[3];
double x0=(qsumx)?(qdc[0]-qdc[1])/qsumx:-2;
double x1=(qsumy)?(qdc[2]-qdc[3])/qsumy:-2;
h2_pos->Fill(x0,x1);
h1_qsumx->Fill(qsumx);
h1_qsumy->Fill(qsumy);
double ph0 = (d[0].edge)? chmax[0][0]: -chmin[0][0];
double ph1 = (d[1].edge)? chmax[1][0]: -chmin[1][0];
h2_ctalk->Fill(ph0,ph1);
253,7 → 269,7
if (ich>=nch) continue;
 
lwfm[ich]=0;
qdc[ich]=0;
qdc[ich]=d[ich].offset;
chmax[ich][0]=-1; chmax[ich][1]=-1;
chmin[ich][0]=1; chmin[ich][1]=-1;
letime[ich]=-1.; letime[ich]=-1.;
362,16 → 378,52
 
printf("number of events: %d\n",iev);
fclose(fin);
 
TString pdfname = Form("%s.pdf",FileName);
gStyle->SetOptStat(1111111);
TCanvas* c_dpo= new TCanvas("c_dpo","DPO",750,50,700,700);
c_dpo->Divide(2,2);
for (i=0; i<nch; i++) {c_dpo->cd(i+1); h2_dpo[i]->DrawCopy("colz");}
 
for (i=0; i<nch; i++) {c_dpo->cd(i+1)->SetLogz(1); h2_dpo[i]->DrawCopy("colz");}
 
 
TCanvas* c_cftdif= new TCanvas("c_cftdif","DPO",750,50,700,700);
c_cftdif->Divide(2,2);
for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();}
TCanvas* c_cftcorr= new TCanvas("c_cftcorr","pulseheight vs timing",750,50,700,700);
c_cftcorr->Divide(2,2);
for (i=0; i<nch; i++) {c_cftcorr->cd(i+1); h2_tdcadc[i]->DrawCopy("colz");}
TCanvas* c_adc= new TCanvas("c_adc","adc",750,50,700,700);
c_adc->Divide(2,2);
for (i=0; i<nch; i++) {c_adc->cd(i+1); h1_qdc[i]->DrawCopy();}
TCanvas* c_qsum= new TCanvas("c_qsum","qsum",750,50,700,700);
c_qsum->Divide(1,2);
c_qsum->cd(1); h1_qsumx->DrawCopy();
c_qsum->cd(2); h1_qsumy->DrawCopy();
gStyle->SetOptStat(0);
TCanvas* c_pos= new TCanvas("c_pos","position",750,50,700,700);
c_pos->cd();
h2_pos->DrawCopy("colz");
c_pos->Print(pdfname+"(","pdf");
c_wfm->Print(pdfname,"pdf");
c_adc->Print(pdfname,"pdf");
c_qsum->Print(pdfname,"pdf");
c_dpo->Print(pdfname,"pdf");
c_cftdif->Print(pdfname + ")","pdf");
froot->Write();
froot->Close();
 
for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();}
froot->Write();
froot->Close();
 
return;
}
 
389,6 → 441,7
float adcgate[4][2]={{105.,125.},{105.,125.},{110.,130.},{60.,80.}};
double vcut[4][2]={{-0.49,-0.07},{-1,1},{-1,1},{-1,1}};
int edge[4]={1,1,1,1};// 0 -- rising, 1 -- falling
float offset[4]={0.25,0.25,0.25,0.25};//
 
DrsChannel c[2];
 
404,8 → 457,8
c[0].vcut[1] = vcut[0][1];
 
c[0].edge = edge[0];
c[0].edge = offset[0];
 
 
c[1].cfrac = CFRAC;
c[1].threshold = threshold[1][0];
c[1].twin[0] = twin[1][0];
418,5 → 471,32
c[1].vcut[1] = vcut[1][1];
 
c[1].edge = edge[1];
drs * d = new drs(FileName, 2, c, trgch, nev, updfrq );
c[1].offset = offset[1];
drs * d = new drs(FileName, 2, c, trgch, nev, updfrq, -0.55,0.55 );
}
 
 
 
void sensl(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){
// nev = -1 all events
double threshold[4]={-0.005,-0.005,-0.005,-0.005}; // threshold for determination of timing
float twin[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980,1150.}}; // window for calculation of the timing
float adcgate[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980.,1150.}}; //integration window
double vcut[4][2]={{-1,1},{-1,1},{-1,1},{-1,1}}; // cut on the pulseheight for filling the timing histograms
int edge[4]={0,0,0,0};// 1 -- rising edge, 0 -- falling edge
float offset[4]={0.25,0.25,0.25,0.25};// qdc offset
DrsChannel c[NCH];
for (int k=0;k<NCH;k++){
c[k].cfrac = CFRAC;
c[k].threshold = threshold[k];
for (int j=0;j<2;j++){
c[k].twin[j] = twin[k][j];
c[k].adcgate[j] = adcgate[k][j];
c[k].vcut[j] = vcut[k][j];
c[k].edge = edge[k];
c[k].offset = offset[k];
}
}
drs * d = new drs(FileName, NCH, c, trgch, nev, updfrq , -0.1,0.12);
}