source: releases/Mars.2014.05.26/macros/test/extralgospline.C@ 19594

Last change on this file since 19594 was 8521, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 1.6 KB
Line 
1void extralgospline()
2{
3 Int_t n = 40;
4
5 TArrayF x(n);
6 TArrayF y(n);
7 for (int i=0; i<n; i++)
8 {
9 x[i] = i;
10 y[i] = gRandom->Uniform(10)-5;
11
12 y[n/2-2] = 50;
13 y[n/2-1] = 100;
14 y[n/2] = 110;
15 y[n/2+1] = 70;
16 y[n/2+2] = 30;
17
18 }
19
20 TArrayF d1(n);
21 TArrayF d2(n);
22
23 // Do some handling if maxpos is last slice!
24 MExtralgoSpline s(y.GetArray(), n, d1.GetArray(), d2.GetArray());
25
26 s.SetHeightTm(0.5);
27 s.SetRiseFallTime(0.5, 0.5);
28
29 Int_t maxpos = TMath::LocMax(n, y.GetArray());
30
31 Float_t time, dtime, sum, dsum, mtime, max;
32 s.SetExtractionType(MExtralgoSpline::kIntegralRel);
33 s.Extract(0, maxpos);
34 s.GetTime(time, dtime);
35 s.GetSignal(sum, dsum);
36
37 s.SetExtractionType(MExtralgoSpline::kAmplitude);
38 s.Extract(0, maxpos);
39 s.GetTime(mtime, dtime);
40 s.GetSignal(max, dsum);
41
42 TGraph gr1(n, x.GetArray(), y.GetArray());
43
44 TGraph gr2;
45 for (int i=0; i<n*10; i++)
46 gr2.SetPoint(gr2.GetN(), 0.1*i, s.EvalAt(0.1*i));
47
48 gr2.SetMarkerColor(kBlue);
49 gr2.SetMarkerStyle(kFullDotMedium);
50 gr1.SetMarkerStyle(kFullDotMedium);
51
52 gr1.DrawClone("AP*");
53 gr2.DrawClone("PL");
54
55 TMarker m;
56 m.SetMarkerStyle(kFullDotMedium);
57 m.SetMarkerColor(kRed);
58 m.DrawMarker(x[maxpos], y[maxpos]);
59
60 TLine line;
61 line.SetLineColor(kRed);
62 line.DrawLine(mtime, max-5, mtime, max+5);
63 line.DrawLine(mtime-0.5, max, mtime+0.5, max);
64 line.SetLineStyle(kDashed);
65 line.DrawLine(time, 0, time, 110);
66
67 gPad->SetGridx();
68 gPad->SetGridy();
69}
Note: See TracBrowser for help on using the repository browser.