Newer
Older
TB_Chris / Kepler / options / ResStudies / .svn / text-base / AlignQualy.py.svn-base
  1. from ROOT import TFile, TCanvas
  2. from Runs import Runs
  3.  
  4. import os, sys
  5. block = ['D1','D2']
  6. indir = '/afs/cern.ch/work/c/chombach/Telescope/ResStudies/'
  7. outdir = '/afs/cern.ch/user/c/chombach/www/public/Telescope/AlignQualy/'
  8.  
  9. os.system('mkdir -p '+outdir)
  10.  
  11. outfile = outdir+'AlignQualy'
  12. for bl in block:
  13. outfile += '_'+bl
  14. outfile += '.pdf'
  15. runs = Runs(block, 'run')
  16. runs.setOutputDir(indir)
  17.  
  18. c = TCanvas('c','c',1200,600)
  19. c.Print(outfile+'(','pdf')
  20.  
  21. def makePlots(tf, title):
  22.  
  23. c.Divide(0,0)
  24. fn = 'Tb/TbTrackPlots/'
  25. chi2 = tf.Get(fn+'Chi2PerDof')
  26. chi2.SetTitle(title)
  27. chi2.Draw()
  28. c.Print(outfile,'pdf')
  29.  
  30. prob = tf.Get(fn+'Probability')
  31. prob.SetTitle(title)
  32. prob.Draw()
  33. c.Print(outfile,'pdf')
  34.  
  35. c.Clear()
  36. c.Divide(5,2)
  37. for i in range(9):
  38. c.cd(i+1)
  39. res_x = tf.Get(fn+'BiasedResiduals/GlobalX/Plane%i' % i )
  40. res_x.SetTitle(title+' GlobalX Plane%i' % i)
  41. res_x.Fit('gaus')
  42. res_x.Draw()
  43. c.Print(outfile,'pdf')
  44. c.Clear()
  45.  
  46. c.Divide(5,2)
  47. for i in range(9):
  48. c.cd(i+1)
  49. res_y = tf.Get(fn+'BiasedResiduals/GlobalY/Plane%i' % i )
  50. res_y.SetTitle(title+' GlobalY Plane%i' % i)
  51. res_y.Fit('gaus')
  52. res_y.Draw()
  53. c.Print(outfile,'pdf')
  54. c.Clear()
  55.  
  56. c.Divide(5,2)
  57. for i in range(9):
  58. c.cd(i+1)
  59. res_xvsx = tf.Get(fn+'BiasedResiduals/GlobalResXvsLocalX/Plane%i' % i )
  60. res_xvsx.SetTitle(title+' GlobalXResvsX Plane%i' % i)
  61. res_xvsx.Draw()
  62. c.Print(outfile,'pdf')
  63. c.Clear()
  64.  
  65. c.Divide(5,2)
  66. for i in range(9):
  67. c.cd(i+1)
  68. res_yvsy = tf.Get(fn+'BiasedResiduals/GlobalResYvsLocalY/Plane%i' % i )
  69. res_yvsy.SetTitle(title+' GlobalYResvsY Plane%i' % i)
  70. res_yvsy.Draw()
  71. c.Print(outfile,'pdf')
  72. c.Clear()
  73. for block in runs.RUNS:
  74. for run in runs.RUNS[block]:
  75. rn = run.RUN
  76. ang = run.ANGLE
  77. bia = run.BIAS
  78. dut = run.DUT
  79. block = run.BLOCK
  80. title = '%s_%s_%s_%s' % (rn, dut, bia, ang)
  81. fn = runs.OUTPUTDIR+block+'/Kepler_%s.root' % title
  82. tf = TFile(fn)
  83. makePlots(tf, title)
  84. tf.Close()
  85. c.Print(outfile+')','pdf')
  86.  
  87.