]>
Commit | Line | Data |
---|---|---|
7466ae1c | 1 | //____________________________________________________________________ |
2 | // | |
3 | // $Id: VA1Train.C 13249 2006-03-24 16:09:36Z cholm $ | |
4 | // | |
5 | // Small script that shows a signal train from a VA1 pre-amp. | |
6 | // | |
7 | /** Make VA1 sample train | |
8 | @ingroup simple_script | |
9 | */ | |
10 | void | |
11 | VA1Train() | |
12 | { | |
13 | gStyle->SetOptTitle(0); | |
14 | gStyle->SetOptFit(0); | |
15 | gStyle->SetOptStat(0); | |
16 | gStyle->SetLabelFont(132, "xyz"); | |
17 | gStyle->SetTitleFont(132, "xyz"); | |
18 | gStyle->SetTitleSize(0.08, "y"); | |
19 | gStyle->SetTitleOffset(0.5, "y"); | |
20 | gStyle->SetTitleSize(0.06, "x"); | |
21 | gStyle->SetTitleOffset(0.7, "x"); | |
22 | ||
23 | TCanvas* c = new TCanvas("c", "C", 800, 500); | |
24 | c->SetFillColor(0); | |
25 | c->SetBorderMode(0); | |
26 | c->SetBorderSize(0); | |
27 | c->SetTopMargin(0.05); | |
28 | c->SetRightMargin(0.05); | |
29 | c->SetGridx(); | |
30 | c->SetGridy(); | |
31 | ||
32 | TArrayF measurements(6); | |
33 | std::cout << "Measurements are: " << std::flush; | |
34 | for (Int_t i = 0; i < measurements.fN; i++) { | |
35 | measurements[i] = gRandom->Uniform(0,1); | |
36 | std::cout << measurements[i] << " " << std::flush; | |
37 | } | |
38 | std::cout << std::endl; | |
39 | ||
40 | Float_t last = 0; | |
41 | Float_t B = 5; | |
42 | TH2* frame = new TH2F("frame", "Frame", measurements.fN, -.1, | |
43 | measurements.fN+.1, 10, 0, 1.05); | |
44 | frame->Draw(); | |
45 | // frame->GetYaxis()->SetRangeUser(0, 1.05); | |
46 | // frame->GetXaxis()->SetRangeUser(-.1, measurements.fN+.1); | |
47 | frame->GetXaxis()->SetNdivisions(measurements.fN+2, kTRUE); | |
48 | frame->GetYaxis()->SetNdivisions(10, kTRUE); | |
49 | frame->SetXTitle("t"); | |
50 | frame->SetYTitle(Form("1-e^{-%3.1f t}", B)); | |
51 | ||
52 | for (Int_t i = 0; i < measurements.fN; i++) { | |
53 | TF1* f = new TF1("f", "[2] + exp(-[1] * (x - [3])) * ([0] - [2])", | |
54 | i, i + 1); | |
55 | f->SetParameter(3, i); | |
56 | f->SetParameter(1, B); | |
57 | f->SetParameter(2, measurements[i]); | |
58 | f->SetParameter(0, last); | |
59 | ||
60 | f->Draw("same"); | |
61 | f->SetLineColor(kRed+i/2); | |
62 | last = measurements[i]; | |
63 | } | |
64 | ||
65 | TLatex* l = new TLatex(measurements.fN/2, .9, | |
66 | "#Delta_{i} + (#Delta_{i-1}-#Delta_{i}) e^{-b (t-i)}"); | |
67 | l->SetTextAlign(22); | |
68 | l->SetTextFont(132); | |
69 | l->Draw(); | |
70 | ||
71 | c->SaveAs("va1_train.png"); | |
72 | } | |
73 | //____________________________________________________________________ | |
74 | // | |
75 | // EOF | |
76 | // |