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