4 from AsgAnalysisAlgorithms.AnalysisObjectSharedSequence
import makeSharedObjectSequence
5 from AnaAlgorithm.AnaAlgSequence
import AnaAlgSequence
6 from AnaAlgorithm.DualUseConfig
import createAlgorithm, addPrivateTool, \
10 deepCopyOutput = False,
11 shallowViewOutput = True,
12 rerunTruthMatching = True,
13 enableCutflow = False,
14 enableKinematicHistograms = False,
15 defineSystObjectLinks = False ):
16 """Create a tau analysis algorithm sequence
19 dataType -- The data type to run on ("data", "mc" or "afii")
20 deepCopyOutput -- If set to 'True', the output containers will be
21 standalone, deep copies (slower, but needed for xAOD
23 shallowViewOutput -- Create a view container if required
24 postfix -- a postfix to apply to decorations and algorithm
25 names. this is mostly used/needed when using this
26 sequence with multiple working points to ensure all
28 rerunTruthMatching -- Whether or not to rerun truth matching
29 enableCutflow -- Whether or not to dump the cutflow
30 enableKinematicHistograms -- Whether or not to dump the kinematic histograms
33 if dataType
not in [
"data",
"mc",
"afii"] :
34 raise ValueError (
"invalid data type: " + dataType)
37 postfix =
'_' + postfix
41 if deepCopyOutput
and shallowViewOutput:
42 raise ValueError (
"deepCopyOutput and shallowViewOutput can't both be true!")
45 seq = AnaAlgSequence(
"TauAnalysisSequence" + postfix )
47 seq.addMetaConfigDefault (
"selectionDecorNames", [])
48 seq.addMetaConfigDefault (
"selectionDecorNamesOutput", [])
49 seq.addMetaConfigDefault (
"selectionDecorCount", [])
51 makeTauCalibrationSequence (seq, dataType, postfix=postfix,
52 rerunTruthMatching = rerunTruthMatching)
53 makeTauWorkingPointSequence (seq, dataType, workingPoint, postfix=postfix)
54 makeSharedObjectSequence (seq, deepCopyOutput = deepCopyOutput,
55 shallowViewOutput = shallowViewOutput,
56 postfix =
'_Tau' + postfix,
57 enableCutflow = enableCutflow,
58 enableKinematicHistograms = enableKinematicHistograms,
59 defineSystObjectLinks = defineSystObjectLinks )
69 rerunTruthMatching = True):
70 """Create tau calibration analysis algorithms
72 This makes all the algorithms that need to be run first befor
73 all working point specific algorithms and that can be shared
74 between the working points.
77 dataType -- The data type to run on ("data", "mc" or "afii")
78 postfix -- a postfix to apply to decorations and algorithm
79 names. this is mostly used/needed when using this
80 sequence with multiple working points to ensure all
82 rerunTruthMatching -- Whether or not to rerun truth matching
85 if dataType
not in [
"data",
"mc",
"afii"] :
86 raise ValueError (
"invalid data type: " + dataType)
89 if rerunTruthMatching
and dataType !=
'data':
91 'TauTruthMatchingAlg' + postfix )
93 'TauAnalysisTools::TauTruthMatchingTool' )
94 seq.append( alg, inputPropName =
'taus',
95 stageName =
'selection',
96 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNames"])} )
100 alg =
createAlgorithm(
'CP::TauSmearingAlg',
'TauSmearingAlg' + postfix )
101 addPrivateTool( alg,
'smearingTool',
'TauAnalysisTools::TauSmearingTool' )
102 seq.append( alg, inputPropName =
'taus', outputPropName =
'tausOut',
103 stageName =
'calibration',
104 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNames"])} )
113 """Create tau analysis algorithms for a single working point
116 dataType -- The data type to run on ("data", "mc" or "afii")
117 postfix -- a postfix to apply to decorations and algorithm
118 names. this is mostly used/needed when using this
119 sequence with multiple working points to ensure all
123 if dataType
not in [
"data",
"mc",
"afii"] :
124 raise ValueError (
"invalid data type: " + dataType)
126 splitWP = workingPoint.split (
'.')
127 if len (splitWP) != 1 :
128 raise ValueError (
'working point should be of format "quality", not ' + workingPoint)
130 nameFormat =
'TauAnalysisAlgorithms/tau_selection_{}.conf'
132 if splitWP[0]
not in [
'Tight',
'Medium',
'Loose',
'VeryLoose',
'NoID',
'Baseline'] :
133 raise ValueError (
"invalid tau quality: \"" + splitWP[0] +
134 "\", allowed values are Tight, Medium, Loose, " +
135 "VeryLoose, NoID, Baseline")
136 inputfile = nameFormat.format(splitWP[0].lower())
140 'TauSelectionTool' + postfix)
141 selectionTool.ConfigPath = inputfile
142 seq.addPublicTool( selectionTool, stageName =
'selection' )
145 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'TauSelectionAlg' + postfix )
146 addPrivateTool( alg,
'selectionTool',
'TauAnalysisTools::TauSelectionTool' )
147 alg.selectionTool.ConfigPath = inputfile
148 alg.selectionDecoration =
'selected_tau' + postfix +
',as_bits'
149 seq.append( alg, inputPropName =
'particles',
150 stageName =
'selection',
151 metaConfig = {
'selectionDecorNames' : [alg.selectionDecoration],
152 'selectionDecorNamesOutput' : [alg.selectionDecoration],
153 'selectionDecorCount' : [6]},
154 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNames"])} )
158 if dataType !=
'data':
160 'TauEfficiencyCorrectionsAlg' + postfix )
162 'TauAnalysisTools::TauEfficiencyCorrectionsTool' )
163 alg.efficiencyCorrectionsTool.TauSelectionTool =
'%s/%s' % \
164 ( selectionTool.getType(), selectionTool.getName() )
165 alg.scaleFactorDecoration =
'tau_effSF' + postfix +
'_%SYS%'
166 alg.outOfValidity = 2
167 alg.outOfValidityDeco =
'bad_eff' + postfix
168 seq.append( alg, inputPropName =
'taus',
169 stageName =
'efficiency',
170 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNames"])} )
174 'TauSelectionSummary' + postfix )
175 alg.selectionDecoration =
'baselineSelection' + postfix +
',as_char'
176 seq.append( alg, inputPropName =
'particles',
177 stageName =
'selection',
178 dynConfig = {
'preselection' :
lambda meta :
"&&".join (meta[
"selectionDecorNames"])} )