4 from AnaAlgorithm.DualUseConfig
import createAlgorithm, addPrivateTool
7 btagWP = "FixedCutBEff_77",
12 kinematicSelection = False,
14 enableCutflow = False,
16 makeViewContainer = False):
17 """Create a ftag analysis algorithm sequence
19 for now the sequence is passed in, I'm unsure if I can concatenate
20 two sequences at the moment, or if that blows things up horribly
23 dataType -- The data type to run on ("data", "mc" or "afii")
24 jetCollection -- Jet container to run on
25 btagWP -- Flavour tagging working point
26 btagger -- Flavour tagger
27 generator -- Generator for MC/MC scale factors
28 kinematicSelection -- Wether to run kinematic selection
29 noEfficiency -- Wether to run efficiencies calculation
30 enableCutflow -- Whether or not to dump the cutflow
31 minPt -- Kinematic selection for jet calibration validity (depending on jet collection)
37 if "EMPFlow" in jetCollection:
39 elif "EMTopo" in jetCollection:
41 elif "VRTrack" in jetCollection:
45 if preselection
is not None and preselection !=
'' :
46 preselectionList.append (preselection)
48 if dataType
not in [
"data",
"mc",
"afii"] :
49 raise ValueError (
"invalid data type: " + dataType)
51 if generator
not in [
"default",
"Pythia8",
"Sherpa221",
"Sherpa2210",
"Sherpa2212",
"Herwig713",
"Herwig721",
"amcAtNLOPythia",
"amcAtNLOHerwig"]:
52 raise ValueError (
"invalid generator type: " + generator)
56 if generator ==
"Sherpa221":
58 elif generator ==
"Sherpa2210":
60 elif generator ==
"Sherpa2212":
62 elif generator ==
"Herwig713":
64 elif generator ==
"Herwig721":
66 elif generator ==
"amcAtNLOPythia":
68 elif generator ==
"amcAtNLOHerwig":
72 bTagCalibFile =
"xAODBTaggingEfficiency/13TeV/2023-22-13TeV-MC20-CDI-2023-09-13_v1.root"
77 if kinematicSelection:
79 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'FTagKinSelectionAlg'+postfix )
80 addPrivateTool( alg,
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
81 alg.selectionTool.minPt = minPt
82 alg.selectionTool.maxEta = 2.5
83 alg.selectionDecoration =
'ftag_kin_select_' + btagger +
'_' + btagWP
84 alg.preselection =
'&&'.join (preselectionList)
85 preselectionList.append (alg.selectionDecoration)
86 seq.append( alg, inputPropName =
'particles' )
88 if makeViewContainer :
92 'FTagKinViewFromSelectionAlg'+postfix )
93 alg.selection = [
'ftag_kin_select_' + btagger +
'_' + btagWP ]
94 seq.append( alg, inputPropName =
'input', outputPropName =
'output',
95 stageName =
'selection' )
98 alg =
createAlgorithm(
'CP::AsgSelectionAlg',
'FTagSelectionAlg' + btagger + btagWP + postfix )
100 alg.selectionTool.TaggerName = btagger
101 alg.selectionTool.OperatingPoint = btagWP
102 alg.selectionTool.JetAuthor = jetCollection
103 alg.selectionTool.FlvTagCutDefinitionsFileName = bTagCalibFile
104 alg.selectionTool.MinPt = 0.
105 alg.preselection =
'&&'.join (preselectionList)
106 alg.selectionDecoration =
'ftag_select_' + btagger +
'_' + btagWP +
',as_char'
107 seq.append( alg, inputPropName =
'particles',
108 stageName =
'selection' )
110 if btagWP ==
'Continuous':
111 alg =
createAlgorithm(
'CP::BTaggingInformationDecoratorAlg',
'FTagInfoAlg' + btagger + btagWP + postfix )
113 alg.selectionTool.TaggerName = btagger
114 alg.selectionTool.OperatingPoint = btagWP
115 alg.selectionTool.JetAuthor = jetCollection
116 alg.selectionTool.FlvTagCutDefinitionsFileName = bTagCalibFile
117 alg.selectionTool.MinPt = 0.
118 alg.preselection =
'&&'.join (preselectionList)
119 alg.quantileDecoration =
'ftag_quantile_' + btagger
120 seq.append( alg, inputPropName =
'jets',
121 stageName =
'selection' )
123 if not noEfficiency
and dataType !=
'data':
126 'FTagEfficiencyScaleFactorAlg' + btagger + btagWP + postfix )
128 'BTaggingEfficiencyTool' )
129 alg.efficiencyTool.TaggerName = btagger
130 alg.efficiencyTool.OperatingPoint = btagWP
131 alg.efficiencyTool.JetAuthor = jetCollection
132 alg.efficiencyTool.ScaleFactorFileName = bTagCalibFile
133 alg.efficiencyTool.SystematicsStrategy =
"Envelope"
134 alg.efficiencyTool.MinPt = 0.
135 if DSID !=
"default":
136 alg.efficiencyTool.EfficiencyBCalibrations = DSID
137 alg.efficiencyTool.EfficiencyTCalibrations = DSID
138 alg.efficiencyTool.EfficiencyCCalibrations = DSID
139 alg.efficiencyTool.EfficiencyLightCalibrations = DSID
140 alg.scaleFactorDecoration =
'ftag_effSF_' + btagger +
'_' + btagWP +
'_%SYS%'
141 alg.selectionDecoration =
'ftag_select_' + btagger +
'_' + btagWP +
',as_char'
142 alg.onlyEfficiency = btagWP ==
'Continuous'
143 alg.outOfValidity = 2
144 alg.outOfValidityDeco =
'no_ftag_' + btagger +
'_' + btagWP
145 alg.preselection =
'&&'.join (preselectionList)
146 seq.append( alg, inputPropName =
'jets',
147 stageName =
'efficiency' )
152 alg =
createAlgorithm(
'CP::ObjectCutFlowHistAlg',
'FTagCutFlowDumperAlg' + btagger + btagWP + postfix )
153 alg.histPattern =
'ftag_cflow_' + btagger +
'_' + btagWP +
'_%SYS%'
154 alg.selections = [
'ftag_select_' + btagger +
'_' + btagWP +
',as_char']
155 seq.append( alg, inputPropName =
'input',
156 stageName =
'selection' )