ATLAS Offline Software
beamspotPlotBcids.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4 
5 from optparse import OptionParser
6 import os, glob
7 import string
8 from math import sqrt
9 
10 __author__ = 'James Walder'
11 __version__ = '$Id$'
12 __usage__ = '%prog [options] '
13 
14 def makeListFromString(s,token=','):
15  names = s.split(token)
16  return names
17 
18 
19 def AddText(xmin,ymin,text,size=0.015, font=None):
20  m = TLatex() # //l.SetTextAlign(12); l.SetTextSize(tsize);
21  m.SetNDC();
22  #m.SetTextFont(72);
23  m.SetTextColor(EColor.kBlack);
24  m.SetTextSize(size)
25  if font != None:
26  m.SetTextFont(font)
27  m.DrawLatex(xmin,ymin,text);
28  labels.append(m)
29 
30 
31 class Event:
32  def __init__(self):
33  self.run =0.
34  self.lbStart =0.
35  self.lumiRange=0.
36  self.nEvents = 0.
37  self.statusWord =0.
38  self.bcid =0.
39 
40 
41 class Beamspot:
42  def __init__(self):
43  self.x0 = 0.
44  self.y0 = 0.
45  self.z = 0.
46  self.sx = 0.
47  self.sy = 0.
48  self.sz = 0.
49  self.ax = 0.
50  self.ay = 0.
51  self.k = 0.
52  self.rhoxy = 0.
53  self.xc = 0.
54  self.yc = 0.
55 
56  self.Ex0 = 0.
57  self.Ey0 = 0.
58  self.Ez = 0.
59  self.Esx = 0.
60  self.Esy = 0.
61  self.Esz = 0.
62  self.Eax = 0.
63  self.Eay = 0.
64  self.Ek = 0.
65  self.Erhoxy = 0.
66  self.Exc = 0.
67  self.Eyc = 0.
68  def clear(self):
69  self.x0 = 0.
70  self.y0 = 0.
71  self.z = 0.
72  self.sx = 0.
73  self.sy = 0.
74  self.sz = 0.
75  self.ax = 0.
76  self.ay = 0.
77  self.k = 0.
78  self.rhoxy = 0.
79  self.xc = 0.
80  self.yc = 0.
81 
82  self.Ex0 = 0.
83  self.Ey0 = 0.
84  self.Ez = 0.
85  self.Esx = 0.
86  self.Esy = 0.
87  self.Esz = 0.
88  self.Eax = 0.
89  self.Eay = 0.
90  self.Ek = 0.
91  self.Erhoxy = 0.
92  self.Exc = 0.
93  self.Eyc = 0.
94  def __str__(self):
95  out = "x0: " + str(self.x0) + " +- " + str(self.Ex0)
96  return out
97 
98 parser = OptionParser(usage=__usage__, version=__version__)
99 parser.add_option('-f','--files',dest='files', default='bs.root', help='Root files for data plots')
100 parser.add_option('-d','--dir',dest='dir', default='Beamspot', help='Root directory for beamspots')
101 parser.add_option('-b','--batch', dest='batch', action='store_true', default=False, help='Run in batch mode')
102 parser.add_option('-t','--tree',dest='tree', default='Beamspots', help='Beamspot root-tree name')
103 
104 (options,args) = parser.parse_args()
105 
106 if options.batch:
107  os.unsetenv('DISPLAY')
108 
109 
110 from ROOT import TH1D, TCanvas
111 from ROOT import gSystem, gROOT, TFile, TH1D, TH2D, TCanvas, TTree, TChain
112 from ROOT import TGraphErrors
113 from ROOT import TMultiGraph
114 from ROOT import EColor
115 from ROOT import TLegend,TLine
116 from ROOT import TLatex,TGaxis
117 from ROOT import EColor
118 
119 legends = [] # holder
120 pdglines= [] # holder
121 labels = []
122 ghists = [] # additional hists
123 failed = [] # list of failed plots
124 graphs = []
125 canvases = []
126 
127 PointSize = 1.6
128 MaxHeightFactor = 1.5
129 
130 plotTextSize = 0.04
131 gROOT.ProcessLine(".L AtlasStyle.C")
132 gROOT.ProcessLine(".L AtlasUtils.C")
133 gROOT.ProcessLine("SetAtlasStyle();")
134 
135 def findBeamspots(file,dir, pattern):
136  import re
137  from ROOT import gDirectory
138  file.cd(dir)
139  p = re.compile(pattern)
140  print p.pattern
141  n = gDirectory.GetListOfKeys().GetSize()
142  print "N: ", n
143  matched = []
144  for i in range(n):
145  name = gDirectory.GetListOfKeys().At(i).GetName()
146  if not p.match(name):
147  continue
148  print name
149  #print p.match(name)
150  h = gDirectory.Get(gDirectory.GetListOfKeys().At(i).GetName())
151  #print h, h.GetName()
152  matched.append(h)
153 
154  file.cd()
155  return matched
156 
157 
159  subs = { 'p':'.', 'm':'-' }
160  n = ""
161  for i in s:
162  c = i
163  if i in subs.keys():
164  c = subs[i]
165  n = n+c
166  return float(n)
167 
168 
169 def splitBeamspotTreeTitle(title, cutToken="CUT"):
170  t = title.split(cutToken)
171  namestring = t[0].strip('_')
172  cutstring = t[-1].strip('_')
173  cuts = cutstring.split('_')
174  output = {}
175  for i in range(0,len(cuts),2):
176  output[cuts[i]] = makeFloatFromString(cuts[i+1])
177 
178  return output,namestring
179 
180 def getTree(name, file, dir):
181  tr = file.Get( dir +"/" + name)
182  print type(tr)
183  return tr
184 
185 # beamspot tree-type stuff
186 def makePull( tree, xval='x0',xcov='x0x0', xTrue=0., isCovErr=True, xlow=-8, xhigh=8, xbins=100, doGausFit=False, cuts=""):
187  h = TH1D("hPull_"+tree.GetName()+"_"+xval, "hPull_"+tree.GetName()+"_"+xval, xbins, xlow,xhigh)
188  if isCovErr:
189  p = '(%(x)s - %(t)s)/sqrt(%(e)s) >> %(h)s' % { 'x':xval, 't':xTrue, 'e':xcov, 'h':h.GetName()}
190  else:
191  p = '(%(x)s - %(t)s)/(%(e)s) >> %(h)s' % { 'x':xval, 't':xTrue, 'e':xcov, 'h':h.GetName()}
192  print p
193  tree.Draw( p , cuts);
194  h.Print()
195 
196  mean = h.GetMean()
197  meanErr = h.GetMeanError()
198  rms = h.GetRMS()
199  rmsErr = h.GetRMSError()
200  if doGausFit:
201  h.Fit("gaus","LL")
202  f = h.GetFunction("gaus")
203  mean = f.GetParameter(1)
204  meanErr = f.GetParError(1)
205  rms = f.GetParameter(2)
206  rmsErr = f.GetParError(2)
207 
208  return (mean, meanErr, rms, rmsErr)
209 
210 
211 # Start of main programs
212 
213 #Open the files
214 
215 files = makeListFromString(options.files)
216 if len(files) == 1:
217  fii = TFile(files[0])
218 else:
219  print "Multiple files not yet supported"
220  sys.exit()
221 
222 
223 # matched = findBeamspots(fii, options.dir, "Beamspots_.*MinVt.*")
224 
225 def makeBeamspotPlots( name, beamspots):
226  if len(beamspots) == 0:
227  print "No beamspot"
228 
229  nPoints = len(beamspots)
230  print "Found", nPoints
231 
232  x = TGraphErrors(nPoints)
233  x.SetName(name + "_x")
234  x.SetTitle(name + " x; lb; x [mm]")
235  y = TGraphErrors(nPoints)
236  y.SetName(name + "_y")
237  y.SetTitle(name + " y; lb; y [mm]")
238  z = TGraphErrors(nPoints)
239  z.SetName(name + "_z")
240  z.SetTitle(name + " z; lb; z [mm]")
241  sx = TGraphErrors(nPoints)
242  sx.SetName(name + "_sx")
243  sx.SetTitle(name + " sx; lb; #sigma(x) [mm]")
244  sy = TGraphErrors(nPoints)
245  sy.SetName(name + "_sy")
246  sy.SetTitle(name + " sy; lb; #sigma(y) [mm]")
247  sz = TGraphErrors(nPoints)
248  sz.SetName(name + "_sz")
249  sz.SetTitle(name + " sz; lb; #sigma(z) [mm]")
250  ax = TGraphErrors(nPoints)
251  ax.SetName(name + "_ax")
252  ax.SetTitle(name + " ax; lb; slope x-z [rad]")
253  ay = TGraphErrors(nPoints)
254  ay.SetName(name + "_ay")
255  ay.SetTitle(name + " ay; lb; slope y-z [rad]")
256  k = TGraphErrors(nPoints)
257  k.SetName(name + "_k")
258  k.SetTitle(name + " k; lb; k")
259  rhoxy = TGraphErrors(nPoints)
260  rhoxy.SetName(name + "_rhoxy")
261  rhoxy.SetTitle(name + " rhoxy; lb; #rho_{xy}")
262 
263  nEvents= TGraphErrors(nPoints)
264  nEvents.SetName(name + "_nEvents")
265  nEvents.SetTitle(name + " nEvents; lb; nEvents")
266 
267 
268 
269  graphs.extend([x,y,z,sx,sy,sz,ax,ay,k,rhoxy,nEvents])
270 
271  point =0
272  for evt,bs in beamspots:
273  xmid = evt.lbStart + 0.5*evt.lumiRange
274  xerr = 0.5*evt.lumiRange
275 
276  x.SetPoint(point, xmid, bs.xc)
277  y.SetPoint(point, xmid, bs.yc)
278  z.SetPoint(point, xmid, bs.z)
279  sx.SetPoint(point, xmid,bs.sx )
280  sy.SetPoint(point, xmid,bs.sy )
281  sz.SetPoint(point, xmid,bs.sz )
282  ax.SetPoint(point, xmid, bs.ax)
283  ay.SetPoint(point, xmid, bs.ay)
284  k.SetPoint(point, xmid, bs.k)
285  rhoxy.SetPoint(point, xmid, bs.rhoxy)
286 
287  nEvents.SetPoint(point, xmid, evt.nEvents)
288 
289  x.SetPointError(point, xerr,bs.Exc )
290  y.SetPointError(point, xerr,bs.Eyc )
291  z.SetPointError(point, xerr,bs.Ez )
292  sx.SetPointError(point, xerr,bs.Esx )
293  sy.SetPointError(point, xerr,bs.Esy )
294  sz.SetPointError(point, xerr,bs.Esz )
295  ax.SetPointError(point, xerr,bs.Eax )
296  ay.SetPointError(point, xerr,bs.Eay )
297 
298  k.SetPointError(point, xerr, bs.Ek)
299  rhoxy.SetPointError(point, xerr, bs.Erhoxy)
300  nEvents.SetPointError(point, xerr, sqrt(evt.nEvents))
301 
302  point = point + 1
303  return (x,y,z,sx,sy,sz,ax,ay,k,rhoxy,nEvents)
304 
305 def makeBeamspotCutPlots(name, points):
306  nPoints = len(points)
307 
308  x = TGraphErrors(nPoints)
309  x.SetName(name)
310  x.SetTitle(name + " x; lb; x [mm]")
311  y = TGraphErrors(nPoints)
312  y.SetName(name)
313  y.SetTitle(name + " y; lb; y [mm]")
314  z = TGraphErrors(nPoints)
315  z.SetName(name)
316  z.SetTitle(name + " z; lb; z [mm]")
317  sx = TGraphErrors(nPoints)
318  sx.SetName(name)
319  sx.SetTitle(name + " sx; lb; #sigma(x) [mm]")
320  sy = TGraphErrors(nPoints)
321  sy.SetName(name)
322  sy.SetTitle(name + " sy; lb; #sigma(y) [mm]")
323  sz = TGraphErrors(nPoints)
324  sz.SetName(name)
325  sz.SetTitle(name + " sz; lb; #sigma(z) [mm]")
326 
327  xrms = TGraphErrors(nPoints)
328  xrms.SetName(name+"_rms")
329  xrms.SetTitle(name+"_rms" + " x")
330  yrms = TGraphErrors(nPoints)
331  yrms.SetName(name+"_rms")
332  yrms.SetTitle(name+"_rms" + " y")
333  zrms = TGraphErrors(nPoints)
334  zrms.SetName(name+"_rms")
335  zrms.SetTitle(name+"_rms" + " z")
336  sxrms = TGraphErrors(nPoints)
337  sxrms.SetName(name+"_rms")
338  sxrms.SetTitle(name+"_rms" + " sx")
339  syrms = TGraphErrors(nPoints)
340  syrms.SetName(name+"_rms")
341  syrms.SetTitle(name+"_rms" + " sy")
342  szrms = TGraphErrors(nPoints)
343  szrms.SetName(name+"_rms")
344  szrms.SetTitle(name+"_rms" + " sz")
345 
346  graphs.extend([x,y,z,sx,sy,sz,xrms,yrms,zrms,sxrms,syrms,szrms])
347  print len(points)
348  for i in range(len(points)):
349  xval = points[i][0]
350  yvals = points[i][1]
351 
352  xerr =0;
353 
354  x.SetPoint(i, xval, yvals[0][0])
355  y.SetPoint(i, xval, yvals[1][0])
356  z.SetPoint(i, xval, yvals[2][0])
357  sx.SetPoint(i, xval, yvals[3][0])
358  sy.SetPoint(i, xval, yvals[4][0])
359  sz.SetPoint(i, xval, yvals[5][0])
360 
361  x.SetPointError(i, xerr, yvals[0][1])
362  y.SetPointError(i, xerr, yvals[1][1])
363  z.SetPointError(i, xerr, yvals[2][1])
364  sx.SetPointError(i, xerr, yvals[3][1])
365  sy.SetPointError(i, xerr, yvals[4][1])
366  sz.SetPointError(i, xerr, yvals[5][1])
367 
368 
369  xrms.SetPoint(i, xval, yvals[0][2])
370  yrms.SetPoint(i, xval, yvals[1][2])
371  zrms.SetPoint(i, xval, yvals[2][2])
372  sxrms.SetPoint(i, xval, yvals[3][2])
373  syrms.SetPoint(i, xval, yvals[4][2])
374  szrms.SetPoint(i, xval, yvals[5][2])
375 
376  xrms.SetPointError(i, xerr, yvals[0][3])
377  yrms.SetPointError(i, xerr, yvals[1][3])
378  zrms.SetPointError(i, xerr, yvals[2][3])
379  sxrms.SetPointError(i, xerr, yvals[3][3])
380  syrms.SetPointError(i, xerr, yvals[4][3])
381  szrms.SetPointError(i, xerr, yvals[5][3])
382 
383  c = TCanvas("cx")
384  c.Divide(3,1)
385  c.cd(1)
386  x.Draw("ap")
387  c.cd(2)
388  y.Draw("ap+Y+")
389  c.cd(3)
390  yaxis_xrms = TGaxis( -1, 0.2, 1 ,0.2, -1, 2,510,"+R")
391  yaxis_xrms.ImportAxisAttributes( y.GetHistogram().GetYaxis() )
392  #g = TMultiGraph()
393  #g.Add(x,"aXp")
394  #g.Add(y,"aY*")
395  #g.Draw("a")
396  # graphs.append(g)
397  # aa = y.GetHistogram()
398 
399  #x.Draw("ap")
400  yaxis_xrms.Draw()
401  #axis.PaintAxis(0,0.5,0.1,0.6,0.4,1.4,510,"+R")
402  #y.Draw("pY+sames")
403  #b.Draw("sames")
404  c.Modified()
405  c.Update()
406  #c.Print()
407  canvases.append(c)
408 
409 def makeCutPlotPulls( file, dir, pattern, name):
410  trueVals = { 'x0':-0.15, 'y0':1., 'z':-9., 'sx':'0.72', 'sy':'0.42', 'sz':44, 'ax':'0.', 'ay':0., 'k':1, 'rhoxy':0.0}
411 
412  # list of trees
413  matched = findBeamspots(file, dir, pattern)
414  points= []
415 
416  for i in matched:
417  # loop over trees and get cut values
418  o, n = splitBeamspotTreeTitle( i.GetName(), "CUT" )
419  # make assumption of only one cut value
420  xval = o[o.keys()[0]]
421  print "JW: ", xval
422  xpos = makePull( getTree( i.GetName(), file, dir), xval='x0', xcov='x0x0', xTrue=trueVals['x0'])
423  ypos = makePull( getTree( i.GetName(), file, dir), xval='y0', xcov='y0y0', xTrue=trueVals['y0'])
424  zpos = makePull( getTree( i.GetName(), file, dir), xval='z', xcov='zz', xTrue=trueVals['z'])
425 
426  sx = makePull( getTree( i.GetName(), file, dir), xval='sx', xcov='sxsx', xTrue=trueVals['sx'])
427  sy = makePull( getTree( i.GetName(), file, dir), xval='sy', xcov='sysy', xTrue=trueVals['sy'])
428  sz = makePull( getTree( i.GetName(), file, dir), xval='sz', xcov='szsz', xTrue=trueVals['sz'])
429  ax = makePull( getTree( i.GetName(), file, dir), xval='ax', xcov='axax', xTrue=trueVals['ax'])
430  ay = makePull( getTree( i.GetName(), file, dir), xval='ay', xcov='ayay', xTrue=trueVals['ay'])
431  k = makePull( getTree( i.GetName(), file, dir), xval='k', xcov='kk', xTrue=trueVals['k'])
432  rhoxy = makePull( getTree( i.GetName(), file, dir), xval='rhoxy', xcov='rhoxyrhoxy', xTrue=trueVals['rhoxy'])
433  points.append( (xval, [xpos, ypos, zpos, sx, sy, sz, ax, ay, k, rhoxy ]) )
434 
435 
436  plots = makeBeamspotCutPlots(name, points)
437 
438 
439 
441 infiles = makeListFromString(options.files)
442 chain = TChain(options.dir+"/"+options.tree)
443 
444 for i in infiles:
445  chain.Add(i)
446 print "Added: ", chain.GetNtrees() , " files."
447 
448 nEntries = chain.GetEntries()
449 
450 lrun = chain.GetLeaf("event/run")
451 lbcid = chain.GetLeaf("event/bcid")
452 lnEvents = chain.GetLeaf("event/nEvents")
453 llbStart = chain.GetLeaf("event/lumiStart")
454 llumiRange= chain.GetLeaf("event/lumiRange")
455 lstatusWord=chain.GetLeaf("event/statusWord")
456 
457 lx0 = chain.GetLeaf("bs/x0")
458 ly0 = chain.GetLeaf("bs/y0")
459 lz = chain.GetLeaf("bs/z")
460 lsx = chain.GetLeaf("bs/sx")
461 lsy = chain.GetLeaf("bs/sy")
462 lsz = chain.GetLeaf("bs/sz")
463 lax = chain.GetLeaf("bs/ax")
464 lay = chain.GetLeaf("bs/ay")
465 lrhoxy= chain.GetLeaf("bs/rhoxy")
466 lk = chain.GetLeaf("bs/k")
467 lxc = chain.GetLeaf("bsCentroid/xc")
468 lyc = chain.GetLeaf("bsCentroid/yc")
469 
470 lCovx0 = chain.GetLeaf("bsCov/x0x0")
471 lCovy0 = chain.GetLeaf("bsCov/y0y0")
472 lCovz = chain.GetLeaf("bsCov/zz")
473 lCovsx = chain.GetLeaf("bsCov/sxsx")
474 lCovsy = chain.GetLeaf("bsCov/sysy")
475 lCovsz = chain.GetLeaf("bsCov/szsz")
476 lCovax = chain.GetLeaf("bsCov/axax")
477 lCovay = chain.GetLeaf("bsCov/ayay")
478 lCovrhoxy= chain.GetLeaf("bsCov/rhoxyrhoxy")
479 lCovk = chain.GetLeaf("bsCov/kk")
480 lCovxc = chain.GetLeaf("bsCovCentroid/xcxc")
481 lCovyc = chain.GetLeaf("bsCovCentroid/ycyc")
482 
483 
484 bcidEvents = {}
485 
486 count = 0
487 for entry in range(nEntries):
488  # Begin loop
489  chain.GetEntry(entry)
490  run = lrun.GetValue()
491  bcid = lbcid.GetValue()
492  nEvents = lnEvents.GetValue()
493  lbStart = llbStart.GetValue()
494  lumiRange = llumiRange.GetValue()
495  statusWord = lstatusWord.GetValue()
496 
497  if nEvents < 200:
498  continue
499  count = count +1
500  if statusWord != 59:
501  continue
502  if count > 1e10:
503  break
504 
505  evt = Event()
506  evt.run = run
507  evt.lbStart = lbStart
508  evt.lumiRange = lumiRange
509  evt.statusWord = statusWord
510  evt.bcid = bcid
511  evt.nEvents = nEvents
512 
513  bs = Beamspot()
514  bs.x0 = lx0.GetValue()
515  bs.y0 = ly0.GetValue()
516  bs.xc = lxc.GetValue()
517  bs.yc = lyc.GetValue()
518  bs.z = lz.GetValue()
519  bs.sx = lsx.GetValue()
520  bs.sy = lsy.GetValue()
521  bs.sz = lsz.GetValue()
522  bs.ax = lax.GetValue()
523  bs.ay = lay.GetValue()
524  bs.k = lk.GetValue()
525  bs.rhoxy = lrhoxy.GetValue()
526 
527  bs.Ek = sqrt(lCovk.GetValue())
528  bs.Ex0 = sqrt(lCovx0.GetValue())
529  bs.Ey0 = sqrt(lCovy0.GetValue())
530  bs.Exc = sqrt(lCovx0.GetValue())
531  bs.Eyc = sqrt(lCovy0.GetValue())
532  bs.Ez = sqrt(lCovz.GetValue())
533  bs.Esx = sqrt(lCovsx.GetValue())
534  bs.Esy = sqrt(lCovsy.GetValue())
535  bs.Esz = sqrt(lCovsz.GetValue())
536  bs.Eax = sqrt(lCovax.GetValue())
537  bs.Eay = sqrt(lCovay.GetValue())
538  bs.Erhoxy = sqrt(lCovrhoxy.GetValue())
539  bs.Ek = sqrt(lCovk.GetValue())
540 
541  if bcid not in bcidEvents.keys():
542  bcidEvents[bcid] = []
543  bcidEvents[bcid].append( (evt, bs) )
544 
545 
546 print bcidEvents
547 for k,v in bcidEvents.items():
548  print k,v
549 
550 plots = {}
551 for k,v in bcidEvents.items():
552  plots[k] = makeBeamspotPlots(str(k), v)
553 
554 #for k,v in plots.items():
555 # c = TCanvas(str(int(k)))
556 # c.Divide(3,3)#
557 #
558 # c.cd(3)
559 # v[10].Draw("ap")
560 #
561 #
562 # c.cd(4)
563 # v[0].Draw("ap")
564 # c.cd(5)
565 # v[1].Draw("ap")
566 # c.cd(6)
567 # v[2].Draw("ap")
568 # c.cd(7)
569 # v[3].Draw("ap")
570 # c.cd(8)
571 # v[4].Draw("ap")
572 # c.cd(9)
573 # v[5].Draw("ap")
574 # c.cd(10)
575 
579 
580 
581 cx = TCanvas("cx","",800,600)
582 cy = TCanvas("cy","",800,600)
583 cz = TCanvas("cz","",800,600)
584 csx = TCanvas("csx","",800,600)
585 csy = TCanvas("csy","",800,600)
586 csz = TCanvas("csz","",800,600)
587 cax = TCanvas("cax","",800,600)
588 cay = TCanvas("cay","",800,600)
589 ck = TCanvas("ck","",800,600)
590 crhoxy = TCanvas("crhoxy","",800,600)
591 cnEvents = TCanvas("cnEvents","",800,600)
592 
593 legx = TLegend(0.75,0.65,0.92,0.94)
594 legy = TLegend(0.75,0.65,0.92,0.94)
595 legz = TLegend(0.75,0.65,0.92,0.94)
596 legsx = TLegend(0.75,0.65,0.92,0.94)
597 legsy = TLegend(0.75,0.65,0.92,0.94)
598 legsz = TLegend(0.75,0.65,0.92,0.94)
599 legax = TLegend(0.75,0.65,0.92,0.94)
600 legay = TLegend(0.75,0.65,0.92,0.94)
601 legk = TLegend(0.75,0.65,0.92,0.94)
602 legrhoxy = TLegend(0.75,0.65,0.92,0.94)
603 legnEvents = TLegend(0.75,0.65,0.92,0.94)
604 legs = [ legx,legy ,legz ,legsx,legsy,legsz,legax,legay,legk ,legrhoxy,legnEvents]
605 for leg in legs:
606  leg.SetFillColor(0);
607  leg.SetFillStyle(0);
608  leg.SetBorderSize(0);
609 
610 
611 c=0
612 m=0
613 first = True
614 colours = [ EColor.kRed+1, EColor.kBlue+1, EColor.kGreen-8, EColor.kYellow+4]
615 markers = [20,25,22,27,23,28,30,21]
616 for k,v in plots.items():
617  if first:
618  dr = "apl"
619  first = False
620  x = [v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10]]
621  for i in v:
622  a = i.GetYaxis()
623  min = a.GetXmin()
624  max = a.GetXmax()
625  a.SetRangeUser( min - 0.1*(max-min), max + 0.5*(max-min))
626 
627  else:
628  dr = "pl"
629 
630  for i in v:
631  i.SetMarkerColor(colours[c])
632  i.SetLineColor(colours[c])
633  i.SetMarkerStyle(markers[m])
634 
635  legx.AddEntry(v[0],str(int(k)),"p")
636  legy.AddEntry(v[1],str(int(k)),"p")
637  legz.AddEntry(v[2],str(int(k)),"p")
638  legsx.AddEntry(v[3],str(int(k)),"p")
639  legsy.AddEntry(v[4],str(int(k)),"p")
640  legsz.AddEntry(v[5],str(int(k)),"p")
641  legax.AddEntry(v[6],str(int(k)),"p")
642  legay.AddEntry(v[7],str(int(k)),"p")
643  legk.AddEntry(v[8],str(int(k)),"p")
644  legrhoxy.AddEntry(v[9],str(int(k)),"p")
645  legnEvents.AddEntry(v[10],str(int(k)),"p")
646 
647 
648 
649  cx.cd()
650  v[0].Draw(dr)
651  cy.cd()
652  v[1].Draw(dr)
653  cz.cd()
654  v[2].Draw(dr)
655  csx.cd()
656  v[3].Draw(dr)
657  csy.cd()
658  v[4].Draw(dr)
659  csz.cd()
660  v[5].Draw(dr)
661  cax.cd()
662  v[6].Draw(dr)
663  cay.cd()
664  v[7].Draw(dr)
665  ck.cd()
666  v[8].Draw(dr)
667  crhoxy.cd()
668  v[9].Draw(dr)
669  cnEvents.cd()
670  v[10].Draw(dr)
671 
672  c = c+1
673  if c == len(colours):
674  m = m+1
675  c=0
676 
677  if m == len(markers):
678  m=0
679 
680 
681 print "Found BICDs: ", bcidEvents.keys()
682 
683 fontSize=0.1
684 cx.cd()
685 AddText(0.2,0.85,"x-position",fontSize)
686 legx.Draw()
687 cy.cd()
688 AddText(0.2,0.85,"y-position",fontSize)
689 legy.Draw()
690 cz.cd()
691 AddText(0.2,0.85,"z-position",fontSize)
692 legz.Draw()
693 csx.cd()
694 AddText(0.2,0.85,"Width #sigma(x)",fontSize)
695 legsx.Draw()
696 csy.cd()
697 AddText(0.2,0.85,"Width #sigma(y)",fontSize)
698 legsy.Draw()
699 csz.cd()
700 AddText(0.2,0.85,"Width #sigma(z)",fontSize)
701 legsz.Draw()
702 cax.cd()
703 AddText(0.2,0.85,"Slope: x-z",fontSize)
704 legax.Draw()
705 cay.cd()
706 AddText(0.2,0.85,"Slope: y-z",fontSize)
707 legay.Draw()
708 ck.cd()
709 AddText(0.2,0.85,"k-factor",fontSize)
710 legk.Draw()
711 crhoxy.cd()
712 legrhoxy.Draw()
713 AddText(0.2,0.85,"#rho_{xy}",fontSize)
714 cnEvents.cd()
715 AddText(0.2,0.85,"N passed vertices",fontSize)
716 legnEvents.Draw()
717 
718 cx.Print("cx.pdf")
719 cy.Print("cy.pdf")
720 cz.Print("cz.pdf")
721 csx.Print("csx.pdf")
722 csy.Print("csy.pdf")
723 csz.Print("csz.pdf")
724 cax.Print("cax.pdf")
725 cay.Print("cay.pdf")
726 ck.Print("ck.pdf")
727 crhoxy.Print("crhoxy.pdf")
728 cnEvents.Print("cnEvents.pdf")
729 
730 
731 s = raw_input('--> ')
732 exit()
733 
beamspotPlotBcids.Beamspot.Esy
Esy
Definition: beamspotPlotBcids.py:60
beamspotPlotBcids.Event.statusWord
statusWord
Definition: beamspotPlotBcids.py:37
beamspotPlotBcids.Beamspot.sz
sz
Definition: beamspotPlotBcids.py:48
beamspotPlotBcids.Beamspot.ay
ay
Definition: beamspotPlotBcids.py:50
beamspotPlotBcids.AddText
def AddText(xmin, ymin, text, size=0.015, font=None)
Definition: beamspotPlotBcids.py:19
beamspotPlotBcids.Event.nEvents
nEvents
Definition: beamspotPlotBcids.py:36
beamspotPlotBcids.Beamspot.ax
ax
Definition: beamspotPlotBcids.py:49
beamspotPlotBcids.Beamspot.x0
x0
Definition: beamspotPlotBcids.py:43
beamspotPlotBcids.Beamspot.__init__
def __init__(self)
Definition: beamspotPlotBcids.py:42
beamspotPlotBcids.makeBeamspotPlots
def makeBeamspotPlots(name, beamspots)
Definition: beamspotPlotBcids.py:225
beamspotPlotBcids.getTree
def getTree(name, file, dir)
Definition: beamspotPlotBcids.py:180
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:94
beamspotPlotBcids.Beamspot.z
z
Definition: beamspotPlotBcids.py:45
beamspotPlotBcids.Beamspot.Eax
Eax
Definition: beamspotPlotBcids.py:62
beamspotPlotBcids.Beamspot.__str__
def __str__(self)
Definition: beamspotPlotBcids.py:94
beamspotPlotBcids.Event.run
run
Definition: beamspotPlotBcids.py:33
beamspotPlotBcids.Beamspot.Ek
Ek
Definition: beamspotPlotBcids.py:64
beamspotPlotBcids.Beamspot.Esx
Esx
Definition: beamspotPlotBcids.py:59
beamspotPlotBcids.Event.bcid
bcid
Definition: beamspotPlotBcids.py:38
beamspotPlotBcids.Beamspot.Ey0
Ey0
Definition: beamspotPlotBcids.py:57
beamspotPlotBcids.makePull
def makePull(tree, xval='x0', xcov='x0x0', xTrue=0., isCovErr=True, xlow=-8, xhigh=8, xbins=100, doGausFit=False, cuts="")
Definition: beamspotPlotBcids.py:186
beamspotPlotBcids.makeListFromString
def makeListFromString(s, token=',')
Definition: beamspotPlotBcids.py:14
beamspotPlotBcids.Event.lbStart
lbStart
Definition: beamspotPlotBcids.py:34
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
beamspotPlotBcids.Beamspot.Erhoxy
Erhoxy
Definition: beamspotPlotBcids.py:65
beamspotPlotBcids.Event.__init__
def __init__(self)
Definition: beamspotPlotBcids.py:32
beamspotPlotBcids.Beamspot.sx
sx
Definition: beamspotPlotBcids.py:46
beamspotPlotBcids.Beamspot.Ez
Ez
Definition: beamspotPlotBcids.py:58
beamspotPlotBcids.Event
Definition: beamspotPlotBcids.py:31
calibdata.exit
exit
Definition: calibdata.py:236
beamspotPlotBcids.Beamspot.xc
xc
Definition: beamspotPlotBcids.py:53
beamspotPlotBcids.splitBeamspotTreeTitle
def splitBeamspotTreeTitle(title, cutToken="CUT")
Definition: beamspotPlotBcids.py:169
beamspotPlotBcids.Beamspot.Esz
Esz
Definition: beamspotPlotBcids.py:61
beamspotPlotBcids.Beamspot.sy
sy
Definition: beamspotPlotBcids.py:47
beamspotPlotBcids.Beamspot.Eay
Eay
Definition: beamspotPlotBcids.py:63
readCCLHist.int
int
Definition: readCCLHist.py:84
beamspotPlotBcids.Beamspot.k
k
Definition: beamspotPlotBcids.py:51
beamspotPlotBcids.Beamspot.clear
def clear(self)
Definition: beamspotPlotBcids.py:68
beamspotPlotBcids.makeBeamspotCutPlots
def makeBeamspotCutPlots(name, points)
Definition: beamspotPlotBcids.py:305
beamspotPlotBcids.Beamspot.rhoxy
rhoxy
Definition: beamspotPlotBcids.py:52
beamspotPlotBcids.Beamspot.Ex0
Ex0
Definition: beamspotPlotBcids.py:56
beamspotPlotBcids.Beamspot.y0
y0
Definition: beamspotPlotBcids.py:44
beamspotPlotBcids.makeCutPlotPulls
def makeCutPlotPulls(file, dir, pattern, name)
Definition: beamspotPlotBcids.py:409
beamspotPlotBcids.Beamspot.yc
yc
Definition: beamspotPlotBcids.py:54
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
beamspotPlotBcids.findBeamspots
def findBeamspots(file, dir, pattern)
Definition: beamspotPlotBcids.py:135
str
Definition: BTagTrackIpAccessor.cxx:11
beamspotPlotBcids.Beamspot.Exc
Exc
Definition: beamspotPlotBcids.py:66
beamspotPlotBcids.Event.lumiRange
lumiRange
Definition: beamspotPlotBcids.py:35
beamspotPlotBcids.makeFloatFromString
def makeFloatFromString(s)
Definition: beamspotPlotBcids.py:158
readCCLHist.float
float
Definition: readCCLHist.py:83
beamspotPlotBcids.Beamspot
Definition: beamspotPlotBcids.py:41
beamspotPlotBcids.Beamspot.Eyc
Eyc
Definition: beamspotPlotBcids.py:67