1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | //////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // pedestalstudies_pisa.C
|
---|
27 | //
|
---|
28 | // macro to study the pedestal and pedestalRMS with the number of FADC
|
---|
29 | // slices summed up.
|
---|
30 | //
|
---|
31 | /////////////////////////////////////////////////////////////////////////////////
|
---|
32 | const TString pedfile = "/data0/Temp/20040422_23203_P_Mrk421_E.root";
|
---|
33 |
|
---|
34 | void pedestalstudies_pisa(const TString pedname=pedfile, Int_t pixin=0, Int_t pixout=397,TString f2="",TString f3="",TString f4="",TString f5="")
|
---|
35 | {
|
---|
36 |
|
---|
37 | Int_t loops = 1;
|
---|
38 | Int_t stepsize = 2;
|
---|
39 |
|
---|
40 | gStyle->SetOptStat(1111);
|
---|
41 | gStyle->SetOptFit();
|
---|
42 |
|
---|
43 | TArrayF *hmeandiffinn = new TArrayF(loops);
|
---|
44 | TArrayF *hrmsdiffinn = new TArrayF(loops);
|
---|
45 | TArrayF *hmeandiffout = new TArrayF(loops);
|
---|
46 | TArrayF *hrmsdiffout = new TArrayF(loops);
|
---|
47 | TArrayF *hmeaninn = new TArrayF(loops);
|
---|
48 | TArrayF *hmeanout = new TArrayF(loops);
|
---|
49 | TArrayF *hrmsinn = new TArrayF(loops);
|
---|
50 | TArrayF *hrmsout = new TArrayF(loops);
|
---|
51 | TArrayF *hmuinn = new TArrayF(loops);
|
---|
52 | TArrayF *hmuout = new TArrayF(loops);
|
---|
53 | TArrayF *hsigmainn = new TArrayF(loops);
|
---|
54 | TArrayF *hsigmaout = new TArrayF(loops);
|
---|
55 |
|
---|
56 | TArrayF *hmeandiffinnerr = new TArrayF(loops);
|
---|
57 | TArrayF *hrmsdiffinnerr = new TArrayF(loops);
|
---|
58 | TArrayF *hmeandiffouterr = new TArrayF(loops);
|
---|
59 | TArrayF *hrmsdiffouterr = new TArrayF(loops);
|
---|
60 | TArrayF *hmeaninnerr = new TArrayF(loops);
|
---|
61 | TArrayF *hmeanouterr = new TArrayF(loops);
|
---|
62 | TArrayF *hrmsinnerr = new TArrayF(loops);
|
---|
63 | TArrayF *hrmsouterr = new TArrayF(loops);
|
---|
64 | TArrayF *hmuinnerr = new TArrayF(loops);
|
---|
65 | TArrayF *hmuouterr = new TArrayF(loops);
|
---|
66 | TArrayF *hsigmainnerr = new TArrayF(loops);
|
---|
67 | TArrayF *hsigmaouterr = new TArrayF(loops);
|
---|
68 |
|
---|
69 |
|
---|
70 | MStatusDisplay *display = new MStatusDisplay;
|
---|
71 | display->SetUpdateTime(500);
|
---|
72 | display->Resize(850,700);
|
---|
73 |
|
---|
74 | //
|
---|
75 | // Create a empty Parameter List and an empty Task List
|
---|
76 | // The tasklist is identified in the eventloop by its name
|
---|
77 | //
|
---|
78 | MParList plist;
|
---|
79 | MTaskList tlist;
|
---|
80 | plist.AddToList(&tlist);
|
---|
81 |
|
---|
82 | TString tabname="";
|
---|
83 |
|
---|
84 | for (Int_t samples=2; samples < stepsize*loops+1; samples=samples+stepsize)
|
---|
85 | {
|
---|
86 |
|
---|
87 | plist.Reset();
|
---|
88 | tlist.Reset();
|
---|
89 |
|
---|
90 | //
|
---|
91 | // Now setup the tasks and tasklist for the pedestals:
|
---|
92 | // ---------------------------------------------------
|
---|
93 | //
|
---|
94 |
|
---|
95 | MReadMarsFile read("Events", pedname);
|
---|
96 | read.DisableAutoScheme();
|
---|
97 |
|
---|
98 | Int_t neventi;
|
---|
99 | neventi=1000;
|
---|
100 |
|
---|
101 | Float_t samplingRate=500; //Hz
|
---|
102 | if (f2!=""){
|
---|
103 | read.AddFile(f2);
|
---|
104 | neventi += 1000;
|
---|
105 | }
|
---|
106 |
|
---|
107 | if (f3!=""){
|
---|
108 | read.AddFile(f3);
|
---|
109 | neventi += 1000;
|
---|
110 | }
|
---|
111 |
|
---|
112 | if (f4!=""){
|
---|
113 | read.AddFile(f4);
|
---|
114 | neventi += 1000;
|
---|
115 | }
|
---|
116 |
|
---|
117 | if (f5!=""){
|
---|
118 | read.AddFile(f5);
|
---|
119 | neventi += 1000;
|
---|
120 | }
|
---|
121 |
|
---|
122 | const Int_t NEvt = neventi;
|
---|
123 | cout << "E" <<neventi<< " NEvt:" << NEvt << endl;
|
---|
124 | Float_t timevt[NEvt];
|
---|
125 |
|
---|
126 | MGeomApply geomapl;
|
---|
127 | //
|
---|
128 | // Set the extraction range higher:
|
---|
129 | //
|
---|
130 | //MExtractFixedWindow sigcalc;
|
---|
131 | //MExtractSignal3 sigcalc;
|
---|
132 | MExtractSlidingWindow sigcalc;
|
---|
133 | sigcalc.SetRange(0,samples-1,0,1);
|
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 | MPedCalcPedRun pedcalc;
|
---|
138 | pedcalc.SetRange(0,samples-1,0,0);
|
---|
139 | pedcalc.SetWindowSize((Int_t)sigcalc.GetNumHiGainSamples());
|
---|
140 |
|
---|
141 | //MPedCalcFromData pedcalc;
|
---|
142 | //pedcalc.SetfHiGainThreshold(100);
|
---|
143 |
|
---|
144 | //
|
---|
145 | // Additionally to calculating the pedestals,
|
---|
146 | // you can fill histograms and look at them
|
---|
147 | //
|
---|
148 | MFillH fill("MHPedestalCam", "MExtractedSignalCam");
|
---|
149 | tabname="PedCam ";
|
---|
150 | tabname += samples;
|
---|
151 | //fill.SetNameTab(Form("%s%2d","PedCam",samples));
|
---|
152 | fill.SetNameTab(tabname);
|
---|
153 |
|
---|
154 | tlist.AddToList(&read);
|
---|
155 | tlist.AddToList(&geomapl);
|
---|
156 | tlist.AddToList(&sigcalc);
|
---|
157 | tlist.AddToList(&pedcalc);
|
---|
158 | tlist.AddToList(&fill);
|
---|
159 |
|
---|
160 | const MGeomCamMagic geomcam;
|
---|
161 | MPedestalCam pedcam;
|
---|
162 | MBadPixelsCam badcam;
|
---|
163 | badcam.AsciiRead("badpixels.dat");
|
---|
164 |
|
---|
165 | MHPedestalCam hpedcam;
|
---|
166 | MCalibrationPedCam cpedcam;
|
---|
167 |
|
---|
168 | plist.AddToList(&geomcam);
|
---|
169 | plist.AddToList(&pedcam);
|
---|
170 | plist.AddToList(&hpedcam);
|
---|
171 | plist.AddToList(&cpedcam);
|
---|
172 | plist.AddToList(&badcam);
|
---|
173 |
|
---|
174 | //
|
---|
175 | // Create and setup the eventloop
|
---|
176 | //
|
---|
177 | MRawEvtHeader *evtheader;
|
---|
178 | MRawEvtData *fRawEvt;
|
---|
179 | TH1F *hpedevt = new TH1F("hpedevt","Pedestals Drift",NEvt,0,(Float_t)NEvt/samplingRate);
|
---|
180 | Bool_t rc;
|
---|
181 | MEvtLoop evtloop;
|
---|
182 |
|
---|
183 | evtloop.SetParList(&plist);
|
---|
184 | evtloop.SetDisplay(display);
|
---|
185 | //tlist.SetDisplay(display);
|
---|
186 | //
|
---|
187 | // Execute first analysis
|
---|
188 | //
|
---|
189 | //if (!evtloop.Eventloop())
|
---|
190 | // return;
|
---|
191 | rc = evtloop.PreProcess();
|
---|
192 |
|
---|
193 | //while (tlist.Process())
|
---|
194 | //{
|
---|
195 | //cout << "bleah" << endl;
|
---|
196 | //}
|
---|
197 | //tlist.SetDisplay(display);
|
---|
198 |
|
---|
199 | Int_t fNumHiGainSample=15;
|
---|
200 | Float_t peddata[NEvt];
|
---|
201 | Int_t evtan=0;
|
---|
202 |
|
---|
203 | if (rc){
|
---|
204 | while (tlist.Process())
|
---|
205 | {
|
---|
206 | fRawEvt=(MRawEvtData *)plist.FindObject("MRawEvtData");
|
---|
207 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
208 |
|
---|
209 | Float_t ped=0;
|
---|
210 | evtan++;
|
---|
211 |
|
---|
212 | while (pixel.Next())
|
---|
213 | {
|
---|
214 |
|
---|
215 | const UInt_t idx = pixel.GetPixelId();
|
---|
216 |
|
---|
217 | // lista di pixel da sommare
|
---|
218 | if (idx >pixout || idx < pixin)
|
---|
219 | continue;
|
---|
220 |
|
---|
221 | Byte_t *ptr = pixel.GetHiGainSamples();
|
---|
222 | const Byte_t *end = ptr + fNumHiGainSample;
|
---|
223 |
|
---|
224 | UInt_t sum = 0;
|
---|
225 | UInt_t sqr = -1;
|
---|
226 |
|
---|
227 | do
|
---|
228 | {
|
---|
229 | sum += *ptr;
|
---|
230 | //sqr += *ptr * *ptr;
|
---|
231 | }
|
---|
232 | while (++ptr != end);
|
---|
233 |
|
---|
234 | ped += (Float_t)sum;
|
---|
235 |
|
---|
236 | //cout << " Pixel " << idx << " pede: " << ped << " --- ";
|
---|
237 | }
|
---|
238 |
|
---|
239 | //rc = evtloop.Process(0);
|
---|
240 | evtheader = (MRawEvtHeader *)plist.FindObject("MRawEvtHeader");
|
---|
241 |
|
---|
242 | ped /= pixout-pixin+1;
|
---|
243 | Int_t evtn=evtheader->GetDAQEvtNumber();
|
---|
244 | evtn=evtan;
|
---|
245 |
|
---|
246 | //test
|
---|
247 | //ped = 150 + sin(((Float_t)evtn/16.-TMath::Floor(evtn/16))*6.28);
|
---|
248 | //cout << ped << " ";
|
---|
249 | timeped = evtn/samplingRate;
|
---|
250 | timevt[evtn-1]=timeped;
|
---|
251 |
|
---|
252 | hpedevt->Fill(timeped,ped);
|
---|
253 |
|
---|
254 | // cout <<" evt:" << evtn;
|
---|
255 | // Save pedestal in array for Fourier analysis
|
---|
256 | peddata[evtn-1]=ped;
|
---|
257 | }
|
---|
258 | }
|
---|
259 | if (!evtloop.PostProcess()){
|
---|
260 | rc = kFALSE;
|
---|
261 | return;
|
---|
262 | }
|
---|
263 |
|
---|
264 | TCanvas &p1 = display->AddTab("ped studies");
|
---|
265 | p1.Divide(1,2);
|
---|
266 | p1.cd(1);
|
---|
267 | hpedevt->GetXaxis()->SetTitle("Time (s)");
|
---|
268 | // hpedevt->Draw();
|
---|
269 |
|
---|
270 | TGraph *drift = new TGraph(evtan,timevt,peddata);
|
---|
271 | drift->SetMarkerStyle(21);
|
---|
272 | drift->SetMarkerSize(0.25);
|
---|
273 | drift->GetXaxis()->SetTitle("time (s)");
|
---|
274 | drift->GetYaxis()->SetTitle(" pedestal");
|
---|
275 | drift->Draw("APL");
|
---|
276 |
|
---|
277 |
|
---|
278 | // Fourier analysis
|
---|
279 | // campionamento a 500Hz (1000 evt) => freq. max a 250Hz
|
---|
280 |
|
---|
281 | MFFT pro;
|
---|
282 | TArrayF *pedarray = new TArrayF(NEvt,peddata);
|
---|
283 | TArrayF *fft; // array con risultato FFT
|
---|
284 | fft = pro.RealFunctionFFT(pedarray);
|
---|
285 | Int_t nsample = (Int_t)(fft->GetSize());
|
---|
286 |
|
---|
287 | const Int_t NNEvt = nsample;
|
---|
288 |
|
---|
289 | Float_t x[10000];
|
---|
290 | Float_t prova;
|
---|
291 | for (int i=0;i<NNEvt;i++)
|
---|
292 | x[i]=(Float_t)i/(NNEvt/(samplingRate/2));
|
---|
293 |
|
---|
294 | Float_t *ffty = fft->GetArray();
|
---|
295 | cout << "Szie:" << fft->GetSize();
|
---|
296 | ffty[0]=0.;
|
---|
297 | TGraph *gr = new TGraph(nsample,x,ffty);
|
---|
298 | p1.cd(2);
|
---|
299 | gr->GetXaxis()->SetTitle("Frequency (Hz)");
|
---|
300 | gr->SetMarkerStyle(20);
|
---|
301 | gr->SetMarkerSize(0.4);
|
---|
302 | gr->Draw("AP");
|
---|
303 |
|
---|
304 |
|
---|
305 |
|
---|
306 | //-------------------------------
|
---|
307 |
|
---|
308 |
|
---|
309 | // Set status lines
|
---|
310 | display->SetStatusLine1(evtloop.GetName());
|
---|
311 | display->SetStatusLine2(rc ? "Done." : "Error!");
|
---|
312 | // Stop automatic update
|
---|
313 | display->StopUpdate();
|
---|
314 | // Reallow context menus
|
---|
315 | display->SetNoContextMenu(kFALSE);
|
---|
316 | // Reallow user to exit window by File menu
|
---|
317 | display->UnLock();
|
---|
318 | //
|
---|
319 | // Look at one specific pixel, after all the histogram manipulations:
|
---|
320 | //
|
---|
321 | /*
|
---|
322 | MHGausEvents &hpix = hpedcam.GetAverageHiGainArea(0);
|
---|
323 | hpix.DrawClone("fourierevents");
|
---|
324 |
|
---|
325 | MHGausEvents &lpix = hpedcam.GetAverageHiGainArea(1);
|
---|
326 | lpix.DrawClone("fourierevents");
|
---|
327 |
|
---|
328 | hpedcam[170].DrawClone("fourierevents");
|
---|
329 |
|
---|
330 | */
|
---|
331 |
|
---|
332 | MHCamera dispped0 (geomcam, "Ped;Pedestal", "Mean per Slice");
|
---|
333 | MHCamera dispped2 (geomcam, "Ped;PedestalRms", "RMS per Slice");
|
---|
334 | MHCamera dispped4 (geomcam, "Ped;Mean", "Fitted Mean per Slice");
|
---|
335 | MHCamera dispped6 (geomcam, "Ped;Sigma", "Fitted Sigma per Slice");
|
---|
336 | MHCamera dispped9 (geomcam, "Ped;DeltaPedMean", "Rel. Diff. Mean per Slice (Fit-Calc.)");
|
---|
337 | MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma", "Rel. Diff. RMS per Slice (Fit-Calc.)");
|
---|
338 |
|
---|
339 | dispped0.SetCamContent( pedcam, 0);
|
---|
340 | dispped0.SetCamError( pedcam, 1);
|
---|
341 | dispped2.SetCamContent( pedcam, 2);
|
---|
342 | dispped2.SetCamError( pedcam, 3);
|
---|
343 |
|
---|
344 | dispped4.SetCamContent( hpedcam, 0);
|
---|
345 | dispped4.SetCamError( hpedcam, 1);
|
---|
346 | dispped6.SetCamContent( hpedcam, 2);
|
---|
347 | dispped6.SetCamError( hpedcam, 3);
|
---|
348 | dispped9.SetCamContent( hpedcam, 5);
|
---|
349 | dispped9.SetCamError( hpedcam, 6);
|
---|
350 | dispped11.SetCamContent(hpedcam, 8);
|
---|
351 | dispped11.SetCamError( hpedcam, 9);
|
---|
352 |
|
---|
353 | dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
|
---|
354 | dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
|
---|
355 | dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
|
---|
356 | dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
|
---|
357 | dispped9.SetYTitle("Rel. Diff. Pedestal per slice Fit-Calc [1]");
|
---|
358 | dispped11.SetYTitle("Rel. Diff. Pedestal RMS per slice Fit-Calc [1]");
|
---|
359 |
|
---|
360 |
|
---|
361 | // Histogram values
|
---|
362 | tabname="MeanRMS ";
|
---|
363 | tabname += samples;
|
---|
364 | //fill.SetNameTab(tabname);
|
---|
365 | TCanvas &b1 = display->AddTab(tabname);
|
---|
366 | b1.Divide(4,3);
|
---|
367 |
|
---|
368 | CamDraw(b1,dispped0,1,4,*hmeaninn,*hmeanout,*hmeaninnerr,*hmeanouterr,samples,stepsize);
|
---|
369 | CamDraw(b1,dispped2,2,4,*hrmsinn,*hrmsout,*hrmsinnerr,*hrmsouterr,samples,stepsize);
|
---|
370 | CamDraw(b1,dispped4,3,4,*hmuinn,*hmuout,*hmuinnerr,*hmuouterr,samples,stepsize);
|
---|
371 | CamDraw(b1,dispped6,4,4,*hsigmainn,*hsigmaout,*hsigmainnerr,*hsigmaouterr,samples,stepsize);
|
---|
372 |
|
---|
373 | tabname="MeanRrmSamples ";
|
---|
374 | tabname += samples;
|
---|
375 | display->SaveAsGIF(3*((samples-1)/stepsize)+2,tabname);
|
---|
376 |
|
---|
377 | // Differences
|
---|
378 | tabname="RelDiff ";
|
---|
379 | tabname += samples;
|
---|
380 | TCanvas &c4 = display->AddTab(tabname);
|
---|
381 | c4.Divide(2,3);
|
---|
382 |
|
---|
383 | CamDraw(c4,dispped9,1,2,*hmeandiffinn,*hmeandiffout,*hmeandiffinnerr,*hmeandiffouterr,samples,stepsize);
|
---|
384 | CamDraw(c4,dispped11,2,2,*hrmsdiffinn,*hrmsdiffout,*hrmsdiffinnerr,*hrmsdiffouterr,samples,stepsize);
|
---|
385 |
|
---|
386 | tabname="RelDiffSamples ";
|
---|
387 | tabname += samples;
|
---|
388 | display->SaveAsGIF(3*((samples-1)/stepsize)+3,tabname);
|
---|
389 |
|
---|
390 | cout << "Loop N. " <<samples << " completed..." <<endl;
|
---|
391 |
|
---|
392 | }
|
---|
393 |
|
---|
394 | /*
|
---|
395 | TF1 *logg = new TF1("logg","[1]+TMath::Log(x-[0])",1.,30.,2);
|
---|
396 | logg->SetParameters(1.,3.5);
|
---|
397 | logg->SetParLimits(0,-1.,3.);
|
---|
398 | logg->SetParLimits(1,-1.,7.);
|
---|
399 | logg->SetLineColor(kRed);
|
---|
400 | */
|
---|
401 |
|
---|
402 | TCanvas *canvas = new TCanvas("PedstudInner","Pedestal Studies Inner Pixels",600,900);
|
---|
403 | canvas->Divide(2,3);
|
---|
404 | canvas->cd(1);
|
---|
405 |
|
---|
406 | TGraphErrors *gmeaninn = new TGraphErrors(hmeaninn->GetSize(),
|
---|
407 | CreateXaxis(hmeaninn->GetSize(),stepsize),hmeaninn->GetArray(),
|
---|
408 | CreateXaxisErr(hmeaninnerr->GetSize(),stepsize),hmeaninnerr->GetArray());
|
---|
409 | gmeaninn->Draw("A*");
|
---|
410 | gmeaninn->SetTitle("Calculated Mean per Slice Inner Pixels");
|
---|
411 | gmeaninn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
412 | gmeaninn->GetYaxis()->SetTitle("Calculated Mean per slice");
|
---|
413 | // gmeaninn->Fit("pol0");
|
---|
414 | // gmeaninn->GetFunction("pol0")->SetLineColor(kGreen);
|
---|
415 | // // gmeaninn->Fit(logg);
|
---|
416 |
|
---|
417 | canvas->cd(2);
|
---|
418 |
|
---|
419 | TGraphErrors *gmuinn = new TGraphErrors(hmuinn->GetSize(),
|
---|
420 | CreateXaxis(hmuinn->GetSize(),stepsize),hmuinn->GetArray(),
|
---|
421 | CreateXaxisErr(hmuinnerr->GetSize(),stepsize),hmuinnerr->GetArray());
|
---|
422 | gmuinn->Draw("A*");
|
---|
423 | gmuinn->SetTitle("Fitted Mean per Slice Inner Pixels");
|
---|
424 | gmuinn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
425 | gmuinn->GetYaxis()->SetTitle("Fitted Mean per Slice");
|
---|
426 | // gmuinn->Fit("pol0");
|
---|
427 | // gmuinn->GetFunction("pol0")->SetLineColor(kGreen);
|
---|
428 | //gmuinn->Fit(logg);
|
---|
429 |
|
---|
430 |
|
---|
431 | canvas->cd(3);
|
---|
432 |
|
---|
433 | TGraphErrors *grmsinn = new TGraphErrors(hrmsinn->GetSize(),
|
---|
434 | CreateXaxis(hrmsinn->GetSize(),stepsize),hrmsinn->GetArray(),
|
---|
435 | CreateXaxisErr(hrmsinnerr->GetSize(),stepsize),hrmsinnerr->GetArray());
|
---|
436 | grmsinn->Draw("A*");
|
---|
437 | grmsinn->SetTitle("Calculated Rms per Slice Inner Pixels");
|
---|
438 | grmsinn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
439 | grmsinn->GetYaxis()->SetTitle("Calculated Rms per Slice");
|
---|
440 | // //grmsinn->Fit("pol2");
|
---|
441 | // //grmsinn->GetFunction("pol2")->SetLineColor(kRed);
|
---|
442 | // grmsinn->Fit(logg);
|
---|
443 |
|
---|
444 | canvas->cd(4);
|
---|
445 |
|
---|
446 | TGraphErrors *gsigmainn = new TGraphErrors(hsigmainn->GetSize(),
|
---|
447 | CreateXaxis(hsigmainn->GetSize(),stepsize),hsigmainn->GetArray(),
|
---|
448 | CreateXaxisErr(hsigmainnerr->GetSize(),stepsize),hsigmainnerr->GetArray());
|
---|
449 | gsigmainn->Draw("A*");
|
---|
450 | gsigmainn->SetTitle("Fitted Sigma per Slice Inner Pixels");
|
---|
451 | gsigmainn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
452 | gsigmainn->GetYaxis()->SetTitle("Fitted Sigma per Slice");
|
---|
453 | // // gsigmainn->Fit("pol2");
|
---|
454 | // // gsigmainn->GetFunction("pol2")->SetLineColor(kRed);
|
---|
455 | // gsigmainn->Fit(logg);
|
---|
456 |
|
---|
457 | canvas->cd(5);
|
---|
458 |
|
---|
459 | TGraphErrors *gmeandiffinn = new TGraphErrors(hmeandiffinn->GetSize(),
|
---|
460 | CreateXaxis(hmeandiffinn->GetSize(),stepsize),hmeandiffinn->GetArray(),
|
---|
461 | CreateXaxisErr(hmeandiffinnerr->GetSize(),stepsize),hmeandiffinnerr->GetArray());
|
---|
462 | gmeandiffinn->Draw("A*");
|
---|
463 | gmeandiffinn->SetTitle("Rel. Difference Mean per Slice Inner Pixels");
|
---|
464 | gmeandiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
465 | gmeandiffinn->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
|
---|
466 | // //gmeandiffinn->Fit("pol2");
|
---|
467 | // //gmeandiffinn->GetFunction("pol2")->SetLineColor(kBlue);
|
---|
468 | // gmeandiffinn->Fit(logg);
|
---|
469 |
|
---|
470 |
|
---|
471 | canvas->cd(6);
|
---|
472 |
|
---|
473 | TGraphErrors *grmsdiffinn = new TGraphErrors(hrmsdiffinn->GetSize(),
|
---|
474 | CreateXaxis(hrmsdiffinn->GetSize(),stepsize),hrmsdiffinn->GetArray(),
|
---|
475 | CreateXaxisErr(hrmsdiffinnerr->GetSize(),stepsize),hrmsdiffinnerr->GetArray());
|
---|
476 | grmsdiffinn->Draw("A*");
|
---|
477 | grmsdiffinn->SetTitle("Rel. Difference Sigma per Slice-RMS Inner Pixels");
|
---|
478 | grmsdiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
479 | grmsdiffinn->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
|
---|
480 | // //grmsdiffinn->Fit("pol2");
|
---|
481 | // //grmsdiffinn->GetFunction("pol2")->SetLineColor(kBlue);
|
---|
482 | // grmsdiffinn->Fit(logg);
|
---|
483 |
|
---|
484 | canvas->SaveAs("PedestalStudyInner.root");
|
---|
485 | canvas->SaveAs("PedestalStudyInner.ps");
|
---|
486 |
|
---|
487 | TCanvas *canvas2 = new TCanvas("PedstudOut","Pedestal Studies Outer Pixels",600,900);
|
---|
488 | canvas2->Divide(2,3);
|
---|
489 | canvas2->cd(1);
|
---|
490 |
|
---|
491 | TGraphErrors *gmeanout = new TGraphErrors(hmeanout->GetSize(),
|
---|
492 | CreateXaxis(hmeanout->GetSize(),stepsize),hmeanout->GetArray(),
|
---|
493 | CreateXaxisErr(hmeanouterr->GetSize(),stepsize),hmeanouterr->GetArray());
|
---|
494 | gmeanout->Draw("A*");
|
---|
495 | gmeanout->SetTitle("Calculated Mean per Slice Outer Pixels");
|
---|
496 | gmeanout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
497 | gmeanout->GetYaxis()->SetTitle("Calculated Mean per Slice");
|
---|
498 | // gmeanout->Fit("pol0");
|
---|
499 | // gmeanout->GetFunction("pol0")->SetLineColor(kGreen);
|
---|
500 | //gmeanout->Fit(logg);
|
---|
501 |
|
---|
502 | canvas2->cd(2);
|
---|
503 |
|
---|
504 | TGraphErrors *gmuout = new TGraphErrors(hmuout->GetSize(),
|
---|
505 | CreateXaxis(hmuout->GetSize(),stepsize),hmuout->GetArray(),
|
---|
506 | CreateXaxisErr(hmuouterr->GetSize(),stepsize),hmuouterr->GetArray());
|
---|
507 | gmuout->Draw("A*");
|
---|
508 | gmuout->SetTitle("Fitted Mean per Slice Outer Pixels");
|
---|
509 | gmuout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
510 | gmuout->GetYaxis()->SetTitle("Fitted Mean per Slice");
|
---|
511 | // gmuout->Fit("pol0");
|
---|
512 | // gmuout->GetFunction("pol0")->SetLineColor(kGreen);
|
---|
513 | //gmuout->Fit(logg);
|
---|
514 |
|
---|
515 | canvas2->cd(3);
|
---|
516 |
|
---|
517 | TGraphErrors *grmsout = new TGraphErrors(hrmsout->GetSize(),
|
---|
518 | CreateXaxis(hrmsout->GetSize(),stepsize),hrmsout->GetArray(),
|
---|
519 | CreateXaxisErr(hrmsouterr->GetSize(),stepsize),hrmsouterr->GetArray());
|
---|
520 | grmsout->Draw("A*");
|
---|
521 | grmsout->SetTitle("Calculated Rms per Slice Outer Pixels");
|
---|
522 | grmsout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
523 | grmsout->GetYaxis()->SetTitle("Calculated Rms per Slice");
|
---|
524 | // //grmsout->Fit("pol2");
|
---|
525 | // //grmsout->GetFunction("pol2")->SetLineColor(kRed);
|
---|
526 | // grmsout->Fit(logg);
|
---|
527 |
|
---|
528 | canvas2->cd(4);
|
---|
529 |
|
---|
530 | TGraphErrors *gsigmaout = new TGraphErrors(hsigmaout->GetSize(),
|
---|
531 | CreateXaxis(hsigmaout->GetSize(),stepsize),hsigmaout->GetArray(),
|
---|
532 | CreateXaxisErr(hsigmaouterr->GetSize(),stepsize),hsigmaouterr->GetArray());
|
---|
533 | gsigmaout->Draw("A*");
|
---|
534 | gsigmaout->SetTitle("Fitted Sigma per Slice Outer Pixels");
|
---|
535 | gsigmaout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
536 | gsigmaout->GetYaxis()->SetTitle("Fitted Sigma per Slice");
|
---|
537 | // //gsigmaout->Fit("pol2");
|
---|
538 | // //gsigmaout->GetFunction("pol2")->SetLineColor(kRed);
|
---|
539 | // gsigmaout->Fit(logg);
|
---|
540 |
|
---|
541 |
|
---|
542 | canvas2->cd(5);
|
---|
543 |
|
---|
544 | TGraphErrors *gmeandiffout = new TGraphErrors(hmeandiffout->GetSize(),
|
---|
545 | CreateXaxis(hmeandiffout->GetSize(),stepsize),hmeandiffout->GetArray(),
|
---|
546 | CreateXaxisErr(hmeandiffouterr->GetSize(),stepsize),hmeandiffouterr->GetArray());
|
---|
547 | gmeandiffout->Draw("A*");
|
---|
548 | gmeandiffout->SetTitle("Rel. Difference Mean per Slice Outer Pixels");
|
---|
549 | gmeandiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
550 | gmeandiffout->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
|
---|
551 | // //gmeandiffout->Fit("pol2");
|
---|
552 | //w //gmeandiffout->GetFunction("pol2")->SetLineColor(kBlue);
|
---|
553 | // gmeandiffout->Fit(logg);
|
---|
554 |
|
---|
555 | canvas2->cd(6);
|
---|
556 |
|
---|
557 | TGraphErrors *grmsdiffout = new TGraphErrors(hrmsdiffout->GetSize(),
|
---|
558 | CreateXaxis(hrmsdiffout->GetSize(),stepsize),hrmsdiffout->GetArray(),
|
---|
559 | CreateXaxisErr(hrmsdiffouterr->GetSize(),stepsize),hrmsdiffouterr->GetArray());
|
---|
560 | grmsdiffout->Draw("A*");
|
---|
561 | grmsdiffout->SetTitle("Rel. Difference Sigma per Slice-RMS Outer Pixels");
|
---|
562 | grmsdiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
|
---|
563 | grmsdiffout->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
|
---|
564 | // //grmsdiffout->Fit("pol2");
|
---|
565 | // //grmsdiffout->GetFunction("pol2")->SetLineColor(kBlue);
|
---|
566 | // grmsdiffout->Fit(logg);
|
---|
567 |
|
---|
568 |
|
---|
569 | canvas2->SaveAs("PedestalStudyOuter.root");
|
---|
570 | canvas2->SaveAs("PedestalStudyOuter.ps");
|
---|
571 |
|
---|
572 |
|
---|
573 | }
|
---|
574 |
|
---|
575 |
|
---|
576 | void CamDraw(TCanvas &c, MHCamera &cam, Int_t i, Int_t j, TArrayF &a1, TArrayF &a2,
|
---|
577 | TArrayF &a1err, TArrayF &a2err, Int_t samp, Int_t stepsize)
|
---|
578 | {
|
---|
579 |
|
---|
580 | c.cd(i);
|
---|
581 | MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
|
---|
582 | obj1->SetDirectory(NULL);
|
---|
583 |
|
---|
584 | c.cd(i+j);
|
---|
585 | obj1->Draw();
|
---|
586 | ((MHCamera*)obj1)->SetPrettyPalette();
|
---|
587 |
|
---|
588 | c.cd(i+2*j);
|
---|
589 | TH1D *obj2 = (TH1D*)obj1->Projection();
|
---|
590 | obj2->SetDirectory(NULL);
|
---|
591 |
|
---|
592 | // obj2->Sumw2();
|
---|
593 | obj2->Draw();
|
---|
594 | obj2->SetBit(kCanDelete);
|
---|
595 |
|
---|
596 | const Double_t min = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
|
---|
597 | const Double_t max = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
|
---|
598 | const Double_t integ = obj2->Integral("width")/2.5066283;
|
---|
599 | const Double_t mean = obj2->GetMean();
|
---|
600 | const Double_t rms = obj2->GetRMS();
|
---|
601 | const Double_t width = max-min;
|
---|
602 |
|
---|
603 | if (rms == 0. || width == 0. )
|
---|
604 | return;
|
---|
605 |
|
---|
606 | TArrayI s0(6);
|
---|
607 | s0[0] = 6;
|
---|
608 | s0[1] = 1;
|
---|
609 | s0[2] = 2;
|
---|
610 | s0[3] = 3;
|
---|
611 | s0[4] = 4;
|
---|
612 | s0[5] = 5;
|
---|
613 |
|
---|
614 | TArrayI inner(1);
|
---|
615 | inner[0] = 0;
|
---|
616 |
|
---|
617 | TArrayI outer(1);
|
---|
618 | outer[0] = 1;
|
---|
619 |
|
---|
620 | // Just to get the right (maximum) binning
|
---|
621 | TH1D *half[2];
|
---|
622 | half[0] = obj1->ProjectionS(s0, inner, "Inner");
|
---|
623 | half[1] = obj1->ProjectionS(s0, outer, "Outer");
|
---|
624 |
|
---|
625 | half[0]->SetDirectory(NULL);
|
---|
626 | half[1]->SetDirectory(NULL);
|
---|
627 |
|
---|
628 | for (int i=0; i<2; i++)
|
---|
629 | {
|
---|
630 | half[i]->SetLineColor(kRed+i);
|
---|
631 | half[i]->SetDirectory(0);
|
---|
632 | half[i]->SetBit(kCanDelete);
|
---|
633 | half[i]->Draw("same");
|
---|
634 | half[i]->Fit("gaus","Q+");
|
---|
635 |
|
---|
636 | if (i==0)
|
---|
637 | {
|
---|
638 | a1[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
|
---|
639 | a1err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
|
---|
640 | if (a1err[(samp-1)/stepsize] > 3.)
|
---|
641 | a1err[(samp-1)/stepsize] = 1.;
|
---|
642 | }
|
---|
643 | if (i==1)
|
---|
644 | {
|
---|
645 | a2[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
|
---|
646 | a2err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
|
---|
647 | if (a2err[(samp-1)/stepsize] > 3.)
|
---|
648 | a2err[(samp-1)/stepsize] = 1.;
|
---|
649 | }
|
---|
650 | }
|
---|
651 |
|
---|
652 |
|
---|
653 | }
|
---|
654 |
|
---|
655 | // -----------------------------------------------------------------------------
|
---|
656 | //
|
---|
657 | // Create the x-axis for the event graph
|
---|
658 | //
|
---|
659 | Float_t *CreateXaxis(Int_t n, Int_t step)
|
---|
660 | {
|
---|
661 |
|
---|
662 | Float_t *xaxis = new Float_t[n];
|
---|
663 |
|
---|
664 | for (Int_t i=0;i<n;i++)
|
---|
665 | xaxis[i] = 2. + step*i;
|
---|
666 |
|
---|
667 | return xaxis;
|
---|
668 |
|
---|
669 | }
|
---|
670 |
|
---|
671 | // -----------------------------------------------------------------------------
|
---|
672 | //
|
---|
673 | // Create the x-axis for the event graph
|
---|
674 | //
|
---|
675 | Float_t *CreateXaxisErr(Int_t n, Int_t step)
|
---|
676 | {
|
---|
677 |
|
---|
678 | Float_t *xaxis = new Float_t[n];
|
---|
679 |
|
---|
680 | for (Int_t i=0;i<n;i++)
|
---|
681 | xaxis[i] = step/2.;
|
---|
682 |
|
---|
683 | return xaxis;
|
---|
684 |
|
---|
685 | }
|
---|