ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
plotBeamSpotVert.Plots Class Reference
Inheritance diagram for plotBeamSpotVert.Plots:
Collaboration diagram for plotBeamSpotVert.Plots:

Public Member Functions

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

Public Attributes

 name
 
 otherMethods
 
 rootObjects
 
 whatList
 
 singleCanvasSize
 
 allCanvasSize
 
 allCanvasDivs
 
 saveAsList
 
 gPadSaveAsList
 

Detailed Description

Definition at line 146 of file plotBeamSpotVert.py.

Member Function Documentation

◆ genPlot()

def 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()

def plotBeamSpotVert.Plots.hist (   self)

Definition at line 148 of file plotBeamSpotVert.py.

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

◆ histErr()

def plotBeamSpotVert.Plots.histErr (   self)

Definition at line 168 of file plotBeamSpotVert.py.

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

◆ histErrComp()

def plotBeamSpotVert.Plots.histErrComp (   self)

Definition at line 186 of file plotBeamSpotVert.py.

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

◆ plot()

def ROOTUtils.PlotLibrary.plot (   self,
  plotName = '',
args 
)
inherited
Make one or all (if plotName=='') 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()

def 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()

def plotBeamSpotVert.Plots.xz (   self)

Definition at line 222 of file plotBeamSpotVert.py.

222  def xz(self):
223  #ROOT.gStyle.SetOptStat(1010)
224  ROOT.gStyle.SetOptStat(0)
225  c = ROOTUtils.protect(ROOTUtils.MyCanvas('xz',options.canvas))
226  c.SetRightMargin(0.14)
227  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))
228  nt.Draw('x:z >> pvXZ',cuts)
229  h.Draw('COLZ')
230  h.GetYaxis().SetTitleOffset(1.0)
231  drawLabels()
232  #ROOTUtils.moveStats(h,-0.16,-0.08)
233  drawInfo(c,h,options.more)
234  ROOT.gPad.Update()
235  c.save()
236 

◆ yx()

def plotBeamSpotVert.Plots.yx (   self)

Definition at line 250 of file plotBeamSpotVert.py.

250  def yx(self):
251  ROOT.gStyle.SetOptStat(0)
252  c = ROOTUtils.protect(ROOTUtils.MyCanvas('yx',options.canvas))
253  c.SetRightMargin(0.14)
254  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))
255  nt.Draw('y:x >> pvYX',cuts)
256  h.Draw('COLZ')
257  h.GetYaxis().SetTitleOffset(1.0)
258  drawLabels()
259  drawInfo(c,h,options.more)
260  ROOT.gPad.Update()
261  c.save()
262 
263 
264 # Start processing

◆ yz()

def plotBeamSpotVert.Plots.yz (   self)

Definition at line 237 of file plotBeamSpotVert.py.

237  def yz(self):
238  ROOT.gStyle.SetOptStat(0)
239  c = ROOTUtils.protect(ROOTUtils.MyCanvas('yz',options.canvas))
240  c.SetRightMargin(0.14)
241  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))
242  nt.Draw('y:z >> pvYZ',cuts)
243  h.Draw('COLZ')
244  h.GetYaxis().SetTitleOffset(1.0)
245  drawLabels()
246  drawInfo(c,h,options.more)
247  ROOT.gPad.Update()
248  c.save()
249 

Member Data Documentation

◆ allCanvasDivs

ROOTUtils.PlotLibrary.allCanvasDivs
inherited

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

◆ allCanvasSize

ROOTUtils.PlotLibrary.allCanvasSize
inherited

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

◆ gPadSaveAsList

ROOTUtils.PlotLibrary.gPadSaveAsList
inherited

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

◆ name

ROOTUtils.PlotLibrary.name
inherited

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

◆ otherMethods

ROOTUtils.PlotLibrary.otherMethods
inherited

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

◆ rootObjects

ROOTUtils.PlotLibrary.rootObjects
inherited

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

◆ saveAsList

ROOTUtils.PlotLibrary.saveAsList
inherited

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

◆ singleCanvasSize

ROOTUtils.PlotLibrary.singleCanvasSize
inherited

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

◆ whatList

ROOTUtils.PlotLibrary.whatList
inherited

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


The documentation for this class was generated from the following file:
ROOTUtils.drawText
def drawText(x=0.74, y=0.87, dy=0.06, text='', font=62, color=1, align=11, linesep=';')
Definition: roofit/ROOTUtils.py:243
plotBeamSpotVert.drawInfo
def drawInfo(c, h, more, x=0.6, size=0.04)
Definition: plotBeamSpotVert.py:136
ROOTUtils.MyCanvas
Definition: roofit/ROOTUtils.py:40
plotmaker.hist
hist
Definition: plotmaker.py:148
ROOTUtils.protect
def protect(obj)
Definition: roofit/ROOTUtils.py:17
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVert.getPlotDef
def getPlotDef(what, property, default='')
Definition: plotBeamSpotVert.py:68
plot
bool plot
Definition: listroot.cxx:44
plotBeamSpotVert.drawLabels
def drawLabels()
Definition: plotBeamSpotVert.py:123