ATLAS Offline Software
Loading...
Searching...
No Matches
plotBeamSpotVert.Plots Class Reference
Inheritance diagram for plotBeamSpotVert.Plots:
Collaboration diagram for plotBeamSpotVert.Plots:

Public Member Functions

 hist (self)
 histErr (self)
 histErrComp (self)
 xz (self)
 yz (self)
 yx (self)
 protect (self, obj)
 plot (self, plotName='', *args)
 genPlot (self, what='ALL', code='plot', labels=[], *args)

Public Attributes

 name = name
list otherMethods = []
list rootObjects = []
list whatList = []
str singleCanvasSize = 'default'
str allCanvasSize = 'page'
tuple allCanvasDivs = (3,4)
list saveAsList = []
list gPadSaveAsList = []

Detailed Description

Definition at line 145 of file plotBeamSpotVert.py.

Member Function Documentation

◆ genPlot()

ROOTUtils.PlotLibrary.genPlot ( self,
what = 'ALL',
code = 'plot',
labels = [],
* args )
inherited
Make plots using a general code. genPlot makes either a single plot defined
   by argument what, or all plots (if what=''). The plots made in the latter
   case are specified by whatList. A canvas that is subdivided if necessary
   is created before the plotting code is called.

Definition at line 116 of file roofit/ROOTUtils.py.

116 def genPlot(self,what='ALL',code='plot',labels=[],*args):
117 """Make plots using a general code. genPlot makes either a single plot defined
118 by argument what, or all plots (if what=''). The plots made in the latter
119 case are specified by whatList. A canvas that is subdivided if necessary
120 is created before the plotting code is called."""
121 if what=='' or what.upper()=='ALL':
122 c = self.protect( MyCanvas('%s-%s-%s' % (self.name,what,code),
123 self.allCanvasSize,self.allCanvasDivs[0],self.allCanvasDivs[1]) )
124 iCanvas = 0
125 for w in self.whatList:
126 iCanvas += 1
127 c.cd(iCanvas)
128 try:
129 self.__class__.__dict__[code](self,w,*args)
130 except:
131 self.__class__.__bases__[0].__dict__[code](self,w,*args)
132 ROOT.gPad.Update()
133 # For some strange reason, this works only for .eps, but not e.g. for gif files...???
134 for o in self.gPadSaveAsList:
135 if o[0]=='.':
136 ROOT.gPad.SaveAs('%s-%s-%s%s' % (self.name,code,w,o))
137 else:
138 ROOT.gPad.SaveAs(o)
139
140 # If we want to put some labels on an empty pad, add them now.
141 if labels!=[] and self.allCanvasDivs[0]*self.allCanvasDivs[1] > len(self.whatList):
142 iCanvas+=1
143 c.cd(iCanvas)
144 xtext=0.0
145 ytext=0.8
146 for label in labels:
147 drawText(xtext,ytext,0.06,label)
148 ytext=ytext-0.1
149 elif labels!=[]:
150 print "ERROR: can't add labels unless we have an empty pad to use. Ignoring labels."
151
152 for o in self.saveAsList:
153 if o[0]=='.':
154 c.SaveAs('%s-%s-%s%s' % (self.name,code,what,o))
155 else:
156 c.SaveAs(o)
157
158 else:
159 c = self.protect( MyCanvas(what,self.singleCanvasSize) )
160 try:
161 self.__class__.__dict__[code](self,what,*args)
162 except:
163 self.__class__.__bases__[0].__dict__[code](self,what,*args)
164 ROOT.gPad.Update()
165 for o in self.saveAsList:
166 if o[0]=='.':
167 c.SaveAs('%s-%s-%s%s' % (self.name,code,what,o))
168 else:
169 c.SaveAs(o)
170

◆ hist()

plotBeamSpotVert.Plots.hist ( self)

Definition at line 147 of file plotBeamSpotVert.py.

147 def hist(self):
148 hname = getPlotDef(options.plot,'hname','h')
149 var = getPlotDef(options.plot,'var')
150 units = getPlotDef(options.plot,'units','')
151 ROOT.gStyle.SetOptStat(options.optstat)
152 if options.fit:
153 ROOT.gStyle.SetOptFit(1111)
154 c = ROOTUtils.protect(ROOTUtils.MyCanvas(var,options.canvas))
155 c.SetRightMargin(0.14)
156 h = ROOTUtils.protect(ROOT.TH1F(hname,'Primary vertex: %s;Primary vertex %s %s' % (var,var,units),nbins,xmin,xmax))
157 nt.Draw('%s >> %s' % (var,hname),cuts)
158 if options.fit:
159 h.Fit(options.fit)
160 ROOTUtils.drawText(0.2,0.77,0.06,runFillInfo,font=42)
161 comment = options.comment if options.comment is not None else '#geq %i tracks/vertex;%s' % (options.ntracks,options.cuts)
162 ROOTUtils.drawText(0.2,0.71,0.06,lhcEnergyInfo+comment,font=42)
163 ROOT.gPad.SetLogy(options.logy)
164 ROOT.gPad.Update()
165 c.save()
166
drawText(x=0.74, y=0.87, dy=0.06, text='', font=62, color=1, align=11, linesep=';')

◆ histErr()

plotBeamSpotVert.Plots.histErr ( self)

Definition at line 167 of file plotBeamSpotVert.py.

167 def histErr(self):
168 hname = getPlotDef(options.plot,'hname','h')
169 var = getPlotDef(options.plot,'var')
170 vName = var[1:] # Ugly - should take from plotDef
171 ROOT.gStyle.SetOptStat(options.optstat)
172 ROOT.gStyle.SetOptFit(0)
173 c = ROOTUtils.protect(ROOTUtils.MyCanvas(var,options.canvas))
174 c.SetRightMargin(0.14)
175 h = ROOTUtils.protect(ROOT.TH1F(hname,'Primary vertex error: %s;Primary vertex error #sqrt{V_{%s}} (#mum);Number of vertices' % (hname,vName),
176 nbins,xmin,xmax))
177 nt.Draw('1e3*sqrt(%s) >> %s' % (var,hname),cuts)
178 ROOTUtils.drawText(0.45,0.86,0.06,'Primary Vertex Error #sqrt{V_{%s}}' % vName)
179 comment = options.comment if options.comment is not None else '#geq %i tracks/vertex;%s' % (options.ntracks,options.cuts)
180 ROOTUtils.drawText(0.45,0.8,0.06,lhcEnergyInfo+comment,font=42)
181 ROOT.gPad.SetLogy(options.logy)
182 ROOT.gPad.Update()
183 c.save()
184

◆ histErrComp()

plotBeamSpotVert.Plots.histErrComp ( self)

Definition at line 185 of file plotBeamSpotVert.py.

185 def histErrComp(self):
186 hname = getPlotDef(options.plot,'hname','h')
187 var = getPlotDef(options.plot,'var')
188 vName = var[1:] # Ugly - should take from plotDef
189 ROOT.gStyle.SetOptStat(0)
190 ROOT.gStyle.SetOptFit(0)
191 c = ROOTUtils.protect(ROOTUtils.MyCanvas(var,options.canvas))
192 c.SetRightMargin(0.14)
193 h = ROOTUtils.protect(ROOT.TH1F(hname,'Vertex Error: %s;Vertex error #sqrt{V_{%s}} [#mum];Fraction of entries' % (hname,vName),
194 nbins,xmin,xmax))
195 nt.Draw('1e3*sqrt(%s) >> %s' % (var,hname),cuts)
196 norm = h.Integral()
197 h.Scale(1./norm)
198 pname = hname+'_pileup'
199 p = ROOTUtils.protect(ROOT.TH1F(pname,'Vertex Error: %s;Vertex error #sqrt{V_{%s}} [#mum];Fraction of entries' % (hname,vName),
200 nbins,xmin,xmax))
201 pcuts = cuts.replace('vType==1','vType==3')
202 print (pcuts)
203 nt.Draw('1e3*sqrt(%s) >> %s' % (var,pname),pcuts,"SAME")
204 pnorm = p.Integral()
205 p.Scale(1./pnorm)
206 p.SetLineColor(4)
207 p.SetLineStyle(2)
208 ROOTUtils.drawText(0.51,0.86,0.06,'Vertex error #sqrt{V_{%s}}' % vName)
209 comment = options.comment if options.comment is not None else '#geq %i tracks/vertex;%s' % (options.ntracks,options.cuts)
210 ROOTUtils.drawText(0.51,0.8,0.06,lhcEnergyInfo+comment,font=42)
211 legend = ROOT.TLegend(.50,.6,.85,.72)
212 legend.AddEntry(h,'Primary vertices','L')
213 legend.AddEntry(p,'Pileup vertices','L')
214 legend.SetFillColor(0)
215 legend.SetBorderSize(0)
216 legend.Draw()
217 ROOT.gPad.SetLogy(options.logy)
218 ROOT.gPad.Update()
219 c.save()
220

◆ plot()

ROOTUtils.PlotLibrary.plot ( self,
plotName = '',
* args )
inherited
Make one or all (if plotName=='') plots.

Reimplemented in beamspotnt.Plots, and beamspotnt.Plots.

Definition at line 106 of file roofit/ROOTUtils.py.

106 def plot(self, plotName='',*args):
107 """Make one or all (if plotName=='') plots."""
108 if plotName:
109 self.__class__.__dict__[plotName](self,*args)
110 else:
111 for i in self.__class__.__dict__:
112 if i[0]=='_': continue # skip private methods
113 if i in self.otherMethods: continue
114 self.__class__.__dict__[i](self,*args)
115

◆ protect()

ROOTUtils.PlotLibrary.protect ( self,
obj )
inherited
Protect ROOT object from garbage collection.

Definition at line 101 of file roofit/ROOTUtils.py.

101 def protect(self,obj):
102 """Protect ROOT object from garbage collection."""
103 self.rootObjects.append(obj)
104 return obj
105

◆ xz()

plotBeamSpotVert.Plots.xz ( self)

Definition at line 221 of file plotBeamSpotVert.py.

221 def xz(self):
222 #ROOT.gStyle.SetOptStat(1010)
223 ROOT.gStyle.SetOptStat(0)
224 c = ROOTUtils.protect(ROOTUtils.MyCanvas('xz',options.canvas))
225 c.SetRightMargin(0.14)
226 h = ROOTUtils.protect(ROOT.TH2F('pvXZ','Primary vertex: x vs z;Primary vertex z [mm];Primary vertex x [mm]',nbins,xmin,xmax,nbins,ymin,ymax))
227 nt.Draw('x:z >> pvXZ',cuts)
228 h.Draw('COLZ')
229 h.GetYaxis().SetTitleOffset(1.0)
230 drawLabels()
231 #ROOTUtils.moveStats(h,-0.16,-0.08)
232 drawInfo(c,h,options.more)
233 ROOT.gPad.Update()
234 c.save()
235

◆ yx()

plotBeamSpotVert.Plots.yx ( self)

Definition at line 249 of file plotBeamSpotVert.py.

249 def yx(self):
250 ROOT.gStyle.SetOptStat(0)
251 c = ROOTUtils.protect(ROOTUtils.MyCanvas('yx',options.canvas))
252 c.SetRightMargin(0.14)
253 h = ROOTUtils.protect(ROOT.TH2F('pvYX','Primary vertex: y vs x;Primary vertex x [mm];Primary vertex y [mm]',nbins,xmin,xmax,nbins,ymin,ymax))
254 nt.Draw('y:x >> pvYX',cuts)
255 h.Draw('COLZ')
256 h.GetYaxis().SetTitleOffset(1.0)
257 drawLabels()
258 drawInfo(c,h,options.more)
259 ROOT.gPad.Update()
260 c.save()
261
262
263# Start processing

◆ yz()

plotBeamSpotVert.Plots.yz ( self)

Definition at line 236 of file plotBeamSpotVert.py.

236 def yz(self):
237 ROOT.gStyle.SetOptStat(0)
238 c = ROOTUtils.protect(ROOTUtils.MyCanvas('yz',options.canvas))
239 c.SetRightMargin(0.14)
240 h = ROOTUtils.protect(ROOT.TH2F('pvYZ','Primary vertex: y vs z;Primary vertex z [mm];Primary vertex y [mm]',nbins,xmin,xmax,nbins,ymin,ymax))
241 nt.Draw('y:z >> pvYZ',cuts)
242 h.Draw('COLZ')
243 h.GetYaxis().SetTitleOffset(1.0)
244 drawLabels()
245 drawInfo(c,h,options.more)
246 ROOT.gPad.Update()
247 c.save()
248

Member Data Documentation

◆ allCanvasDivs

tuple ROOTUtils.PlotLibrary.allCanvasDivs = (3,4)
inherited

Definition at line 97 of file roofit/ROOTUtils.py.

◆ allCanvasSize

str ROOTUtils.PlotLibrary.allCanvasSize = 'page'
inherited

Definition at line 96 of file roofit/ROOTUtils.py.

◆ gPadSaveAsList

list ROOTUtils.PlotLibrary.gPadSaveAsList = []
inherited

Definition at line 99 of file roofit/ROOTUtils.py.

◆ name

ROOTUtils.PlotLibrary.name = name
inherited

Definition at line 88 of file roofit/ROOTUtils.py.

◆ otherMethods

list ROOTUtils.PlotLibrary.otherMethods = []
inherited

Definition at line 89 of file roofit/ROOTUtils.py.

◆ rootObjects

list ROOTUtils.PlotLibrary.rootObjects = []
inherited

Definition at line 91 of file roofit/ROOTUtils.py.

◆ saveAsList

list ROOTUtils.PlotLibrary.saveAsList = []
inherited

Definition at line 98 of file roofit/ROOTUtils.py.

◆ singleCanvasSize

str ROOTUtils.PlotLibrary.singleCanvasSize = 'default'
inherited

Definition at line 95 of file roofit/ROOTUtils.py.

◆ whatList

list ROOTUtils.PlotLibrary.whatList = []
inherited

Definition at line 94 of file roofit/ROOTUtils.py.


The documentation for this class was generated from the following file: