3 This module defines the standard JetModifier tools used in jet reco
5 Definitions are grouped in a dictionary of tool configurations using the helpers defined
7 This dict maps a modifier alias to the JetModifier config object
8 that in turn will be responsible for generating a configured tool.
10 The JetModifier config class is defined in JetDefinition.py
12 Args to the JetModifier constructor are:
13 1. Tool Type (ignored if the helper is a custom one)
14 2. Tool Name (ignored if the helper is a custom one)
15 3. createfn : helper function which build the actual tool. If none, we just instantiate the tool type.
16 4. prereqs : Prerequisites (default to []). Can also be a function which returns a list
17 X. all other keyword arguments are directly interpreted as Property of the tool.
18 for ex, passing 'PtMin=10.' will configure the tool as in 'tool.PtMin = 10'
19 we can pass function as the value :
20 'JetContainerName=nameFunc' will configure as in 'tool.JetContainerName=nameFunc(jetdef, modspec)'
22 --> should this be by default? prefer to avoid ignored args
24 from .JetDefinition
import JetModifier
25 from .Utilities
import ldict
26 from .StandardJetConstits
import inputsFromContext
32 stdJetModifiers.update(
37 PtMin =
lambda jdef,modspec:
int(modspec)
39 Filter_ifnotESD =
JetModifier(
"JetFilterTool",
"jetptfilter_{modspec}",
40 PtMin =
lambda _,modspec: 1,
43 Filter_calibThreshold =
JetModifier(
"JetFilterTool",
"jetptfilter_{modspec}",
44 PtMin =
lambda jetdef,modspec: 1
if not jetdef._cflags.Jet.useCalibJetThreshold
else int(modspec),
56 from JetCalibTools
import JetCalibToolsConfig
57 stdJetModifiers.update(
58 Calib =
JetModifier(
"JetCalibrationTool",
"jetcalib_jetcoll_calibseq",
59 createfn=JetCalibToolsConfig.getJetCalibToolFromString,
62 except ModuleNotFoundError:
76 return jetdef.fullname()
79 """A simple filter function for testing if we're running in MC
80 returns (bool, str) where the str contains an explanation of why the bool is False.
81 (probably worth re-allocating somehere else)"""
82 return flags.Input.isMC,
"Input file is not MC"
86 """Returns the exact constituent container name used to build jetdef"""
87 constitdef = jetdef.inputdef
88 containername = constitdef.containername(jetdef).
split(
':')[-1]
if callable(constitdef.containername)
else constitdef.containername
94 from JetMomentTools
import JetMomentToolsConfig
95 stdJetModifiers.update(
98 ClusterMoments =
JetModifier(
"JetClusterMomentsTool",
"clsmoms", JetContainer = _jetname),
99 ECPSFrac =
JetModifier(
"JetECPSFractionTool",
"ecpsfrac", JetContainer = _jetname),
100 Width =
JetModifier(
"JetWidthTool",
"width", JetContainer = _jetname),
103 CaloEnergies =
JetModifier(
"JetCaloEnergies",
"jetens",
104 prereqs=[
"mod:EMScaleMom"],
105 Calculations=[
"EMFrac",
"HECFrac",
"PSFrac",
"FracSamplingMax"], JetContainer = _jetname,
108 CaloEnergiesLargeR =
JetModifier(
"JetCaloEnergies",
"jetenslargeR",
109 prereqs=[
"mod:EMScaleMom"],
110 Calculations=[
"EMFrac",
"HECFrac",
"PSFrac",
"EM3Frac",
"Tile0Frac",
"EffNClusts"], JetContainer = _jetname,
111 calcClusterBasedVars =
True,
115 CaloEnergiesClus =
JetModifier(
"JetCaloEnergies",
"jetensclus",
116 prereqs=[
"mod:EMScaleMom"],
117 Calculations=[
"EMFrac",
"HECFrac",
"PSFrac",
"FracSamplingMax"], JetContainer = _jetname,
118 calcClusterBasedVars =
True),
120 CaloQuality =
JetModifier(
"JetCaloQualityTool",
"caloqual",
122 Calculations = [
"LArQuality",
"N90Constituents",
"NegativeE",
"Timing",
"HECQuality",
"Centroid",
"AverageLArQF",
"BchCorrCell"],JetContainer = _jetname),
124 CaloQualityFE =
JetModifier(
"JetCaloQualityToolFE",
"caloqualFE",
126 ThresholdCuts = [90],
127 Calculations = [
"LArQuality",
"NegativeE",
"Timing",
"HECQuality",
"Centroid",
"AverageLArQF",
"BchCorrCell"],JetContainer = _jetname),
130 Calculations = [
"N90Constituents"],JetContainer = _jetname),
132 ConstitFourMom =
JetModifier(
"JetConstitFourMomTool",
"constitfourmom_basename",
133 createfn=JetMomentToolsConfig.getConstitFourMomTool,),
134 EMScaleMom =
JetModifier(
"JetEMScaleMomTool",
"emscalemom_basename",
135 createfn=JetMomentToolsConfig.getEMScaleMomTool,
136 JetContainer = _jetname),
139 createfn=JetMomentToolsConfig.getJVFTool,
141 JetContainer = _jetname),
143 createfn=JetMomentToolsConfig.getJVTTool,
144 prereqs = [
"mod:JVF" ],JetContainer = _jetname),
146 createfn=JetMomentToolsConfig.getNNJvtTool,
147 prereqs = [
"mod:JVF" ],JetContainer = _jetname),
148 LArHVCorr =
JetModifier(
"JetLArHVTool",
"larhvcorr",
149 prereqs = [
"mod:EMScaleMom"],JetContainer = _jetname),
150 OriginSetPV =
JetModifier(
"JetOriginCorrectionTool",
"origin_setpv",
151 prereqs = [
"mod:JVF" ],JetContainer = _jetname, OnlyAssignPV=
True),
152 TrackMoments =
JetModifier(
"JetTrackMomentsTool",
"trkmoms",
153 createfn=JetMomentToolsConfig.getTrackMomentsTool,
156 TrackSumMoments =
JetModifier(
"JetTrackSumMomentsTool",
"trksummoms",
157 createfn=JetMomentToolsConfig.getTrackSumMomentsTool,
160 prereqs = [
"ghost:Track" ]),
162 QGTagging =
JetModifier(
"JetQGTaggerVariableTool",
"qgtagging",
163 createfn=JetMomentToolsConfig.getQGTaggingTool,
164 prereqs =
lambda _,jetdef :
166 ([
"mod:JetPtAssociation"]
if not isMC(jetdef._cflags)
else []),
167 JetContainer = _jetname),
169 fJVT =
JetModifier(
"JetForwardPFlowJvtTool",
"fJVT",
170 createfn=JetMomentToolsConfig.getPFlowfJVTTool,
172 JetContainer = _jetname),
174 bJVT =
JetModifier(
"JetBalancePFlowJvtTool",
"bJVT",
175 createfn=JetMomentToolsConfig.getPFlowbJVTTool,
177 JetContainer = _jetname),
179 ConstitFrac =
JetModifier(
"JetConstituentFrac",
"constitFrac",
180 JetContainer = _jetname,
183 groomMRatio =
JetModifier(
"JetGroomMRatio",
"groomMRatio",
184 JetContainer = _jetname,
187 JetPtAssociation =
JetModifier(
"JetPtAssociationTool",
"jetPtAssociation",
189 createfn=JetMomentToolsConfig.getJetPtAssociationTool,
190 prereqs=[
"ghost:Truth"],
191 JetContainer = _jetname
197 JetContainer=_jetname,
198 InputConstitContainer = _constitContainername,
199 IsolationCalculations = [
"IsoFixedCone:5:Pt",
"IsoFixedCone:5:PtPUsub",],
200 RhoKey =
lambda jetdef, specs :
"Kt4"+jetdef.inputdef.label+
"EventShape" ,
201 prereqs= [
"input:EventDensity"],
204 jetisoTruth =
JetModifier(
"JetIsolationTool",
"isoTruth",
205 JetContainer=_jetname,
206 InputConstitContainer = _constitContainername,
207 IsolationCalculations = [
"IsoFixedCone:5:Pt", ],
213 except ModuleNotFoundError:
218 from ParticleJetTools
import ParticleJetToolsConfig
219 stdJetModifiers.update(
221 PartonTruthLabel =
JetModifier(
"Analysis::JetPartonTruthLabel",
"partontruthlabel",
222 prereqs=[
"ghost:Partons"]),
225 JetDeltaRLabel =
JetModifier(
"ParticleJetDeltaRLabelTool",
"jetdrlabeler_jetptmin",
226 createfn=ParticleJetToolsConfig.getJetDeltaRLabelTool,
227 prereqs=[
"ghost:BHadronsFinal",
228 "ghost:CHadronsFinal",
233 JetGhostLabel =
JetModifier(
"ParticleJetGhostLabelTool",
"jetghostlabeler",
234 createfn=ParticleJetToolsConfig.getJetGhostLabelTool,
235 prereqs=[
"ghost:BHadronsFinal",
236 "ghost:CHadronsFinal",
241 JetTaggingTruthLabel =
JetModifier(
"JetTaggingTruthLabel",
"truthlabeler_{mods}",
243 createfn=ParticleJetToolsConfig.getJetTruthLabelTool,
247 JetPileupLabel =
JetModifier(
"JetPileupLabel",
"pileuplabeler_{mods}",
249 createfn=ParticleJetToolsConfig.getJetPileupLabelTool,
250 prereqs=[
"input:AntiKt4TruthDressedWZJets"]
257 stdJetModifiers.update(
258 nsubjettiness =
JetModifier(
"NSubjettinessTool",
"nsubjettiness",Alpha = 1.0),
259 nsubjettinessR =
JetModifier(
"NSubjettinessRatiosTool",
"nsubjettinessR",),
268 dipolarity =
JetModifier(
"DipolarityTool",
"dipolarity",SubJetRadius = 0.3),
274 ecorr =
JetModifier(
"EnergyCorrelatorTool",
"ecorr", Beta = 1.0),
277 ecorrgeneral =
JetModifier(
"EnergyCorrelatorGeneralizedTool",
"ecorrgeneral", DoLSeries =
True),
278 ecorrgeneralratios =
JetModifier(
"EnergyCorrelatorGeneralizedRatiosTool",
"ecorrgeneralratios", DoLSeries =
True),
282 pull =
JetModifier(
"JetPullTool",
"pull", UseEtaInsteadOfY =
False, IncludeTensorMoments =
True ),
288 softdropobs =
JetModifier(
"SoftDropObservablesTool",
"softdropobs"),
293 from JetMomentTools
import JetMomentToolsConfig
294 stdJetModifiers.update(
295 qgtransformer =
JetModifier(
"BoostedJetTaggerTool",
"qgtransformer",
296 createfn=JetMomentToolsConfig.getBoostedJetTaggerTool,
297 JetContainer = _jetname),
299 except ModuleNotFoundError:
304 stdJetModifiers.update(
305 vr =
JetModifier(
"FlavorTagDiscriminants::VRJetOverlapDecoratorTool",
"vr")