test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
produceOfflineValidationTex Namespace Reference

Classes

class  PageLayout
 
class  ValidationPlots
 

Functions

def main
 
def plotSortKey
 
def writePage
 
def writePageReg
 
def writeSubsection
 

Variables

list subdetectors = ["BPIX", "FPIX", "TIB", "TOB", "TID", "TEC"]
 

Function Documentation

def produceOfflineValidationTex.main ( )

Definition at line 166 of file produceOfflineValidationTex.py.

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

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

Definition at line 152 of file produceOfflineValidationTex.py.

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

Definition at line 136 of file produceOfflineValidationTex.py.

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

Referenced by writePageReg().

137 def writePage(plots, title, layout):
138  plotrows = []
139  for row in layout.pattern:
140  plotrow = []
141  for i in xrange(len(row)):
142  plotrow.append(plotTemplate.replace('[width]', str(layout.width)).\
143  replace('[height]', str(layout.height)).\
144  replace('[path]', plots[row[i]-1]))
145  plotrows.append('\n'.join(plotrow))
146  script = ' \\\\\n'.join(plotrows)
147 
148  return frameTemplate.replace('[plots]', script).replace('[title]', title)
149 
150 
151 # Sort key to rearrange a plot list.
# Arguments: plot: to be sorted.
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().

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

Definition at line 96 of file produceOfflineValidationTex.py.

References writePageReg().

Referenced by main().

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

Variable Documentation

list produceOfflineValidationTex.subdetectors = ["BPIX", "FPIX", "TIB", "TOB", "TID", "TEC"]

Definition at line 28 of file produceOfflineValidationTex.py.

Referenced by TrackAnalyzer.bookHistosForTrackerSpecific(), and PSimHitSelector.PSimHitSelector().