16 * Structure to draw the ALICE logo on a pad (canvas). The logo and
17 * text is drawn using ROOT primitives and the result is somewhat
20 * Note, you can save the logo as a PNG, PDF, or SVG to include it in
21 * some other document or the like.
27 * TH1* h = new TH1F("h", "h", 60, -3, 3);
28 * h->SetFillColor(kRed+1);
29 * h->SetFillStyle(3001);
30 * h->FillRandom("gaus");
33 * gROOT->LoadMacro("AliceLogo.C");
34 * AliceLogo* al = new AliceLogo();
35 * // al->Draw(0, .75, .4, .25, "preliminary");
36 * // al->Draw(0, .75, .4, .25, "performance");
37 * // al->Draw(0, .75, .4, .25, "","text l3 many particles");
38 * al->Draw(0, .75, .4, .25, "preliminary", "text l3 many particles");
42 * There are many options for colours and options for preliminary,
43 * performance and just the logo.
45 * The logo produced does not exactly match the logos found on the
48 * https://aliceinfo.cern.ch/Figure/alice_logo
50 * In particular, the 'C' was hard to get right. However, the logo
51 * does follow the charter as described in
53 * http://aliweb.cern.ch/system/files/documents/charter/charte_A5_120628.pdf
55 * Use the static member function(s) AliceLogo::Check to see how well
56 * this code reproduces the logos. Note, you need the official logos
57 * in PNG format for this. Here's a list of places to get them:
59 * - https://aliceinfo.cern.ch/Figure/sites/aliceinfo.cern.ch.Figure/files/Figures/General/elopez/2012-Jul-04-Preliminary_Logo.png
60 * - https://aliceinfo.cern.ch/Figure/sites/aliceinfo.cern.ch.Figure/files/Figures/General/elopez/2012-Jul-04-Performance_Logo.png
61 * - https://aliceinfo.cern.ch/Figure/sites/aliceinfo.cern.ch.Figure/files/Figures/General/elopez/2012-Jul-04-4_Color_Logo_CB.png
63 * @author Christian Holm Christensen <cholm@nbi.dk>
79 kBW = 0, // Black and white only
80 kText = 0x1, // Text is coloured dark-blue
81 kL3 = 0x2, // Colour L3 red
82 kParticles = 0x4, // Particles coloured red
83 kMany = 0x8, // Many particles in many colours
84 kPad = 0x10, // BAckground from pad
85 kReverse = 0x20 // Text is white
90 AliceLogo(Bool_t debug=false)
98 fRed = TColor::GetColor(226, 0, 26);
99 fYellow = TColor::GetColor(238, 125, 17);
100 fPink = TColor::GetColor(202, 71, 67);
101 fBlue = TColor::GetColor(40, 58, 68);
104 * Parse a string with colour options
108 * @return Colour flags
110 static UInt_t ParseColors(const TString& what)
112 UInt_t col = AliceLogo::kBW;
113 if (what.Contains("l3", TString::kIgnoreCase)) col |= kL3;
114 if (what.Contains("text", TString::kIgnoreCase)) col |= kText;
115 if (what.Contains("part", TString::kIgnoreCase)) col |= kParticles;
116 if (what.Contains("many", TString::kIgnoreCase)) col |= kMany;
117 if (what.Contains("pad", TString::kIgnoreCase)) col |= kPad;
118 if (what.Contains("rever", TString::kIgnoreCase)) col |= kReverse;
124 * @param what String to parse
128 static UShort_t ParseTag(const TString& what)
130 UShort_t tag = AliceLogo::kNone;
131 if (what.BeginsWith("pre", TString::kIgnoreCase)) tag = kPreliminary;
132 else if (what.BeginsWith("per", TString::kIgnoreCase)) tag = kPerformance;
138 * @param p Pad to draw in
139 * @param x Starting X position
140 * @param y Starting Y position
141 * @param h Relative height
143 * @param colors Color options
145 void Draw(TVirtualPad* p, Double_t x=.77, Double_t y=.35, Double_t h=.25,
146 const TString& tag="", const TString& colors="")
148 Draw(p, x, y, h, ParseTag(tag), ParseColors(colors));
153 * @param p Pad to draw in
154 * @param x Starting X position
155 * @param y Starting Y position
156 * @param h Relative height
158 * @param color Color options
160 void Draw(TVirtualPad* p, Double_t x, Double_t y, Double_t h,
161 UShort_t tag, UInt_t color)
165 Error("AliceLogo::Draw", "No pad to draw in");
169 Printf("Pad to draw logo in: %s", p->GetName());
170 // p->SetFixedAspectRatio(true);
171 Int_t pH = p->YtoPixel(0);
173 Int_t pW = p->XtoPixel(1);
174 Double_t pA = Double_t(pW) / pH;
175 Printf("pA=%d/%d=%lf", pW, pH, pA);
180 fAspect = 1437. / 1933. ;
185 fAspect = 1835. / 2272. ;
188 fL3Width = fL3Height / fAspect;
189 Int_t hP = Int_t(h * pH+.5); // Height in pixels
190 Int_t wP = Int_t(fAspect * hP + .5); // Width in pixels
191 Int_t xP = p->XtoPixel(x); // X pos in pixels
192 Int_t rP = xP + wP; // Right in pixels;
193 Double_t topX = p->PixeltoX(rP);
194 Double_t topY = y + h; // p->PixeltoY(tP); // y + h;
196 Int_t yP = p->YtoPixel(y); // X pos in pixels
197 Int_t tP = yP - hP; // Top in pixels
198 Printf("(x,y)=(%d,%d) hP=%d wP=%d xP=%d yP=%d rP=%d tP=%d",
199 xP, yP, hP, wP, xP, yP, rP, tP);
201 if (topX > 1 || topY > 1) {
202 Warning("AliceLogo::Draw", "with (x,y)=(%f,%f) and h=%f -> top=(%f,%f)",
203 x, y, h, topX, topY);
204 topX = TMath::Min(topX, 1.);
205 topY = TMath::Min(topY, 1.);
209 fPad = new TPad("logo", "logo", x, y, topX, topY);
210 fPad->SetFixedAspectRatio(true);
211 fPad->SetFillColor(fDebug ? kGreen-4 : 0);
212 fPad->SetFillStyle(fDebug ? 4030 : 0);
213 fPad->SetBorderSize(fDebug ? 1 : 0);
214 fPad->SetBorderMode(fDebug ? 1 : 0);
215 fPad->SetLineColor(fDebug ? kBlue+1 : 0);
216 fPad->SetLineWidth(fDebug ? 1 : 0);
217 fPad->SetTopMargin(0);
218 fPad->SetBottomMargin(0);
219 fPad->SetLeftMargin(0);
220 fPad->SetRightMargin(0);
223 Printf("(x,y)=(%f,%f) (tx,ty)=(%f,%f) (x1,y1)=(%f,%f) (x2,y2)=(%f,%f)",
224 x, y, topX, topY, GetX1(), GetY1(), GetX2(), GetY2());
227 Int_t ppH = fPad->YtoPixel(0);
228 Int_t ppW = fPad->XtoPixel(1);
229 Double_t ppA = Double_t(ppW) / ppH;
230 Printf("ppA=%d/%d=%lf A=%lf",ppW, ppH, ppA, fAspect);
231 // Printf("ppA/A=%lf/%lf=%lf", ppA, fAspect, ppA/fAspect);
234 Int_t bg = (color & kPad) ? p->GetFillColor() : Int_t(kWhite);
236 DrawL3(color, (color & kReverse && !(color & kL3) ? bg : kWhite));
238 Int_t txtFg = kBlack;
240 txtFg = (color & kReverse ? kWhite : fBlue);
241 DrawALICE(txtFg, bg);
242 if (tag == kPreliminary) DrawLabel(txtFg, bg, true);
243 else if (tag == kPerformance) DrawLabel(txtFg, bg, false);
248 * Draw the L3 outline. Note, this is put in a sub-pad of it's own.
250 * @param color Colour flags
251 * @param bg Background color
253 void DrawL3(UInt_t color, Int_t bg)
255 printf("Drawing L3 image ");
257 Double_t o = TMath::Max((1-fL3Width)/2,0.);
258 TVirtualPad* pad = new TPad("l3","L3",o, 1-fL3Height,
259 TMath::Min(fL3Width+o,1.), 1);
260 pad->SetFixedAspectRatio(true);
261 pad->SetFillColor(fDebug ? kGreen-4 : 0);
262 pad->SetFillStyle(fDebug ? 4030 : 0);
263 pad->SetBorderSize(fDebug ? 1 : 0);
264 pad->SetBorderMode(fDebug ? 1 : 0);
265 pad->SetLineColor(fDebug ? kRed+1 : 0);
266 pad->SetLineWidth(fDebug ? 1 : 0);
267 pad->SetTopMargin(0);
268 pad->SetBottomMargin(0);
269 pad->SetLeftMargin(0);
270 pad->SetRightMargin(0);
273 Int_t lcol = (color & kL3 ? fRed : kBlack);
274 if (color & kReverse && lcol == kBlack) lcol = kWhite;
276 Double_t dA = 2 * TMath::Pi() / 8;
277 Double_t ro = .5 + .5 * (1 - TMath::Cos(dA/2));
278 Double_t ri = ro - 1. / fL3Height * fL3Thick;
281 TGraph* gi = new TGraph(9);
282 TGraph* go = new TGraph(9);
283 gi->SetName("L3_inner");
284 go->SetName("L3_outer");
286 SetAttr(go, go, lcol);
287 for (Int_t i = 0; i < 9; i++) {
288 Double_t a = (i + .5) * dA;
289 go->SetPoint(i, x0 + ro * TMath::Cos(a), y0 + ro * TMath::Sin(a));
290 gi->SetPoint(i, x0 + ri * TMath::Cos(a), y0 + ri * TMath::Sin(a));
301 for (Int_t i = 0; i < 36; i++) {
304 case 1: case 5: case 10: case 20: case 24: case 27: case 33: case 34:
306 case 3: case 4: case 8: case 16: case 19: case 23: case 29: case 30:
309 case 9: case 12: case 14: case 18: case 25: case 28: case 35:
316 case 1: case 9: case 8: case 10: case 19: case 21: case 33:
318 case 2: case 7: case 11: case 12: case 15: case 16: case 20: case 34:
320 case 3: case 6: case 13: case 17: case 25: case 29:
322 case 23: case 27: case 28:
328 DrawSpoke(i * 360/36, w, l, col);
333 Int_t col = (color & kParticles ? fRed : kBlack);
334 if (bg != kWhite) col = kWhite;
335 for (Int_t i = 0; i < 18; i++) {
340 case 1: case 6: case 8:
343 case 3: case 4: case 5: case 7: case 12:
353 DrawSpoke(i * 360/18, w, l, col);
360 * Draw a spoke in the L3 outline.
362 * @param ang Rotation angle in degrees.
364 * @param len Length of spoke
365 * @param fg Foreground colour
367 void DrawSpoke(Int_t ang, Double_t w, Double_t len, Int_t fg)
373 Double_t xl = r1+len;
375 Double_t rad = TMath::Pi() / 180 * ang;
376 Double_t xtl = .5 + xx * TMath::Cos(rad) - yy * TMath::Sin(rad);
377 Double_t ytl = .5 + xx * TMath::Sin(rad) + yy * TMath::Cos(rad);
378 Double_t xbl = .5 + xx * TMath::Cos(rad) + yy * TMath::Sin(rad);
379 Double_t ybl = .5 + xx * TMath::Sin(rad) - yy * TMath::Cos(rad);
380 Double_t xtr = .5 + xl * TMath::Cos(rad) - yy * TMath::Sin(rad);
381 Double_t ytr = .5 + xl * TMath::Sin(rad) + yy * TMath::Cos(rad);
382 Double_t xbr = .5 + xl * TMath::Cos(rad) + yy * TMath::Sin(rad);
383 Double_t ybr = .5 + xl * TMath::Sin(rad) - yy * TMath::Cos(rad);
385 TGraph* tri = new TGraph(4);
386 SetAttr(tri, tri, fg);
387 tri->SetName(Form("spoke_tr_%03d", ang));
388 tri->SetPoint(0, 0.5,0.5);
389 tri->SetPoint(3, 0.5,0.5);
390 tri->SetPoint(1, xtl, ytl);
391 tri->SetPoint(2, xbl, ybl);
392 tri->Draw("same lf");
394 TGraph* lne = new TGraph(4);
395 SetAttr(lne, lne, fg);
396 lne->SetName(Form("spoke_ln_%03d", ang));
397 lne->SetPoint(0, xtl, ytl);
398 lne->SetPoint(1, xbl, ybl);
399 lne->SetPoint(2, xbr, ybr);
400 lne->SetPoint(3, xtr, ytr);
401 lne->SetPoint(4, xtl, ytl);
402 lne->Draw("same lf");
406 * Draw the text ALICE in a separate pad
409 void DrawALICE(Int_t fg, Int_t bg)
411 printf("Drawing ALICE title ");
413 Double_t o = TMath::Max((1-fL3Width)/2,0.);
414 Double_t r = fL3Width/2;
415 Double_t t = r*TMath::Sin(TMath::Pi()/8-.05);
416 Double_t t2 = r*TMath::Sin(TMath::Pi()/8+.05);
417 // Middle-bottom-left point is
419 Double_t mblY = (1-fL3Height/2) - t;
420 // Bottom-left point is
421 Double_t blY = (1-fL3Height);
422 Double_t blX = .5 - t2;
424 Double_t a = (blY - mblY) / (blX - mblX);
425 // Y is then, using y = y1 + a (x - x1)
426 Double_t b = mblY + a * (.5 - mblX);
428 Double_t top = 1-fL3Height-fL3Thick;
429 Double_t hh = 2 * (top - b);
430 Double_t bot = TMath::Max(top - hh,0.);
431 TVirtualPad* pad = new TPad("alice", "alice", o, bot+.005,
432 TMath::Min(o+fL3Width,1.), top+.005);
433 pad->SetFixedAspectRatio(true);
434 pad->SetFillColor(fDebug ? kGreen-4 : 0);
435 pad->SetFillStyle(fDebug ? 4030 : 0);
436 pad->SetBorderSize(fDebug ? 1 : 0);
437 pad->SetBorderMode(fDebug ? 1 : 0);
438 pad->SetLineColor(fDebug ? kMagenta+1 : 0);
439 pad->SetLineWidth(fDebug ? 1 : 0);
440 pad->SetTopMargin(0);
441 pad->SetBottomMargin(0);
442 pad->SetLeftMargin(0);
443 pad->SetRightMargin(0);
447 Double_t wp = pad->XtoPixel(1);
448 Double_t hp = pad->YtoPixel(0);
453 DrawA(0, 0.01, w, a, fg, bg);
455 DrawL(.5 - 5.8*a*w, 0.01, w, a, fg);
457 DrawI(.5 - 1.5*a*w, 0.01, w, a, fg);
459 DrawC(.5 + 2.6*a*w, 0.00, /*w,*/ a, fg, bg);
461 DrawE(1 - 3.5*a*w, 0.01, w, a, fg);
469 * @param x Base X coordinate
470 * @param y Base Y coordinate
471 * @param w Line width
472 * @param a Aspect ratio of pad
473 * @param fg Foreground colour
474 * @param bg Background colour
476 void DrawA(Double_t x, Double_t y, Double_t w, Double_t a,
479 Double_t u = 4.5 * w;
481 TBox* b1 = new TBox(x, y, x + a * w, y + 1 - r);
484 b1->DrawBox(x + (u-w) * a, y, x + u * a, y + 1 - r);
485 b1->DrawBox(x, y+1-r-2*w, x + u * a, y + 1 - r -w);
486 TEllipse* a1 = new TEllipse(x+u*a/2, y+1-r-.01, (r-.005)*a, r, 0, 180);
489 TEllipse* a2 = new TEllipse(x+u*a/2, y+1-r-.01, (r-w-.005)*a, r-w, 0, 180);
494 // To draw as lines - note line width does not scale
495 Int_t lw = w*gPad->YtoPixel(0);
496 Double_t x1 = x+a*w/2;
497 Double_t x2 = x+a*(u-w/2);
498 Double_t y1 = y + 1 - r - 1.5*w;
499 TLine* l1 = new TLine(x1, y, x1, y+1-r);
500 l1->SetLineWidth(lw);
501 l1->SetLineColor(kBlue);
503 l1->DrawLine(x2, y,x2, y+1-r);
504 l1->DrawLine(x1, y1,x2, y1);
506 TEllipse* a3 = new TEllipse(x+u*a/2, y+1-r-.01,
507 (r-w/2-.005)*a, r-w/2, 0, 180);
510 // Int_t lw = w*gPad->YtoPixel(0);
511 Printf("Setting line width to %d", lw);
512 a3->SetLineWidth(lw);
513 a3->SetLineColor(kBlue);
520 * @param x Base X coordinate
521 * @param y Base Y coordinate
522 * @param w Line width
523 * @param a Aspect ratio of pad
524 * @param fg Foreground colour
526 void DrawL(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
528 TBox* b1 = new TBox(x, y, x+3.1 * a * w, y + w);
531 b1->DrawBox(x, y , x + a * w,y+.99);
536 * @param x Base X coordinate
537 * @param y Base Y coordinate
538 * @param w Line width
539 * @param a Aspect ratio of pad
540 * @param fg Foreground colour
542 void DrawI(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
544 TBox* b1 = new TBox(x, y, x+3 * a * w, y + w);
547 b1->DrawBox(x+a*w,y,x+2*a*w,y+.99);
548 b1->DrawBox(x,y+1-w,x+3*a*w,y+.99);
553 * @param x Base X coordinate
554 * @param y Base Y coordinate
555 * @param a Aspect ratio of pad
556 * @param fg Foreground colour
557 * @param bg Background colour
559 void DrawC(Double_t x, Double_t y, Double_t a, Int_t fg, Int_t bg)
564 /* 0 */ 0.698245 +dx, 0.271355,
565 /* 1 */ 0.590204 +dx, 0.0755058,
566 /* 2 */ 0.424947 +dx, 0.00,
567 /* 3 */ 0.220343 +dx, 0.015668+.005,
568 /* 4 */ 0.0629551 +dx, 0.15668,
569 /* 5 */ 0.00786939+dx, 0.329027,
570 /* 6 */ -0.005, 0.564046,
571 /* 7 */ 0.00786939+dx, 1-0.329027,
572 /* 8 */ 0.0629551 +dx, 1-0.15668,
573 /* 9 */ 0.220343 +dx, 1-0.015668-.005,
574 /* 10 */ 0.424947 +dx, .99,
575 /* 11 */ 0.590204 +dx, 1-0.0755058,
576 /* 12 */ 0.6982450 +dx, 1-0.271355, 0 };
577 TGraph* gO = new TGraph(nO);
578 gO->SetName("c_ext");
579 gO->SetLineColor(fDebug ? kGreen+1 : fg);
580 gO->SetLineWidth(fDebug ? 1 : 0);
581 gO->SetFillColor(fDebug ? kGreen+1 : fg);
582 gO->SetFillStyle(fDebug ? 0 : 1001);
583 for (Int_t i = 0; i < nO; i++)
584 gO->SetPoint(i, x+pO[2*i]*a,y+pO[2*i+1]);
588 /* 0 */ 0.551869, 1-0.713617,
589 /* 1 */ 0.481045, 1-0.821127,
590 /* 2 */ 0.363004, 1-0.853799,
591 /* 3 */ 0.213486, 1-0.783625,
592 /* 4 */ 0.158508, 1-0.635277,
593 /* 4 */ 0.158, 0.5, // 1-0.635277,
594 /* 5 */ 0.158508, 0.635277,
595 /* 6 */ 0.213486, 0.773625,
596 /* 7 */ 0.363004, 0.853799,
597 /* 8 */ 0.481045, 0.821127,
598 /* 9 */ 0.551869, 0.713617, 0 };
599 TGraph* gI = new TGraph(nI);
600 gI->SetName("c_int");
601 gI->SetLineColor(fDebug ? kGreen+1 : bg);
602 gI->SetLineWidth(fDebug ? 1 : 0);
603 gI->SetFillColor(fDebug ? kGreen+1 : bg);
604 gI->SetFillStyle(fDebug ? 0 : 1001);
605 for (Int_t i = 0; i < nI; i++)
606 gI->SetPoint(i, x+pI[2*i]*a,y+pI[2*i+1]);
610 TGraph* gC = new TGraph(5);
611 gC->SetName("c_cut");
613 gC->SetPoint(0, gO->GetX()[0], gO->GetY()[0]);
614 gC->SetPoint(1, gI->GetX()[0], gI->GetY()[0]);
615 gC->SetPoint(2, gI->GetX()[nI-1], gI->GetY()[nI-1]);
616 gC->SetPoint(3, gO->GetX()[nO-1], gO->GetY()[nO-1]);
617 gC->SetPoint(4, gO->GetX()[0], gO->GetY()[0]);
623 * @param x Base X coordinate
624 * @param y Base Y coordinate
625 * @param w Line width
626 * @param a Aspect ratio of pad
627 * @param fg Foreground colour
629 void DrawE(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
632 TBox* b1 = new TBox(x, y, x + a * w, y + .99);
635 b1->DrawBox(x, y, x + u*a*w, y+w);
636 b1->DrawBox(x, y+.99-w, x + u*a*w, y+.99);
637 b1->DrawBox(x, y+.5-w/2+.02, x + (u-.1)*a*w, y+.5+w/2+.02);
642 * @param x Base X coordinate
643 * @param y Base Y coordinate
644 * @param w Line width
645 * @param a Aspect ratio of pad
646 * @param fg Foreground colour
648 void DrawF(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
651 TBox* b1 = new TBox(x, y, x + a * w, y + .99);
654 b1->DrawBox(x, y+.99-w, x + u*a*w, y+.99);
655 b1->DrawBox(x, y+.5-w/2+.02, x + (u-.1)*a*w, y+.5+w/2+.02);
658 * Draw the label text ("Preliminary" or "Performance") in it's own pad
660 * @param fg Foreground colour
661 * @param bg Background colour
662 * @param preliminary If true, draw preliminary, otherwise performance
664 void DrawLabel(Int_t fg, Int_t bg, bool preliminary=true)
666 printf("Drawing stamp ");
671 TVirtualPad* pad = new TPad("label", "label", 0, bot, 1, top);
672 pad->SetFixedAspectRatio(true);
673 pad->SetFillColor(fDebug ? kGreen-4 : 0);
674 pad->SetFillStyle(fDebug ? 4030 : 0);
675 pad->SetBorderSize(fDebug ? 1 : 0);
676 pad->SetBorderMode(fDebug ? 1 : 0);
677 pad->SetLineColor(fDebug ? kCyan+2 : 0);
678 pad->SetLineWidth(fDebug ? 1 : 0);
679 pad->SetTopMargin(0);
680 pad->SetBottomMargin(0);
681 pad->SetLeftMargin(0);
682 pad->SetRightMargin(0);
686 Double_t wp = pad->XtoPixel(1);
687 Double_t hp = pad->YtoPixel(0);
688 Double_t a = hp / wp;
692 printf("."); DrawP(0, 0.01, w, a, fg, bg);
693 printf("."); DrawR(6.3 * w * a, 0.01, w, a, fg, bg);
694 printf("."); DrawE(13 * w * a, 0.01, w, a, fg);
695 printf("."); DrawL(18.7 * w * a, 0.01, w, a, fg);
696 printf("."); DrawI(23.3 * w * a, 0.01, w, a, fg);
697 printf("."); DrawM(29 * w * a, 0.01, w, a, fg);
698 printf("."); DrawI(37.2 * w * a, 0.01, w, a, fg);
699 printf("."); DrawN(42.5 * w * a, 0.01, w, a, fg);
700 printf("."); DrawA(49.4 * w * a, 0.01, w, a, fg, bg);
701 printf("."); DrawR(56.4 * w * a, 0.01, w, a, fg, bg);
702 printf("."); DrawY(62.3 * w * a, 0.01, w, a, fg);
705 printf("."); DrawP(0, 0.01, w, a, fg, bg);
706 printf("."); DrawE(6.3 * w * a, 0.01, w, a, fg);
707 printf("."); DrawR(12 * w * a, 0.01, w, a, fg, bg);
708 printf("."); DrawF(18.7 * w * a, 0.01, w, a, fg);
709 printf("."); DrawO(24 * w * a, 0.01, w, a, fg, bg);
710 printf("."); DrawR(30.7 * w * a, 0.01, w, a, fg, bg);
711 printf("."); DrawM(37.5 * w * a, 0.01, w, a, fg);
712 printf("."); DrawA(45.5 * w * a, 0.01, w, a, fg, bg);
713 printf("."); DrawN(52.4 * w * a, 0.01, w, a, fg);
714 printf("."); DrawC(58.7 * w * a, 0.01, /*w,*/ a, fg, bg);
715 printf("."); DrawE(64.8 * w * a, 0.01, w, a, fg);
724 * @param x Base X coordinate
725 * @param y Base Y coordinate
726 * @param w Line width
727 * @param a Aspect ratio of pad
728 * @param fg Foreground colour
729 * @param bg Background colour
731 void DrawO(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg, Int_t bg)
735 TEllipse* a1 = new TEllipse(x+fw/2*a*w, y + .495, a*w*fw/2, .495, 0, 360);
738 TEllipse* a2 = new TEllipse(x+fw/2*a*w, y + .495, a*w*(fw/2-1), .495-w);
745 * @param x Base X coordinate
746 * @param y Base Y coordinate
747 * @param w Line width
748 * @param a Aspect ratio of pad
749 * @param fg Foreground colour
750 * @param bg Background colour
752 void DrawP(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg, Int_t bg)
754 Double_t u = 4.3 * w;
755 Double_t r = 4.3 * w / 2;
757 TBox* b1 = new TBox(x, y, x + a * w, y + .99);
760 b1->DrawBox(x + a * w, y + .99 - w, x + 2.5 * a * w, y + .99);
761 b1->DrawBox(x + a * w, y + .99 - u, x + 2.5 * a * w, y + .99 - u + w);
762 TEllipse* a1 = new TEllipse(x+2.5*a*w, y + .99 - r, a*r, r-.01, -90, 90);
765 TEllipse* a2 = new TEllipse(x+2.5*a*w, y + .99 - r, a*(r-w), r-w-.01,
773 * @param x Base X coordinate
774 * @param y Base Y coordinate
775 * @param w Line width
776 * @param a Aspect ratio of pad
777 * @param fg Foreground colour
778 * @param bg Background colour
780 void DrawR(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg, Int_t bg)
782 DrawP(x, y, w, a, fg, bg);
784 Double_t u = 4.3 * w;
785 Double_t fw = 2.5 + 4.3 / 2;
786 Double_t ang = 60 * TMath::Pi() / 180;
787 Double_t o = w / TMath::Sin(ang);
789 TGraph* g = new TGraph(5);
792 g->SetPoint(0, x+a*(2*w+o), y+1-u+.01);
794 g->SetPoint(1, x+a*2*w, y+1-u+.01);
796 g->SetPoint(2, x+a*(fw*w-o+.06), y);
798 g->SetPoint(3, x+a*(fw*w+.06), y);
799 g->SetPoint(4, g->GetX()[0], g->GetY()[0]);
805 * @param x Base X coordinate
806 * @param y Base Y coordinate
807 * @param w Line width
808 * @param a Aspect ratio of pad
809 * @param fg Foreground colour
811 void DrawM(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
813 TBox* b1 = new TBox(x, y, x + a * w, y + 1);
816 b1->DrawBox(x+4.8*a*w, y, x+5.8*a*w, y+1);
818 Double_t ang = 28 * TMath::Pi() / 180;
819 Double_t o = w / TMath::Sin(ang);
821 TGraph* gl = new TGraph(7);
823 gl->SetPoint(0, x+a*w, y+1);
824 gl->SetPoint(1, x+a*w, y+1-o);
825 gl->SetPoint(2, x+a*w*(1+3.8/2), y+w);
826 gl->SetPoint(3, x+a*w*4.8, y+1-o);
827 gl->SetPoint(4, x+a*w*4.8, y+1);
828 gl->SetPoint(5, x+a*w*(1+3.8/2), y+w+o);
829 gl->SetPoint(6, x+a*w, y+1);
836 * @param x Base X coordinate
837 * @param y Base Y coordinate
838 * @param w Line width
839 * @param a Aspect ratio of pad
840 * @param fg Foreground colour
842 void DrawN(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
845 TBox* b1 = new TBox(x, y, x + a * w, y + 1);
848 b1->DrawBox(x+a*w*(fw-1), y, x+a*w*(fw), y+1);
850 Double_t ang = 28 * TMath::Pi() / 180;
851 Double_t o = w / TMath::Sin(ang);
853 TGraph* gl = new TGraph(5);
854 gl->SetLineColor(fDebug ? kGreen+1 : fg);
855 gl->SetLineWidth(fDebug ? 1 : 0);
856 gl->SetFillColor(fDebug ? kGreen+1 : fg);
857 gl->SetFillStyle(fDebug ? 0 : 1001);
858 gl->SetPoint(0, x+a*w, y+1);
859 gl->SetPoint(1, x+a*w, y+1-o);
860 gl->SetPoint(2, x+a*w*(fw-1), y);
861 gl->SetPoint(3, x+a*w*(fw-1), y+o);
862 gl->SetPoint(4, x+a*w, y+1);
868 * @param x Base X coordinate
869 * @param y Base Y coordinate
870 * @param w Line width
871 * @param a Aspect ratio of pad
872 * @param fg Foreground colour
874 void DrawY(Double_t x, Double_t y, Double_t w, Double_t a, Int_t fg)
879 TBox* b1 = new TBox(x+a*w*(fw/2-.5), y, x + a * w *(fw/2+.5), y + 1 - u);
880 b1->SetLineColor(fDebug ? kGreen+1 : fg);
881 b1->SetFillColor(fDebug ? 0 : fg);
882 b1->SetFillStyle(fDebug ? 0 : 1001);
885 Double_t ang = 40 * TMath::Pi() / 180;
886 Double_t o = w / TMath::Sin(ang);
887 Double_t o2 = w / TMath::Cos(ang);
890 TGraph* g = new TGraph(8);
892 g->SetPoint(0, x+a*w*(fw/2-.5), y + 1-u);
893 g->SetPoint(1, x, y + 1);
894 g->SetPoint(2, x+a*o2, y + 1);
895 g->SetPoint(3, x+a*w*fw/2, y + 1 - u + o);
896 g->SetPoint(4, x+a*w*fw-a*o2, y+1);
897 g->SetPoint(5, x+a*w*fw, y+1);
898 g->SetPoint(6, x+a*w*(fw/2+.5), y + 1-u);
899 g->SetPoint(7, x+a*w*(fw/2-.5), y + 1-u);
905 * Set Line and Fill attributes
907 * @param lne Line attribute interface
908 * @param fll Fill attribute interface
911 void SetAttr(TAttLine* lne, TAttFill* fll, Int_t col)
914 lne->SetLineColor(fDebug ? kGreen+1 : col);
915 lne->SetLineWidth(fDebug ? 1 : 0);
918 fll->SetFillColor(fDebug ? kGreen+1 : col);
919 fll->SetFillStyle(fDebug ? 0 : 1001);
922 Double_t GetX1() const { return fPad ? fPad->GetXlowNDC() : -1; }
923 Double_t GetX2() const { return fPad ? GetX1()+fPad->GetWNDC() : -1; }
924 Double_t GetY1() const { return fPad ? fPad->GetYlowNDC() : -1; }
925 Double_t GetY2() const { return fPad ? GetY1()+fPad->GetHNDC() : -1; }
926 Double_t GetCX() const { return fPad ? (GetX1()+GetX2())/2 : -1; }
927 Double_t GetCY() const { return fPad ? (GetY1()+GetY2())/2 : -1; }
933 static void Test(const TString& what)
935 Test(AliceLogo::ParseTag(what), AliceLogo::ParseColors(what),
936 what.Contains("debug", TString::kIgnoreCase));
945 static void Test(UShort_t tag, UInt_t col, Bool_t debug)
947 TCanvas* c = new TCanvas("test", "Test of AliceLogo");
948 c->SetFillColor(kYellow-10);
949 TH1* h = new TH1F("h", "h", 60, -3, 3);
950 h->SetFillColor(kRed+1);
951 h->SetFillStyle(3001);
952 h->FillRandom("gaus");
955 AliceLogo* dut = new AliceLogo(debug);
956 dut->Draw(c, .75, .4, .25, tag, col);
958 c->SaveAs("test.png");
959 c->SaveAs("test.pdf");
960 c->SaveAs("test.svg");
963 * Check compatiblity by overlaying this logo on 'official' images
967 static void Check(const TString& what)
969 Check(AliceLogo::ParseTag(what), AliceLogo::ParseColors(what),
970 what.Contains("debug", TString::kIgnoreCase));
973 * Check compatiblity by overlaying this logo on 'official' images
979 static void Check(UShort_t tag, UInt_t col, Bool_t debug=true)
982 TImage* img = TImage::Create();
983 TString imgName = "2012-Jul-04-Base_Logo.png";
984 // Int_t logoW = 0; // img->GetWidth();
985 // Int_t logoH = 0; // img->GetHeight();
987 case AliceLogo::kPreliminary:
990 imgName = "2012-Jul-04-Preliminary_Logo.png";
992 case AliceLogo::kPerformance:
993 imgName = "2012-Jul-04-Performance_Logo.png";
997 imgName = "2012-Jul-04-4_Color_Logo_CB.png";
999 imgName = "2012-Jul-04-Base_Logo.png";
1001 Printf("Reading %s", imgName.Data());
1002 img->ReadImage(imgName);
1003 Int_t logoW = img->GetWidth();
1004 Int_t logoH = img->GetHeight();
1005 Double_t logoA = Float_t(logoH) / logoW;
1007 Printf("Logo dimensions (wxh): (%d x %d)", logoW, logoH);
1008 Int_t myHeight = 800;
1009 TCanvas* c = new TCanvas("check", "Check of AliceLogo",
1010 (myHeight-22)/logoA, myHeight);
1012 c->SetRightMargin(0);
1013 c->SetBottomMargin(0);
1014 c->SetLeftMargin(0);
1015 c->SetFillColor(debug ? kRed-4 : kWhite);
1016 c->SetBorderSize(0);
1017 c->SetBorderMode(0);
1018 if (col & AliceLogo::kReverse /*&& !(col & AliceLogo::kL3)*/ && !debug)
1019 c->SetFillColor(kBlack);
1021 if (debug) img->Draw();
1023 AliceLogo* dut = new AliceLogo(debug);
1024 dut->Draw(c, 0, 0, 1, tag, col);
1026 c->SaveAs("check.svg");
1029 TVirtualPad* fPad; // Our pad
1030 Double_t fAspect; // Aspect ratio of our pad
1031 Double_t fL3Thick; // Fraction of canvas height
1032 Double_t fL3Height; // Fraction of canvas height
1033 Double_t fL3Width; // Width of L3 sub-pad
1034 Bool_t fDebug; // Debug (make outline only)
1035 Int_t fRed; // The red color
1036 Int_t fYellow; // The yellow-ish color
1037 Int_t fPink; // The dark-red pink-ish color
1038 Int_t fBlue; // The blue gray-ish color