Rev 206 | Rev 301 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 206 | Rev 208 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | #define NCH 4 |
16 | #define NCH 4 |
17 | #include "drs.h" |
17 | #include "drs.h" |
18 | 18 | ||
19 | ClassImp (drs) |
19 | ClassImp (drs) |
20 | 20 | ||
- | 21 | ||
- | 22 | TH1F *h1_chmax[NCH]; |
|
- | 23 | TH1F *h1_chmaxt[NCH]; |
|
- | 24 | TH1F *h1_chmin[NCH]; |
|
- | 25 | TH1F *h1_chmint[NCH]; |
|
- | 26 | TH1F *h1_letime[NCH]; |
|
- | 27 | TH1F *h1_cftime[NCH]; |
|
- | 28 | TH1F *h1_cftdif[NCH]; |
|
- | 29 | TH1F *h1_qdc[NCH]; |
|
- | 30 | TH2F *h2_dpo[NCH]; |
|
- | 31 | TH2F *h2_tdcadc[NCH]; |
|
- | 32 | TH2F *h2_ctdcadc[NCH]; |
|
- | 33 | TH2F *h2_ctalk; |
|
- | 34 | TGraph *gr_wfm[NCH]; |
|
- | 35 | TLegend *leg; |
|
- | 36 | ||
- | 37 | ||
- | 38 | TFile *froot; |
|
- | 39 | ||
- | 40 | int drs::histoinit( int nch, DrsChannel* d, int trgch){ |
|
- | 41 | char histname[128]; |
|
- | 42 | leg = new TLegend(0.8, 0.8, 1, 1); |
|
- | 43 | for (int i=0; i<nch; i++) { |
|
- | 44 | sprintf(histname,"chmax_%02d",i); |
|
- | 45 | h1_chmax[i]=new TH1F(histname,histname,1100,-0.88,0.88); |
|
- | 46 | sprintf(histname,"chmaxt_%02d",i); |
|
- | 47 | h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7); |
|
- | 48 | sprintf(histname,"chmin_%02d",i); |
|
- | 49 | h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55); |
|
- | 50 | sprintf(histname,"chmint_%02d",i); |
|
- | 51 | h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7); |
|
- | 52 | sprintf(histname,"letime_%02d",i); |
|
- | 53 | h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
|
- | 54 | sprintf(histname,"cftime_%02d",i); |
|
- | 55 | h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
|
- | 56 | sprintf(histname,"cftdif_%02d",i); |
|
- | 57 | h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
|
- | 58 | sprintf(histname,"qdc_%02d",i); |
|
- | 59 | h1_qdc[i]=new TH1F(histname,histname,500,-0.5,4.5); |
|
- | 60 | sprintf(histname,"dpo_%02d",i); |
|
- | 61 | h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,200.7,3000,-0.9,0.9); |
|
- | 62 | sprintf(histname,"tdcadc_%02d",i); |
|
- | 63 | 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]); |
|
- | 64 | sprintf(histname,"ctdcadc_%02d",i); |
|
- | 65 | 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]); |
|
- | 66 | gr_wfm[i]=new TGraph(DWIDTH); |
|
- | 67 | gr_wfm[i]->SetMinimum(-0.9); |
|
- | 68 | gr_wfm[i]->SetMaximum(0.9); |
|
- | 69 | gr_wfm[i]->SetLineColor(i+1); |
|
- | 70 | gr_wfm[i]->SetMarkerColor(i+1); |
|
- | 71 | sprintf(histname,"ch %d",i); |
|
- | 72 | leg->AddEntry(gr_wfm[i], histname, "l"); |
|
- | 73 | if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
|
- | 74 | gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
|
- | 75 | } |
|
- | 76 | ||
- | 77 | ||
- | 78 | h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
|
- | 79 | return 0; |
|
- | 80 | } |
|
- | 81 | ||
21 | drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch, int |
82 | drs::drs( const char *FileName, int nch, DrsChannel* d, int trgch, int first, int neve, int updfrq) |
22 | { |
83 | { |
23 | int debug=0; |
84 | int debug=0; |
24 | int i,ich,iev; |
85 | int i,ich,iev; |
25 | int stat; |
86 | int stat; |
26 |
|
87 | int nev = first + neve; |
27 | // char FileName[300]="./data/n2.dat"; |
88 | // char FileName[300]="./data/n2.dat"; |
28 | FILE *fin; |
89 | FILE *fin; |
29 | 90 | ||
30 | char recid[5]="SAMO"; |
91 | char recid[5]="SAMO"; |
31 | unsigned short *srecid = (unsigned short *) &recid[0]; |
92 | unsigned short *srecid = (unsigned short *) &recid[0]; |
Line 59... | Line 120... | ||
59 | 120 | ||
60 | // gROOT->Reset(); |
121 | // gROOT->Reset(); |
61 | 122 | ||
62 | gStyle->SetOptStat(1111111); |
123 | gStyle->SetOptStat(1111111); |
63 | // gStyle->SetPalette(52); |
124 | // gStyle->SetPalette(52); |
64 | 125 | ||
65 | TH1F *h1_chmax[NCH]; |
- | |
66 | TH1F *h1_chmaxt[NCH]; |
- | |
67 |
|
126 | char rootname[0xFF]; |
68 | TH1F *h1_chmint[NCH]; |
- | |
69 |
|
127 | sprintf(rootname, "%s_x%d_y%d.root", FileName, 0,0); |
70 |
|
128 | TFile *froot = new TFile(rootname,"RECREATE"); |
71 | TH1F *h1_cftdif[NCH]; |
- | |
72 | TH1F *h1_qdc[NCH]; |
- | |
73 |
|
129 | histoinit(nch, d, trgch); |
74 | TH2F *h2_tdcadc[NCH]; |
- | |
75 | TH2F *h2_ctdcadc[NCH]; |
- | |
76 | TH2F *h2_ctalk; |
- | |
77 |
|
130 | leg->Draw(); |
78 | - | ||
79 | TFile *froot = new TFile(TString(FileName) + ".root","RECREATE"); |
- | |
80 | - | ||
81 | TCanvas *c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700); |
131 | TCanvas *c_wfm= new TCanvas("c_wfm","WFM",50,50,700,700); |
82 |
|
132 | |
83 | c_wfm->Divide(1,1); |
133 | c_wfm->Divide(1,1); |
84 | c_wfm->cd(1); |
134 | c_wfm->cd(1); |
85 | 135 | ||
86 | for (i=0; i<nch; i++) { |
- | |
87 | sprintf(histname,"chmax_%02d",i); |
- | |
88 | h1_chmax[i]=new TH1F(histname,histname,1100,-0.88,0.88); |
- | |
89 | sprintf(histname,"chmaxt_%02d",i); |
- | |
90 | h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,204.7); |
- | |
91 | sprintf(histname,"chmin_%02d",i); |
- | |
92 | h1_chmin[i]=new TH1F(histname,histname,1100,-0.55,0.55); |
- | |
93 | sprintf(histname,"chmint_%02d",i); |
- | |
94 | h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,504.7); |
- | |
95 | sprintf(histname,"letime_%02d",i); |
- | |
96 | h1_letime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
- | |
97 | sprintf(histname,"cftime_%02d",i); |
- | |
98 | h1_cftime[i]=new TH1F(histname,histname,500,d[i].twin[0],d[i].twin[1]); |
- | |
99 | sprintf(histname,"cftdif_%02d",i); |
- | |
100 | h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
- | |
101 | sprintf(histname,"qdc_%02d",i); |
- | |
102 | h1_qdc[i]=new TH1F(histname,histname,500,-0.5,4.5); |
- | |
103 | sprintf(histname,"dpo_%02d",i); |
- | |
104 | h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,200.7,3000,-0.9,0.9); |
- | |
105 | sprintf(histname,"tdcadc_%02d",i); |
- | |
106 | 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]); |
- | |
107 | sprintf(histname,"ctdcadc_%02d",i); |
- | |
108 | 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]); |
- | |
109 | gr_wfm[i]=new TGraph(DWIDTH); |
- | |
110 | gr_wfm[i]->SetMinimum(-0.9); |
- | |
111 | gr_wfm[i]->SetMaximum(0.9); |
- | |
112 | gr_wfm[i]->SetLineColor(i+1); |
- | |
113 | gr_wfm[i]->SetMarkerColor(i+1); |
- | |
114 | sprintf(histname,"ch %d",i); |
- | |
115 | leg->AddEntry(gr_wfm[i], histname, "l"); |
- | |
116 | if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
- | |
117 | gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
- | |
118 |
|
136 | |
119 | - | ||
120 | leg->Draw(); |
- | |
121 | h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
- | |
122 | 137 | ||
123 | fin=fopen(FileName,"rb"); |
138 | fin=fopen(FileName,"rb"); |
124 | if (fin==NULL) { |
139 | if (fin==NULL) { |
125 | printf("Error opening file %s\n",FileName); |
140 | printf("Error opening file %s\n",FileName); |
126 | return; |
141 | return; |
Line 154... | Line 169... | ||
154 | case 'P':{ // position record |
169 | case 'P':{ // position record |
155 | int len; |
170 | int len; |
156 | stat=fread(&len,1,4,fin); |
171 | stat=fread(&len,1,4,fin); |
157 | if (len>0 && len<37) { |
172 | if (len>0 && len<37) { |
158 | stat=fread(posrec,1,len,fin); |
173 | stat=fread(posrec,1,len,fin); |
159 | if (recid[3]=='R') |
174 | if (recid[3]=='R'){ |
- | 175 | if (iev>=first){ |
|
- | 176 | froot->Write(); |
|
- | 177 | froot->Close(); |
|
- | 178 | sprintf(rootname, "%s_x%d_y%d.root", FileName, posrec[3], posrec[4]); |
|
- | 179 | froot = new TFile(rootname,"RECREATE"); |
|
- | 180 | histoinit(nch,d, trgch); |
|
- | 181 | } |
|
160 | printf("Position len=%d x=%d y=%d ix=%d iy=%d\n", len, posrec[0], posrec[1], posrec[3], posrec[4]); |
182 | printf("Position len=%d x=%d y=%d ix=%d iy=%d\n", len, posrec[0], posrec[1], posrec[3], posrec[4]); |
161 | else |
183 | } else |
162 | printf("Position record buffer length %d\n", len); |
184 | printf("Position record buffer length %d\n", len); |
163 | } else { |
185 | } else { |
164 | printf("Wrong buffer length %d\n", len); |
186 | printf("Wrong buffer length %d\n", len); |
165 | } |
187 | } |
166 | break; |
188 | break; |
167 | } |
189 | } |
168 | case 'D': // DRS |
190 | case 'D': // DRS |
169 | version = atoi(&recid[3]); |
191 | version = atoi(&recid[3]); |
170 | break; |
192 | break; |
171 | case 'T': // TIME |
193 | case 'T': // TIME |
Line 202... | Line 224... | ||
202 | break; |
224 | break; |
203 | default: |
225 | default: |
204 | printf("Unknown header! %s\n", recid); |
226 | printf("Unknown header! %s\n", recid); |
205 | break; |
227 | break; |
206 | } |
228 | } |
207 | - | ||
- | 229 | if (iev<first) continue; |
|
208 | 230 | ||
209 | if (recid[0] == 'E') { |
231 | if (recid[0] == 'E') { |
210 | for ( i=0; i<nch; i++) { |
232 | for ( i=0; i<nch; i++) { |
211 | if (!lwfm[i]) continue; |
233 | if (!lwfm[i]) continue; |
212 | double pulseheight = (d[i].edge)? chmax[i][0]: chmin[i][0]; |
234 | double pulseheight = (d[i].edge)? chmax[i][0]: chmin[i][0]; |