31 const string myname =
"test_RootPalette: ";
32 cout << myname <<
"Starting test" <<
endl;
34 cout << myname <<
"NDEBUG must be off." <<
endl;
37 string line =
"-----------------------------";
40 cout << myname << line <<
endl;
41 cout << myname <<
"Test data" <<
endl;
43 vector<double> peak1 = { 1.5, 6.0, 22.3, 50.3, 74.1, 92.3, 100.0, 95.1, 89.2, 64.3, 40.2, 18.0, 4.8, 0.6 };
44 vector<double> peak2 = { 1.5, 6.0, 22.3, 50.3, 74.1, 92.3, 100.0, 95.1, 89.2, 64.3, 40.2, 18.0, 4.8,
45 -12.0, -26.1, -51.2, -93.7, -95.8, -80.6, -64.3, -49.3, -35.0, -22.1, -15.3,
49 for (
unsigned int ipk=0; ipk<peak1.
size(); ++ipk ) {
50 wf1[ipk] = 0.80*peak1[ipk];
52 for (
unsigned int ipk=0; ipk<peak2.
size(); ++ipk ) {
53 wf2[ipk] = 0.80*peak2[ipk];
56 cout << myname << line <<
endl;
57 cout << myname <<
"Create histogram." <<
endl;
58 TH1* ph1 =
new TH2F(
"h2",
"My histo; Tick; Channel", 100, 0, 100, 50, 0, 50);
59 TH1* ph2 =
new TH2F(
"h2",
"My histo; Tick; Channel", 100, 0, 100, 50, 0, 50);
60 for ( TH1* ph : {ph1, ph2} ) {
69 for (
unsigned int jbin=1; jbin<=100; ++jbin ) {
70 for (
unsigned int ibin=1; ibin<=100; ++ibin ) {
71 int iwf = ( 190 + ibin - jbin)%100;
73 z1 += gRandom->Gaus(0.0, 5.0);
74 ph1->SetBinContent(ibin, jbin, z1);
76 z2 += gRandom->Gaus(0.0, 5.0);
77 ph2->SetBinContent(ibin, jbin, z2);
81 TCanvas* pcan =
new TCanvas;
87 cout << myname << line <<
endl;
88 cout << myname <<
"Draw with default palette." <<
endl;
89 ph->SetTitle(
"Default palette");
90 ncol = gStyle->GetNumberOfColors();
91 cout << myname <<
" Color count: " << ncol <<
endl;
93 pcan->Print(
"test_RootPalette_default.png");
97 cout << myname << line <<
endl;
98 cout << myname <<
"Draw with palette 1010." <<
endl;
101 ncol = gStyle->GetNumberOfColors();
102 cout << myname <<
" Color count: " << ncol <<
endl;
103 ph->SetTitle(
"Palette 1010");
105 pcan->Print(
"test_RootPalette_1010.png");
107 cout << myname << line <<
endl;
108 cout << myname <<
"Draw with palette 1016." <<
endl;
111 ncol = gStyle->GetNumberOfColors();
112 cout << myname <<
" Color count: " << ncol <<
endl;
113 ph->SetTitle(
"Palette 1016");
115 pcan->Print(
"test_RootPalette_1016.png");
117 cout << myname << line <<
endl;
118 cout << myname <<
"Draw with palette 1017." <<
endl;
121 ncol = gStyle->GetNumberOfColors();
122 cout << myname <<
" Color count: " << ncol <<
endl;
123 ph->SetTitle(
"Palette 1017");
125 pcan->Print(
"test_RootPalette_1017.png");
127 cout << myname << line <<
endl;
128 cout << myname <<
"Draw with palette 1019." <<
endl;
131 ncol = gStyle->GetNumberOfColors();
132 cout << myname <<
" Color count: " << ncol <<
endl;
133 ph->SetTitle(
"Palette 1019");
135 pcan->Print(
"test_RootPalette_1019.png");
137 cout << myname << line <<
endl;
138 cout << myname <<
"Draw with palette 1020." <<
endl;
141 ncol = gStyle->GetNumberOfColors();
142 cout << myname <<
" Color count: " << ncol <<
endl;
143 ph->SetTitle(
"Palette 1020");
145 pcan->Print(
"test_RootPalette_1020.png");
147 cout << myname << line <<
endl;
148 cout << myname <<
"Draw with palette 1026." <<
endl;
151 ncol = gStyle->GetNumberOfColors();
152 cout << myname <<
" Color count: " << ncol <<
endl;
153 ph->SetTitle(
"Palette 1026");
155 pcan->Print(
"test_RootPalette_1026.png");
157 cout << myname << line <<
endl;
158 cout << myname <<
"Draw with palette 1027." <<
endl;
161 ncol = gStyle->GetNumberOfColors();
162 cout << myname <<
" Color count: " << ncol <<
endl;
163 ph->SetTitle(
"Palette 1027");
165 pcan->Print(
"test_RootPalette_1027.png");
167 cout << myname << line <<
endl;
168 cout << myname <<
"Draw with palette 1029." <<
endl;
171 ncol = gStyle->GetNumberOfColors();
172 cout << myname <<
" Color count: " << ncol <<
endl;
173 ph->SetTitle(
"Palette 1029");
175 pcan->Print(
"test_RootPalette_1029.png");
177 cout << myname << line <<
endl;
178 cout << myname <<
"Draw with rainbow palette." <<
endl;
181 ncol = gStyle->GetNumberOfColors();
182 cout << myname <<
" Color count: " << ncol <<
endl;
183 ph->SetTitle(
"Palette kRainBow");
185 pcan->Print(
"test_RootPalette_rainbow.png");
187 cout << myname << line <<
endl;
188 cout << myname <<
"Draw with palette zero." <<
endl;
190 ncol = gStyle->GetNumberOfColors();
191 cout << myname <<
" Color count: " << ncol <<
endl;
192 ph->SetTitle(
"Palette zero (default)");
194 pcan->Print(
"test_RootPalette_zero.png");
196 cout << myname << line <<
endl;
197 cout << myname <<
"Draw with invalid palette 720." <<
endl;
199 ncol = gStyle->GetNumberOfColors();
200 cout << myname <<
" Color count: " << ncol <<
endl;
201 ph->SetTitle(
"Palette 720 (invalid)");
203 pcan->Print(
"test_RootPalette_0720.png");
205 cout << myname << line <<
endl;
206 cout << myname <<
"Draw with invalid palette 12." <<
endl;
209 ncol = gStyle->GetNumberOfColors();
210 cout << myname <<
" Color count: " << ncol <<
endl;
211 ph->SetTitle(
"Palette 12 (invalid)");
213 pcan->Print(
"test_RootPalette_0012.png");
215 cout << myname << line <<
endl;
216 cout << myname <<
"Draw with kGistEarthlette inverted." <<
endl;
219 ncol = gStyle->GetNumberOfColors();
220 cout << myname <<
" Color count: " << ncol <<
endl;
221 ph->SetTitle(
"Palette kGistEarth inverted)");
223 pcan->Print(
"test_RootPalette_gistearth.png");
225 cout << myname << line <<
endl;
226 cout << myname <<
"Draw with back body palette." <<
endl;
229 ncol = gStyle->GetNumberOfColors();
230 cout << myname <<
" Color count: " << ncol <<
endl;
231 ph->SetTitle(
"Palette kBlackBody");
233 pcan->Print(
"test_RootPalette_blackbody.png");
235 cout << myname << line <<
endl;
236 cout << myname <<
"Draw with inverted deep sea palette." <<
endl;
239 TColor::InvertPalette();
240 ncol = gStyle->GetNumberOfColors();
241 cout << myname <<
" Color count: " << ncol <<
endl;
242 ph->SetTitle(
"Palette kDeepSea inverted");
244 pcan->Print(
"test_RootPalette_deepsea_inv.png");
246 cout << myname << line <<
endl;
247 cout << myname <<
"Draw with inverted cherry palette." <<
endl;
250 ncol = gStyle->GetNumberOfColors();
251 cout << myname <<
" Color count: " << ncol <<
endl;
252 ph->SetTitle(
"Palette kCherry inverted");
254 pcan->Print(
"test_RootPalette_cherry_inv.png");
256 cout << myname << line <<
endl;
257 cout << myname <<
"Draw with default palette positive." <<
endl;
260 ncol = gStyle->GetNumberOfColors();
261 cout << myname <<
" Color count: " << ncol <<
endl;
262 ph->SetTitle(
"Palette default pos");
264 pcan->Print(
"test_RootPalette_default_pos.png");
266 cout << myname << line <<
endl;
267 cout << myname <<
"Done." <<
endl;
static bool set(int ipal)
static const RootPalette * defaultPalette()
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)