Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HIGG1D2.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 #!/usr/bin/env python
3 #====================================================================
4 # DAOD_HIGG1D2.py
5 # This defines DAOD_HIGG1D2, a di-photon skimmed DAOD format for Run 3.
6 # It contains the variables and objects needed for analyses with
7 # merged electrons, particularly H->yy*.
8 # It requires the flag HIGG1D2 in Derivation_tf.py
9 #====================================================================
10 
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 from AthenaConfiguration.Enums import MetadataCategory
14 from AthenaCommon.SystemOfUnits import GeV
15 
16 # Main algorithm config
17 def HIGG1D2KernelCfg(flags, name='HIGG1D2Kernel', **kwargs):
18  """Configure the derivation framework driving algorithm (kernel) for HIGG1D2"""
19  acc = ComponentAccumulator()
20 
21  # Common augmentations
22  from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
23  acc.merge(PhysCommonAugmentationsCfg(flags, TriggerListsHelper = kwargs['TriggerListsHelper']))
24 
25  # Common Calo decorator tool (as in EGAM, for calibration of merged electrons)
26  from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
27  CaloDecoratorKernelCfg)
28  acc.merge(CaloDecoratorKernelCfg(flags))
29 
30  # Thinning tools
31  from DerivationFrameworkInDet.InDetToolsConfig import TrackParticleThinningCfg, MuonTrackParticleThinningCfg
32  from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import GenericTruthThinningCfg
33 
34  # Inner detector group recommendations for indet tracks in analysis
35  # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations
36  HIGG1D2_thinning_expression = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm && InDetTrackParticles.pt > 10*GeV"
37 
38  HIGG1D2TrackParticleThinningTool = acc.getPrimaryAndMerge(TrackParticleThinningCfg(
39  flags,
40  name = "HIGG1D2TrackParticleThinningTool",
41  StreamName = kwargs['StreamName'],
42  SelectionString = HIGG1D2_thinning_expression,
43  InDetTrackParticlesKey = "InDetTrackParticles"))
44 
45  # Include inner detector tracks associated with muons
46  HIGG1D2MuonTPThinningTool = acc.getPrimaryAndMerge(
48  flags,
49  name = "HIGG1D2MuonTPThinningTool",
50  StreamName = kwargs['StreamName'],
51  MuonKey = "Muons",
52  InDetTrackParticlesKey = "InDetTrackParticles"
53  )
54  )
55 
56  # Include inner detector tracks associated with electrons
57  HIGG1D2ElectronTPThinningTool = (
58  CompFactory.DerivationFramework.EgammaTrackParticleThinning(
59  name = "HIGG1D2ElectronTPThinningTool",
60  StreamName = kwargs['StreamName'],
61  SGKey = "Electrons",
62  BestMatchOnly = False
63  )
64  )
65  acc.addPublicTool(HIGG1D2ElectronTPThinningTool)
66 
67  # Include inner detector tracks associated with photons
68  HIGG1D2PhotonTPThinningTool = (
69  CompFactory.DerivationFramework.EgammaTrackParticleThinning(
70  name = "HIGG1D2PhotonTPThinningTool",
71  StreamName = kwargs['StreamName'],
72  SGKey = "Photons",
73  GSFConversionVerticesKey = "GSFConversionVertices",
74  BestMatchOnly = False
75  )
76  )
77  acc.addPublicTool(HIGG1D2PhotonTPThinningTool)
78 
79  # Include topoclusters around electrons, needed for calibration of merged electrons
80  from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import CaloClusterThinningCfg
81 
82  HIGG1D2CCTCThinningTool = acc.getPrimaryAndMerge(
84  flags,
85  name = "HIGG1D2CCTCThinningTool",
86  StreamName = kwargs['StreamName'],
87  SGKey = "Electrons",
88  SelectionString = "Electrons.pt>4*GeV",
89  TopoClCollectionSGKey = "CaloCalTopoClusters",
90  ConeSize = 0.5
91  )
92  )
93 
94  thinningTools = [HIGG1D2TrackParticleThinningTool,
95  HIGG1D2MuonTPThinningTool,
96  HIGG1D2ElectronTPThinningTool,
97  HIGG1D2PhotonTPThinningTool,
98  HIGG1D2CCTCThinningTool]
99 
100  # Photon vertex
101  from DerivationFrameworkEGamma.EGammaToolsConfig import PhotonVertexSelectionWrapperKernelCfg
102  acc.merge(PhotonVertexSelectionWrapperKernelCfg(flags))
103 
104  # Truth thinning
105  if flags.Input.isMC :
106  truth_cond_1 = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs
107  truth_cond_2 = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons
108  truth_cond_3 = "((abs(TruthParticles.pdgId) == 6))" # Top quark
109  truth_cond_4 = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon
110  truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles
111  truth_expression = '('+truth_cond_1+' || '+truth_cond_2 +' || '+truth_cond_3 +' || '+truth_cond_4+') || ('+truth_cond_finalState+')'
112 
113  HIGG1D2GenericTruthThinningTool = acc.getPrimaryAndMerge(GenericTruthThinningCfg(
114  flags,
115  name = "HIGG1D2GenericTruthThinningTool",
116  StreamName = kwargs['StreamName'],
117  ParticleSelectionString = truth_expression,
118  PreserveDescendants = False,
119  PreserveGeneratorDescendants = True,
120  PreserveAncestors = True))
121  acc.addPublicTool(HIGG1D2GenericTruthThinningTool)
122  thinningTools.append(HIGG1D2GenericTruthThinningTool)
123 
124  # SkimmingTool
125  from DerivationFrameworkHiggs.SkimmingToolHIGG1Config import SkimmingToolHIGG1Cfg
126  from DerivationFrameworkHiggs.HIGG1TriggerContent import expressionTriggers, mergedTriggers
127 
128  SkipTriggerRequirement = flags.Input.isMC or not flags.Reco.EnableTrigger
129  TriggerExp = []
130  TriggerMerged = []
131 
132  if not SkipTriggerRequirement:
133 
134  MenuType = None
135  if float(flags.Beam.Energy) == 6500000.0:
136  # 13 TeV
137  MenuType = "Run2"
138  elif float(flags.Beam.Energy) == 6800000.0:
139  # 13.6 TeV
140  MenuType = "Run3"
141 
142  TriggerExp = expressionTriggers[MenuType]
143  TriggerMerged = mergedTriggers[MenuType]
144 
145  # Merged electrons for skimming
146  from ROOT import egammaPID
147 
148  MergedElectronIsEM = CompFactory.AsgElectronIsEMSelector("MergedElectronIsEM")
149  MergedElectronIsEM.ConfigFile = "ElectronPhotonSelectorTools/trigger/rel21_20161021/ElectronIsEMMergedTightSelectorCutDefs.conf"
150  MergedElectronIsEM.isEMMask = egammaPID.ElectronTightHLT
151  acc.addPublicTool(MergedElectronIsEM)
152 
153  # Set up skimming for merged and resolved events
154  skimmingTool = acc.popToolsAndMerge( SkimmingToolHIGG1Cfg(flags,
155  name = "HIGG1D2SkimmingTool",
156  RequireGRL = False,
157  ReqireLArError = True,
158  RequireTrigger = not SkipTriggerRequirement,
159  IncludeDoublePhotonPreselection = False,
160  RequirePreselection = False,
161  RequireKinematic = False,
162  RequireQuality = False,
163  RequireIsolation = False,
164  RequireInvariantMass = False,
165  Triggers = TriggerExp,
166  MergedElectronTriggers = TriggerMerged,
167  IncludeSingleElectronPreselection = False,
168  IncludeDoubleElectronPreselection = False,
169  IncludeSingleMuonPreselection = False,
170  IncludePhotonDoubleElectronPreselection = True,
171  IncludeDoubleMuonPreselection = True,
172  IncludePhotonMergedElectronPreselection = True,
173  IncludeHighPtPhotonElectronPreselection = True,
174  MinimumPhotonPt = 9.9*GeV,
175  MinimumElectronPt = 4.4*GeV,
176  MinimumMergedElectronPt = 18*GeV,
177  MinimumMuonPt = 2.9*GeV,
178  MaxMuonEta = 2.7,
179  RemoveCrack = False,
180  MaxEta = 2.5,
181  MergedElectronCutTool = MergedElectronIsEM))
182 
183  acc.addPublicTool(skimmingTool)
184 
185  # Augmentation tool for merged electron ID
186  from DerivationFrameworkHiggs.MergedElectronConfig import MergedElectronDetailsDecoratorCfg
187  HIGG1D2MergedElectronDetailsDecorator = acc.getPrimaryAndMerge(MergedElectronDetailsDecoratorCfg(flags,
188  name = "HIGG1D2MergedElectronDetailsDecorator"))
189  augmentationTools = [HIGG1D2MergedElectronDetailsDecorator]
190 
191 
193  from IsolationSelection.IsolationSelectionConfig import IsoCloseByAlgsCfg
194  contNames = ["Muons", "Electrons", "Photons"]
195  acc.merge(IsoCloseByAlgsCfg(flags, suff = "_HIGG1D2", isPhysLite = False, containerNames = contNames, stream_name = kwargs['StreamName']))
196 
197  # Kernel now
198  DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
199  acc.addEventAlgo(DerivationKernel(name,
200  SkimmingTools = [skimmingTool],
201  ThinningTools = thinningTools,
202  AugmentationTools = augmentationTools))
203  return acc
204 
205 
206 def HIGG1D2Cfg(flags):
207 
208  acc = ComponentAccumulator()
209 
210  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
211  HIGG1D2TriggerListsHelper = TriggerListsHelper(flags)
212 
213  acc.merge(HIGG1D2KernelCfg(flags, name="HIGG1D2Kernel", StreamName = 'StreamDAOD_HIGG1D2', TriggerListsHelper = HIGG1D2TriggerListsHelper))
214 
215  # Define contents of the format
216  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
217  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
218  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
219 
220  HIGG1D2SlimmingHelper = SlimmingHelper("HIGG1D2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
221  HIGG1D2SlimmingHelper.SmartCollections = ["EventInfo",
222  "Electrons",
223  "Photons",
224  "Muons",
225  "PrimaryVertices",
226  "InDetTrackParticles",
227  "AntiKt4EMPFlowJets",
228  "BTagging_AntiKt4EMPFlow"]
229 
230  # Trigger content
231  HIGG1D2SlimmingHelper.IncludeTriggerNavigation = False
232  HIGG1D2SlimmingHelper.IncludeJetTriggerContent = False
233  HIGG1D2SlimmingHelper.IncludeMuonTriggerContent = False
234  HIGG1D2SlimmingHelper.IncludeEGammaTriggerContent = False
235  HIGG1D2SlimmingHelper.IncludeJetTauEtMissTriggerContent = False
236  HIGG1D2SlimmingHelper.IncludeTauTriggerContent = False
237  HIGG1D2SlimmingHelper.IncludeEtMissTriggerContent = False
238  HIGG1D2SlimmingHelper.IncludeBJetTriggerContent = False
239  HIGG1D2SlimmingHelper.IncludeBPhysTriggerContent = False
240  HIGG1D2SlimmingHelper.IncludeMinBiasTriggerContent = False
241 
242  # Variables to include
243  HIGG1D2SlimmingHelper.AllVariables = ["Electrons","Photons","egammaClusters","GSFConversionVertices","PrimaryVertices","MET_Track","CaloCalTopoClusters"]
244 
245  HIGG1D2SlimmingHelper.ExtraVariables = ["Photons.zvertex",
246  "Muons.quality.EnergyLoss.energyLossType.etcone20.ptconecoreTrackPtrCorrection",
247  "MuonClusterCollection.eta_sampl.phi_sampl",
248  "GSFTrackParticles.parameterX.parameterY.parameterZ.parameterPX.parameterPY.parameterPZ.parameterPosition.vx.vy.eProbabilityHT",
249  "InDetTrackParticles.vx.vy.TTVA_AMVFVertices.TTVA_AMVFWeights.eProbabilityHT.numberOfTRTHits.numberOfTRTOutliers",
250  "AntiKt4EMPFlowJets.Jvt.JVFCorr",
251  "CombinedMuonTrackParticles.z0.vz",
252  "BTagging_AntiKt4EMTopo.MV1_discriminant",
253  "ExtrapolatedMuonTrackParticles.z0.vz",
254  "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights.TTVA_AMVFVertices_forReco.TTVA_AMVFWeights_forReco.TTVA_AMVFVertices_forHiggs.TTVA_AMVFWeights_forHiggs.eProbabilityHT.numberOfTRTHits.numberOfTRTOutliers",
255  "EventInfo.hardScatterVertexLink.timeStampNSOffset"]
256 
257  # Add Btagging information
258  from DerivationFrameworkFlavourTag.BTaggingContent import BTaggingStandardContent, BTaggingXbbContent
259  HIGG1D2SlimmingHelper.ExtraVariables += BTaggingStandardContent("AntiKt4EMPFlowJets", flags)
260  HIGG1D2SlimmingHelper.ExtraVariables += BTaggingXbbContent("AntiKt4EMPFlowJets", flags)
261 
262  # Truth containers
263  if flags.Input.isMC:
264  HIGG1D2SlimmingHelper.AppendToDictionary = {'TruthEvents':'xAOD::TruthEventContainer','TruthEventsAux':'xAOD::TruthEventAuxContainer',
265  'MET_Truth':'xAOD::MissingETContainer','MET_TruthAux':'xAOD::MissingETAuxContainer',
266  'TruthElectrons':'xAOD::TruthParticleContainer','TruthElectronsAux':'xAOD::TruthParticleAuxContainer',
267  'TruthMuons':'xAOD::TruthParticleContainer','TruthMuonsAux':'xAOD::TruthParticleAuxContainer',
268  'TruthPhotons':'xAOD::TruthParticleContainer','TruthPhotonsAux':'xAOD::TruthParticleAuxContainer',
269  'TruthBoson':'xAOD::TruthParticleContainer','TruthBosonAux':'xAOD::TruthParticleAuxContainer',
270  'BornLeptons':'xAOD::TruthParticleContainer','BornLeptonsAux':'xAOD::TruthParticleAuxContainer',
271  'TruthBosonsWithDecayParticles':'xAOD::TruthParticleContainer','TruthBosonsWithDecayParticlesAux':'xAOD::TruthParticleAuxContainer',
272  'TruthBosonsWithDecayVertices':'xAOD::TruthVertexContainer','TruthBosonsWithDecayVerticesAux':'xAOD::TruthVertexAuxContainer',
273  'HardScatterParticles':'xAOD::TruthParticleContainer','HardScatterParticlesAux':'xAOD::TruthParticleAuxContainer',
274  'HardScatterVertices':'xAOD::TruthVertexContainer','HardScatterVerticesAux':'xAOD::TruthVertexAuxContainer',
275  'TruthHFWithDecayParticles':'xAOD::TruthParticleContainer','TruthHFWithDecayParticlesAux':'xAOD::TruthParticleAuxContainer',
276  'TruthPrimaryVertices':'xAOD::TruthVertexContainer','TruthPrimaryVerticesAux':'xAOD::TruthVertexAuxContainer'}
277 
278  from DerivationFrameworkMCTruth.MCTruthCommonConfig import addTruth3ContentToSlimmerTool
279  addTruth3ContentToSlimmerTool(HIGG1D2SlimmingHelper)
280  HIGG1D2SlimmingHelper.AllVariables += ['TruthHFWithDecayParticles',
281  'AntiKt4TruthDressedWZJets',
282  'AntiKt4TruthWZJets',
283  'TruthEvents',
284  'TruthPrimaryVertices',
285  'TruthVertices',
286  'TruthParticles',
287  'TruthElectrons',
288  'TruthParticles',
289  'TruthPhotons',
290  'TruthMuons',
291  'TruthBoson']
292  HIGG1D2SlimmingHelper.ExtraVariables += ["Electrons.TruthLink",
293  "Muons.TruthLink",
294  "Photons.TruthLink"]
295 
296 
297  HIGG1D2SlimmingHelper.AppendToDictionary.update({'MET_Track':'xAOD::MissingETContainer','MET_TrackAux':'xAOD::MissingETAuxContainer'})
298 
299  # Trigger matching
300  # Run 2
301  if flags.Trigger.EDMVersion == 2:
302  from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
303  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = HIGG1D2SlimmingHelper,
304  OutputContainerPrefix = "TrigMatch_",
305  TriggerList = HIGG1D2TriggerListsHelper.Run2TriggerNamesTau)
306  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = HIGG1D2SlimmingHelper,
307  OutputContainerPrefix = "TrigMatch_",
308  TriggerList = HIGG1D2TriggerListsHelper.Run2TriggerNamesNoTau)
309  # Run 3
310  if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
311  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
313 
314  # Output stream
315  HIGG1D2ItemList = HIGG1D2SlimmingHelper.GetItemList()
316  acc.merge(OutputStreamCfg(flags, "DAOD_HIGG1D2", ItemList=HIGG1D2ItemList, AcceptAlgs=["HIGG1D2Kernel"]))
317  acc.merge(SetupMetaDataForStreamCfg(flags, "DAOD_HIGG1D2", AcceptAlgs=["HIGG1D2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))
318 
319  return acc
TrigNavSlimmingMTConfig.AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
def AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(slimmingHelper)
Definition: TrigNavSlimmingMTConfig.py:98
SystemOfUnits
DerivationFrameworkCaloConfig.CaloClusterThinningCfg
def CaloClusterThinningCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:104
python.HIGG1D2.HIGG1D2Cfg
def HIGG1D2Cfg(flags)
Definition: HIGG1D2.py:206
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.SkimmingToolHIGG1Config.SkimmingToolHIGG1Cfg
def SkimmingToolHIGG1Cfg(ConfigFlags, **kwargs)
Definition: SkimmingToolHIGG1Config.py:7
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.HIGG1D2.HIGG1D2KernelCfg
def HIGG1D2KernelCfg(flags, name='HIGG1D2Kernel', **kwargs)
Definition: HIGG1D2.py:17
python.BTaggingContent.BTaggingXbbContent
def BTaggingXbbContent(jetcol, ConfigFlags=None)
Definition: BTaggingContent.py:177
python.InDetToolsConfig.TrackParticleThinningCfg
def TrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:458
IsolationSelectionConfig.IsoCloseByAlgsCfg
def IsoCloseByAlgsCfg(flags, suff="", isPhysLite=False, containerNames=["Muons", "Electrons", "Photons"], stream_name="", ttva_wp="Nonprompt_All_MaxWeight", useSelTools=False, isoDecSuffix="CloseByCorr", hasLRT=False)
Definition: IsolationSelectionConfig.py:145
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:49
python.MergedElectronConfig.MergedElectronDetailsDecoratorCfg
def MergedElectronDetailsDecoratorCfg(flags, name, **kwargs)
Definition: MergedElectronConfig.py:12
python.BTaggingContent.BTaggingStandardContent
def BTaggingStandardContent(jetcol, ConfigFlags=None)
Definition: BTaggingContent.py:163
python.TruthDerivationToolsConfig.GenericTruthThinningCfg
def GenericTruthThinningCfg(flags, name, **kwargs)
Definition: TruthDerivationToolsConfig.py:401
python.InDetToolsConfig.MuonTrackParticleThinningCfg
def MuonTrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:542
python.MCTruthCommonConfig.addTruth3ContentToSlimmerTool
def addTruth3ContentToSlimmerTool(slimmer)
Definition: MCTruthCommonConfig.py:466
DerivationFrameworkCaloConfig.CaloDecoratorKernelCfg
def CaloDecoratorKernelCfg(flags, name="CaloDecoratorKernel", **kwargs)
Definition: DerivationFrameworkCaloConfig.py:82
python.PhysCommonConfig.PhysCommonAugmentationsCfg
def PhysCommonAugmentationsCfg(flags, **kwargs)
Definition: PhysCommonConfig.py:14
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:222
SlimmingHelper
Definition: SlimmingHelper.py:1
python.HION12.DerivationKernel
DerivationKernel
Definition: HION12.py:66
python.EGammaToolsConfig.PhotonVertexSelectionWrapperKernelCfg
def PhotonVertexSelectionWrapperKernelCfg(flags, name="PhotonVertexSelectionWrapperKernel", **kwargs)
Definition: EGammaToolsConfig.py:95
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65