Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 207 → Rev 208

/drs/drs.C
18,12 → 18,73
 
ClassImp (drs)
 
drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch, int nev, int updfrq)
 
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;
 
TFile *froot;
 
int drs::histoinit( int nch, DrsChannel* d, int trgch){
char histname[128];
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);
sprintf(histname,"chmaxt_%02d",i);
h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7);
sprintf(histname,"chmin_%02d",i);
h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55);
sprintf(histname,"chmint_%02d",i);
h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7);
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]);
sprintf(histname,"qdc_%02d",i);
h1_qdc[i]=new TH1F(histname,histname,500,-0.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);
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]);
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]);
gr_wfm[i]=new TGraph(DWIDTH);
gr_wfm[i]->SetMinimum(-0.9);
gr_wfm[i]->SetMaximum(0.9);
gr_wfm[i]->SetLineColor(i+1);
gr_wfm[i]->SetMarkerColor(i+1);
sprintf(histname,"ch %d",i);
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");
}
 
h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5);
return 0;
}
 
drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch, int first, int neve, int updfrq)
{
int debug=0;
int i,ich,iev;
int stat;
char histname[128];
int nev = first + neve;
// char FileName[300]="./data/n2.dat";
FILE *fin;
 
62,64 → 123,18
gStyle->SetOptStat(1111111);
// gStyle->SetPalette(52);
 
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];
TFile *froot = new TFile(TString(FileName) + ".root","RECREATE");
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);
TLegend *leg = new TLegend(0.8, 0.8, 1, 1);
c_wfm->Divide(1,1);
c_wfm->cd(1);
 
for (i=0; i<nch; i++) {
sprintf(histname,"chmax_%02d",i);
h1_chmax[i]=new TH1F(histname,histname,1100,-0.88,0.88);
sprintf(histname,"chmaxt_%02d",i);
h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7);
sprintf(histname,"chmin_%02d",i);
h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55);
sprintf(histname,"chmint_%02d",i);
h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7);
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]);
sprintf(histname,"qdc_%02d",i);
h1_qdc[i]=new TH1F(histname,histname,500,-0.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);
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]);
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]);
gr_wfm[i]=new TGraph(DWIDTH);
gr_wfm[i]->SetMinimum(-0.9);
gr_wfm[i]->SetMaximum(0.9);
gr_wfm[i]->SetLineColor(i+1);
gr_wfm[i]->SetMarkerColor(i+1);
sprintf(histname,"ch %d",i);
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");
}
 
leg->Draw();
h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5);
fin=fopen(FileName,"rb");
if (fin==NULL) {
printf("Error opening file %s\n",FileName);
156,9 → 171,16
stat=fread(&len,1,4,fin);
if (len>0 && len<37) {
stat=fread(posrec,1,len,fin);
if (recid[3]=='R')
if (recid[3]=='R'){
if (iev>=first){
froot->Write();
froot->Close();
sprintf(rootname, "%s_x%d_y%d.root", FileName, posrec[3], posrec[4]);
froot = new TFile(rootname,"RECREATE");
histoinit(nch,d, trgch);
}
printf("Position len=%d x=%d y=%d ix=%d iy=%d\n", len, posrec[0], posrec[1], posrec[3], posrec[4]);
else
} else
printf("Position record buffer length %d\n", len);
} else {
printf("Wrong buffer length %d\n", len);
204,8 → 226,8
printf("Unknown header! %s\n", recid);
break;
}
if (iev<first) continue;
 
 
if (recid[0] == 'E') {
for ( i=0; i<nch; i++) {
if (!lwfm[i]) continue;
/drs/drs.h
2,9 → 2,11
#define _drs_
#include "DrsChannel.h"
class drs {
public:
drs(const char *FileName, int nch, DrsChannel* ch, int trgch=0, int nev=1000, int updfrq=20 );
drs(const char *FileName, int nch, DrsChannel* ch, int trgch=0, int first=0, int nev=1000, int updfrq=20 );
~drs(){};
int histoinit(int nch, DrsChannel* d, int trgch);
ClassDef ( drs, 1 ) //
};
 
/drs/drsgui.C
225,6 → 225,7
TGTextButton *fStart;
TGTextButton *fSelect;
TGTextEntry *fFile;
TGNumberEntry *fFirst;
TGNumberEntry *fNeve;
TGNumberEntry *fUpdFrq;
TGTextBuffer *fFileText;
276,10 → 277,11
 
 
int nev=fNeve->GetIntNumber();
int first=fFirst->GetIntNumber();
int updfrq=fUpdFrq->GetIntNumber();;
 
int trgch=fTrgch->GetSelected();
drs * d = new drs(fFileText->GetString(), nch, c, trgch, nev, updfrq );
drs * d = new drs(fFileText->GetString(), nch, c, trgch,first, nev, updfrq );
 
 
}
382,17 → 384,22
}
fTrgch->Resize(50, 20);
fTrgch->Select(0);
TGLabel *fLTrgch = new TGLabel(fStartFrame, "Trg Channel:");
TGLabel *fLTrgch = new TGLabel(fStartFrame, "Trg Chan:");
fNeve = new TGNumberEntry(fStartFrame, 5000, 5,999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative );
TGLabel *fLNeve = new TGLabel(fStartFrame, "Number of events:");
TGLabel *fLNeve = new TGLabel(fStartFrame, "Number of ev.:");
fFirst = new TGNumberEntry(fStartFrame, 0, 5,999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative );
TGLabel *fLFirst = new TGLabel(fStartFrame, "First ev.:");
 
fUpdFrq = new TGNumberEntry(fStartFrame, 50, 5,999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative );
TGLabel *fLUpdFrq = new TGLabel(fStartFrame, "Update Frequency:");
TGLabel *fLUpdFrq = new TGLabel(fStartFrame, "Update Freq.:");
 
fStartFrame->AddFrame(fLTrgch, fBly);
fStartFrame->AddFrame(fTrgch, fBly);
fStartFrame->AddFrame(fLNeve, fBly);
fStartFrame->AddFrame(fNeve, fBly);
fStartFrame->AddFrame(fLFirst, fBly);
fStartFrame->AddFrame(fFirst, fBly);
fStartFrame->AddFrame(fLUpdFrq, fBly);
fStartFrame->AddFrame(fUpdFrq, fBly);