ATLAS Offline Software
G4DebuggerConfig.py
Go to the documentation of this file.
1 import ROOT
2 import os
3 
4 def merge_two_dicts(x, y):
5  z = x.copy() # start with x's keys and values
6  z.update(y) # modifies z with y's keys and values & returns None
7  return z
8 
9 AtlasStylePath = os.environ['HOME']+'/RootUtils/AtlasStyle'
10 AtlasStyle = os.path.exists(AtlasStylePath)
11 if AtlasStyle:
12  ROOT.gROOT.LoadMacro(AtlasStylePath+"/AtlasStyle.C")
13  ROOT.gROOT.LoadMacro("common/AtlasLabels.C")
14  ROOT.gROOT.LoadMacro("common/AtlasUtils.C")
15  ROOT.SetAtlasStyle()
16 
17 particles = ["other","gamma","e-","neutron",]
18 otherParticles = ["nucleus","proton","e+"]
19 # particles = ["other","nucleus","proton","neutron","gamma","e-","e+"]
20 
21 egamma = ["gamma","e-","e+"]
22 electrons = ["e-","e+"]
23 neutrons = ["neutron"]
24 hadrons = ["proton","neutron","nucleus"]
25 
26 colors = {
27  'e-':ROOT.kRed-6,
28  'e+':ROOT.kBlack,
29  'neutron':ROOT.kBlue-9,
30  'gamma':ROOT.kGray,
31  'other':ROOT.kGray+1,
32  'proton':ROOT.kBlack,
33  'nucleus':ROOT.kCyan-4,
34  'proton':ROOT.kPink+2,
35 }
36 
37 colorsNew = {
38  'e-':ROOT.kRed-2,
39  'e+':ROOT.kBlack,
40  'neutron':ROOT.kBlue-2,
41  'gamma':ROOT.kGray+2,
42  'other':ROOT.kGray+3,
43  'proton':ROOT.kBlack,
44  'nucleus':ROOT.kCyan,
45  'proton':ROOT.kPink+6,
46 }
47 
48 styles = {
49 'gamma': 3354,
50 }
51 
52 samecolor = [
53 'other',
54 'gamma',
55 'e+',
56 ]
57 
58 linecolor = {
59 'neutron':ROOT.kBlue,
60 'e-':ROOT.kRed+2,
61 }
62 
63 translate = {
64 'e-':'electrons',
65 'e+':'positrons',
66 'gamma':'photons',
67 'neutron':'neutrons',
68 # 'Section':'Beampipe',
69 'Section':'ID services',
70 'EMEC':'EM end-cap',
71 'EMB':'EM barrel',
72 'FC1':'FCal1',
73 'FC23':'FCal2/3',
74 'FCOther':'other',
75 'HEC':'Had. end-cap',
76 'LAr':'LAr services',
77 'Cryo':'LAr services',
78 'Service':'ID services',
79 'other':'Other',
80 }
81 
82 label = {
83 'stepLength':'log( step length [mm] )',
84 'stepEnergyDeposit':'log( energy deposit [MeV] )',
85 'stepSecondaryKinetic':'log( kinetic energy of the secondary [MeV] )',
86 'stepEnergyNonIonDeposit':'log( non-ionizing energy deposit [MeV] )',
87 'stepKineticEnergy':'log( kinetic energy in current step [MeV] )',
88 'stepPseudorapidity':'#eta in current step',
89 }
90 
91 labelAllATLAS = {
92 'numberOfSteps':'number of steps',
93 'numberOfStepsPerInitialE':'log( Initial kinetic [MeV] )',
94 'CumulativeNumberOfStepsPerInitialE':'log( Initial kinetic [MeV] )',
95 'InitialE':'log( Initial kinetic [MeV] )',
96 'CumulativeInitialE':'log( Initial kinetic [MeV] )',
97 'averageNumberOfStepsPerInitialE':'log( Initial kinetic [MeV] )',
98 }
99 
100 labelAll = merge_two_dicts(label,labelAllATLAS)
101 
103  rsplit = 0.4
104  pad1TopMarin = 0.08
105  pad1BotMarin = 0.04
106  pad2TopMarin = 0.03
107  pad2BotMarin = 0.6
108  LeftMargin = 0.15
109  # yaxis = "Relative steps [%]"
110  yaxis = "Steps / Event"
111 
112  def getCanvas(self, uniqueName):
113  canv = ROOT.TCanvas(uniqueName,uniqueName,700,600)
114  pad1 = ROOT.TPad("pad1"+uniqueName,"top pad"+uniqueName,0.,self.rsplit,1.,1.)
115  pad1.SetTopMargin(self.pad1TopMarin)
116  pad1.SetBottomMargin(self.pad1BotMarin)
117  pad1.SetLeftMargin(self.LeftMargin)
118  pad1.Draw()
119  pad2 = ROOT.TPad("pad2"+uniqueName,"bottom pad"+uniqueName,0,0,1,self.rsplit)
120  pad2.SetTopMargin(self.pad2TopMarin)
121  pad2.SetBottomMargin(self.pad2BotMarin)
122  pad2.SetLeftMargin(self.LeftMargin)
123  pad2.SetTicky()
124  pad2.SetTickx()
125  pad2.Draw()
126  return canv, pad1, pad2
127 
128  def configureUpperPad(self,hs1):
129  hs1.GetXaxis().SetLabelSize(0)
130  hs1.GetYaxis().SetLabelSize(0.075)
131  hs1.GetYaxis().SetTitleSize(0.082)
132  hs1.GetYaxis().SetTitleOffset(0.7)
133  hs1.GetYaxis().SetTitle(self.yaxis)
134  ROOT.gPad.RedrawAxis()
135 
136  def configureLowerPad(self,h2,ratiodn,ratioup,xaxis,yaxisr):
137  h2.SetFillColor(0)
138  h2.SetFillStyle(0)
139  h2.GetXaxis().SetTitle(xaxis)
140  h2.GetYaxis().SetTitle(yaxisr)
141  h2.GetYaxis().SetRangeUser(1.0 - ratiodn, 1.0 + ratioup)
142  h2.SetLineColor(ROOT.kBlack)
143  h2.GetXaxis().LabelsOption("v")
144  h2.GetXaxis().SetLabelSize(0.15)
145  h2.GetXaxis().SetLabelOffset(0.02)
146  h2.GetXaxis().SetTitleOffset(2.2)
147  h2.GetXaxis().SetTitleSize(0.14)
148  h2.GetYaxis().SetLabelSize(0.11)
149  h2.GetYaxis().SetNdivisions(3)
150  h2.GetYaxis().SetTitleOffset(0.5)
151  h2.GetYaxis().SetTitleSize(0.12)
152  ROOT.gPad.RedrawAxis()
153 
155  rsplit = 0.35
156  pad1TopMarin = 0.07
157  pad1BotMarin = 0.04
158  pad2TopMarin = 0.03
159  pad2BotMarin = 0.4
160  LeftMargin = 0.15
161  yaxis = "Steps"
162 
163  def getCanvas(self, uniqueName, nologx = False, nology = False):
164  canv = ROOT.TCanvas(uniqueName,uniqueName,800,600)
165  pad1 = ROOT.TPad("pad1"+uniqueName,"top pad"+uniqueName,0.,self.rsplit,1.,1.)
166  pad1.SetTopMargin(self.pad1TopMarin)
167  pad1.SetBottomMargin(self.pad1BotMarin)
168  pad1.SetLeftMargin(self.LeftMargin)
169  if not nologx:
170  pad1.SetLogx()
171  if not nology:
172  pad1.SetLogy()
173  pad1.Draw()
174  pad2 = ROOT.TPad("pad2"+uniqueName,"bottom pad"+uniqueName,0,0,1,self.rsplit)
175  pad2.SetTopMargin(self.pad2TopMarin)
176  pad2.SetBottomMargin(self.pad2BotMarin)
177  pad2.SetLeftMargin(self.LeftMargin)
178  pad2.SetTicky()
179  pad2.SetTickx()
180  if not nologx:
181  pad2.SetLogx()
182  pad2.SetGridy()
183  pad2.Draw()
184  return canv, pad1, pad2
185 
186  def configureUpperPad(self,hs1, yaxis=""):
187  hs1.GetXaxis().SetLabelSize(0)
188  hs1.GetYaxis().SetLabelSize(0.06)
189  hs1.GetYaxis().SetTitleSize(0.06)
190  hs1.GetYaxis().SetTitleOffset(0.95)
191  hs1.GetYaxis().SetTitle(self.yaxis if yaxis=="" else yaxis)
192  ROOT.gPad.RedrawAxis()
193 
194  def configureLowerPad(self,h2,ratio,xaxis,yaxisr):
195  h2.GetXaxis().SetTitle(xaxis)
196  h2.GetYaxis().SetTitle(yaxisr)
197  h2.GetXaxis().SetTitleSize(0.13)
198  h2.GetXaxis().SetTitleOffset(0.9)
199  h2.GetXaxis().SetLabelSize(0.10)
200  h2.GetYaxis().SetTitleSize(0.12)
201  h2.GetYaxis().SetTitleOffset(0.5)
202  h2.GetYaxis().SetLabelSize(0.10)
203  h2.GetYaxis().SetLabelOffset(0.015)
204  h2.GetYaxis().SetRangeUser(0.5,1.5)
205  h2.GetYaxis().SetNdivisions(6)
206  h2.SetMinimum(1.0 - ratio)
207  h2.SetMaximum(1.0 + ratio)
208  ROOT.gPad.RedrawAxis()
209 
210 
211 
212 
213 summary = summaryDefs()
214 histograms = histogramDefs()
215 
python.plotting.G4DebuggerConfig.merge_two_dicts
def merge_two_dicts(x, y)
Definition: G4DebuggerConfig.py:4
python.plotting.G4DebuggerConfig.histogramDefs.configureLowerPad
def configureLowerPad(self, h2, ratio, xaxis, yaxisr)
Definition: G4DebuggerConfig.py:194
python.plotting.G4DebuggerConfig.summaryDefs.LeftMargin
float LeftMargin
Definition: G4DebuggerConfig.py:108
python.plotting.G4DebuggerConfig.histogramDefs.pad1BotMarin
float pad1BotMarin
Definition: G4DebuggerConfig.py:157
python.plotting.G4DebuggerConfig.summaryDefs.rsplit
float rsplit
Definition: G4DebuggerConfig.py:103
python.plotting.G4DebuggerConfig.histogramDefs.pad1TopMarin
float pad1TopMarin
Definition: G4DebuggerConfig.py:156
python.plotting.G4DebuggerConfig.summaryDefs.configureLowerPad
def configureLowerPad(self, h2, ratiodn, ratioup, xaxis, yaxisr)
Definition: G4DebuggerConfig.py:136
python.plotting.G4DebuggerConfig.summaryDefs.pad2BotMarin
float pad2BotMarin
Definition: G4DebuggerConfig.py:107
python.plotting.G4DebuggerConfig.histogramDefs.pad2TopMarin
float pad2TopMarin
Definition: G4DebuggerConfig.py:158
python.plotting.G4DebuggerConfig.summaryDefs.configureUpperPad
def configureUpperPad(self, hs1)
Definition: G4DebuggerConfig.py:128
python.plotting.G4DebuggerConfig.histogramDefs.rsplit
float rsplit
Definition: G4DebuggerConfig.py:155
python.plotting.G4DebuggerConfig.histogramDefs.LeftMargin
float LeftMargin
Definition: G4DebuggerConfig.py:160
python.plotting.G4DebuggerConfig.histogramDefs.yaxis
string yaxis
Definition: G4DebuggerConfig.py:161
python.plotting.G4DebuggerConfig.summaryDefs.pad1BotMarin
float pad1BotMarin
Definition: G4DebuggerConfig.py:105
python.plotting.G4DebuggerConfig.histogramDefs.configureUpperPad
def configureUpperPad(self, hs1, yaxis="")
Definition: G4DebuggerConfig.py:186
python.plotting.G4DebuggerConfig.histogramDefs.getCanvas
def getCanvas(self, uniqueName, nologx=False, nology=False)
Definition: G4DebuggerConfig.py:163
python.plotting.G4DebuggerConfig.summaryDefs.yaxis
string yaxis
Definition: G4DebuggerConfig.py:110
python.plotting.G4DebuggerConfig.histogramDefs
Definition: G4DebuggerConfig.py:154
python.plotting.G4DebuggerConfig.summaryDefs.getCanvas
def getCanvas(self, uniqueName)
Definition: G4DebuggerConfig.py:112
python.plotting.G4DebuggerConfig.summaryDefs
Definition: G4DebuggerConfig.py:102
python.plotting.G4DebuggerConfig.summaryDefs.pad1TopMarin
float pad1TopMarin
Definition: G4DebuggerConfig.py:104
python.plotting.G4DebuggerConfig.summaryDefs.pad2TopMarin
float pad2TopMarin
Definition: G4DebuggerConfig.py:106
python.plotting.G4DebuggerConfig.histogramDefs.pad2BotMarin
float pad2BotMarin
Definition: G4DebuggerConfig.py:159