ATLAS Offline Software
Loading...
Searching...
No Matches
bin/beamspotnt.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
5
6"""
7beamspotnt is a command line utility for beam spot ntuples.
8"""
9__author__ = 'Juerg Beringer'
10__version__ = 'beamspotnt.py atlas/athena'
11__usage__ = '''%prog [options] command [args ...]
12
13Commands are:
14
15dump Dump contents of a beam spot ntuple
16maketable Make LaTeX table of selected entries
17inspect Inspect ntuple and provide summary of contents
18merge SRCNT Merge source beam spot ntuple into master ntuple
19 (use --srcnt to specify type if not BeamSpotFinderNt)
20ave Calculate average of beam spot parameters
21hist var Histogram of var
22histvspileup var Profile histogram of var vs pileup
23pull var:value Pull of var with respect to true value
24plot var History of var
25summary Summary history plots
26ascii filename Write ASCII file with data in Massi\'s format
27
28Examples:
29
30beamspotnt -t BeamSpotCOOL -f IndetBeampos-ES1-UPD2 --ru 165815 --rl 165815 dump
31'''
32
33#periodDef = '/afs/cern.ch/atlas/www/GROUPS/DATAPREPARATION/DataPeriods'
34periodDef = '/afs/cern.ch/user/a/atlidbs/nt/DataPeriods'
35
36import sys, os, time, glob, re, copy, math
37
38# Create a properly quoted string of the command line to save
39qargv = [ ]
40for s in sys.argv:
41 if re.search(r'\s|\*|\?',s): # any white space or special characters in word so we need quoting?
42 if "'" in s:
43 qargv.append('"%s"' % re.sub('"',"'",s))
44 else:
45 qargv.append("'%s'" % re.sub("'",'"',s))
46 else:
47 qargv.append(s)
48qcmd = ' '.join(qargv)
49
50from optparse import OptionParser
51parser = OptionParser(usage=__usage__, version=__version__)
52parser.add_option('-f', '--nt', dest='ntname', default='beamspotnt.root', help='master ntuple file name or COOL tag (default: beamspotnt.root)')
53parser.add_option('-t', '--type', dest='type', default='BeamSpotNt', help='master ntuple type (default: BeamSpotNt)')
54parser.add_option('-s', '--srctype', dest='srctype', default='BeamSpotNt', help='source ntuple type for merging (default: BeamSpotNt)')
55parser.add_option('-v', '--verbose', dest='verbose', action='store_true', default=False, help='verbose output')
56parser.add_option('-d', '--debug', dest='debug', action='store_true', default=False, help='debug output')
57parser.add_option('-q', '--quiet', dest='quiet', action='store_true', default=False, help='reduce output')
58parser.add_option('-r', '--run', dest='run', type='int', default=None, help='run number (single run)')
59parser.add_option('', '--rl', dest='runMin', type='int', default=None, help='minimum run number (inclusive)')
60parser.add_option('', '--ru', dest='runMax', type='int', default=None, help='maximum run number (inclusive)')
61parser.add_option('', '--re', dest='runExclude', default=None, help='comma seperated list of runs to exclude')
62parser.add_option('', '--fill', dest='fill', type='int', default=None, help='fill number (single fill)')
63parser.add_option('', '--fl', dest='fillMin', type='int', default=None, help='minimum fill number (inclusive)')
64parser.add_option('', '--fu', dest='fillMax', type='int', default=None, help='maximum fill number (inclusive)')
65parser.add_option('', '--bcid', dest='bcid', type='int', default=None, help='BCID number (single BCID)')
66parser.add_option('', '--bcl', dest='bcidMin', type='int', default=None, help='minimum BCID number (inclusive)')
67parser.add_option('', '--bcu', dest='bcidMax', type='int', default=None, help='maximum BCID number (inclusive)')
68parser.add_option('', '--lbl', dest='lbMin', type='int', default=None, help='minimum LB number (inclusive)')
69parser.add_option('', '--lbu', dest='lbMax', type='int', default=None, help='maximum LB number (inclusive)')
70parser.add_option('', '--tl', dest='timeMin', default=None, help='minimum start time')
71parser.add_option('', '--tu', dest='timeMax', default=None, help='maximum end time')
72parser.add_option('', '--status', dest='status', default='59', help='comma-separated list of accepted fit status values (default: 59)')
73parser.add_option('', '--energy', dest='energy', default='13', help='center-of-mass energy')
74parser.add_option('-p', '--period', dest='period', default=None, help='comma-separated list of accepted run periods (e.g. data10_7TeV.G)')
75parser.add_option('', '--perioddef', dest='periodDef', default=periodDef, help='location of run period definition files (default: %s)' % periodDef)
76parser.add_option('-g', '--grl', dest='grl', default=None, help='GRL to select runs/Lbs')
77parser.add_option('', '--mc', dest='mc', action='store_true', default=False, help='flag to indicate beam spot results are from MC')
78parser.add_option('', '--fillCOOL', dest='fillcooldata', action='store_true', default=False, help='fill data from COOL (time, fill#)')
79parser.add_option('', '--fillDQ', dest='filldqdata', action='store_true', default=False, help='fill data from DataQualtiy')
80parser.add_option('', '--pLbFile', dest='pseudoLbFile', default=None, help='File for pseudo LB info from scan')
81parser.add_option('', '--pLbTimeUnit', dest='pseudoLbTimeUnit', default=1., help='Time unit for pseudo LB relative to seconds, e.g. 1e-9 for ns')
82parser.add_option('', '--tz', dest='timezone', default='CET', help='time zone to use for time represenation (default: CERN local time)')
83parser.add_option('', '--simpleaverage', dest='simpleaverage', action='store_true', default=False, help='use simple instead of weighted average (for checks only)')
84parser.add_option('', '--lumicalcnt', dest='lumicalcnt', default=None, help='ave: use luminosity ntuple (from iLumiCalc.exe) for weighted average')
85parser.add_option('', '--latex', dest='latex', action='store_true', default=False, help='output results in LaTeX')
86parser.add_option('', '--splittable', dest='splittable', type='int', default=None, help='latex: split table, put first n cols into first table')
87parser.add_option('', '--hist', dest='hist', action='store_true', default=False, help='ave: produce validation histograms')
88parser.add_option('', '--summary', dest='summary', action='store_true', default=False, help='ave: produce validation summary plots')
89parser.add_option('', '--rms', dest='rms', action='store_true', default=False, help='Use RMS instead of error on mean')
90parser.add_option('', '--varlist', dest='varlist', default=None, help='list of beam spot variables used by ave')
91parser.add_option('-n', '--nbins', dest='nbins', type='int', default=None, help='number of bins')
92parser.add_option('', '--xmin', dest='xmin', default=None, help='x axis minimum')
93parser.add_option('', '--xmax', dest='xmax', default=None, help='x axis maximum')
94parser.add_option('', '--timeaxis', dest='timeaxis', action='store_true', default=False, help='use time on x axis instead of run or LB numbers')
95parser.add_option('', '--talabel', dest='talabel', default=None, help='time axis label (default: Time (timezone))')
96parser.add_option('', '--perbcid', dest='perbcid', action='store_true', default=False, help='plot per BCID instead of vs time/LB')
97parser.add_option('', '--separation', dest='separation', action='store_true', default=False, help='plot versus beam separation for scans')
98parser.add_option('', '--vsbunchpos', dest='vsbunchpos', action='store_true', default=False, help='plot versus bunch position in train')
99parser.add_option('', '--ndivs', dest='ndivs', type='int', default=None, help='Number of x axis divisions (ROOT format)')
100parser.add_option('', '--ymin', dest='ymin', type='float', default=None, help='y axis minimum')
101parser.add_option('', '--ymax', dest='ymax', type='float', default=None, help='y axis maximum')
102parser.add_option('-y', '--yscale', dest='yscale', type='float', default=1.0, help='y axis scale factor')
103parser.add_option('-m', '--msize', dest='msize', type='float', default=None, help='set marker size')
104parser.add_option('', '--lsize', dest='lsize', type='float', default=None, help='set axis label size')
105parser.add_option('', '--ydef', dest='ydef', action='store_true', default=False, help='use default y range for given quantity')
106parser.add_option('', '--defaults', dest='defaults', default='Gen', help='choose varDef defauls (default: Gen')
107parser.add_option('', '--logy', dest='logy', action='store_true', default=False, help='log scale')
108parser.add_option('', '--fit', dest='fit', default='', help='fit function (e.g. pol1)')
109parser.add_option('', '--optfit', dest='optfit', default='', help="fit options (default: '')")
110parser.add_option('-c', '--canvas', dest='canvas', default='', help='canvas size: default, page, wide, extrawide or square')
111parser.add_option('', '--xdivs', dest='xdivs', type='int', default=1, help='number of pads on canvas in x (needs -c, default: 1)')
112parser.add_option('', '--ydivs', dest='ydivs', type='int', default=1, help='number of pads on canvas in y (needs -c, default: 1)')
113parser.add_option('', '--optstat', dest='optstat', default='emruo', help='default OptStat value (Default: emruo)')
114parser.add_option('', '--ave', dest='ave', action='store_true', default=False, help='show average on plot')
115parser.add_option('', '--newave', dest='newave', action='store_true', default=False, help='replicate the functionality of the old aveBeamSpot.py script.')
116parser.add_option('', '--title', dest='title', default='', help='title text on plots')
117parser.add_option('', '--comment', dest='comment', default='', help='additional text (use semicolon to indicate line breaks)')
118parser.add_option('', '--datefmt', dest='datefmt', default='', help='date format')
119parser.add_option('', '--adatefmt', dest='adatefmt', default='', help='axis date format')
120parser.add_option('', '--plegend', dest='plegend', default='fit to groups of LBs', help='legend text for points')
121parser.add_option('', '--alegend', dest='alegend', default='average of data shown:', help='legend text for average')
122parser.add_option('', '--maxlegends', dest='maxlegends', type='int', default=10, help='maximum number of legend entries')
123parser.add_option('', '--omitfill', dest='omitfill', action='store_true', default=False, help='remove any fill info from legend')
124parser.add_option('', '--omitrun', dest='omitrun', action='store_true', default=False, help='remove any run info from legend')
125parser.add_option('', '--omittime', dest='omittime', action='store_true', default=False, help='remove any time info from legend')
126parser.add_option('', '--public', dest='public', action='store_true', default=False, help='use labelling for public plots')
127parser.add_option('', '--prelim', dest='prelim', action='store_true', default=False, help='add ATLAS Preliminary to figure')
128parser.add_option('', '--approval', dest='approval', action='store_true', default=False, help='Label figure ATLAS for approval')
129parser.add_option('', '--published', dest='published', action='store_true', default=False, help='add ATLAS to figure')
130parser.add_option('', '--customlabel', dest='customlabel', default='', help='add custom label after ATLAS to figure')
131parser.add_option('', '--xtitoffset', dest='xtitoffset', type='float', default=None, help='x axis title offset')
132parser.add_option('', '--ytitoffset', dest='ytitoffset', type='float', default=None, help='y axis title offset')
133parser.add_option('', '--atlasx', dest='atlasx', type='float', default=None, help='x position for drawing ATLAS (Preliminary) label')
134parser.add_option('', '--atlasy', dest='atlasy', type='float', default=None, help='y position for drawing ATLAS (Preliminary) label')
135parser.add_option('', '--atlasdx', dest='atlasdx', type='float', default=None, help='x position offset for drawing Preliminary label')
136parser.add_option('-o', '--output', dest='output', default='.gif', help='comma-separated list of output files or formats (default: .gif)')
137parser.add_option('', '--name', dest='name', default='BeamSpotNtPlots', help='base name for plots (default: BeamSpotNtPlots)')
138parser.add_option('', '--tgraphfile', dest='tgraphfile', default='', help='optional root file to save TGraph into')
139parser.add_option('', '--tag', dest='cooltag', default='', help='COOL tag for writing average into beam spot SQLite file (also determines file name)')
140parser.add_option('-i', '--interactive', dest='interactive', action='store_true', default=False, help='interactive')
141parser.add_option('-b', '--batch', dest='batch', action='store_true', default=False, help='run in batch mode')
142parser.add_option('', '--fullCorrelations', dest='fullCorrelations', action='store_true', default=False, help='Get all correlations')
143parser.add_option('', '--scans', dest='scans', default='', help='comma-separated list of hypenated lb ranges for lumi scans')
144parser.add_option('', '--acqFlag', dest='acqFlag', default = False, action='store_true', help='Cut on AcquistionFlag=1.0 for stationary points of VdM scan')
145parser.add_option('', '--overlayScans', dest='overlayScans', default = False, action='store_true', help='overlay VdM scans on same plot')
146parser.add_option('', '--useAve', dest='useAve', action='store_true', default=False, help='Average over poor fits in the beamspot -- performed during merging step')
147parser.add_option('', '--database', dest='database', default='COOLOFL_INDET/CONDBR2', help='DB to read beamspot info from when -s BeamSpotCOOL is enabled and running merge')
148parser.add_option('', '--dbfolder', dest='dbfolder', default='/Indet/Beampos', help='Folder to read beamspot info from when -s BeamSpotCOOL is enabled and running merge')
149parser.add_option('', '--addScanVars', dest='addScanVars', action='store_true', default=False, help='Add variables for VdM scan')
150
151(options,args) = parser.parse_args()
152if len(args) < 1:
153 parser.error('wrong number of command line arguments')
154cmd = args[0]
155
156if options.fillcooldata and options.pseudoLbFile:
157 sys.exit('Options fillColl and pseudoLbFile are mutually exclusive')
158
159# Reset DISPLAY if in batch
160if options.batch:
161 os.unsetenv('DISPLAY')
162
163# Place after OptionParse to avoid conflict with ROOT option parsing
164import ROOT
165import InDetBeamSpotExample
166
167# Get BeamSpotData class and choose beam spot variable defaults
168from InDetBeamSpotExample import BeamSpotData
169if options.defaults:
170 BeamSpotData.varDefs = getattr(BeamSpotData,'varDefs'+options.defaults)
172
173#from InDetBeamSpotExample.COOLUtils import *
174from InDetBeamSpotExample.Utils import getUserName, getHostName
175from InDetBeamSpotExample import ROOTUtils
177from math import *
178
179cmdOk = False
180if options.interactive:
181 os.environ['PYTHONINSPECT'] = '1'
182
183if options.timezone:
184 os.environ['TZ'] = options.timezone
185 time.tzset()
186 timeLabel = 'Time (%s)' % options.timezone
187else:
188 timeLabel = 'Local time'
189if options.talabel:
190 timeLabel = options.talabel
191
192if not options.datefmt:
193 if options.public:
194 options.datefmt = '%b %Y'
195 else:
196 options.datefmt = '%a %b %d'
197
198# Graphics defaults
199if options.atlasx==None:
200 if options.published:
201 options.atlasx = 0.83 if 'wide' in options.canvas else 0.8
202 else:
203 options.atlasx = 0.72 if 'wide' in options.canvas else 0.645
204if options.atlasy==None:
205 if options.public:
206 options.atlasy = 0.86
207if options.atlasdx==None:
208 options.atlasdx = 0.08 if 'wide' in options.canvas else 0.115
209
210ntClass = locals()[options.type]
211
212def setCuts(nt):
213 if options.run!=None:
214 nt.runMin = options.run
215 nt.runMax = options.run
216 if options.runMin!=None:
217 nt.runMin = options.runMin
218 if options.runMax!=None:
219 nt.runMax = options.runMax
220 if options.runExclude!=None:
221 nt.runListExclude = [int(r) for r in options.runExclude.split(',')]
222 if options.fill!=None:
223 nt.fillMin = options.fill
224 nt.fillMax = options.fill
225 if options.fillMin!=None:
226 nt.fillMin = options.fillMin
227 if options.fillMax!=None:
228 nt.fillMax = options.fillMax
229 if options.bcid!=None:
230 nt.bcidMin = options.bcid
231 nt.bcidMax = options.bcid
232 if options.bcidMin!=None:
233 nt.bcidMin = options.bcidMin
234 if options.bcidMax!=None:
235 nt.bcidMax = options.bcidMax
236 if options.lbMin!=None:
237 nt.lbMin = options.lbMin
238 if options.lbMax!=None:
239 nt.lbMax = options.lbMax
240 if options.timeMin!=None:
241 nt.timeMin = time.mktime(time.strptime(options.timeMin,'%b %d %H:%M:%S %Y'))
242 if options.timeMax!=None:
243 nt.timeMax = time.mktime(time.strptime(options.timeMax,'%b %d %H:%M:%S %Y'))
244 if options.status:
245 nt.statusList = [int(x) for x in options.status.split(',')]
246 if options.period:
247 for p in options.period.split(','):
248 project,period = p.split('.')
249 location = os.path.normpath(options.periodDef + '/' + project)
250 try:
251 fileName = glob.glob('%s/%s.runs.list' % (location,period))[0]
252 nt.runList.extend([int(r) for r in open(fileName).read().split()])
253 except:
254 sys.exit('ERROR: Definition file for period %s not found in directory %s' % (options.period, location))
255
256 if not nt.runList:
257 sys.exit('ERROR: no runs found for requested periods')
258
259 if options.grl:
260 nt.grl = options.grl
261
262 if options.acqFlag:
263 nt.acqFlag = 1.0
264
265def getNt():
266 try:
267 if options.fullCorrelations:
268 nt = ntClass(options.ntname,fullCorrelations=True)
269 else:
270 nt = ntClass(options.ntname)
271 except Exception as e:
272 sys.exit('ERROR: '+str(e))
273
274 setCuts(nt)
275 print (nt.summary())
276 print (nt.cutSummary())
277 return nt
278
279def cleanUpLowStat( allBSResultsInNt, averagenVtx, lbSize ):
280 i=0
281 while i < len( allBSResultsInNt ):
282 b = allBSResultsInNt[i]
283 if b.status < 70 and b.sigmaZErr == 0:
284 print ("Will change Z error for lb's " + str(b.lbStart) +" to " + str(b.lbEnd) + " which has " + str(b.nValid) + " verticies")
285 b.sigmaZErr = b.sigmaZ * 0.5
286 i += 1
287
288 i=0
289 while i < len( allBSResultsInNt ):
290 b = allBSResultsInNt[i]
291
292 if b.status < 70 and b.nValid < 2000 and b.nValid < averagenVtx:
293 print ("Will take an average for lb's " + str(b.lbStart) +" to " + str(b.lbEnd) + " which has " + str(b.nValid) + " verticies" )
294 lastGoodEntry = b
295 nextGoodEntry = b
296 iNeg = i-1;
297 # Find previous good entry
298 while iNeg >= 0:
299 if allBSResultsInNt[iNeg].status == 59 and allBSResultsInNt[iNeg].nValid > 2000 :
300 lastGoodEntry = allBSResultsInNt[iNeg]
301 print (" --- Starting with lb : " + str(lastGoodEntry.lbStart) +" to " + str(lastGoodEntry.lbEnd))
302 break
303 iNeg -= 1
304
305 # Find the next good entry
306 iPos = i+1;
307 while iPos < len(allBSResultsInNt):
308 if allBSResultsInNt[iPos].status == 59 and allBSResultsInNt[iPos].nValid > 2000:
309 nextGoodEntry = allBSResultsInNt[iPos]
310 print (" --- Ending with lb : " + str(nextGoodEntry.lbStart) +" to " + str(nextGoodEntry.lbEnd))
311 break
312 iPos += 1
313
314 #if all entries are useless then we are in trouble dont do anything
315 if lastGoodEntry == b and nextGoodEntry == b :
316 print ("Failed to do average - no good entries were found")
317 i+=1
318 continue
319
320 #check the entries are reasonablly close to each other
321 if( ( nextGoodEntry == b or abs(nextGoodEntry.lbStart - b.lbEnd) > abs(lbSize) ) and (lastGoodEntry == b or abs(b.lbStart - lastGoodEntry.lbEnd) > abs(lbSize) ) ):
322 print ("Failed to do average - entries were too far away")
323 i+=1
324 continue
325
326 #Calculate the average beamspot position for the following parameters
327 varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
328 if options.cooltag:
329 varList.append('sigmaXY')
330 calc = BeamSpotAverage(varList ,weightedAverage=True)
331 #Add current entry if it is reliable
332 if( b.status == 59 and b.posXErr != 0 and not math.isnan(b.posX) and not math.isnan(b.posZ) and not math.isnan(b.sigmaZ) ):
333 calc.add(b)
334 #Add previous entry if it is not too far away in time
335 if lastGoodEntry != b and abs(b.lbStart - lastGoodEntry.lbEnd) <= abs(lbSize) :
336 calc.add(lastGoodEntry)
337 #Add next entry if it is not too far away in time
338 if nextGoodEntry != b and abs(nextGoodEntry.lbStart - b.lbEnd) <= abs(lbSize) :
339 calc.add(nextGoodEntry)
340 calc.average()
341
342 ave = calc.ave
343 err = calc.err
344 b.status = 666 #b.status << 4
345 bcopy = copy.deepcopy(b)
346
347 for var in varList:
348 setattr(bcopy, var, ave[calc.varList.index(var)])
349 setattr(bcopy, var+"Err", err[calc.varList.index(var)])
350
351 bcopy.status = 59
352 i += 1
353 allBSResultsInNt.insert(i, bcopy)
354 i += 1
355
356
357
358
359def fillInMissingLbs(allBSResultsInNt, lbSize):
360 i=0
361 lastValidEntry = -1
362 nextValidEntry = -1
363 while i < len( allBSResultsInNt ):
364 if allBSResultsInNt[i].status != 59:
365 i += 1
366 continue
367
368 nextValidEntry = i
369
370 if(lastValidEntry >= 0):
371 if allBSResultsInNt[nextValidEntry].lbStart != allBSResultsInNt[lastValidEntry].lbEnd + 1:
372 print ("Missing Lumi block from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd + 1 , allBSResultsInNt[nextValidEntry].lbStart))
373
374
375 if allBSResultsInNt[nextValidEntry].lbStart - allBSResultsInNt[lastValidEntry].lbEnd + 1 > lbSize:
376 print ("--Lumi block gap too large wont fill in the gap" )
377 elif (allBSResultsInNt[nextValidEntry].lbStart-1) - (allBSResultsInNt[lastValidEntry].lbEnd+1) < 0 :
378 print ("Missing Lumi block is invalid from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd+1, allBSResultsInNt[nextValidEntry].lbStart -1))
379 else:
380 varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
381 if options.cooltag:
382 varList.append('sigmaXY')
383 calc = BeamSpotAverage(varList ,weightedAverage=True)
384 calc.add(allBSResultsInNt[nextValidEntry])
385 calc.add(allBSResultsInNt[lastValidEntry])
386 calc.average()
387
388 ave = calc.ave
389 err = calc.err
390
391 bcopy = copy.deepcopy(b)
392
393 for var in varList:
394 setattr(bcopy, var, ave[calc.varList.index(var)])
395 setattr(bcopy, var+"Err", err[calc.varList.index(var)])
396
397 bcopy.status = 59
398 bcopy.timeStart = 0
399 bcopy.timeEnd = 0
400 bcopy.nEvents = 1
401 bcopy.nValid = 1
402 bcopy.nVtxAll = 1
403 bcopy.nVtxPrim = 1
404 bcopy.lbStart = allBSResultsInNt[lastValidEntry].lbEnd + 1
405 bcopy.lbEnd = allBSResultsInNt[nextValidEntry].lbStart-1
406 allBSResultsInNt.insert(lastValidEntry+1, bcopy)
407 i += 1
408 nextValidEntry += 1
409
410 lastValidEntry = nextValidEntry
411 i += 1
412
413
414
416
417 def __init__(self,nt):
418 ROOTUtils.PlotLibrary.__init__(self,options.name)
419 self.nt = nt
420 self.whatList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY','k','nValid']
421
422 def writeText(self, var, legendList=[],
423 showRuns=True, showFills=True, showTime=True, otherTitle=None, otherComment=None,
424 legendX=0.6):
425 # Title and comment lines with optional run, fill and time/date info
426 if otherTitle!=None:
427 self.protect( ROOTUtils.drawText(0.2,0.86,0.06,otherTitle) )
428 else:
429 title = options.title or varDef(var,'title',var)
430 self.protect( ROOTUtils.drawText(0.2,0.86,0.06,title) )
431 comments = []
432 if otherComment:
433 comments.append(otherComment)
434 if options.comment:
435 comments.append(options.comment)
436 if showRuns and not options.omitrun:
437 if self.nt.selRunMin==self.nt.selRunMax:
438 comments.append('Run %i' % self.nt.selRunMin)
439 else:
440 comments.append('Runs %i - %i' % (self.nt.selRunMin,self.nt.selRunMax))
441 if showFills and not options.omitfill:
442 if self.nt.selFillMin==self.nt.selFillMax:
443 comments.append('Fill %i' % self.nt.selFillMin)
444 else:
445 comments.append('Fills %i - %i' % (self.nt.selFillMin,self.nt.selFillMax))
446 if showTime and not options.omittime:
447 if options.public:
448 t1 = time.strftime(options.datefmt,time.localtime(self.nt.selTimeMin))
449 t2 = time.strftime(options.datefmt,time.localtime(self.nt.selTimeMax))
450 else:
451 t1 = time.strftime(options.datefmt,time.localtime(self.nt.selTimeMin))
452 t2 = time.strftime(options.datefmt,time.localtime(self.nt.selTimeMax))
453 if t1==t2:
454 comments.append(t1)
455 else:
456 comments.append('%s - %s' % (t1,t2))
457
458 self.protect( ROOTUtils.drawText(0.2,0.79,0.06,';'.join(comments),font=42) )
459 # ATLAS (preliminary) label
460 logoSize = options.lsize if options.lsize else 0.5
461 if options.prelim:
462 ROOTUtils.atlasLabel(options.atlasx,options.atlasy,True,offset=options.atlasdx,energy=options.energy,size=logoSize)
463 if options.approval:
464 ROOTUtils.atlasLabel(options.atlasx,options.atlasy,False,offset=options.atlasdx,isForApproval=True,energy=options.energy,size=logoSize)
465 if options.published:
466 ROOTUtils.atlasLabel(options.atlasx,options.atlasy,False,offset=options.atlasdx,energy=options.energy,size=logoSize)
467 if options.customlabel!="":
468 ROOTUtils.atlasLabel(options.atlasx,options.atlasy,False,offset=options.atlasdx,isForApproval=False,customstring=options.customlabel,energy=options.energy,size=logoSize)
469 # Legend
470 if legendList:
471 legendMinY = max(0.91-0.07*len(legendList),0.2)
472 self.protect( ROOTUtils.drawLegend(legendX,legendMinY,0.92,0.91,legendList) )
473
474 def hist(self,what):
475 """Histogram of variable what.
476
477 If what is of the form NAME:VALUE, VALUE will be subtracted
478 from each entry in order to produce plots of measured minus
479 true value."""
480 shift = 0.
481 try:
482 (what,shift) = what.split(':')
483 shift = float(shift)
484 except:
485 pass
486 ROOT.gStyle.SetOptStat(options.optstat) # emruo to add underflow, overflow
487 title = varDef(what,'title',what)+';'+varDef(what,'atit',what)
488 nBins = options.nbins if options.nbins else varDef(what,'nBins',100)
489 xmin = float(options.xmin) if options.xmin!=None else varDef(what,'min',-100)
490 xmax = float(options.xmax) if options.xmax!=None else varDef(what,'max',+100)
491 h = self.protect( ROOT.TH1F(what,title,nBins,xmin,xmax) )
492 if options.fit:
493 h.Sumw2()
494 h.GetYaxis().SetTitle('Number of fit results')
495 arescale = varDef(what,'arescale',1.0)
496 try:
497 for b in nt:
498 h.Fill(arescale*(getattr(b,what)-shift))
499 except Exception as e:
500 print ('ERROR filling histogram:',str(e))
501 h.Draw()
502 if options.fit:
503 ROOT.gStyle.SetOptFit(1111)
504 h.Fit(options.fit,options.optfit)
505 if options.logy:
506 ROOT.gPad.SetLogy(options.logy)
507 ndivs = varDef(what,'ndivs',override=options.ndivs)
508 if ndivs:
509 h.GetXaxis().SetNdivisions(ndivs,0)
510 if options.mc:
511 self.writeText(what,[],False,False,False)
512 else:
513 self.writeText(what,[],not options.public,options.public)
514
515 def histvspileup(self,what):
516 """Profile histogram of variable what vs pileup.
517
518 If what is of the form NAME:VALUE, VALUE will be subtracted
519 from each entry in order to produce plots of measured minus
520 true value."""
521 shift = 0.
522 try:
523 (what,shift) = what.split(':')
524 shift = float(shift)
525 except:
526 pass
527 ROOT.gStyle.SetOptStat(options.optstat) # emruo to add underflow, overflow
528 title = varDef(what,'title',what)+';Number of pileup vertices;'+varDef(what,'atit',what)
529 nBins = options.nbins if options.nbins else varDef(what,'nBins',100)
530 xmin = float(options.xmin) if options.xmin!=None else varDef(what,'min',-100)
531 xmax = float(options.xmax) if options.xmax!=None else varDef(what,'max',+100)
532 h = self.protect( ROOT.TProfile(what,title,nBins,0,nBins) )
533 if options.fit:
534 h.Sumw2()
535 h.GetYaxis().SetRangeUser(xmin,xmax)
536 arescale = varDef(what,'arescale',1.0)
537 try:
538 for b in nt:
539 h.Fill(getattr(b,'pileup'),arescale*(getattr(b,what)-shift))
540 except Exception as e:
541 print ('ERROR filling histogram:',str(e))
542 h.Draw()
543 if options.fit:
544 ROOT.gStyle.SetOptFit(1111)
545 h.Fit(options.fit,options.optfit)
546 if options.logy:
547 ROOT.gPad.SetLogy(options.logy)
548 ndivs = varDef(what,'ndivs',override=options.ndivs)
549 if ndivs:
550 h.GetYaxis().SetNdivisions(ndivs,0)
551 if options.mc:
552 self.writeText(what,[],False,False,False)
553 else:
554 self.writeText(what,[],not options.public,options.public)
555
556 def pull(self,what):
557 """Pull histogram of variable what.
558
559 what must be of the form name:value, where value is the
560 correct value of variable name."""
561 try:
562 (what,value) = what.split(':')
563 value = float(value)
564 except:
565 print(('ERROR: Illegal input %s for pull variable - must be of the form NAME:VALUE' % what))
566 return
567 ROOT.gStyle.SetOptStat(options.optstat)
568 title = ';Pull'
569 nBins = options.nbins if options.nbins else varDef(what,'nBins',100)
570 xmin = float(options.xmin) if options.xmin!=None else -4.
571 xmax = float(options.xmax) if options.xmax!=None else +4.
572 h = self.protect( ROOT.TH1F(what,title,nBins,xmin,xmax) )
573 if options.fit:
574 h.Sumw2()
575 h.GetYaxis().SetTitle('Number of fit results')
576 whatErr = what+'Err'
577 try:
578 for b in nt:
579 h.Fill((getattr(b,what)-value)/getattr(b,whatErr))
580 except Exception as e:
581 print ('ERROR filling histogram:',str(e))
582 h.Draw()
583 if options.fit:
584 ROOT.gStyle.SetOptFit(1111)
585 h.Fit(options.fit,options.optfit)
586 if options.logy:
587 ROOT.gPad.SetLogy(options.logy)
588 if options.ndivs:
589 h.GetXaxis().SetNdivisions(options.ndivs,0)
590 if options.mc:
591 self.writeText(what,[],False,False,False)
592 else:
593 self.writeText(what,[],not options.public,options.public)
594
595 def plot(self,what):
596 """History of variable what vs LB or time."""
597 ROOT.gStyle.SetOptStat(0)
598 if options.ave:
599 calc = BeamSpotAverage([what],weightedAverage=not options.simpleaverage)
600 grDict = {}
601
602 arescale = varDef(what,'arescale',1.0)
603 for b in nt:
604 if b.sigmaX < 0.005 or b.sigmaY < 0.005:
605 print ("OUTLIER ", b.run, b.lbStart, b.lbEnd, b.sigmaX, b.sigmaY)
606 if not b.bcid in grDict:
607 grDict[b.bcid] = BeamSpotGraph(timeAxis=options.timeaxis, separationAxis=options.separation)
608 # What was this for? Why ignore if no time info available?
609 #if b.timeStart>0 and b.timeEnd>0:
610 grDict[b.bcid].add(b,what,arescale)
611 if options.ave:
612 calc.add(b)
613
614 print ('Plotting data from %i BCID ...\n' % len(grDict))
615
616 # Determine axis range
617 xmin = 1E10
618 xmax = -1E10
619 ymin = 1E10
620 ymax = -1E10
621 for gr in [grDict.get(bcid) for bcid in grDict]:
622 xmin = min(xmin,gr.xmin)
623 xmax = max(xmax,gr.xmax)
624 ymin = min(ymin,gr.ymin)
625 ymax = max(ymax,gr.ymax)
626
627 # Prevent xmin>xmax or ymin>ymax if no succesful fits (but still allow user to override)
628 if xmin>xmax:
629 xmin,xmax=0,1
630 if ymin>ymax:
631 ymin,ymax=0,1
632
633 h = (xmax-xmin)
634 xmax += .05*h if len(grDict)==1 else 0.3*h
635 xmin -= .05*h
636 h = (ymax-ymin)/2*options.yscale
637 ymax += 1.3*h
638 ymin -= 0.5*h
639 if options.xmin!=None:
640 xmin = time.mktime(time.strptime(options.xmin,'%b %d %H:%M:%S %Y')) if options.timeaxis else float(options.xmin)
641 if options.xmax!=None:
642 xmax = time.mktime(time.strptime(options.xmax,'%b %d %H:%M:%S %Y')) if options.timeaxis else float(options.xmax)
643 if options.ydef:
644 ymin = varDef(what,'min',-100)
645 ymax = varDef(what,'max',+100)
646 if options.ymin!=None:
647 ymin = options.ymin
648 if options.ymax!=None:
649 ymax = options.ymax
650
651 # Axis settings
652 if options.timeaxis:
653 atit = ';%s;%s' % (timeLabel,varDef(what,'atit',what))
654 elif options.separation:
655 atit = ';%s;%s' % ('Nominal Separation [mm]',varDef(what,'atit',what))
656 else:
657 atit = ';%s;%s' % ('Luminosity block number',varDef(what,'atit',what))
658 frame = ROOTUtils.drawAxisFrame(xmin,xmax,ymin,ymax,atit)
659 if options.logy:
660 ROOT.gPad.SetLogy(options.logy)
661 if options.timeaxis:
662 xAxis = frame.GetXaxis()
663 yAxis = frame.GetYaxis()
664 xAxis.SetTimeDisplay(1)
665
666 # this may or may not be needed depending on the ROOT version... not sure whether to specify it or not.
667 # Setting this option in 5.34 seems to work, in 5.30 it offsets things by an hour, but then not setting it
668 # appears to result in bogus x-axis values.
669 xAxis.SetTimeOffset(0) # FIXME: this ignores options.timezone!
670
671 if (xmax-xmin)/86400 < 1:
672 xAxis.SetTimeFormat('%H:%M')
673 else:
674 #d0 = ceil(xmin/86400) # day w/first tick mark
675 #d1 = floor(xmax/86400) # day w/last tick mark
676 #nTicks = d1-d0+1
677 #nDays = floor((xmax-xmin)/86400)
678 if options.public:
679 xAxis.SetTimeFormat('%b %d')
680 else:
681 xAxis.SetTimeFormat('#splitline{%b %d}{%H:%M}')
682 xAxis.SetLabelOffset(0.02)
683 xAxis.SetTitleOffset(1.6)
684 if options.lsize:
685 xAxis.SetLabelSize(options.lsize)
686 xAxis.SetTitleSize(options.lsize)
687 yAxis.SetLabelSize(options.lsize)
688 yAxis.SetTitleSize(options.lsize)
689 else:
690 xAxis.SetLabelSize(0.044)
691 if options.adatefmt:
692 xAxis.SetTimeFormat(options.adatefmt)
693 if options.ndivs:
694 xAxis.SetNdivisions(options.ndivs,0)
695 frame.LabelsOption('d','X') # Doesn't seem to work
696
697 if options.xtitoffset:
698 xAxis.SetTitleOffset(options.xtitoffset)
699 if options.ytitoffset:
700 yAxis.SetTitleOffset(options.ytitoffset)
701
702 legendList = []
703
704 # Show average
705 if options.ave:
706 calc.average()
707 dx = (xmax-xmin)/30
708 mean = calc.ave[0]
709 if options.rms:
710 error = calc.rms[0]
711 else:
712 error = calc.err[0]
713 b = ROOTUtils.drawHorizontalBand(xmin+dx,xmax-dx,mean,error,centralLine=True)
714 legendList.append([b,options.alegend,'FL'])
715 legendList.append([None,'%s %s #pm %s %s' % (fmtVal(what,mean,True),varDef(what,'units'),
716 fmtVal(what,error,True),varDef(what,'units')),''])
717
718 # Loop over graphs for all BCIDs
719 styleFactory = ROOTUtils.StyleFactory()
720 for bcid in sorted(grDict.keys()):
721 gr = grDict[bcid]
722
723 # Get and save TGraphErrors, if desired
724 name = what if bcid==0 else '%s-bcid%04i' % (what,bcid)
725 tgraph = self.protect( gr.getTGraph(name) )
726 if not tgraph:
727 continue
728 if options.tgraphfile:
729 print ('Saving TGraphErrors',tgraph.GetName(),'to file',options.tgraphfile)
730 tgraphfile = ROOT.TFile(options.tgraphfile,'UPDATE')
731 tgraph.Write()
732 tgraphfile.Close()
733
734 # Draw data points
735 if len(grDict)==1:
736 tgraph.SetMarkerSize(options.msize if options.msize else 0.8)
737 if options.plegend:
738 legendList.append([tgraph,options.plegend,'PLE'])
739 else:
740 tgraph.SetMarkerColor(styleFactory.nextColorStyle())
741 tgraph.SetMarkerStyle(styleFactory.nextMarkerStyle())
742 tgraph.SetMarkerSize(options.msize if options.msize else 1.2)
743 if len(legendList)<options.maxlegends:
744 text = 'All' if bcid==0 else 'BCID %i' % bcid
745 legendList.append([tgraph,text,'PLE'])
746 tgraph.Draw('P')
747
748 # Fit data, if desired
749 if options.fit and len(grDict)==1:
750 ROOT.gStyle.SetOptFit(1111)
751 legendList = [] # No legend to avoid crowding plot
752 tgraph.Fit(options.fit,'','SAME', gr.xmin,gr.xmax) #-0.05, 0.05) #ZEBRA
753
754 # Draw title and legend
755 legendX = 0.6 if len(grDict)==1 else 0.8
756 self.writeText(what,legendList if not options.public else [],not options.public,legendX=legendX)
757
758 def perbcid(self,what):
759 """Variable what vs BCID."""
760 ROOT.gStyle.SetOptStat(0)
761 if options.ave:
762 calc = BeamSpotAverage([what],weightedAverage=not options.simpleaverage)
763 gr = BeamSpotGraph(bcidAxis=True)
764 for b in nt:
765 gr.add(b,what)
766 if options.ave:
767 calc.add(b)
768 atit = ';%s;%s' % ('BCID',varDef(what,'atit',what))
769
770 # Axis range and labels
771 xmin = max(-100,gr.xmin-100)
772 xmax = min(3600,gr.xmax+100) # 3564 is the max number of BCIDS + a little space
773 ymin = gr.ymin
774 ymax = gr.ymax
775
776 # Prevent xmin>xmax or ymin>ymax if no succesful fits (but still allow user to override)
777 if xmin>xmax:
778 xmin,xmax=0,1
779 if ymin>ymax:
780 ymin,ymax=0,1
781
782 h = (ymax-ymin)/2*options.yscale
783 ymax += 1.3*h
784 ymin -= 0.5*h
785 if options.ydef:
786 ymin = varDef(what,'min',-100)
787 ymax = varDef(what,'max',+100)
788 if options.ymin!=None:
789 ymin = options.ymin
790 if options.ymax!=None:
791 ymax = options.ymax
792 frame = ROOTUtils.drawAxisFrame(xmin,xmax,ymin,ymax,atit)
793 if options.logy:
794 ROOT.gPad.SetLogy(options.logy)
795
796 legendList = []
797
798 # Show average
799 if options.ave:
800 calc.average()
801 dx = (xmax-xmin)/30
802 mean = calc.ave[0]
803 if options.rms:
804 error = calc.rms[0]
805 else:
806 error = calc.err[0]
807 b = ROOTUtils.drawHorizontalBand(xmin+dx,xmax-dx,mean,error,centralLine=True)
808 legendList.append([b,options.alegend,'FL'])
809 legendList.append([None,'%s %s #pm %s %s' % (fmtVal(what,mean,True),varDef(what,'units'),
810 fmtVal(what,error,True),varDef(what,'units')),''])
811
812 # Save and draw graph
813 name = '%s-perBCID' % what
814 tgraph = self.protect( gr.getTGraph(name) )
815 if not tgraph:
816 return
817 if options.tgraphfile:
818 print ('Saving TGraphErrors',tgraph.GetName(),'to file',options.tgraphfile)
819 tgraphfile = ROOT.TFile(options.tgraphfile,'UPDATE')
820 tgraph.Write()
821 tgraphfile.Close()
822 tgraph.SetMarkerSize(options.msize if options.msize else 0.8)
823 if options.plegend:
824 legendList.append([tgraph,options.plegend,'PLE'])
825 tgraph.Draw('P')
826
827 # Draw title and legend
828 self.writeText(what,legendList,not options.public)
829
830 def vsBunchPos(self,what):
831 """Variable what vs bunch position in train."""
832 ROOT.gStyle.SetOptStat(0)
833
834 lastb = -999
835 startb = -999
836 calcmap = {}
837 bunchnrs = []
838 trainGap = 36
839
840 for b in nt:
841 if b.bcid - lastb > trainGap:
842 startb = b.bcid
843
844 lastb = b.bcid
845 bunchnumber = b.bcid - startb
846
847 if bunchnumber in calcmap:
848 calcmap[bunchnumber].add(b)
849 else:
850 calcmap[bunchnumber] = BeamSpotAverage([what], weightedAverage = not options.simpleaverage)
851 bunchnrs.append(bunchnumber)
852
853 gr = self.protect( ROOT.TGraphErrors(len(bunchnrs)))
854 counter = 0
855 xmin = -10
856 xmax = 1
857 ymin = 1e9
858 ymax = -1e9
859
860 for bunchnr in bunchnrs:
861 calcmap[bunchnr].average()
862 gr.SetPoint(counter, bunchnr, calcmap[bunchnr].ave[0])
863 gr.SetPointError(counter, 0.5, calcmap[bunchnr].err[0])
864 xmax = max(xmax, bunchnr)
865 ymin = min(ymin, calcmap[bunchnr].ave[0])
866 ymax = max(ymax, calcmap[bunchnr].ave[0])
867 counter += 1
868
869 if xmin>xmax:
870 xmin,xmax=0,1
871 if ymin>ymax:
872 ymin,ymax=0,1
873
874 xmax = xmax + 10
875 h = (ymax - ymin)/2*options.yscale
876 ymax += 2.0*h
877 ymin -= 1.0*h
878
879 if options.xmin != None:
880 xmin = options.xmin
881 if options.xmax != None:
882 xmax = options.xmax
883 if options.ymin != None:
884 ymin = options.ymin
885 if options.ymax != None:
886 ymax = options.ymax
887
888 gr.SetMarkerSize(options.msize if options.msize else 0.8)
889
890 atit = ';%s;%s' % ('Bunch position in train',varDef(what,'atit',what))
891 frame = ROOTUtils.drawAxisFrame(xmin,xmax,ymin,ymax,atit)
892 if gr.GetN() == 0:
893 return
894
895 legendList = []
896 if options.plegend:
897 legendList.append([gr,options.plegend,'PLE'])
898 gr.Draw('P')
899 self.writeText(what,legendList,not options.public)
900
901 def plotscan(self,what):
902 """History of variable what vs LB, time or separation. Additionally overlap the results of more than one scan
903 """
904
905 ROOT.gStyle.SetOptStat(0)
906 if options.ave:
907 calc = BeamSpotAverage([what],weightedAverage=not options.simpleaverage)
908 grDict = {}
909
910 scans = [(int(s.split('-')[0]), int(s.split('-')[1])) for s in options.scans.split(',')]
911
912 for b in nt:
913
914 if options.separation and options.overlayScans:
915 try:
916 scanGroup = [s for s in scans if s[0] <= b.lbStart <= s[1]][0]
917 except IndexError:
918 # plB outside of scan ranges
919 continue
920 else:
921 scanGroup = 0
922
923 if not scanGroup in grDict:
924 grDict[scanGroup] = BeamSpotGraph(timeAxis=options.timeaxis, separationAxis=options.separation)
925 grDict[scanGroup].add(b,what)
926 if options.ave:
927 calc.add(b)
928
929 print ('Plotting data from %i scans ...\n' % len(grDict))
930
931 # Determine axis range
932 xmin = 1E10
933 xmax = -1E10
934 ymin = 1E10
935 ymax = -1E10
936 for gr in [grDict.get(scan) for scan in grDict]:
937 xmin = min(xmin,gr.xmin)
938 xmax = max(xmax,gr.xmax)
939 ymin = min(ymin,gr.ymin)
940 ymax = max(ymax,gr.ymax)
941
942 # Prevent xmin>xmax or ymin>ymax if no succesful fits (but still allow user to override)
943 if xmin>xmax:
944 xmin,xmax=0,1
945 if ymin>ymax:
946 ymin,ymax=0,1
947
948 h = (xmax-xmin)
949 xmax += .05*h if len(grDict)==1 else 0.3*h
950 xmin -= .05*h
951 h = (ymax-ymin)/2*options.yscale
952 ymax += 1.3*h
953 ymin -= 0.5*h
954 if options.xmin!=None:
955 xmin = time.mktime(time.strptime(options.xmin,'%b %d %H:%M:%S %Y')) if options.timeaxis else float(options.xmin)
956 if options.xmax!=None:
957 xmax = time.mktime(time.strptime(options.xmax,'%b %d %H:%M:%S %Y')) if options.timeaxis else float(options.xmax)
958 if options.ydef:
959 ymin = varDef(what,'min',-100)
960 ymax = varDef(what,'max',+100)
961 if options.ymin!=None:
962 ymin = options.ymin
963 if options.ymax!=None:
964 ymax = options.ymax
965
966 # Axis settings
967 if options.timeaxis:
968 atit = ';%s;%s' % (timeLabel,varDef(what,'atit',what))
969 elif options.separation:
970 atit = ';%s;%s' % ('Nominal Separation [mm]',varDef(what,'atit',what))
971 else:
972 atit = ';%s;%s' % ('Luminosity block number',varDef(what,'atit',what))
973 frame = ROOTUtils.drawAxisFrame(xmin,xmax,ymin,ymax,atit)
974 if options.logy:
975 ROOT.gPad.SetLogy(options.logy)
976 if options.timeaxis:
977 xAxis = frame.GetXaxis()
978 xAxis.SetTimeDisplay(1)
979 if (xmax-xmin)/86400 < 1:
980 xAxis.SetTimeFormat('%H:%M')
981 else:
982 #d0 = ceil(xmin/86400) # day w/first tick mark
983 #d1 = floor(xmax/86400) # day w/last tick mark
984 #nTicks = d1-d0+1
985 #nDays = floor((xmax-xmin)/86400)
986 xAxis.SetTimeFormat('#splitline{%b %d}{%H:%M}')
987 xAxis.SetLabelOffset(0.025)
988 xAxis.SetTitleOffset(1.6)
989 if options.adatefmt:
990 xAxis.SetTimeFormat(options.adatefmt)
991 if options.ndivs:
992 xAxis.SetNdivisions(options.ndivs,0)
993 frame.LabelsOption('d','X') # Doesn't seem to work
994
995 legendList = []
996
997 # Show average
998 if options.ave:
999 calc.average()
1000 dx = (xmax-xmin)/30
1001 mean = calc.ave[0]
1002 if options.rms:
1003 error = calc.rms[0]
1004 else:
1005 error = calc.err[0]
1006 b = ROOTUtils.drawHorizontalBand(xmin+dx,xmax-dx,mean,error,centralLine=True)
1007 legendList.append([b,options.alegend,'FL'])
1008 legendList.append([None,'%s %s #pm %s %s' % (fmtVal(what,mean,True),varDef(what,'units'),
1009 fmtVal(what,error,True),varDef(what,'units')),''])
1010
1011 # Loop over graphs for all scans
1012 styleFactory = ROOTUtils.StyleFactory()
1013 for scan in sorted(grDict.keys()):
1014 gr = grDict[scan]
1015
1016 # Get and save TGraphErrors, if desired
1017 name = what if scan==0 else '%s-scanoverlay' % (what)
1018 tgraph = self.protect( gr.getTGraph(name) )
1019 if not tgraph:
1020 continue
1021 if options.tgraphfile:
1022 print ('Saving TGraphErrors',tgraph.GetName(),'to file',options.tgraphfile)
1023 tgraphfile = ROOT.TFile(options.tgraphfile,'UPDATE')
1024 tgraph.Write()
1025 tgraphfile.Close()
1026
1027 # Draw data points
1028 if len(grDict)==1:
1029 tgraph.SetMarkerSize(options.msize if options.msize else 0.8)
1030 if options.plegend:
1031 legendList.append([tgraph,options.plegend,'PLE'])
1032 else:
1033 tgraph.SetMarkerColor(styleFactory.nextColorStyle())
1034 tgraph.SetMarkerStyle(styleFactory.nextMarkerStyle())
1035 tgraph.SetMarkerSize(options.msize if options.msize else 1.2)
1036 if len(legendList)<options.maxlegends:
1037 text = 'All' if scan==0 else 'scan %i - %i' % scan
1038 legendList.append([tgraph,text,'PLE'])
1039 tgraph.Draw('P')
1040
1041 # Indicate if legend incomplete
1042 if len(grDict)>options.maxlegends:
1043 legendList.append([None,'...',''])
1044
1045 # Fit data, if desired
1046 if options.fit and len(grDict)==1:
1047 ROOT.gStyle.SetOptFit(1111)
1048 legendList = [] # No legend to avoid crowding plot
1049 tgraph.Fit(options.fit,'','SAME',gr.xmin,gr.xmax)
1050
1051 # Draw title and legend
1052 legendX = 0.6 if len(grDict)==1 else 0.8
1053 self.writeText(what,legendList,not options.public,legendX=legendX)
1054
1055
1056
1057#
1058# Dump beam spot ntuple
1059#
1060if cmd=='dump' and len(args)==1:
1061 print()
1062 nt = getNt()
1063 for b in nt:
1064 b.dump(options.verbose)
1065 cmdOk = True
1066
1067
1068#
1069# Make LaTeX table of results
1070#
1071
1072tableTemplate = r"""
1073\documentclass[12pt,twoside]{article}
1074\usepackage[landscape]{geometry}
1075\RequirePackage{xspace}
1076\def\lumposx {\ensuremath{\overline{x}_{\mathcal{L}}}\xspace}
1077\def\lumposy {\ensuremath{\overline{y}_{\mathcal{L}}}\xspace}
1078\def\lumposz {\ensuremath{\overline{z}_{\mathcal{L}}}\xspace}
1079\def\lumsigx {\ensuremath{\sigma_{x{\mathcal L}}}\xspace}
1080\def\lumsigy {\ensuremath{\sigma_{y{\mathcal L}}}\xspace}
1081\def\lumsigz {\ensuremath{\sigma_{z{\mathcal L}}}\xspace}
1082\def\lumtiltx {\ensuremath{\overline{x}_{\mathcal{L}}'}\xspace}
1083\def\lumtilty {\ensuremath{\overline{y}_{\mathcal{L}}'}\xspace}
1084\def\lumrhoxy {\ensuremath{\rho_{xy}}\xspace}
1085\begin{document}
1086
1087\begin{table}[htbp]
1088\begin{center}
1089\begin{tabular}{%s}
1090\hline \hline
1091%s \\
1092\hline \hline
1093
1094%s
1095
1096\hline \hline
1097\end{tabular}
1098\end{center}
1099\end{table}
1100
1101\end{document}
1102"""
1103
1104if cmd=='maketable' and len(args)==1:
1105 if options.varlist is None:
1106 #varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY','k']
1107 varList = ['status','posX','posY','posZ','sigmaX','sigmaY','sigmaZ','k']
1108 else:
1109 varList = options.varlist.split(',')
1110 nt = getNt()
1111 rows = []
1112 for b in nt:
1113 cols = []
1114 for v in varList:
1115 try:
1116 cols.append(r'%s $\pm$ %s' % (fmtVal(v,getattr(b,v),True,useAlternate=True),
1117 fmtVal(v,getattr(b,v+'Err'),True,useAlternate=True)))
1118 except:
1119 cols.append('%10s' % (fmtVal(v,getattr(b,v),True,useAlternate=True)))
1120 rows.append('%s \\\\' % ' & '.join(cols))
1121 print()
1122 print (tableTemplate % (len(varList)*'c',
1123 ' & '.join(['%s' % varDef(n,'latexheader',useAlternate=True) for n in varList]),
1124 '\n'.join(rows)))
1125 print()
1126 cmdOk = True
1127
1128
1129#
1130# Dump beam spot ntuple
1131#
1132if cmd=='inspect' and len(args)==1:
1133 print()
1134 nt = getNt()
1135 runInfo = {}
1136 for b in nt:
1137 r = b.run
1138 if not b.run in runInfo:
1139 runInfo[r] = {
1140 'lbStart': None,
1141 'lbEnd': None,
1142 'status': set(),
1143 'hasErrors': False,
1144 'hasCOOL' : False
1145 }
1146 if runInfo[r]['lbStart'] is None or b.lbStart<runInfo[r]['lbStart']: runInfo[r]['lbStart'] = b.lbStart
1147 if runInfo[r]['lbEnd'] is None or b.lbEnd>runInfo[r]['lbEnd']: runInfo[r]['lbEnd'] = b.lbEnd
1148 runInfo[r]['status'].add(b.status)
1149 if b.timeStart and b.timeEnd and b.fill: runInfo[r]['hasCOOL'] = True
1150 if b.posXErr: runInfo[r]['hasErrors'] = True
1151 for r in sorted(runInfo.keys()):
1152 print ('%6s [ %10i, %10i ] %7s %9s fit status = %s' % (r,
1153 runInfo[r]['lbStart'],
1154 runInfo[r]['lbEnd'],
1155 'hasCOOL' if runInfo[r]['hasCOOL'] else '',
1156 'hasErrors' if runInfo[r]['hasErrors'] else '',
1157 sorted(list(runInfo[r]['status']))))
1158 print()
1159 print ('%i runs found\n' % len(runInfo.keys()))
1160 cmdOk = True
1161
1162
1163
1164#
1165# Merge beam spot finder ntuple into master beam spot ntuple
1166#
1167if cmd=='merge' and len(args)==2:
1168 srcNtClass = locals()[options.srctype]
1169 if (options.srctype == 'BeamSpotCOOL'):
1170 print ('\n Reading in from database ')
1171 srcNt = srcNtClass(args[1],database=options.database,folder=options.dbfolder,fullCorrelations=options.fullCorrelations)
1172 else :
1173 srcNt = srcNtClass(args[1],fullCorrelations=options.fullCorrelations)
1174
1175 setCuts(srcNt)
1176 print ('\nImporting from '+srcNt.summary())
1177 print (srcNt.cutSummary())
1178 dstNt = ntClass(options.ntname,True,fullCorrelations=options.fullCorrelations,addScanVars=options.addScanVars)
1179 print ('\nMerging into '+dstNt.summary())
1180
1181 totalEntries = 0
1182 totalVtxs = 0
1183 lbSize = 0
1184 allBSResultsInNt = []
1185 for b in srcNt:
1186 allBSResultsInNt.append( b )
1187 if b.status == 59:
1188 totalEntries += 1
1189 totalVtxs += b.nValid
1190 lbSize += b.lbEnd - b.lbStart
1191
1192 if totalEntries == 0:
1193 totalEntries = 1
1194 averagenVtx = totalVtxs/totalEntries
1195 print ('Average Entries: '+ str(averagenVtx))
1196 averagenVtx *= 0.33
1197
1198 lbSize = lbSize/totalEntries + 1
1199 print ('Average number of lb used for fit: '+ str( lbSize ))
1200
1201 #Sort entries in order of lb number
1202 #allBSResultsInNt.sort(key=lambda x: x.lbStart, reverse=False)
1203 allBSResultsInNt.sort()
1204 if options.useAve:
1205 cleanUpLowStat( allBSResultsInNt, averagenVtx, lbSize * 10)
1206 allBSResultsInNt.sort()
1207 fillInMissingLbs(allBSResultsInNt, lbSize * 10)
1208
1209 for b in allBSResultsInNt:
1210 if options.fillcooldata:
1211 b.fillDataFromCOOL()
1212 if options.addScanVars:
1213 b.fillScanData()
1214 if options.pseudoLbFile:
1215 b.fillDataFromPseudoLb(options.pseudoLbFile, float(options.pseudoLbTimeUnit))
1216 if options.filldqdata:
1217 b.fillDataFromDQ()
1218 if not options.quiet:
1219 b.dump(options.verbose)
1220 dstNt.fill(b)
1221 cmdOk = True
1222
1223
1224
1225#
1226# Calculate average of beam spot parameters
1227#
1228if cmd=='ave' and len(args)==1:
1229 nt = getNt()
1230 if options.varlist is None:
1231 #varList = 'posX,posY,posZ,sigmaX,sigmaY,sigmaZ,tiltX,tiltY,rhoXY,sigmaXY,k'
1232 varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
1233 if options.cooltag:
1234 varList.append('sigmaXY')
1235 else:
1236 varList = options.varlist.split(',')
1237
1238 # Summary plot for checks
1239 plots = Plots(nt)
1240 plots.whatList = varList
1241 plots.saveAsList = options.output.split(',')
1242 plots.allCanvasSize = 'landscape'
1243 plots.allCanvasDivs = (3,3)
1244 if options.hist:
1245 plots.genPlot('all','hist')
1246 if options.summary:
1247 plots.genPlot('all','plot')
1248 print()
1249
1250 # Averages
1251 calc = BeamSpotAverage(varList,weightedAverage=not options.simpleaverage)
1252 if options.lumicalcnt is not None:
1253 calc.readLumiData(options.lumicalcnt)
1254 minrun=1e10
1255 maxrun=0
1256 for b in nt:
1257 if options.verbose or options.debug:
1258 b.dump(options.debug)
1259 calc.add(b)
1260 minrun = min(b.run,minrun)
1261 maxrun = max(b.run,maxrun)
1262 calc.average()
1263 ave = calc.ave
1264 err = calc.err
1265 rms = calc.rms
1266 if calc.nWarnings:
1267 print ('... %i warnings detected' % calc.nWarnings)
1268 if options.lumicalcnt is not None:
1269 print ('... integrated luminosity of selected runs = %6.1f / pb' % (calc.sumw[0]/1.E6))
1270 print()
1271 if options.splittable:
1272 varRanges = [ range(options.splittable),
1273 range(options.splittable,len(calc.varList)) ]
1274 else:
1275 varRanges = [ range(len(calc.varList)) ]
1276 if options.latex:
1277 for r in varRanges:
1278 try:
1279 iTable += 1
1280 except:
1281 iTable = 1
1282 latexheader = 'Period '
1283 latexrow = '%s' % options.period.replace('_',r'\_')
1284 print ('\nAverage beam spot parameters (part %i):\n' % iTable)
1285 for i in r:
1286 parName = calc.varList[i]
1287 print ('%7s: %s +- %s %-3s (RMS = %s)' % (parName,
1288 fmtVal(parName,ave[i]),
1289 fmtVal(parName,err[i]),
1290 varDef(parName,'units'),
1291 fmtVal(parName,rms[i])))
1292 latexheader += '& %s ' % varDef(parName,'latexheader',parName,useAlternate=True)
1293 if options.rms:
1294 latexrow += r' & %s $\pm$ %s' % (fmtVal(parName,ave[i],useAlternate=True),fmtVal(parName,rms[i],useAlternate=True))
1295 else:
1296 latexrow += r' & %s $\pm$ %s' % (fmtVal(parName,ave[i],useAlternate=True),fmtVal(parName,err[i],useAlternate=True))
1297 print()
1298 print ('\nLaTeX code for table %i:\n' % iTable)
1299 print ('\\begin{table}[htbp]\n\\begin{center}\n\\begin{tabular}{l%s}' % (len(r)*'c'))
1300 print (r'\hline \hline')
1301 print (latexheader,r'\\\\ \hline')
1302 print()
1303 print (latexrow,' \\\\')
1304 print()
1305 print (r'\hline \hline')
1306 print ('\\end{tabular}\n\\end{center}\n\\caption{\\label{tab:}}\n\\end{table}')
1307 print()
1308 if options.cooltag and minrun<1e10:
1309 from InDetBeamSpotExample.COOLUtils import *
1310 sqliteFile= options.cooltag+'.db'
1311 folderHandle = openBeamSpotDbFile(sqliteFile,True)
1312
1313 if not options.newave:
1314 print ('\nWriting average to COOL SQLite file %s (folder tag = %s) ...' % (sqliteFile,options.cooltag))
1315 writeBeamSpotEntry(folderHandle,tag=options.cooltag,
1316 status=0,
1317 posX=ave[calc.varList.index('posX')],
1318 posY=ave[calc.varList.index('posY')],
1319 posZ=ave[calc.varList.index('posZ')],
1320 sigmaX=ave[calc.varList.index('sigmaX')],
1321 sigmaY=ave[calc.varList.index('sigmaY')],
1322 sigmaZ=ave[calc.varList.index('sigmaZ')],
1323 tiltX=ave[calc.varList.index('tiltX')],
1324 tiltY=ave[calc.varList.index('tiltY')],
1325 sigmaXY=ave[calc.varList.index('sigmaXY')],
1326 posXErr=err[calc.varList.index('posX')],
1327 posYErr=err[calc.varList.index('posY')],
1328 posZErr=err[calc.varList.index('posZ')],
1329 sigmaXErr=err[calc.varList.index('sigmaX')],
1330 sigmaYErr=err[calc.varList.index('sigmaY')],
1331 sigmaZErr=err[calc.varList.index('sigmaZ')],
1332 tiltXErr=err[calc.varList.index('tiltX')],
1333 tiltYErr=err[calc.varList.index('tiltY')],
1334 sigmaXYErr=err[calc.varList.index('sigmaXY')])
1335
1336 else:
1337 print ('\nWriting average and LB info to COOL SQLite file %s (folder tag = %s) ...' % (sqliteFile,"nominal"))
1338 writeBeamSpotEntry(folderHandle,tag="nominal",
1339 runMin=int(minrun),runMax=int(maxrun),
1340 status=0,
1341 posX=ave[calc.varList.index('posX')],
1342 posY=ave[calc.varList.index('posY')],
1343 posZ=ave[calc.varList.index('posZ')],
1344 sigmaX=ave[calc.varList.index('sigmaX')],
1345 sigmaY=ave[calc.varList.index('sigmaY')],
1346 sigmaZ=ave[calc.varList.index('sigmaZ')],
1347 tiltX=ave[calc.varList.index('tiltX')],
1348 tiltY=ave[calc.varList.index('tiltY')],
1349 sigmaXY=ave[calc.varList.index('sigmaXY')],
1350 posXErr=err[calc.varList.index('posX')],
1351 posYErr=err[calc.varList.index('posY')],
1352 posZErr=err[calc.varList.index('posZ')],
1353 sigmaXErr=err[calc.varList.index('sigmaX')],
1354 sigmaYErr=err[calc.varList.index('sigmaY')],
1355 sigmaZErr=err[calc.varList.index('sigmaZ')],
1356 tiltXErr=err[calc.varList.index('tiltX')],
1357 tiltYErr=err[calc.varList.index('tiltY')],
1358 sigmaXYErr=err[calc.varList.index('sigmaXY')])
1359
1360 print ('Copying beam spot data from',options.ntname)
1361 for b in nt:
1362 if options.lbMin and options.lbMin>b.lbStart:
1363 continue
1364 if options.lbMax and options.lbMax<b.lbEnd+1:
1365 continue
1366 try:
1367 runEndInt = b.runEnd
1368 except AttributeError:
1369 runEndInt = b.run
1370
1371 if b.status in nt.statusList:
1372 writeBeamSpotEntry(folderHandle,tag='nominal',
1373 runMin=b.run,
1374 runMax=runEndInt,
1375 lbMin=b.lbStart,
1376 lbMax=b.lbEnd, # Beware - lbMax is inclusive
1377 status=b.status,
1378 posX=b.posX, posY=b.posY, posZ=b.posZ,
1379 sigmaX=b.sigmaX, sigmaY=b.sigmaY, sigmaZ=b.sigmaZ,
1380 tiltX=b.tiltX, tiltY=b.tiltY,
1381 sigmaXY=b.rhoXY*b.sigmaX*b.sigmaY,
1382 posXErr=b.posXErr, posYErr=b.posYErr, posZErr=b.posZErr,
1383 sigmaXErr=b.sigmaXErr, sigmaYErr=b.sigmaYErr, sigmaZErr=b.sigmaZErr,
1384 tiltXErr=b.tiltXErr, tiltYErr=b.tiltYErr,
1385 sigmaXYErr=sqrt( (b.sigmaX*b.sigmaX) * (b.sigmaY*b.sigmaY) * (b.rhoXYErr*b.rhoXYErr) +(b.sigmaX*b.sigmaX) * (b.sigmaYErr*b.sigmaYErr) * (b.rhoXY*b.rhoXY) + (b.sigmaXErr*b.sigmaXErr) * (b.sigmaY*b.sigmaY) * (b.rhoXY*b.rhoXY) ) )
1386
1387 cmdOk = True
1388
1389#
1390# Different histograms of beam spot variables
1391#
1392if (cmd=='hist' or cmd=='histvspileup' or cmd=='pull') and len(args)==2:
1393 var = args[1]
1394 nt = getNt()
1395 plots = Plots(nt)
1396 plots.saveAsList = options.output.split(',')
1397 if options.canvas:
1398 plots.singleCanvasSize = options.canvas
1399 plots.allCanvasSize = options.canvas
1400 plots.allCanvasDivs = (options.xdivs,options.ydivs)
1401 if ',' in var:
1402 plots.whatList = var.split(',')
1403 plots.genPlot('all',cmd)
1404 else:
1405 plots.genPlot(var,cmd)
1406 cmdOk = True
1407
1408
1409#
1410# Plot of beam spot variables vs LB or time
1411#
1412if cmd=='plot' and len(args)==2:
1413 var = args[1]
1414 nt = getNt()
1415 plots = Plots(nt)
1416 plots.saveAsList = options.output.split(',')
1417 if options.canvas:
1418 plots.singleCanvasSize = options.canvas
1419 plots.allCanvasSize = options.canvas
1420 plots.allCanvasDivs = (options.xdivs,options.ydivs)
1421 if options.perbcid:
1422 plotType = 'perbcid'
1423 elif options.vsbunchpos:
1424 plotType = 'vsBunchPos'
1425 else:
1426 plotType = 'plot'
1427 if ',' in var:
1428 plots.whatList = var.split(',')
1429 plots.genPlot('all',plotType)
1430 else:
1431 plots.genPlot(var,plotType)
1432 cmdOk = True
1433
1434
1435#
1436# Summary history of beam spot variables
1437#
1438if cmd=='summary' and len(args)==1:
1439 nt = getNt()
1440 if not options.msize:
1441 options.msize = 0.5
1442 plots = Plots(nt)
1443 plots.saveAsList = options.output.split(',')
1444 plots.allCanvasSize = 'landscape'
1445
1446 labels=[]
1447 if "COOL-Current" not in options.ntname:
1448 plots.allCanvasDivs = (4,3)
1449 plots.whatList = ['posX','posY','posZ','k','sigmaX','sigmaY','sigmaZ','nValid','tiltX','tiltY','rhoXY']
1450 datasetinfo=options.ntname.replace("-DB_BEAMSPOT","").split('.')
1451 labels=["%s.%s.%s.%s" % (datasetinfo[0],datasetinfo[1],datasetinfo[2],datasetinfo[3])]
1452 labels+=["Generated on %s, at %s (%s)" % (time.strftime("%x"), time.strftime("%X"), time.strftime("%Z"))]
1453 else:
1454 plots.allCanvasDivs = (3,3)
1455 plots.whatList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
1456
1457 # add some labels to the empty pad
1458
1459 if options.perbcid:
1460 plots.genPlot('all','perbcid',labels=labels)
1461 elif options.vsbunchpos:
1462 plots.whatList.remove('nValid')
1463 plots.genPlot('all','vsBunchPos',labels=labels)
1464 else:
1465 plots.genPlot('all','plot',labels=labels)
1466
1467 cmdOk = True
1468
1469
1470#
1471# Plot of beam spot variables vs LB or time
1472#
1473if cmd=='ascii' and len(args)==2:
1474 time0 = 1262304000 # unix time for Jan 1, 2010, 00:00:00 CET
1475 ascii = open(args[1],'w')
1476 ascii.write('# Beam spot data file\n')
1477 ascii.write('# Generated %s by %s on host %s using command:\n' % (time.asctime(),getUserName(),getHostName()))
1478 ascii.write('# %s\n' % qcmd)
1479 nt = getNt()
1480 for b in nt:
1481 ascii.write('1 ') # IP number
1482 ascii.write('%s ' % str(b.fill))
1483 ascii.write('%s ' % str(b.timeStart - time0 + int((b.timeEnd-b.timeStart)/2))) # Time in sec since Jan 1, 2010
1484 ascii.write('%s ' % str(b.posX))
1485 ascii.write('%s ' % str(b.posXErr))
1486 ascii.write('%s ' % str(b.posY))
1487 ascii.write('%s ' % str(b.posYErr))
1488 ascii.write('%s ' % str(b.posZ))
1489 ascii.write('%s ' % str(b.posZErr))
1490 ascii.write('0 0 0 0 0 0 ') # No data from raw Gauss fit w/o subtracting vtx-resolution
1491 ascii.write('%s ' % str(b.sigmaX))
1492 ascii.write('%s ' % str(b.sigmaXErr))
1493 ascii.write('%s ' % str(b.sigmaY))
1494 ascii.write('%s ' % str(b.sigmaYErr))
1495 ascii.write('%s ' % str(b.sigmaZ))
1496 ascii.write('%s ' % str(b.sigmaZErr))
1497 ascii.write('0 0 0\n') # No RMS info
1498 ascii.close()
1499 cmdOk = True
1500
1501
1502if cmd=='scan' and len(args)==1:
1503
1504 if not options.msize:
1505 options.msize = 0.5
1506
1507 if options.timeaxis:
1508 xtype = 'time'
1509 elif options.separation:
1510 xtype = 'sep'
1511 else:
1512 xtype = 'lb'
1513
1514 # Plot summary plots for full scan
1515 nt = getNt()
1516
1517 plots = Plots(nt)
1518 plots.allCanvasSize = 'landscape'
1519 plots.allCanvasDivs = (3,3)
1520 plots.whatList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
1521 plots.saveAsList = ['%s-scanfull-%s-all.gif' %(options.name,xtype),
1522 '%s-scanfull-%s-all.eps' %(options.name,xtype),]
1523
1524 if options.separation and options.overlayScans:
1525 plots.genPlot('all','plotscan')
1526 else:
1527 plots.genPlot('all','plot')
1528
1529 plots.whatList.append('k')
1530
1531 # Individual plot for full scan
1532 plots.singleCanvasSize = 'wide'
1533 for var in plots.whatList:
1534 plots.saveAsList = ['%s-scanfull-%s-%s.gif' %(options.name,xtype,var),
1535 '%s-scanfull-%s-%s.eps' %(options.name,xtype,var) ]
1536 if options.separation and options.overlayScans:
1537 graphs = plots.genPlot(var,'plotscan')
1538 else:
1539 graphs = plots.genPlot(var,'plot')
1540
1541
1542 # Plots for each scan range
1543 if options.scans:
1544 scans = [(int(s.split('-')[0]), int(s.split('-')[1])) for s in options.scans.split(',')]
1545 else:
1546 scans = []
1547
1548 options.overlayScans = False
1549 for (lbMin, lbMax) in scans:
1550
1551 nt = getNt()
1552 nt.lbMin = lbMin
1553 nt.lbMax = lbMax
1554
1555 # Summary plot for each scan range
1556 plots = Plots(nt)
1557 plots.allCanvasSize = 'landscape'
1558 plots.allCanvasDivs = (3,3)
1559 plots.whatList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY']
1560 plots.saveAsList = ['%s-scan%s-%s-%s-all.gif' %(options.name,lbMin,lbMax,xtype),
1561 '%s-scan%s-%s-%s-all.eps' %(options.name,lbMin,lbMax,xtype) ]
1562 plots.genPlot('all','plot')
1563
1564 plots.whatList.append('k')
1565
1566 # Individual plot for each scan range
1567 plots.singleCanvasSize = 'default'
1568 for var in plots.whatList:
1569 plots.saveAsList = ['%s-scan%s-%s-%s-%s.gif' %(options.name,lbMin,lbMax,xtype,var),
1570 '%s-scan%s-%s-%s-%s.eps' %(options.name,lbMin,lbMax,xtype,var) ]
1571 graphs = plots.genPlot(var,'plot')
1572
1573 cmdOk = True
1574
1575
1576if not cmdOk:
1577 print ('ERROR: Illegal command or number of arguments')
1578 sys.exit(1)
if(febId1==febId2)
void print(char *figname, TCanvas *c1)
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
__init__(self, name='MyPlots', otherMethods=[])
plotscan(self, what)
vsBunchPos(self, what)
writeText(self, var, legendList=[], showRuns=True, showFills=True, showTime=True, otherTitle=None, otherComment=None, legendX=0.6)
histvspileup(self, what)
perbcid(self, what)
STL class.
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
atlasLabel(x, y, isPreliminary=False, color=1, offset=0.115, isForApproval=False, energy=8, customstring="", size=0.05)
setStyle(style=None)
drawText(x=0.74, y=0.87, dy=0.06, text='', font=62, color=1, align=11, linesep=';')
drawAxisFrame(xmin, xmax, ymin, ymax, title='', xTitleOffset=None, yTitleOffset=None, doPlot=True, protectFrame=True)
drawLegend(x1, y1, x2, y2, legendList=[], fillColor=0, lineColor=0, textSize=None, protectLegend=True)
drawHorizontalBand(xmin, xmax, y, ywidth, color=33, protectBand=True, centralLine=False)
cleanUpLowStat(allBSResultsInNt, averagenVtx, lbSize)
fillInMissingLbs(allBSResultsInNt, lbSize)
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)