CMS 3D CMS Logo

Classes | Functions | Variables
produceOfflineValidationTex Namespace Reference

Classes

class  PageLayout
 
class  ValidationPlots
 

Functions

def main ()
 
def plotSortKey (plot)
 
def writePage (plots, title, layout)
 
def writePageReg (identifier, title, validations, layout=0)
 
def writeSubsection (identifier, title, validations)
 

Variables

 subdetectors
 

Function Documentation

def produceOfflineValidationTex.main ( )

Definition at line 166 of file produceOfflineValidationTex.py.

References python.rootplot.root2matplotlib.replace(), writePageReg(), and writeSubsection().

166 def main():
167  print 'Producing a .tex file from plots...'
168 
169  # Get plots from given paths
170  if len(sys.argv) < 2:
171  print 'Error: Need path of plots as an argument!'
172  sys.exit(1)
173 
174  validations = []
175  for plotpath in sys.argv[1:]:
176  validations.append(ValidationPlots(plotpath))
177 
178  # Compose .tex frames
179  frames = ''
180  # chi2
181  frames += subsectionTemplate.replace('[title]', 'Chi^2 plots')
182  frames += writePageReg('chi2', r'$\chi^2$ plots', validations)
183  # DMRs
184  frames += writeSubsection('DmedianY*R.*plain.eps$', 'DMR', validations)
185  # Split DMRs
186  frames += writeSubsection('DmedianY*R.*split.eps$','Split DMR',validations)
187  # DRnRs:
188  frames += writeSubsection('DrmsNY*R.*plain.eps$', 'DRnR', validations)
189  # Surface Shapes
190  frames += writeSubsection('SurfaceShape', 'Surface Shape', validations)
191  # Additional plots
192  #frames += writePageReg('YourRegExp', 'PageTitle', validations)
193 
194  # Write final .tex file
195  file = open('presentation.tex', 'w')
196  file.write(texTemplate.replace('[frames]', frames).\
197  replace('[time]', time.ctime()))
198  file.close()
199 
200  # A script to get from .tex to .pdf
201  pdfScript = open('toPdf.sh', 'w')
202  pdfScript.write(toPdf)
203  pdfScript.close()
204  os.chmod("toPdf.sh", stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
205 
206 
207 
def replace(string, replacements)
def writePageReg(identifier, title, validations, layout=0)
def writeSubsection(identifier, title, validations)
def produceOfflineValidationTex.plotSortKey (   plot)

Definition at line 152 of file produceOfflineValidationTex.py.

152 def plotSortKey(plot):
153  # Move normchi2 before chi2Prob
154  if plot.find('normchi2') != -1:
155  return 'chi2a'
156  if plot.find('chi2Prob') != -1:
157  return 'chi2b'
158  return plot
159 
160 
161 
162 
163 
164 
165 # Script execution.
def produceOfflineValidationTex.writePage (   plots,
  title,
  layout 
)

Definition at line 136 of file produceOfflineValidationTex.py.

References join(), python.rootplot.root2matplotlib.replace(), and harvestTrackValidationPlots.str.

Referenced by writePageReg().

136 def writePage(plots, title, layout):
137  plotrows = []
138  for row in layout.pattern:
139  plotrow = []
140  for i in xrange(len(row)):
141  plotrow.append(plotTemplate.replace('[width]', str(layout.width)).\
142  replace('[height]', str(layout.height)).\
143  replace('[path]', plots[row[i]-1]))
144  plotrows.append('\n'.join(plotrow))
145  script = ' \\\\\n'.join(plotrows)
146 
147  return frameTemplate.replace('[plots]', script).replace('[title]', title)
148 
149 
150 # Sort key to rearrange a plot list.
151 # Arguments: plot: to be sorted.
def replace(string, replacements)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def produceOfflineValidationTex.writePageReg (   identifier,
  title,
  validations,
  layout = 0 
)

Definition at line 112 of file produceOfflineValidationTex.py.

References writePage().

Referenced by main(), and writeSubsection().

112 def writePageReg(identifier, title, validations, layout=0):
113  plots = []
114  for validation in validations:
115  valiplots = [validation.path+plot for plot in validation.plots
116  if re.search(identifier, plot)]
117  valiplots.sort(key=plotSortKey)
118  plots.append(valiplots)
119  if sum(len(p) for p in plots) == 0:
120  print 'Warning: no plots matching ' + identifier
121  return ''
122 
123  # Create layout, if not given.
124  if layout == 0:
125  layout = PageLayout()
126  layout.fit(plots)
127 
128  return writePage([p for vali in plots for p in vali], title, layout)
129 
130 
131 # Write the given plots on a page.
132 # Arguments: plots: paths of plots to be drawn on the page
133 # title: title of the plot type
134 # layout: a PageLayout object definig the layout.
135 # Returns the parsed script.
def writePageReg(identifier, title, validations, layout=0)
def produceOfflineValidationTex.writeSubsection (   identifier,
  title,
  validations 
)

Definition at line 96 of file produceOfflineValidationTex.py.

References writePageReg().

Referenced by main().

96 def writeSubsection(identifier, title, validations):
97  script = ''
98  for subdetector in subdetectors:
99  script += writePageReg('(?=.*%s)%s'%(subdetector, identifier),
100  title+': ' +subdetector, validations)
101  if script != '':
102  script = subsectionTemplate.replace('[title]', title)+script
103  return script
104 
105 
106 # Write a page containing plots of given type.
107 # Arguments: identifier: regular expression to get the wanted plots
108 # title: title of the plot type
109 # validations: list of relevant ValidationPlots objects
110 # layout: given page layout.
111 # Returns the parsed script.
def writePageReg(identifier, title, validations, layout=0)
def writeSubsection(identifier, title, validations)

Variable Documentation

produceOfflineValidationTex.subdetectors