21 #include <TAttMarker.h>
22 #include <TCollection.h>
31 #include <TLegendEntry.h>
71 TStyle* defaultSty =
new TStyle(
"default",
"default");
72 defaultSty->SetPaperSize(TStyle::kA4);
73 defaultSty->SetTextFont(font);
76 defaultSty->SetCanvasBorderMode(0);
77 defaultSty->SetCanvasColor(bgrdcolor);
78 defaultSty->SetCanvasDefH(600);
79 defaultSty->SetCanvasDefW(600);
80 defaultSty->SetCanvasDefX(0);
81 defaultSty->SetCanvasDefY(0);
84 defaultSty->SetPadBorderMode(0);
86 defaultSty->SetPadColor(bgrdcolor);
87 defaultSty->SetPadGridX(
false);
88 defaultSty->SetPadGridY(
false);
89 defaultSty->SetGridColor(0);
90 defaultSty->SetGridStyle(3);
91 defaultSty->SetGridWidth(1);
94 defaultSty->SetFrameBorderMode(0);
95 defaultSty->SetFrameBorderSize(1);
96 defaultSty->SetFrameFillColor(bgrdcolor);
97 defaultSty->SetFrameFillStyle(0);
98 defaultSty->SetFrameLineColor(1);
99 defaultSty->SetFrameLineStyle(1);
100 defaultSty->SetFrameLineWidth(1);
103 defaultSty->SetPadTopMargin(0.075);
104 defaultSty->SetPadBottomMargin(0.18);
105 defaultSty->SetPadLeftMargin(0.18);
106 defaultSty->SetPadRightMargin(0.075);
109 defaultSty->SetHistFillColor(bgrdcolor);
111 defaultSty->SetHatchesSpacing(2.);
112 defaultSty->SetHatchesLineWidth(2);
113 defaultSty->SetHistLineColor(1);
114 defaultSty->SetHistLineStyle(0);
115 defaultSty->SetHistLineWidth(2);
117 defaultSty->SetHistMinimumZero();
119 defaultSty->SetErrorX(0.0);
120 defaultSty->SetLineColor(1);
121 defaultSty->SetMarkerColor(1);
122 defaultSty->SetMarkerStyle(kFullCircle);
123 defaultSty->SetMarkerSize(1.5);
127 defaultSty->SetOptFit(1);
128 defaultSty->SetFitFormat(
"5.4g");
129 defaultSty->SetFuncColor(2);
130 defaultSty->SetFuncStyle(1);
131 defaultSty->SetFuncWidth(1);
134 defaultSty->SetOptDate(22);
137 defaultSty->GetAttDate()->SetTextColor(kGray);
138 defaultSty->GetAttDate()->SetTextFont(font);
139 defaultSty->GetAttDate()->SetTextSize(0.02);
142 defaultSty->SetOptFile(0);
143 defaultSty->SetOptStat(
146 defaultSty->SetStatColor(kWhite);
147 defaultSty->SetStatFont(font);
148 defaultSty->SetStatFontSize(0.02);
149 defaultSty->SetStatTextColor(kGray);
150 defaultSty->SetStatFormat(
"6.4g");
151 defaultSty->SetStatBorderSize(1);
152 defaultSty->SetStatH(0.1);
153 defaultSty->SetStatW(0.5);
154 defaultSty->SetStatStyle(kFEmpty);
155 defaultSty->SetStatX(0.01);
156 defaultSty->SetStatY(0.01);
159 defaultSty->SetOptTitle(0);
160 defaultSty->SetTitleFont(font,
"T");
161 defaultSty->SetTitleSize(0.05,
"T");
162 defaultSty->SetTitleColor(bgrdcolor,
"T");
163 defaultSty->SetTitleTextColor(1);
164 defaultSty->SetTitleFillColor(bgrdcolor);
165 defaultSty->SetTitleFontSize(0.06);
167 defaultSty->SetTitleW(0.5);
168 defaultSty->SetTitleX(0.25);
170 defaultSty->SetTitleStyle(kFEmpty);
172 defaultSty->SetPaintTextFormat(
177 defaultSty->SetFillStyle(kFEmpty);
178 defaultSty->SetLineColor(0);
179 defaultSty->SetLineWidth(0);
180 defaultSty->SetLineStyle(1);
183 defaultSty->SetTitleColor(1,
"XYZ");
184 defaultSty->SetTitleFont(font,
"XYZ");
185 defaultSty->SetTitleSize(0.06,
"XYZ");
188 defaultSty->SetTitleXOffset(1.0);
189 defaultSty->SetTitleYOffset(1.25);
193 defaultSty->SetLabelColor(1,
"XYZ");
194 defaultSty->SetLabelFont(font,
"XYZ");
195 defaultSty->SetLabelOffset(0.007,
"XYZ");
196 defaultSty->SetLabelSize(0.04,
198 defaultSty->SetLabelSize(0.03,
202 defaultSty->SetHistMinimumZero();
203 defaultSty->SetAxisColor(1,
"XYZ");
206 defaultSty->SetNdivisions(
208 defaultSty->SetPadTickX(
210 defaultSty->SetPadTickY(1);
213 defaultSty->SetOptLogx(0);
214 defaultSty->SetOptLogy(0);
215 defaultSty->SetOptLogz(0);
219 const Int_t NRGBs = 5;
220 const Int_t NCont = 255;
222 Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
223 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
226 Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
227 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
228 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
229 defaultSty->SetNumberContours(NCont);
233 defaultSty->SetLegendFillColor(bgrdcolor);
235 defaultSty->SetLegendFont(font);
239 defaultSty->SetFillStyle(4000);
240 defaultSty->SetStatStyle(0);
241 defaultSty->SetTitleStyle(0);
242 defaultSty->SetCanvasBorderSize(0);
243 defaultSty->SetFrameBorderSize(0);
244 defaultSty->SetLegendBorderSize(0);
245 defaultSty->SetStatBorderSize(0);
246 defaultSty->SetTitleBorderSize(0);
256 TGaxis::SetMaxDigits(3);
257 TGaxis::SetExponentOffset(-1. * 0.06, 0.,
"y");
270 if (obj->InheritsFrom(TH1::Class()) && gPad) {
272 dynamic_cast<TH1*
>(obj)->GetXaxis()->SetName(
"xaxis");
273 dynamic_cast<TH1*
>(obj)->GetYaxis()->SetName(
"yaxis");
275 if (gPad->GetLogx()) {
276 dynamic_cast<TH1*
>(obj)->GetXaxis()->SetMoreLogLabels(kTRUE);
277 dynamic_cast<TH1*
>(obj)->GetXaxis()->SetNoExponent(kTRUE);
279 if (gPad->GetLogy()) {
280 dynamic_cast<TH1*
>(obj)->GetYaxis()->SetMoreLogLabels(kTRUE);
281 dynamic_cast<TH1*
>(obj)->GetYaxis()->SetNoExponent(kTRUE);
283 if (gPad->GetLogz()) {
284 dynamic_cast<TH1*
>(obj)->GetZaxis()->SetMoreLogLabels(kTRUE);
285 dynamic_cast<TH1*
>(obj)->GetZaxis()->SetNoExponent(kTRUE);
290 if (obj->InheritsFrom(TAttMarker::Class())) {
292 dynamic_cast<TAttMarker*
>(obj)->SetMarkerSize(
fSze[idx -
kRaw]);
293 dynamic_cast<TAttMarker*
>(obj)->SetMarkerStyle(
fMrk[idx -
kRaw]);
294 dynamic_cast<TAttMarker*
>(obj)->SetMarkerColor(
fCol[idx -
kRaw]);
296 dynamic_cast<TAttMarker*
>(obj)->SetMarkerSize(1.5);
298 dynamic_cast<TAttMarker*
>(obj)->SetMarkerColor(
Color[idx %
kNMaxColor]);
301 dynamic_cast<TAttMarker*
>(obj)->SetMarkerColor(
302 TColor::GetColorDark(
Color[idx]));
305 dynamic_cast<TAttMarker*
>(obj)->SetMarkerColor(
306 TColor::GetColorBright(
Color[idx]));
312 if (obj->InheritsFrom(TAttLine::Class())) {
315 dynamic_cast<TAttLine*
>(obj)->SetLineWidth(
fWdt[idx -
kRaw]);
316 dynamic_cast<TAttLine*
>(obj)->SetLineStyle(
fLne[idx -
kRaw]);
317 dynamic_cast<TAttLine*
>(obj)->SetLineColor(
fCol[idx -
kRaw]);
319 dynamic_cast<TAttLine*
>(obj)->SetLineWidth(2);
320 dynamic_cast<TAttLine*
>(obj)->SetLineStyle(
Line[idx %
kNMaxLine]);
324 dynamic_cast<TAttLine*
>(obj)->SetLineColor(
325 TColor::GetColorDark(
Color[idx]));
328 dynamic_cast<TAttLine*
>(obj)->SetLineColor(
329 TColor::GetColorBright(
Color[idx]));
335 if (obj->InheritsFrom(TAttFill::Class())) {
337 if (idx >= 100 &&
fFll[idx -
kRaw] >= 0) {
338 dynamic_cast<TAttFill*
>(obj)->SetFillColor(
fCol[idx -
kRaw]);
339 dynamic_cast<TAttFill*
>(obj)->SetFillStyle(
fFll[idx -
kRaw]);
340 }
else if (
Fill[0] >= 0) {
344 dynamic_cast<TAttFill*
>(obj)->SetFillColor(
345 TColor::GetColorDark(
Color[idx]));
348 dynamic_cast<TAttFill*
>(obj)->SetFillColor(
349 TColor::GetColorBright(
Color[idx]));
351 dynamic_cast<TAttFill*
>(obj)->SetFillStyle(
Fill[0]);
401 case kOpenTriangleUp:
404 case kOpenTriangleDown:
422 case kFullTriangleUp:
425 case kFullTriangleDown:
478 Double_t maxhgth = 0.0;
479 Double_t symblwdth = 0.065;
480 Double_t txtsze = 0.04;
482 Double_t entrysep = 1.25;
485 Double_t maxwdth = 0.0;
486 TList* llist = leg->GetListOfPrimitives();
487 Int_t nent = llist->GetEntries();
489 if (nent > 5) txtsze = 0.03;
490 leg->SetTextSize(txtsze);
494 for (Int_t il = 0; il < nent; il++) {
495 TLegendEntry* lent =
static_cast<TLegendEntry*
>(llist->At(il));
496 TString lst(lent->GetLabel());
499 lst.ReplaceAll(
"{",
"");
500 lst.ReplaceAll(
"}",
"");
501 lst.ReplaceAll(
"^",
"");
502 lst.ReplaceAll(
"_",
"");
503 lst.ReplaceAll(
"#LT",
"#");
504 lst.ReplaceAll(
"#GT",
"#");
505 lst.ReplaceAll(
"#phi",
"#");
506 lst.ReplaceAll(
"#rho",
"#");
507 lst.ReplaceAll(
"#omega",
"#");
508 lst.ReplaceAll(
"#eta",
"#");
509 lst.ReplaceAll(
"#epsilon",
"#");
510 lst.ReplaceAll(
"#psi",
"#");
511 lst.ReplaceAll(
"#pi",
"#");
512 lst.ReplaceAll(
"#alpha",
"#");
513 lst.ReplaceAll(
"#gamma",
"#");
514 lst.ReplaceAll(
"#rightarrow",
"#");
517 TLatex entrytex(0., 0., lst.Data());
518 entrytex.SetNDC(kTRUE);
519 entrytex.SetTextSize(txtsze);
520 entrytex.SetTextFont(gStyle->GetLegendFont());
522 Double_t wdth = entrytex.GetXsize();
523 Double_t hgth = entrytex.GetYsize();
525 if (maxwdth < wdth) maxwdth = wdth;
531 maxhgth = nent * txtsze * entrysep;
537 leg->SetY2(1. - gPad->GetTopMargin() - gStyle->GetTickLength(
"X"));
538 leg->SetY1(leg->GetY2() - maxhgth);
540 leg->SetY1(0. + gPad->GetBottomMargin() + gStyle->GetTickLength(
"X"));
541 leg->SetY2(leg->GetY1() + maxhgth);
544 leg->SetX2(1. - gPad->GetRightMargin()
545 - gStyle->GetTickLength(
"Y") * 1.0);
546 leg->SetX1(leg->GetX2() - maxwdth * 1.0 - symblwdth);
548 leg->SetX1(0. + gPad->GetLeftMargin() + gStyle->GetTickLength(
"Y"));
549 leg->SetX2(leg->GetX1() + maxwdth * 1.0 + symblwdth);
553 leg->SetMargin(symblwdth / (leg->GetX2() - leg->GetX1()));
554 leg->SetEntrySeparation(entrysep - 1.);
558 leg->SetFillStyle(1001);
560 leg->SetFillStyle(kFEmpty);
573 const Int_t NRGBs = 5;
574 const Int_t NCont = 255;
575 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
579 Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
580 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
581 Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
583 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
585 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
589 Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.36};
590 Double_t green[NRGBs] = {0.20, 0.81, 1.00, 0.20, 0.00};
591 Double_t blue[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
593 TColor::CreateGradientColorTable(NRGBs, stops, green, red, blue, NCont);
595 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
601 gStyle->SetNumberContours(NCont);
611 Error(
"GetFirstHistogram",
"No pad found, return NULL pointer!!");
615 TIter nextObj(gPad->GetListOfPrimitives());
617 while ((obj = nextObj())) {
618 if (obj->InheritsFrom(TH1::Class())) {
return (
static_cast<TH1*
>(obj)); }
619 if (obj->InheritsFrom(TGraph::Class())) {
620 return (
static_cast<TH1*
>(
static_cast<TGraph*
>(obj)->GetHistogram()));
622 if (obj->InheritsFrom(THStack::Class())) {
623 return (
static_cast<TH1*
>(
static_cast<THStack*
>(obj)->GetHistogram()));
636 Error(
"GetLegendEntry",
"No pad found, return NULL pointer!!");
640 TList* prim = gPad->GetListOfPrimitives();
641 if (!prim)
return NULL;
642 TLegend* leg =
dynamic_cast<TLegend*
>(prim->FindObject(
"TPave"));
643 if (!leg)
return NULL;
644 TList* entries = leg->GetListOfPrimitives();
645 if (!entries)
return NULL;
646 return (
dynamic_cast<TLegendEntry*
>(entries->At(idx)));