-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgiotto.cc
More file actions
58 lines (47 loc) · 1.63 KB
/
Copy pathgiotto.cc
File metadata and controls
58 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <algorithm>
#include <numeric>
#include <TAxis.h>
#include <TSystem.h>
#include "giotto.hh"
#include "evaristo.hh"
#include "sibilla.hh"
#include "attila.hh"
#include <iostream>
#include <cstdlib>
giotto::giotto () {
if (sibilla::evoke ()("quiet")) { window = 0; return; }
if (!std::getenv("DISPLAY")) ATTILA << "DISPLAY not set";
int arg = 0;
app = std::unique_ptr<TApplication>(new TApplication("application",&arg,0));
window = std::unique_ptr<TCanvas>(new TCanvas());
}
giotto::~giotto () {
graphs.resize(0);
window = 0;
app = 0;
}
void giotto::draw (evaristo* ev) {
if (!window || !ev->n_channels) return;
window->cd();
if (graphs.size () != ev->n_channels || graphs[0]->GetN () != int(ev->n_samples)) {
graphs.clear ();
graphs.resize (ev->n_channels);
for (size_t i = 0; i < ev->n_channels; i++) {
graphs[i] = std::unique_ptr<TGraph>(new TGraph(ev->n_samples));
std::iota (graphs[i]->GetX (), graphs[i]->GetX () + graphs[i]->GetN (), 0);
}
}
u_int16_t up=0, down=-1;
for (size_t i = 0; i < ev->n_channels; i++) {
std::copy (ev->samples + ev->n_samples * i, ev->samples + ev->n_samples * (i + 1), graphs[i]->GetY ());
up = std::max(*std::max_element (ev->samples + ev->n_samples * i, ev->samples + ev->n_samples * (i + 1)), up);
down = std::min(*std::min_element (ev->samples + ev->n_samples * i, ev->samples + ev->n_samples * (i + 1)), down);
}
for (size_t i = 0; i < ev->n_channels; i++) {
graphs[i]->GetYaxis()->SetRangeUser (down, up);
if (i == 0) graphs[i]->Draw ("AL+");
else graphs[i]->Draw ("L+S");
}
window->Update();
gSystem->ProcessEvents();
}