ROOT logo

From $ROOTSYS/tutorials/graphics/mass_spectrum.C

// This macro makes use of some basic graphics primitives such as line, arrow
// and text. It as been written using the TCanvas ToolBar to produce a first
// draft and was then modified for fine adjustments. Note also the use
// of C funtions. They allow to simplify the macro reading and editing by 
// avoiding code repetition or defining some graphics attributes in one single
// place. This technique to generate drawings may appear not very user friendly
// compare to all the "wysiwyg" graphics editors available. In some cases it can
// be more powerful than a GUI interface because it allows to generate very 
// precise drawing and using computation to generate them.
//Author: Olivier Couet

void mass_spectrum()
{
   TCanvas *C = new TCanvas("C","C",800,500);

   hline (0.10,0.25);
   hline (0.10,0.80);
   hline (0.30,0.90);
   hline (0.30,0.35);
   hline (0.45,0.60);
   hline (0.58,0.68);
   hline (0.73,0.70);
   hline (0.89,0.75);

   arrow(0.32, 0.90, 0.32, 0.35, 1);
   arrow(0.34, 0.90, 0.34, 0.35, 1);
   arrow(0.36, 0.90, 0.36, 0.60, 1);
   arrow(0.38, 0.90, 0.38, 0.70, 1);

   arrow(0.30, 0.90, 0.18, 0.25, 1);
   arrow(0.30, 0.35, 0.19, 0.25, 1);
   arrow(0.40, 0.90, 0.47, 0.61, 1);

   arrow(0.15, 0.25, 0.15, 0.19, 1);
   arrow(0.15, 0.80, 0.15, 0.74, 1);
   
   arrow(0.50, 0.60, 0.50, 0.54, 1);
   arrow(0.60, 0.68, 0.60, 0.62, 1);
   arrow(0.94, 0.75, 0.94, 0.69, 1);
   
   arrow(0.32, 0.35, 0.32, 0.19, 1);
   arrow(0.36, 0.35, 0.36, 0.19, 1);
   arrow(0.38, 0.35, 0.38, 0.19, 1);

   arrow(0.40, 0.90, 0.60, 0.68, 1);
   arrow(0.40, 0.90, 0.90, 0.75, 1);
   arrow(0.45, 0.60, 0.35, 0.35, 1);
   arrow(0.30, 0.90, 0.18, 0.80, 2);
   arrow(0.67, 0.68, 0.36, 0.35, 1);
   arrow(0.78, 0.70, 0.37, 0.35, 2);
   arrow(0.91, 0.75, 0.39, 0.35, 1);

   TLatex l1;
   l1.SetTextSize(0.035);
   l1.SetTextAlign(22);
   l1.SetTextFont(132);
   l1.DrawLatex(0.15, 0.73, "hadrons");
   l1.DrawLatex(0.15, 0.18, "hadrons");
   l1.DrawLatex(0.32, 0.18, "hadrons");
   l1.DrawLatex(0.38, 0.59, "hadrons");
   l1.DrawLatex(0.50, 0.53, "hadrons");
   l1.DrawLatex(0.94, 0.68, "hadrons");
   l1.DrawLatex(0.58, 0.62, "hadrons");
   l1.DrawLatex(0.41, 0.18, "radiative");

   TLatex l2;
   l2.SetTextSize(0.038);
   l2.SetTextAlign(22);
   l2.SetTextFont(132);
   l2.DrawLatex(0.07, 0.08, "#font[12]{J^{PC}} =");
   l2.DrawLatex(0.15, 0.08, "0^{-+}");
   l2.DrawLatex(0.35, 0.08, "1^{--}");
   l2.DrawLatex(0.50, 0.08, "0^{++}");
   l2.DrawLatex(0.62, 0.08, "1^{++}");
   l2.DrawLatex(0.77, 0.08, "1^{+-}");
   l2.DrawLatex(0.93, 0.08, "2^{++}");
   l2.DrawLatex(0.15, 0.83, "#eta_{c}(2S)");
   l2.DrawLatex(0.15, 0.28, "#eta_{c}(1S)");
   l2.DrawLatex(0.35, 0.93, "#psi(2S)");
   l2.DrawLatex(0.45, 0.35, "#font[12]{J}/#psi(1S)");
   l2.DrawLatex(0.51, 0.63, "#chi_{c0}(1P)");
   l2.DrawLatex(0.63, 0.71, "#chi_{c1}(1P)");
   l2.DrawLatex(0.78, 0.73, "h_{c1}(1P)");
   l2.DrawLatex(0.94, 0.78, "#chi_{c2}(1P)");

   TLatex l3;
   l3.SetTextSize(0.037);
   l3.SetTextAlign(11);
   l3.SetTextFont(132);
   l3.DrawLatex(0.23, 0.86, "#font[152]{g}");
   l3.DrawLatex(0.23, 0.57, "#font[152]{g}");
   l3.DrawLatex(0.44, 0.77, "#font[152]{g}");
   l3.DrawLatex(0.40, 0.50, "#font[152]{g}");
   l3.DrawLatex(0.45, 0.46, "#font[152]{g}");
   l3.DrawLatex(0.71, 0.61, "#font[152]{g}");
   l3.DrawLatex(0.24, 0.31, "#font[152]{g}");
   l3.DrawLatex(0.38, 0.81, "#font[152]{g^{*}}");
   l3.DrawLatex(0.355, 0.16, "#font[152]{g^{*}}");
   l3.DrawLatex(0.295, 0.50, "#pi#pi");
   l3.DrawLatex(0.345, 0.53, "#eta,#pi^{0}");
   l3.DrawLatex(0.70, 0.65, "#pi^{0}");
}

void hline (Double_t x, Double_t y)
{
   Double_t dx = 0.1;
   TLine *l = new TLine(x,y,x+dx,y);
   l->Draw();
   l->SetLineWidth(4);
}

void arrow (Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t ls)
{
   arrow = new TArrow(x1,y1,x2,y2,0.025,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->SetLineStyle(ls);
   arrow->SetAngle(19);
   arrow->Draw();
}
 mass_spectrum.C:1
 mass_spectrum.C:2
 mass_spectrum.C:3
 mass_spectrum.C:4
 mass_spectrum.C:5
 mass_spectrum.C:6
 mass_spectrum.C:7
 mass_spectrum.C:8
 mass_spectrum.C:9
 mass_spectrum.C:10
 mass_spectrum.C:11
 mass_spectrum.C:12
 mass_spectrum.C:13
 mass_spectrum.C:14
 mass_spectrum.C:15
 mass_spectrum.C:16
 mass_spectrum.C:17
 mass_spectrum.C:18
 mass_spectrum.C:19
 mass_spectrum.C:20
 mass_spectrum.C:21
 mass_spectrum.C:22
 mass_spectrum.C:23
 mass_spectrum.C:24
 mass_spectrum.C:25
 mass_spectrum.C:26
 mass_spectrum.C:27
 mass_spectrum.C:28
 mass_spectrum.C:29
 mass_spectrum.C:30
 mass_spectrum.C:31
 mass_spectrum.C:32
 mass_spectrum.C:33
 mass_spectrum.C:34
 mass_spectrum.C:35
 mass_spectrum.C:36
 mass_spectrum.C:37
 mass_spectrum.C:38
 mass_spectrum.C:39
 mass_spectrum.C:40
 mass_spectrum.C:41
 mass_spectrum.C:42
 mass_spectrum.C:43
 mass_spectrum.C:44
 mass_spectrum.C:45
 mass_spectrum.C:46
 mass_spectrum.C:47
 mass_spectrum.C:48
 mass_spectrum.C:49
 mass_spectrum.C:50
 mass_spectrum.C:51
 mass_spectrum.C:52
 mass_spectrum.C:53
 mass_spectrum.C:54
 mass_spectrum.C:55
 mass_spectrum.C:56
 mass_spectrum.C:57
 mass_spectrum.C:58
 mass_spectrum.C:59
 mass_spectrum.C:60
 mass_spectrum.C:61
 mass_spectrum.C:62
 mass_spectrum.C:63
 mass_spectrum.C:64
 mass_spectrum.C:65
 mass_spectrum.C:66
 mass_spectrum.C:67
 mass_spectrum.C:68
 mass_spectrum.C:69
 mass_spectrum.C:70
 mass_spectrum.C:71
 mass_spectrum.C:72
 mass_spectrum.C:73
 mass_spectrum.C:74
 mass_spectrum.C:75
 mass_spectrum.C:76
 mass_spectrum.C:77
 mass_spectrum.C:78
 mass_spectrum.C:79
 mass_spectrum.C:80
 mass_spectrum.C:81
 mass_spectrum.C:82
 mass_spectrum.C:83
 mass_spectrum.C:84
 mass_spectrum.C:85
 mass_spectrum.C:86
 mass_spectrum.C:87
 mass_spectrum.C:88
 mass_spectrum.C:89
 mass_spectrum.C:90
 mass_spectrum.C:91
 mass_spectrum.C:92
 mass_spectrum.C:93
 mass_spectrum.C:94
 mass_spectrum.C:95
 mass_spectrum.C:96
 mass_spectrum.C:97
 mass_spectrum.C:98
 mass_spectrum.C:99
 mass_spectrum.C:100
 mass_spectrum.C:101
 mass_spectrum.C:102
 mass_spectrum.C:103
 mass_spectrum.C:104
 mass_spectrum.C:105
 mass_spectrum.C:106
 mass_spectrum.C:107
 mass_spectrum.C:108
 mass_spectrum.C:109
 mass_spectrum.C:110
 mass_spectrum.C:111
 mass_spectrum.C:112
 mass_spectrum.C:113
 mass_spectrum.C:114
 mass_spectrum.C:115
 mass_spectrum.C:116
 mass_spectrum.C:117
 mass_spectrum.C:118
 mass_spectrum.C:119
 mass_spectrum.C:120
 mass_spectrum.C:121
thumb