Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
PlottingEngineRoot.cc
Go to the documentation of this file.
1#include <iomanip>
2#include <iostream>
3
4#include <TROOT.h>
5#include <TF1.h>
6#include <TAxis.h>
7#include <TCanvas.h>
8
10
11namespace Garfield {
12
14
16 : PlottingEngine("PlottingEngineRoot"),
17 m_garfieldStyle("Garfield", "Garfield Style") {}
18
20
22 m_garfieldStyle.Reset();
23 m_garfieldStyle.SetFillColor(1);
24 m_garfieldStyle.SetFillStyle(1001);
25 m_garfieldStyle.SetCanvasBorderMode(0);
26 m_garfieldStyle.SetCanvasColor(0);
27 m_garfieldStyle.SetCanvasDefH(600);
28 m_garfieldStyle.SetCanvasDefW(600);
29 m_garfieldStyle.SetPadBorderMode(0);
30 m_garfieldStyle.SetPadColor(0);
31 m_garfieldStyle.SetPadLeftMargin(0.15);
32 m_garfieldStyle.SetPadBottomMargin(0.1);
33 m_garfieldStyle.SetPadRightMargin(0.05);
34 m_garfieldStyle.SetPadTopMargin(0.05);
35 m_garfieldStyle.SetPadTickX(1);
36 m_garfieldStyle.SetPadTickY(1);
37 m_garfieldStyle.SetFrameFillColor(0);
38 m_garfieldStyle.SetFrameBorderMode(0);
39 m_garfieldStyle.SetDrawBorder(0);
40 m_garfieldStyle.SetLegendBorderSize(0);
41
42 m_garfieldStyle.SetGridColor(kGray);
43 m_garfieldStyle.SetGridStyle(3);
44 m_garfieldStyle.SetGridWidth(1);
45 m_garfieldStyle.SetPadGridX(kTRUE);
46 m_garfieldStyle.SetPadGridY(kTRUE);
47
48 const int font = m_serif ? 132 : 42;
49 const double tsize = 0.04;
50 m_garfieldStyle.SetTextFont(font);
51 m_garfieldStyle.SetTextSize(tsize);
52 m_garfieldStyle.SetTitleStyle(0);
53 m_garfieldStyle.SetTitleBorderSize(0);
54 m_garfieldStyle.SetTitleColor(1, "xyz");
55 m_garfieldStyle.SetTitleColor(1, "t");
56 m_garfieldStyle.SetTitleFillColor(0);
57 m_garfieldStyle.SetTitleFont(font, "xyz");
58 m_garfieldStyle.SetTitleFont(font, "t");
59 m_garfieldStyle.SetTitleOffset(1.2, "x");
60 m_garfieldStyle.SetTitleOffset(0, "y");
61 m_garfieldStyle.SetTitleSize(tsize, "xyz");
62 m_garfieldStyle.SetTitleSize(tsize, "t");
63
64 m_garfieldStyle.SetLegendFont(font);
65 m_garfieldStyle.SetStatStyle(0);
66 m_garfieldStyle.SetStatBorderSize(0);
67 m_garfieldStyle.SetStatColor(0);
68 m_garfieldStyle.SetStatFont(font);
69 m_garfieldStyle.SetStatFontSize(tsize);
70 m_garfieldStyle.SetStatX(0.88);
71 m_garfieldStyle.SetStatY(0.88);
72 m_garfieldStyle.SetStatW(0.25);
73 m_garfieldStyle.SetStatH(0.1);
74 m_garfieldStyle.SetOptStat(111110);
75 m_garfieldStyle.SetStatFormat("6.3g");
76 m_garfieldStyle.SetLabelFont(font, "xyz");
77 m_garfieldStyle.SetLabelSize(tsize, "xyz");
78 m_garfieldStyle.SetLabelOffset(0.01, "xyz");
79 m_garfieldStyle.SetOptTitle(0);
80 m_garfieldStyle.SetPaperSize(TStyle::kA4);
81 m_garfieldStyle.SetFuncWidth(2);
82 m_garfieldStyle.SetHistLineColor(kOrange - 3);
83 // m_garfieldStyle.SetPalette(1);
84 m_garfieldStyle.SetAxisColor(kBlack, "X");
85 m_garfieldStyle.SetAxisColor(kBlack, "Y");
86 m_garfieldStyle.SetAxisColor(kBlack, "Z");
87 m_garfieldStyle.SetNdivisions(505, "x");
88 m_garfieldStyle.SetNdivisions(510, "y");
89 m_garfieldStyle.SetMarkerStyle(20);
90 m_garfieldStyle.SetMarkerSize(1.2);
91 const double lw = 2;
92 m_garfieldStyle.SetLineWidth(lw);
93 m_garfieldStyle.SetLineStyleString(2, "[12 12]");
94 m_garfieldStyle.SetFrameLineWidth(lw);
95 m_garfieldStyle.SetHistLineWidth(lw);
96 m_garfieldStyle.SetFuncWidth(lw);
97 m_garfieldStyle.SetGridWidth(lw);
98 m_garfieldStyle.cd();
99}
100
102 int rootcol = 0;
103 if (!GetRootColor(m_colorLine1, rootcol)) {
104 m_colorLine1 = m_colorLine1Default;
105 GetRootColor(m_colorLine1, rootcol);
106 }
107 return rootcol;
108}
109
111 int rootcol = 0;
112 if (!GetRootColor(m_colorLine2, rootcol)) {
113 m_colorLine2 = m_colorLine2Default;
114 GetRootColor(m_colorLine2, rootcol);
115 }
116 return rootcol;
117}
118
120 int rootcol = 0;
121 if (!GetRootColor(m_colorElectron, rootcol)) {
122 m_colorElectron = m_colorElectronDefault;
124 }
125 return rootcol;
126}
127
129 int rootcol = 0;
130 if (!GetRootColor(m_colorHole, rootcol)) {
131 m_colorHole = m_colorHoleDefault;
132 GetRootColor(m_colorHole, rootcol);
133 }
134 return rootcol;
135}
136
138 int rootcol = 0;
139 if (!GetRootColor(m_colorIon, rootcol)) {
140 m_colorIon = m_colorIonDefault;
141 GetRootColor(m_colorIon, rootcol);
142 }
143 return rootcol;
144}
145
147 int rootcol = 0;
148 if (!GetRootColor(m_colorPhoton, rootcol)) {
149 m_colorPhoton = m_colorPhotonDefault;
150 GetRootColor(m_colorPhoton, rootcol);
151 }
152 return rootcol;
153}
154
156 int rootcol = 0;
157 if (!GetRootColor(m_colorChargedParticle, rootcol)) {
158 m_colorChargedParticle = m_colorChargedParticleDefault;
160 }
161 return rootcol;
162}
163
164bool PlottingEngineRoot::GetRootColor(std::string color, int& rootcol) {
165 rootcol = kBlack;
166
167 // Convert to upper-case.
168 for (unsigned int i = 0; i < color.length(); ++i) {
169 color[i] = toupper(color[i]);
170 }
171
172 if (color == "BLACK") {
173 rootcol = kBlack;
174 return true;
175 }
176 if (color == "RED") {
177 rootcol = kRed + 1;
178 return true;
179 } else if (color == "GREEN") {
180 rootcol = kGreen + 2;
181 return true;
182 } else if (color == "BLUE") {
183 rootcol = kBlue + 2;
184 return true;
185 } else if (color == "DARK-RED") {
186 rootcol = kRed + 3;
187 return true;
188 } else if (color == "DARK-GREEN") {
189 rootcol = kGreen + 3;
190 return true;
191 } else if (color == "DARK-BLUE") {
192 rootcol = kBlue + 3;
193 return true;
194 } else if (color == "ORANGE") {
195 rootcol = kOrange - 3;
196 return true;
197 } else if (color == "PURPLE") {
198 rootcol = kViolet - 7;
199 return true;
200 } else if (color == "CYAN") {
201 rootcol = kCyan + 3;
202 return true;
203 } else if (color == "OLIVE") {
204 rootcol = kSpring + 4;
205 return true;
206 }
207 if (m_debug) {
208 std::cerr << m_className << "::GetRootColor:\n";
209 std::cerr << " Unknown color (" << color << ").\n";
210 }
211 return false;
212}
213}
Definition of styles and color schemes.
virtual ~PlottingEngineRoot()
Destructor.
bool GetRootColor(std::string color, int &rootcol)
void SetDefaultStyle()
Apply the default Garfield ROOT style.
Abstract base class for plotting engines.
std::string m_colorChargedParticle
PlottingEngineRoot plottingEngine