1 """@package CrombieTools.SkimmingTools.Corrector 3 Submodule of CrombieTools.SkimmingTools 4 Contains the constructor and default object for Corrector and CorrectorApplicator. 5 A couple of convenience functions are also used to create these objects with 6 some parameters filled. 8 @author Daniel Abercrombie <dabercro@mit.edu> 15 newCorrector =
Load(
'Corrector')
16 """Corrector constructor""" 17 newApplicator =
Load(
'CorrectorApplicator')
18 """CorrectorApplicator constructor""" 21 def MakeApplicator(name, saveAll, inputTree='events', outputTree='events', reportFreq=100000, isUnc=False):
22 """Make a CorrectorApplicator with parameters filled 24 @param name is a string that names the branch to merge all of the correction factors into. 25 @param saveAll is a bool to determine whether or not to save each correction factor 27 @param inputTree is the name of the tree to read as input. 28 @param outputTree is the name of the tree to place the output branches. 29 @param reportFreq is the number of events to pass between reporting progress. 30 @param isUnc sets whether this corrector is for uncertainties or not 31 @returns a CorrectorApplicator object. 34 applicator.SetInputTreeName(inputTree)
35 applicator.SetOutputTreeName(outputTree)
36 applicator.SetReportFrequency(reportFreq)
37 applicator.SetIsUncertainty(isUnc)
41 def MakeCorrector(Name, inExpressions, inCut, correctionFile, correctionHist):
42 """Make a Corrector object 44 @param Name is the name of the branch for this Corrector if the CorrectorApplicator 45 is saving all branches. 46 @param inExpressions is the expression to evaluate before reading from the Correction histogram. 47 If the histogram is multi-dimensional, a list can be passed to this parameter. 48 @param inCut is the cut that a tree must pass in order for the Correction to be applied. 49 @param correctionFile is the name of the file holding the correction histogram 50 @param correctionHist is the name of the histograms to apply corrections with. 51 Two histograms from the same file can be divided by passing a list 52 of [numerator_name, denominator_name]. 53 @returns a filled Corrector object. 56 if type(inExpressions)
is list:
57 for inExpr
in inExpressions:
58 corrector.AddInExpression(inExpr)
60 corrector.AddInExpression(inExpressions)
62 corrector.SetInCut(inCut)
63 corrector.SetCorrectionFile(correctionFile)
64 if type(correctionHist)
is list:
65 corrector.SetCorrectionHist(correctionHist[0], correctionHist[1])
67 corrector.SetCorrectionHist(correctionHist)