Newer
Older
TB_Chris / Kepler / GangaPlugin / Lib / .svn / text-base / TbMetaAnaylsisMerger.py.svn-base
  1. from ROOT import *
  2. from RecursiveSearch import RecursiveSearch
  3.  
  4. # main programme
  5.  
  6.  
  7. all_histograms = []
  8. RecursiveSearch( f, all_histograms , 5 )
  9.  
  10. output = TFile('Meta-graphs.root','RECREATE')
  11.  
  12. # clone the directory structure
  13.  
  14. for x in all_histograms:
  15. directories = x.split('/')
  16. layer = output
  17. path = ""
  18. for ind in range( 0, len(directories) -1 ) :
  19. tmpKey = layer.FindKey( directories[ind] )
  20. if not tmpKey :
  21. foo = layer.mkdir( directories[ind], directories[ind] )
  22. layer.cd()
  23. foo.Write()
  24. layer.Write()
  25. layer = foo
  26. else : layer = tmpKey.ReadObj()
  27.  
  28. output.Write()
  29.  
  30. output.Close()
  31.  
  32. output = TFile('Meta-graphs.root','UPDATE')
  33.  
  34. for x in all_histograms:
  35. obj = f.Get( x )
  36.  
  37. k = x.rfind('/')
  38. path = x[:k]
  39. name = x[k+1:]
  40. output.cd( path )
  41.  
  42. graph_mean = TGraph( )
  43. graph_mean.SetNameTitle( name + "_mean" , obj.GetTitle() )
  44. graph_mean.SetPoint( graph_mean.GetN() , 0, obj.GetMean() )
  45. graph_mean.Write()
  46.  
  47. graph = TGraph( )
  48. graph.SetNameTitle( name + "_sigma" , obj.GetTitle() )
  49. graph.SetPoint( graph.GetN() , 0, obj.GetRMS() )
  50. graph.Write()
  51.  
  52.  
  53.  
  54. output.Write()