Crombie Tools
RatioComparison.py
Go to the documentation of this file.
1 from .. import Load, DirFromEnv, Nminus1Cut
2 
3 newRatioComparer = Load('RatioComparison')
4 plotter = newRatioComparer()
5 
6 
7 def SetupFromEnv(aPlotter=plotter):
8  """A function that sets up a plotter after sourcing a config file.
9 
10  @param aPlotter is the plotter to setup. Defaults to plotter in this module.
11  """
12  from ..CommonTools.FileConfigReader import SetupConfigFromEnv, SetFunctionFromEnv
13 
14  SetupConfigFromEnv(aPlotter)
15 
16  DirFromEnv('CrombieOutPlotDir')
18  (aPlotter.SetOutDirectory, 'CrombieOutPlotDir'),
19  ])
20 
21 
22 def SetCuts(category1, region1, region2, category2=None, aPlotter=plotter, Nminus1=''):
23  """ Sets cuts based on category and region.
24 
25  @param category1 is the category of the analysis being used.
26  @param region1 is the region of the numerator.
27  @param region2 is the region of the denominator.
28  @param category2 if set, is the category of the denominator.
29  Otherwise, the category is assumed to be the same
30  @param aPlotter is the plotter that is having its cuts set.
31  Default is the plotter defined in this module.
32  @param Nminus1 is a parameter to not cut on
33  """
34 
35  from ..LoadConfig import cuts
36 
37  category2 = category2 or category1
38 
39  aPlotter.Reset()
40 
41  numerator_cut = Nminus1Cut(cuts.cut(category1, region1), Nminus1) if Nminus1 else cuts.cut(category1, region1)
42  denominator_cut = Nminus1Cut(cuts.cut(category2, region2), Nminus1) if Nminus1 else cuts.cut(category2, region2)
43 
44  aPlotter.AddRatioCuts(numerator_cut + ' && ' + cuts.dataMCCuts(region1, True),
45  denominator_cut + ' && ' + cuts.dataMCCuts(region2, True),
46  aPlotter.kData, 'Data', 1)
47 
48  aPlotter.AddRatioCuts(numerator_cut + ' * ' + cuts.dataMCCuts(region1, False),
49  denominator_cut + ' * ' + cuts.dataMCCuts(region2, False),
50  aPlotter.kBackground, 'MC', 2)
51 
52  aPlotter.SetDataIndex(0)
53  aPlotter.SetRatioIndex(1)