1 |
pam-fi |
1.1 |
#include <utils/yodaUtility.h> |
2 |
|
|
#include "TrkFunctions.cpp" |
3 |
|
|
#include <iostream> |
4 |
|
|
#include <fstream> |
5 |
|
|
#include <TPaveText.h> |
6 |
|
|
#include <TLatex.h> |
7 |
|
|
#include <TCanvas.h> |
8 |
|
|
#include <TGraph.h> |
9 |
|
|
#include <TStyle.h> |
10 |
|
|
#include <TObjString.h> |
11 |
|
|
#include <PscuHeader.h> |
12 |
|
|
#include <EventHeader.h> |
13 |
|
|
#include <CalibTrk1Event.h> |
14 |
|
|
#include <CalibTrk2Event.h> |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
/** |
18 |
|
|
* readpedsig --> is a function to read the calculated mean value for |
19 |
|
|
* sigma, variance of sigma, pedestal and variance of pedestal |
20 |
|
|
* from the pedsig.root file and draw these values vs. the time |
21 |
|
|
* |
22 |
|
|
* autor: D.Fedele |
23 |
|
|
* version 1.0 |
24 |
|
|
* Parameters: |
25 |
|
|
* file - the path to the root file to analyse |
26 |
|
|
* outdir - total path of output file |
27 |
|
|
* |
28 |
|
|
*/ |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
void readpedsig(TString file,TString outdir) |
32 |
|
|
{ |
33 |
|
|
// |
34 |
|
|
// obtain information about the data file and select the output dir |
35 |
|
|
const string filepath=file.Data(); |
36 |
|
|
Int_t dwpos = filepath.find("pedsig"); |
37 |
|
|
TString fpath=(filepath.c_str()); |
38 |
|
|
TString base; |
39 |
|
|
stringcopy(base,fpath,0,dwpos); |
40 |
|
|
|
41 |
|
|
TString out; |
42 |
|
|
if(outdir.Length()==0){ |
43 |
|
|
out = base; |
44 |
|
|
}else{ |
45 |
|
|
out = outdir; |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
stringstream fromfile,rep,tit; |
49 |
|
|
fromfile<<"readpedsig from File: "<<file; |
50 |
|
|
|
51 |
|
|
// |
52 |
|
|
// Set some ROOT variables and create the canvases |
53 |
|
|
gStyle->SetFillColor(10); |
54 |
|
|
gStyle->SetTitleFillColor(10); |
55 |
|
|
gStyle->SetTitleFontSize(0.06); |
56 |
|
|
gStyle->SetOptStat(0); |
57 |
|
|
gStyle->SetLabelSize(0.05,"x"); |
58 |
|
|
gStyle->SetLabelSize(0.05,"y"); |
59 |
|
|
gStyle->SetLabelOffset(0.01,"x"); |
60 |
|
|
gStyle->SetLabelOffset(0.01,"y"); |
61 |
|
|
gStyle->SetTitleOffset(1.,"y"); |
62 |
|
|
gStyle->SetTitleOffset(0.9,"x"); |
63 |
|
|
gStyle->SetTitleSize(0.05,"y"); |
64 |
|
|
gStyle->SetTitleSize(0.05,"x"); |
65 |
|
|
|
66 |
|
|
TLatex *tzz=new TLatex(); |
67 |
|
|
tzz->SetTextFont(32); |
68 |
|
|
tzz->SetTextColor(1); |
69 |
|
|
tzz->SetTextAlign(12); |
70 |
|
|
tzz->SetTextSize(0.02); |
71 |
|
|
|
72 |
|
|
Int_t canvasx=900; |
73 |
|
|
Int_t canvasy=1200; |
74 |
|
|
TCanvas *c[12][3][2]; |
75 |
|
|
TCanvas *cb[12]; |
76 |
|
|
|
77 |
|
|
for(Int_t i=0;i<12;i++){ |
78 |
|
|
rep.str(""); |
79 |
|
|
tit.str(""); |
80 |
|
|
tit<<"readpedsig bad "<<i; |
81 |
|
|
rep<<"c["<<i<<"]"; |
82 |
|
|
cb[i]=new TCanvas(rep.str().c_str(),tit.str().c_str(),canvasx,canvasy); |
83 |
|
|
cb[i]->Range(0,0,100,100); |
84 |
|
|
tzz->DrawLatex(1,98.5,fromfile.str().c_str()); |
85 |
|
|
rep.str(""); |
86 |
|
|
rep<<"number of BAD strip "<<"----> DSP "<<i+1; |
87 |
|
|
tzz->DrawLatex(65,98.5,rep.str().c_str()); |
88 |
|
|
|
89 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
90 |
|
|
for(Int_t iii=0;iii<2;iii++){ |
91 |
|
|
rep.str(""); |
92 |
|
|
tit.str(""); |
93 |
|
|
tit<<"readpedsig "<<i<<"-"<<ii<<"-"<<iii; |
94 |
|
|
rep<<"c["<<i<<"]["<<ii<<"]["<<iii<<"]"; |
95 |
|
|
c[i][ii][iii] = new TCanvas(rep.str().c_str(),tit.str().c_str(),canvasx,canvasy); |
96 |
|
|
c[i][ii][iii]->Range(0,0,100,100); |
97 |
|
|
tzz->DrawLatex(1,98.5,fromfile.str().c_str()); |
98 |
|
|
if(iii==0){ |
99 |
|
|
rep.str(""); |
100 |
|
|
rep<<"<SIG> e varianza "<<"----> DSP "<<i+1<<" ladder "<<ii+1; |
101 |
|
|
tzz->DrawLatex(60,98.5,rep.str().c_str()); |
102 |
|
|
} |
103 |
|
|
else{ |
104 |
|
|
rep.str(""); |
105 |
|
|
rep<<"<PED> e varianza "<<"----> DSP "<<i+1<<" ladder "<<ii+1; |
106 |
|
|
tzz->DrawLatex(60,98.5,rep.str().c_str()); |
107 |
|
|
} |
108 |
|
|
} |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
// |
113 |
|
|
// inizialise the variables and open the file |
114 |
|
|
|
115 |
|
|
Int_t numbad[12][12]; |
116 |
|
|
Float_t pedav[12][12],sigav[12][12]; |
117 |
|
|
Float_t pedvar[12][12],sigvar[12][12]; |
118 |
|
|
|
119 |
|
|
for(Int_t i=0;i<12;i++){ |
120 |
|
|
for(Int_t ii=0;ii<12;ii++){ |
121 |
|
|
pedav[i][ii]=0; |
122 |
|
|
sigav[i][ii]=0; |
123 |
|
|
pedvar[i][ii]=0; |
124 |
|
|
sigvar[i][ii]=0; |
125 |
|
|
numbad[i][ii]=0; |
126 |
|
|
} |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
TFile *pedsig = new TFile("/home/fedele/compiledScripts/pedsig.root"); |
130 |
|
|
|
131 |
|
|
TTree *pstree = (TTree*)pedsig->Get("pstree"); |
132 |
|
|
pstree->SetBranchAddress("pedav",pedav); |
133 |
|
|
pstree->SetBranchAddress("pedvar",pedvar); |
134 |
|
|
pstree->SetBranchAddress("sigav",sigav); |
135 |
|
|
pstree->SetBranchAddress("sigvar",sigvar); |
136 |
|
|
pstree->SetBranchAddress("numbad",numbad); |
137 |
|
|
|
138 |
|
|
Int_t totev=pstree->GetEntries(); |
139 |
|
|
const Int_t nev=totev; |
140 |
|
|
|
141 |
|
|
Float_t pedavtemp[nev],sigavtemp[nev],pedvartemp[nev],sigvartemp[nev]; |
142 |
|
|
Float_t x[nev]; |
143 |
|
|
Float_t numbadtemp[nev]; |
144 |
|
|
|
145 |
|
|
for(Int_t vii=0;vii<nev;vii++){ |
146 |
|
|
x[vii]=0; |
147 |
|
|
pedavtemp[vii]= 0; |
148 |
|
|
pedvartemp[vii]= 0; |
149 |
|
|
sigavtemp[vii]=0; |
150 |
|
|
sigvartemp[vii]=0; |
151 |
|
|
numbadtemp[vii]=0; |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
// |
155 |
|
|
// Create Pads and Graphs |
156 |
|
|
TPad *pad1[12][3][8]; |
157 |
|
|
TPad *pad2[12][3][8]; |
158 |
|
|
TPad *pad3[12][12]; |
159 |
|
|
TGraph *histosigav[12][3][4]; |
160 |
|
|
TGraph *histopedav[12][3][4]; |
161 |
|
|
TGraph *histosigvar[12][3][4]; |
162 |
|
|
TGraph *histopedvar[12][3][4]; |
163 |
|
|
TGraph *histobad[12][12]; |
164 |
|
|
|
165 |
|
|
Float_t posy = 0.95; // up y-coord - top pads |
166 |
|
|
Float_t hpad = 0; // pad height |
167 |
|
|
Float_t posx1=0; // left x-coord - pad column |
168 |
|
|
Float_t posx0=0; // x-coord - column division |
169 |
|
|
Float_t wrel = 0; // relative x size of first sub-column |
170 |
|
|
Float_t marg = 0.004; // margin among pads |
171 |
|
|
|
172 |
|
|
hpad = (posy-marg*7)/4; |
173 |
|
|
wrel = (1-marg*4)/2; |
174 |
|
|
|
175 |
|
|
for(Int_t n = 0; n<8; n++){ |
176 |
|
|
if ( (n+1)%2==1 ) { |
177 |
|
|
if(n>1)posy = posy-(marg*2+hpad); |
178 |
|
|
posx1 = marg; |
179 |
|
|
posx0 = posx1 +wrel; |
180 |
|
|
} else { |
181 |
|
|
posx1 = posx0 + 2*marg; |
182 |
|
|
posx0 = posx1 + wrel; |
183 |
|
|
}; |
184 |
|
|
for(Int_t i=0;i<12;i++){ |
185 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
186 |
|
|
pad1[i][ii][n] = new TPad("pad1"," ",posx1,posy-hpad,posx0,posy,18,0,0); |
187 |
|
|
pad2[i][ii][n] = new TPad("pad2"," ",posx1,posy-hpad,posx0,posy,18,0,0); |
188 |
|
|
} |
189 |
|
|
} |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
posy = 0.95; |
193 |
|
|
posx1=0; |
194 |
|
|
posx0=0; |
195 |
|
|
hpad = (posy-marg*11)/6; |
196 |
|
|
wrel = (1-marg*4)/2; |
197 |
|
|
|
198 |
|
|
for(Int_t n = 0; n<12; n++){ |
199 |
|
|
if ( (n+1)%2==1 ) { |
200 |
|
|
if(n>1)posy = posy-(marg*2+hpad); |
201 |
|
|
posx1 = marg; |
202 |
|
|
posx0 = posx1 +wrel; |
203 |
|
|
} else { |
204 |
|
|
posx1 = posx0 + 2*marg; |
205 |
|
|
posx0 = posx1 + wrel; |
206 |
|
|
}; |
207 |
|
|
for(Int_t i=0;i<12;i++){ |
208 |
|
|
pad3[i][n] = new TPad("pad3"," ",posx1,posy-hpad,posx0,posy,18,0,0); |
209 |
|
|
} |
210 |
|
|
} |
211 |
|
|
|
212 |
|
|
//********************************************************************** |
213 |
|
|
// |
214 |
|
|
// LOOP OVER EVENTS |
215 |
|
|
// |
216 |
|
|
//********************************************************************** |
217 |
|
|
|
218 |
|
|
for(Int_t i=0;i<12;i++){ |
219 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
220 |
|
|
for(Int_t iv=0;iv<4;iv++){ |
221 |
|
|
for(Int_t ev = 0; ev < nev; ev++){ |
222 |
|
|
x[0]=1.; |
223 |
|
|
pstree->GetEntry(ev); |
224 |
|
|
|
225 |
|
|
// |
226 |
|
|
// fill the graphs whit the right values |
227 |
|
|
|
228 |
|
|
if(ev>0) x[ev]=x[ev-1]+1.; |
229 |
|
|
pedavtemp[ev]= pedav[i][(ii*4)+iv]; |
230 |
|
|
pedvartemp[ev]= pedvar[i][(ii*4)+iv]; |
231 |
|
|
sigavtemp[ev]=sigav[i][(ii*4)+iv]; |
232 |
|
|
sigvartemp[ev]=sigvar[i][(ii*4)+iv]; |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
c[i][ii][1]->cd(); |
236 |
|
|
pad1[i][ii][iv*2]->SetFillColor(10); |
237 |
|
|
pad1[i][ii][iv*2]->SetFrameFillColor(10); |
238 |
|
|
pad1[i][ii][iv*2]->Draw(); |
239 |
|
|
pad1[i][ii][iv*2]->cd(); |
240 |
|
|
tit.str(""); |
241 |
|
|
histopedav[i][ii][iv] = new TGraph(nev,x,pedavtemp); |
242 |
|
|
tit<<"<PED> --> DSP "<<i+1<<" - VA1 pair # "<<iv+1; |
243 |
|
|
histopedav[i][ii][iv]->SetTitle(tit.str().c_str()); |
244 |
|
|
histopedav[i][ii][iv]->GetXaxis()->SetTitle("time (arbitrary unit)"); |
245 |
|
|
histopedav[i][ii][iv]->GetXaxis()->CenterTitle(); |
246 |
|
|
histopedav[i][ii][iv]->GetYaxis()->SetTitle("<PED>"); |
247 |
|
|
histopedav[i][ii][iv]->GetYaxis()->SetTitleOffset(1.1); |
248 |
|
|
histopedav[i][ii][iv]->GetYaxis()->CenterTitle(); |
249 |
|
|
histopedav[i][ii][iv]->SetMarkerStyle(23); |
250 |
|
|
histopedav[i][ii][iv]->SetMarkerSize(0.4); |
251 |
|
|
histopedav[i][ii][iv]->SetMarkerColor(2); |
252 |
|
|
histopedav[i][ii][iv]->Draw("acp"); |
253 |
|
|
tit.str(""); |
254 |
|
|
c[i][ii][1]->Update(); |
255 |
|
|
|
256 |
|
|
c[i][ii][1]->cd(); |
257 |
|
|
pad1[i][ii][iv*2+1]->SetFillColor(10); |
258 |
|
|
pad1[i][ii][iv*2+1]->SetFrameFillColor(10); |
259 |
|
|
pad1[i][ii][iv*2+1]->Draw(); |
260 |
|
|
pad1[i][ii][iv*2+1]->cd(); |
261 |
|
|
tit.str(""); |
262 |
|
|
histopedvar[i][ii][iv]= new TGraph(nev,x,pedvartemp); |
263 |
|
|
tit<<"VAR PED --> DSP "<<i+1<<" - VA1 pair # "<<iv+1; |
264 |
|
|
histopedvar[i][ii][iv]->SetTitle(tit.str().c_str()); |
265 |
|
|
histopedvar[i][ii][iv]->GetXaxis()->SetTitle("time (arbitrary unit)"); |
266 |
|
|
histopedvar[i][ii][iv]->GetXaxis()->CenterTitle(); |
267 |
|
|
histopedvar[i][ii][iv]->GetYaxis()->SetTitle("VAR <PED>"); |
268 |
|
|
histopedvar[i][ii][iv]->GetYaxis()->CenterTitle(); |
269 |
|
|
histopedvar[i][ii][iv]->SetMarkerStyle(23); |
270 |
|
|
histopedvar[i][ii][iv]->SetMarkerSize(0.4); |
271 |
|
|
histopedvar[i][ii][iv]->SetMarkerColor(2); |
272 |
|
|
histopedvar[i][ii][iv]->Draw("acp"); |
273 |
|
|
tit.str(""); |
274 |
|
|
c[i][ii][1]->Update(); |
275 |
|
|
|
276 |
|
|
c[i][ii][0]->cd(); |
277 |
|
|
pad2[i][ii][iv*2]->SetFillColor(10); |
278 |
|
|
pad2[i][ii][iv*2]->SetFrameFillColor(10); |
279 |
|
|
pad2[i][ii][iv*2]->Draw(); |
280 |
|
|
pad2[i][ii][iv*2]->cd(); |
281 |
|
|
tit.str(""); |
282 |
|
|
histosigav[i][ii][iv]= new TGraph(nev,x,sigavtemp); |
283 |
|
|
tit<<"<SIG> --> DSP "<<i+1<<" - VA1 pair # "<<iv+1; |
284 |
|
|
histosigav[i][ii][iv]->SetTitle(tit.str().c_str()); |
285 |
|
|
histosigav[i][ii][iv]->GetXaxis()->SetTitle("time (arbitrary unit)"); |
286 |
|
|
histosigav[i][ii][iv]->GetXaxis()->CenterTitle(); |
287 |
|
|
histosigav[i][ii][iv]->GetYaxis()->SetTitle("<SIG>"); |
288 |
|
|
histosigav[i][ii][iv]->GetYaxis()->SetTitleOffset(0.8); |
289 |
|
|
histosigav[i][ii][iv]->GetYaxis()->CenterTitle(); |
290 |
|
|
histosigav[i][ii][iv]->SetMarkerStyle(23); |
291 |
|
|
histosigav[i][ii][iv]->SetMarkerSize(0.4); |
292 |
|
|
histosigav[i][ii][iv]->SetMarkerColor(2); |
293 |
|
|
histosigav[i][ii][iv]->Draw("acp"); |
294 |
|
|
tit.str(""); |
295 |
|
|
c[i][ii][0]->Update(); |
296 |
|
|
|
297 |
|
|
c[i][ii][0]->cd(); |
298 |
|
|
pad2[i][ii][iv*2+1]->SetFillColor(10); |
299 |
|
|
pad2[i][ii][iv*2+1]->SetFrameFillColor(10); |
300 |
|
|
pad2[i][ii][iv*2+1]->Draw(); |
301 |
|
|
pad2[i][ii][iv*2+1]->cd(); |
302 |
|
|
tit.str(""); |
303 |
|
|
histosigvar[i][ii][iv]= new TGraph(nev,x,sigvartemp); |
304 |
|
|
tit<<"VAR SIG --> DSP "<<i+1<<" - VA1 pair # "<<iv+1; |
305 |
|
|
histosigvar[i][ii][iv]->SetTitle(tit.str().c_str()); |
306 |
|
|
histosigvar[i][ii][iv]->GetXaxis()->SetTitle("time (arbitrary unit)"); |
307 |
|
|
histosigvar[i][ii][iv]->GetXaxis()->CenterTitle(); |
308 |
|
|
histosigvar[i][ii][iv]->GetYaxis()->SetTitle("VAR <SIG>"); |
309 |
|
|
histosigvar[i][ii][iv]->GetYaxis()->SetTitleOffset(0.9); |
310 |
|
|
histosigvar[i][ii][iv]->GetYaxis()->CenterTitle(); |
311 |
|
|
histosigvar[i][ii][iv]->SetMarkerStyle(23); |
312 |
|
|
histosigvar[i][ii][iv]->SetMarkerSize(0.4); |
313 |
|
|
histosigvar[i][ii][iv]->SetMarkerColor(2); |
314 |
|
|
histosigvar[i][ii][iv]->Draw("acp"); |
315 |
|
|
tit.str(""); |
316 |
|
|
c[i][ii][0]->Update(); |
317 |
|
|
} |
318 |
|
|
} |
319 |
|
|
|
320 |
|
|
for(Int_t ix=0;ix<12;ix++){ |
321 |
|
|
for (Int_t ev = 0; ev < nev; ev++) |
322 |
|
|
numbadtemp[ev]=(Float_t)numbad[i][ix]; |
323 |
|
|
|
324 |
|
|
cb[i]->cd(); |
325 |
|
|
pad3[i][ix]->SetFillColor(10); |
326 |
|
|
pad3[i][ix]->SetFrameFillColor(10); |
327 |
|
|
pad3[i][ix]->Draw(); |
328 |
|
|
pad3[i][ix]->cd(); |
329 |
|
|
tit.str(""); |
330 |
|
|
histobad[i][ix]= new TGraph(nev,x,numbadtemp); |
331 |
|
|
tit<<"VA1 pair # "<<ix+1; |
332 |
|
|
histobad[i][ix]->SetTitle(tit.str().c_str()); |
333 |
|
|
histobad[i][ix]->GetXaxis()->SetTitle("time (arbitrary unit)"); |
334 |
|
|
histobad[i][ix]->GetXaxis()->CenterTitle(); |
335 |
|
|
histobad[i][ix]->GetYaxis()->SetTitle("number of bads"); |
336 |
|
|
histobad[i][ix]->GetYaxis()->CenterTitle(); |
337 |
|
|
histobad[i][ix]->SetMarkerStyle(23); |
338 |
|
|
histobad[i][ix]->SetMarkerSize(0.4); |
339 |
|
|
histobad[i][ix]->SetMarkerColor(2); |
340 |
|
|
histobad[i][ix]->Draw("acp"); |
341 |
|
|
tit.str(""); |
342 |
|
|
cb[i]->Update(); |
343 |
|
|
} |
344 |
|
|
} |
345 |
|
|
|
346 |
|
|
// |
347 |
|
|
// Close the input file and update the canvases |
348 |
|
|
pedsig->Close(); |
349 |
|
|
|
350 |
|
|
for(Int_t i=0;i<12;i++){ |
351 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
352 |
|
|
for(Int_t iii=0;iii<2;iii++) |
353 |
|
|
c[i][ii][iii]->Update(); |
354 |
|
|
} |
355 |
|
|
cb[i]->Update(); |
356 |
|
|
} |
357 |
|
|
|
358 |
|
|
// |
359 |
|
|
// Create the output files |
360 |
|
|
stringstream nom1,nom2,nom3; |
361 |
|
|
|
362 |
|
|
nom1<<"readpedsig.ps("; |
363 |
|
|
nom2<<"readpedsig.ps"; |
364 |
|
|
nom3<<"readpedsig.ps)"; |
365 |
|
|
c[0][0][0]->Print(out+nom1.str().c_str()); |
366 |
|
|
for(Int_t i=0;i<12;i++){ |
367 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
368 |
|
|
for(Int_t iii=0;iii<2;iii++){ |
369 |
|
|
if(i==11 && ii==2 && iii==1) |
370 |
|
|
continue; |
371 |
|
|
if( i==0 && ii==0 && iii==0) |
372 |
|
|
continue; |
373 |
|
|
c[i][ii][iii]->Print(out+nom2.str().c_str()); |
374 |
|
|
} |
375 |
|
|
} |
376 |
|
|
cb[i]->Print(out+nom2.str().c_str()); |
377 |
|
|
} |
378 |
|
|
c[11][2][1]->Print(out+nom3.str().c_str()); |
379 |
|
|
nom1.str(""); |
380 |
|
|
nom2.str(""); |
381 |
|
|
nom3.str(""); |
382 |
|
|
|
383 |
|
|
for(Int_t i=0;i<12;i++){ |
384 |
|
|
for(Int_t ii=0;ii<3;ii++){ |
385 |
|
|
for(Int_t iii=0;iii<2;iii++) |
386 |
|
|
delete c[i][ii][iii]; |
387 |
|
|
} |
388 |
|
|
delete cb[i]; |
389 |
|
|
} |
390 |
|
|
nom1<<"ps2pdf13 "<<out<<"readpedsig.ps "<<out<<"readpedsig.pdf"; |
391 |
|
|
system(nom1.str().c_str()); |
392 |
|
|
nom2<<"rm -f "<<out<<"readpedsig.ps"; |
393 |
|
|
system(nom2.str().c_str()); |
394 |
|
|
|
395 |
|
|
return; |
396 |
|
|
} |