Functions
test_LineColors.cxx File Reference
#include "../LineColors.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include "TH1F.h"
#include "TCanvas.h"

Go to the source code of this file.

Functions

int test_LineColors ()
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 71 of file test_LineColors.cxx.

71  {
72  return test_LineColors();
73 }
int test_LineColors()
int test_LineColors ( )

Definition at line 27 of file test_LineColors.cxx.

27  {
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 }
int ColorType
Definition: LineColors.h:20
static ColorType color(Index icolin, Index ncol=size())
Definition: LineColors.h:43
unsigned int Index
Definition: LineColors.h:21
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)