예제 #1
0
def BkgPlot( Input, Detector, Stat ):

  ##### General commands #####
  ROOT.gROOT.SetBatch()
  ROOT.gErrorIgnoreLevel = 3000

  ##### Opening file and read all contents #####
  MyObjects = []
  AllTypes = { 'Regions': set(), 'VarPtBins': set() }
  InputFile = ROOT.TFile( Input )
  Keys = ROOT.gDirectory.GetListOfKeys() 
  Reg = re.compile( '(\w+)~BkgFit~(\w+)~(\w+)' ) 
  for Key in Keys:
    Match = Reg.search( Key.GetName() )
    if not Match:
      continue
    #print Key.GetName()
    Region = Match.group( 1 )
    Variable = Match.group( 2 )
    PtBin = Match.group( 3 )
    AllTypes[ 'Regions' ].add( Region )
    AllTypes[ 'VarPtBins' ].add( ( Variable, PtBin ) )
    MyObjects.append( Objects.BkgObject( InputFile.Get( Key.GetName() ), Region, InputFile.Get( Region ).GetTitle(), Variable, PtBin ) )

  AllPlotsDone = []
  for MyObject in MyObjects:
    for path in PlottingTools.DoBackgroundPlot( MyObject, Detector, Stat ):
      AllPlotsDone.append( os.path.abspath( path ) )
  return AllPlotsDone