Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Utility
test
test_LineColors.cxx
Go to the documentation of this file.
1
// test_LineColors.cxx
2
3
// David Adams
4
// Feruary 2018
5
//
6
// This is a test and demonstration for LineColors.
7
8
#undef NDEBUG
9
10
#include "../LineColors.h"
11
#include <string>
12
#include <iostream>
13
#include <iomanip>
14
#include <cassert>
15
#include <vector>
16
#include "TH1F.h"
17
#include "TCanvas.h"
18
19
using
std::string
;
20
using
std::cout;
21
using
std::endl
;
22
using
std::setw
;
23
using
std::vector
;
24
25
//**********************************************************************
26
27
int
test_LineColors
() {
28
const
string
myname =
"test_LineColors: "
;
29
cout << myname <<
"Starting test"
<<
endl
;
30
#ifdef NDEBUG
31
cout << myname <<
"NDEBUG must be off."
<<
endl
;
32
abort();
33
#endif
34
string
line
=
"-----------------------------"
;
35
string
scfg;
36
37
cout << myname << line <<
endl
;
38
cout << myname <<
"Create histos."
<<
endl
;
39
TH1* ph0 =
new
TH1F(
"hrate"
,
"Rate; x; y"
, 50, 0, 10);
40
ph0->SetStats(0);
41
ph0->SetLineWidth(2);
42
for
(
int
ibin=0; ibin<50; ++ibin ) {
43
ph0->SetBinContent(ibin+1, 0.02*ibin);
44
}
45
vector<TH1*> hsts;
46
LineColors
lc;
47
LineColors::Index
ncol = 12;
48
for
(
LineColors::Index
iidx=0; iidx<ncol; ++iidx ) {
49
LineColors::ColorType
icol = lc.
color
(iidx, ncol);
50
cout << myname << iidx <<
": "
<< icol <<
endl
;
51
TH1* ph =
dynamic_cast<
TH1*
>
(ph0->Clone());
52
ph->Scale(iidx+1);
53
ph->SetLineColor(icol);
54
hsts.push_back(ph);
55
}
56
57
cout << myname << line <<
endl
;
58
cout << myname <<
"Draw histos."
<<
endl
;
59
TCanvas* pcan =
new
TCanvas;
60
ph0->SetMaximum(ncol + 0.2);
61
ph0->Draw(
"axis"
);
62
for
( TH1* ph : hsts ) ph->Draw(
"hist same"
);
63
pcan->RedrawAxis();
64
pcan->Print(
"test_LineColors.png"
);
65
66
return
0;
67
}
68
69
//**********************************************************************
70
71
int
main
() {
72
return
test_LineColors
();
73
}
74
75
//**********************************************************************
main
int main()
Definition:
test_LineColors.cxx:71
string
std::string string
Definition:
nybbler.cc:12
vector
struct vector vector
LineColors::ColorType
int ColorType
Definition:
LineColors.h:20
LineColors::color
static ColorType color(Index icolin, Index ncol=size())
Definition:
LineColors.h:43
LineColors
Definition:
LineColors.h:16
LineColors::Index
unsigned int Index
Definition:
LineColors.h:21
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
test_LineColors
int test_LineColors()
Definition:
test_LineColors.cxx:27
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11