From 66a16ea7a68b570c3bd512e410bdadcb27b482ea Mon Sep 17 00:00:00 2001 From: James Richard Catmore Date: Fri, 11 Jun 2021 15:32:55 +0200 Subject: [PATCH 1/2] Factoring out common content of DAOD_PHYS and PHYSLITE into a single config file ATLASG-1598 This MR takes the content of DAOD_PHYS and DAOD_PHYSLITE that is common to both and puts it into a new config file that is imported by both. This fixes name clashes and duplicate problems that have occurred when trying to run both formats in a train. Most of the changes are just moving existing content from one python file to another. However, in order abide by the Python checker (Flake8) rules I have found it necessary to put the content that schedules common augmentations for tracks, muons and e-gamma into methods that are then called in the new config file. For jets, MET and flavour tagging, this is already how they have things set up. This will have a knock-on effect for other DAOD formats who will either need to call these methods themselves or (better) also include the new common config file. Since no other DAODs are currently being used in release 22, I don't see this as a problem, and in any case, I think it is better Python. As well as fixing the issues with trains, this will also mean that changes to the common content will only have to be done once. --- .../python/EGammaCommon.py | 891 +++++++++--------- .../python/FtagRun3DerivationConfig.py | 39 +- .../python/InDetCommon.py | 143 +-- .../python/MuonsCommon.py | 169 ++-- .../python/PhysCommon.py | 168 ++++ .../DerivationFrameworkPhys/share/PHYS.py | 195 +--- .../DerivationFrameworkPhys/share/PHYSLITE.py | 175 +--- 7 files changed, 821 insertions(+), 959 deletions(-) create mode 100644 PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py index e83e0549757..6eb122bfd90 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py @@ -5,453 +5,454 @@ # Schedules all tools needed for e-gamma object selection and writes # results into SG. These may then be accessed along the train #******************************************************************** -from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob, DerivationFrameworkSimBarcodeOffset -from AthenaCommon import CfgMgr -from AthenaCommon.GlobalFlags import globalflags -from AthenaCommon.AppMgr import ToolSvc, ServiceMgr as svcMgr -#==================================================================== -# PHOTON ETA (=ETA2), ET (=E/COSH(ETA2)) -#==================================================================== -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__PhotonsDirectionTool -DFCommonPhotonsDirection = DerivationFramework__PhotonsDirectionTool(name = "DFCommonPhotonsDirection", - EtaSGEntry = "DFCommonPhotons_eta", - PhiSGEntry = "DFCommonPhotons_phi", - EtSGEntry = "DFCommonPhotons_et" - #ESGEntry = "DFCommonPhotons_e" - #PhotonContainer = "Photons" - ) -ToolSvc += DFCommonPhotonsDirection +def makeEGammaDFCommon(): -#==================================================================== -# SHOWER SHAPE FUDGING IN MC -# (TUNE22: FUDGE FACTORS RUN2 2015+2016 DATA, Rel 21) -#==================================================================== - -from PyUtils import AthFile -af = AthFile.fopen(svcMgr.EventSelector.InputCollections[0]) #opens the first file from the InputCollections list -af.fileinfos #this is a dict of dicts, take a look at what's available! Below are some examples: - -isMC = 'IS_SIMULATION' in af.fileinfos['evt_type'] -beam_energy = af.fileinfos['beam_energy'] -conditions_tag = af.fileinfos['conditions_tag'] #useful for figuring out which mc production this is -isFullSim = False -if isMC: - simulationFlavour = af.fileinfos['metadata']['/Simulation/Parameters']['SimulationFlavour'] - isFullSim = simulationFlavour in ('default', 'MC12G4', 'FullG4') - -print("EGammaCommon: isMC = ", isMC) -if isMC: - print("EGammaCommon: isFullSim = ", isFullSim) - -if isFullSim: - from EGammaVariableCorrection.EGammaVariableCorrectionConf import ElectronPhotonVariableCorrectionTool - EGVariableCorrectionTool = ElectronPhotonVariableCorrectionTool(name = 'EGVariableCorrectionTool', - ConfigFile = 'EGammaVariableCorrection/TUNE22/ElPhVariableNominalCorrection.conf') - ToolSvc += EGVariableCorrectionTool - print(EGVariableCorrectionTool) - -#==================================================================== -# ELECTRON LH SELECTORS -# see http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py on how to configure the selectors -#==================================================================== -from ROOT import LikeEnum - -from ElectronPhotonSelectorTools.ConfiguredAsgElectronLikelihoodTools import ConfiguredAsgElectronLikelihoodTool - -# Very Loose -ElectronLHSelectorVeryLoose = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorVeryLoose", LikeEnum.VeryLoose) -ElectronLHSelectorVeryLoose.primaryVertexContainer = "PrimaryVertices" -ToolSvc += ElectronLHSelectorVeryLoose - -# Loose -ElectronLHSelectorLoose = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorLoose", LikeEnum.Loose) -ElectronLHSelectorLoose.primaryVertexContainer = "PrimaryVertices" -ToolSvc += ElectronLHSelectorLoose - -# Medium -ElectronLHSelectorMedium = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorMedium", LikeEnum.Medium) -ElectronLHSelectorMedium.primaryVertexContainer = "PrimaryVertices" -ToolSvc += ElectronLHSelectorMedium - -# Tight -ElectronLHSelectorTight = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorTight", LikeEnum.Tight) -ElectronLHSelectorTight.primaryVertexContainer = "PrimaryVertices" -ToolSvc += ElectronLHSelectorTight - -# LooseBL -from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronLikelihoodTool -ElectronLHSelectorLooseBL = AsgElectronLikelihoodTool("ElectronLHSelectorLooseBL", WorkingPoint="LooseBLLHElectron") -ElectronLHSelectorLooseBL.primaryVertexContainer = "PrimaryVertices" -ToolSvc += ElectronLHSelectorLooseBL - -#==================================================================== -# ELECTRON CHARGE SELECTION -#==================================================================== -from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronChargeIDSelectorTool -ElectronChargeIDSelector = AsgElectronChargeIDSelectorTool("ElectronChargeIDSelectorLoose") -ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices" -ElectronChargeIDSelector.TrainingFile = "ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root" -ToolSvc += ElectronChargeIDSelector - -#==================================================================== -# FWD ELECTRON LH SELECTORS -#==================================================================== -from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgForwardElectronLikelihoodTool - -ForwardElectronLHSelectorLoose = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorLoose", WorkingPoint="LooseLHForwardElectron") -ToolSvc += ForwardElectronLHSelectorLoose - -ForwardElectronLHSelectorMedium = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorMedium", WorkingPoint="MediumLHForwardElectron") -ToolSvc += ForwardElectronLHSelectorMedium - -ForwardElectronLHSelectorTight = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorTight", WorkingPoint="TightLHForwardElectron") -ToolSvc += ForwardElectronLHSelectorTight - - -#==================================================================== -# PHOTON SELECTION (loose and tight cut-based) -#==================================================================== -from ROOT import egammaPID - -from ElectronPhotonSelectorTools.ConfiguredAsgPhotonIsEMSelectors import ConfiguredAsgPhotonIsEMSelector -from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu - -# Loose -PhotonIsEMSelectorLoose = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorLoose", egammaPID.PhotonIDLoose) -ToolSvc += PhotonIsEMSelectorLoose - -# Tight (default == pt-dependent) -PhotonIsEMSelectorTight = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTight", egammaPID.PhotonIDTight) -ToolSvc += PhotonIsEMSelectorTight - -# Tight (pt-inclusive) -# To be removed when pt-dependent menu above is supported with scale factors -PhotonIsEMSelectorTightPtIncl = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTightPtIncl", egammaPID.PhotonIDTight,menu=photonPIDmenu.menuPtInclJan2018) -ToolSvc += PhotonIsEMSelectorTightPtIncl - - - -#==================================================================== -# RECTANGULAR CLUSTER TOOLS -#==================================================================== - -from CaloClusterCorrection.CaloClusterCorrectionConf import CaloFillRectangularCluster - -EGAMCOM_caloFillRect55 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster55", - cells_name = "AllCalo", - eta_size = 5, - phi_size = 5, - fill_cluster = True) -ToolSvc += EGAMCOM_caloFillRect55 - -EGAMCOM_caloFillRect35 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster35", - cells_name = "AllCalo", - eta_size = 3, - phi_size = 5, - fill_cluster = True) -ToolSvc += EGAMCOM_caloFillRect35 - -EGAMCOM_caloFillRect37 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster37", - cells_name = "AllCalo", - eta_size = 3, - phi_size = 7, - fill_cluster = True) -ToolSvc += EGAMCOM_caloFillRect37 - -EGAMCOM_caloFillRect711 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster711", - cells_name = "AllCalo", - eta_size = 7, - phi_size = 11, - fill_cluster = True) -ToolSvc += EGAMCOM_caloFillRect711 - - -#==================================================================== -# AUGMENTATION TOOLS -#==================================================================== -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGSelectionToolWrapper -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronLikelihoodToolWrapper - -# decorate electrons with the output of LH very loose -ElectronPassLHVeryLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHVeryLoose", - EGammaElectronLikelihoodTool = ElectronLHSelectorVeryLoose, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHVeryLoose", - ContainerName = "Electrons", - StoreTResult = False) -ToolSvc += ElectronPassLHVeryLoose -print(ElectronPassLHVeryLoose) - -# decorate electrons with the output of LH loose -ElectronPassLHLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHLoose", - EGammaElectronLikelihoodTool = ElectronLHSelectorLoose, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHLoose", - ContainerName = "Electrons", - StoreTResult = False) -ToolSvc += ElectronPassLHLoose -print(ElectronPassLHLoose) - -# decorate electrons with the output of LH loose+BL -ElectronPassLHLooseBL = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHLooseBL", - EGammaElectronLikelihoodTool = ElectronLHSelectorLooseBL, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHLooseBL", - ContainerName = "Electrons", - StoreTResult = False) -ToolSvc += ElectronPassLHLooseBL -print (ElectronPassLHLooseBL) - -# decorate electrons with the output of LH medium -ElectronPassLHMedium = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHMedium", - EGammaElectronLikelihoodTool = ElectronLHSelectorMedium, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHMedium", - ContainerName = "Electrons", - StoreTResult = False) -ToolSvc += ElectronPassLHMedium -print(ElectronPassLHMedium) - -# decorate electrons with the output of LH tight -ElectronPassLHTight = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHTight", - EGammaElectronLikelihoodTool = ElectronLHSelectorTight, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHTight", - ContainerName = "Electrons", - StoreTResult = False) -ToolSvc += ElectronPassLHTight -print(ElectronPassLHTight) - -# decorate electrons with the output of ECIDS -ElectronPassECIDS = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassECIDS", - EGammaElectronLikelihoodTool = ElectronChargeIDSelector, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonElectronsECIDS", - ContainerName = "Electrons", - StoreTResult = True) -ToolSvc += ElectronPassECIDS -print (ElectronPassECIDS) - -# decorate forward electrons with the output of LH loose -ForwardElectronPassLHLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHLoose", - EGammaElectronLikelihoodTool = ForwardElectronLHSelectorLoose, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonForwardElectronsLHLoose", - ContainerName = "ForwardElectrons") -ToolSvc += ForwardElectronPassLHLoose -print (ForwardElectronPassLHLoose) - -# decorate forward electrons with the output of LH medium -ForwardElectronPassLHMedium = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHMedium", - EGammaElectronLikelihoodTool = ForwardElectronLHSelectorMedium, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonForwardElectronsLHMedium", - ContainerName = "ForwardElectrons") -ToolSvc += ForwardElectronPassLHMedium -print (ForwardElectronPassLHMedium) - -# decorate forward electrons with the output of LH tight -ForwardElectronPassLHTight = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHTight", - EGammaElectronLikelihoodTool = ForwardElectronLHSelectorTight, - EGammaFudgeMCTool = "", - CutType = "", - StoreGateEntryName = "DFCommonForwardElectronsLHTight", - ContainerName = "ForwardElectrons") -ToolSvc += ForwardElectronPassLHTight -print (ForwardElectronPassLHTight) - - -# decorate photons with the output of IsEM loose -# on MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) -if isFullSim: - PhotonPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMLoose", - EGammaSelectionTool = PhotonIsEMSelectorLoose, - EGammaFudgeMCTool = EGVariableCorrectionTool, - CutType = "", - StoreGateEntryName = "DFCommonPhotonsIsEMLoose", - ContainerName = "Photons") -else: - PhotonPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMLoose", - EGammaSelectionTool = PhotonIsEMSelectorLoose, - EGammaFudgeMCTool = None, - CutType = "", - StoreGateEntryName = "DFCommonPhotonsIsEMLoose", - ContainerName = "Photons") -ToolSvc += PhotonPassIsEMLoose -print(PhotonPassIsEMLoose) - -# decorate photons with the output of IsEM tight -# on full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) -if isFullSim: - PhotonPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTight", - EGammaSelectionTool = PhotonIsEMSelectorTight, - EGammaFudgeMCTool = EGVariableCorrectionTool, - CutType = "", - StoreGateEntryName = "DFCommonPhotonsIsEMTight", - ContainerName = "Photons") -else: - PhotonPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTight", - EGammaSelectionTool = PhotonIsEMSelectorTight, - EGammaFudgeMCTool = None, - CutType = "", - StoreGateEntryName = "DFCommonPhotonsIsEMTight", - ContainerName = "Photons") -ToolSvc += PhotonPassIsEMTight -print(PhotonPassIsEMTight) - -# decorate photons with the output of IsEM tight pt-inclusive menu -# Can be removed once pt-dependent cuts are fully supported. -# On full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) -PhotonPassIsEMTightPtIncl = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTightPtIncl", - EGammaSelectionTool = PhotonIsEMSelectorTightPtIncl, - EGammaFudgeMCTool = (EGVariableCorrectionTool if isFullSim else None), - CutType = "", - StoreGateEntryName = "DFCommonPhotonsIsEMTightPtIncl", - ContainerName = "Photons") -ToolSvc += PhotonPassIsEMTightPtIncl -print (PhotonPassIsEMTightPtIncl) - -# decorate photons with the photon cleaning flags -# on MC, fudge the shower shapes before computing the flags -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGPhotonCleaningWrapper -if isFullSim: - PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", - EGammaFudgeMCTool = EGVariableCorrectionTool, - StoreGateEntryName = "DFCommonPhotonsCleaning", - ContainerName = "Photons") -else: - PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", - EGammaFudgeMCTool = None, - StoreGateEntryName = "DFCommonPhotonsCleaning", - ContainerName = "Photons") -ToolSvc += PhotonPassCleaning -print (PhotonPassCleaning) - -# decorate central electrons and photons with a flag to tell the the candidates are affected by the crack bug in mc16a and data 2015+2016 -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGCrackVetoCleaningTool as DF_EGCVCT -PhotonPassCrackVeto = DF_EGCVCT(name = "PhotonPassCrackVeto", - StoreGateEntryName = "DFCommonCrackVetoCleaning", - ContainerName = "Photons") -ElectronPassCrackVeto = DF_EGCVCT(name = "ElectronPassCrackVeto", - StoreGateEntryName = "DFCommonCrackVetoCleaning", - ContainerName = "Electrons") -ToolSvc += [PhotonPassCrackVeto,ElectronPassCrackVeto] - -# decorate some electrons with an additional ambiguity flag against internal and early material conversion -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronAmbiguityTool as DF_EGEAT -ElectronAmbiguity = DF_EGEAT(name = "ElectronAdditionnalAmbiguity", - isMC = (globalflags.DataSource()!='data')) -ToolSvc += ElectronAmbiguity - -# -# Commented ForwardElectronPassLHLoose, ForwardElectronPassLHMedium, ForwardElectronPassLHTight tools due to they are not available in R22 yet -# -# list of all the decorators so far -EGAugmentationTools = [DFCommonPhotonsDirection, - ElectronPassLHVeryLoose, ElectronPassLHLoose, ElectronPassLHLooseBL, ElectronPassLHMedium, ElectronPassLHTight, - ForwardElectronPassLHLoose, ForwardElectronPassLHMedium, ForwardElectronPassLHTight, - ElectronPassECIDS, - PhotonPassIsEMLoose, PhotonPassIsEMTight, - PhotonPassIsEMTightPtIncl, - PhotonPassCleaning, - PhotonPassCrackVeto,ElectronPassCrackVeto, - ElectronAmbiguity] - -#================================================== -# Truth Related tools -from RecExConfig.RecFlags import rec -if rec.doTruth(): - - # Decorate Electron with bkg electron type/origin - from MCTruthClassifier.MCTruthClassifierBase import MCTruthClassifier as BkgElectronMCTruthClassifier - BkgElectronMCTruthClassifier.barcodeG4Shift=(DerivationFrameworkSimBarcodeOffset+1) - BkgElectronMCTruthClassifier.ParticleCaloExtensionTool="" - - from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__BkgElectronClassification - BkgElectronClassificationTool = DerivationFramework__BkgElectronClassification (name = "BkgElectronClassificationTool", - MCTruthClassifierTool = BkgElectronMCTruthClassifier, - barcodeCut=DerivationFrameworkSimBarcodeOffset) - ToolSvc += BkgElectronClassificationTool - print(BkgElectronClassificationTool) - EGAugmentationTools.append(BkgElectronClassificationTool) - - # Decorate egammaTruthParticles with truth-particle-level etcone20,30,40 - from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthIsolationTool as dtit - TruthEgetIsolationTool = dtit(name = "TruthEgetIsolationTool", - isoParticlesKey = "egammaTruthParticles", - allParticlesKey = "TruthParticles", - particleIDsToCalculate = [-11,11,22], - IsolationConeSizes = [0.2,0.3,0.4], - excludeIDsFromCone = [-16,-14,-13,-12,12,13,14,16], - IsolationVarNamePrefix = 'etcone', - ChargedParticlesOnly = False) - ToolSvc += TruthEgetIsolationTool - print(TruthEgetIsolationTool) - EGAugmentationTools.append(TruthEgetIsolationTool) - - # Decorate egammaTruthParticles with truth-particle-level ptcone20,30,40 - TruthEgptIsolationTool = dtit(name = "TruthEgptIsolationTool", - isoParticlesKey = "egammaTruthParticles", - allParticlesKey = "TruthParticles", - particleIDsToCalculate = [-11,11,22], - IsolationConeSizes = [0.2,0.3,0.4], - IsolationVarNamePrefix = 'ptcone', - ChargedParticlesOnly = True) - ToolSvc += TruthEgptIsolationTool - print(TruthEgptIsolationTool) - EGAugmentationTools.append(TruthEgptIsolationTool) - - # Compute the truth-particle-level energy density in the central eta region - from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAthAlg - from JetRec.JetRecStandard import jtm - tc=configEventDensityTool("EDTruthCentralTool", jtm.truthget.Label, - 0.5, - AbsRapidityMin = 0.0, - AbsRapidityMax = 1.5, - OutputContainer = "TruthIsoCentralEventShape", - OutputLevel = 3 - ) - ToolSvc += tc - - # Compute the truth-particle-level energy density in the forward eta region - tf=configEventDensityTool("EDTruthForwardTool", jtm.truthget.Label, - 0.5, - AbsRapidityMin = 1.5, - AbsRapidityMax = 3.0, - OutputContainer = "TruthIsoForwardEventShape", - OutputLevel = 3, - ) - ToolSvc += tf - - # Schedule the two energy density tools for running - from AthenaCommon.AlgSequence import AlgSequence - topSequence = AlgSequence() - topSequence += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc ) - topSequence += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf ) - -#======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM -#======================================= - -DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("EGammaCommonKernel", - AugmentationTools = EGAugmentationTools + from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob, DerivationFrameworkSimBarcodeOffset + from AthenaCommon import CfgMgr + from AthenaCommon.GlobalFlags import globalflags + from AthenaCommon.AppMgr import ToolSvc, ServiceMgr as svcMgr + + #==================================================================== + # PHOTON ETA (=ETA2), ET (=E/COSH(ETA2)) + #==================================================================== + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__PhotonsDirectionTool + DFCommonPhotonsDirection = DerivationFramework__PhotonsDirectionTool(name = "DFCommonPhotonsDirection", + EtaSGEntry = "DFCommonPhotons_eta", + PhiSGEntry = "DFCommonPhotons_phi", + EtSGEntry = "DFCommonPhotons_et" + #ESGEntry = "DFCommonPhotons_e" + #PhotonContainer = "Photons" ) - -#======================================= -# ADD TOOLS -#======================================= - -import IsolationAlgs.IsoUpdatedTrackCones as isoCones -if not hasattr(DerivationFrameworkJob,"IsolationBuilderTight1000"): - DerivationFrameworkJob += isoCones.GetUpdatedIsoTrackCones() + ToolSvc += DFCommonPhotonsDirection + + #==================================================================== + # SHOWER SHAPE FUDGING IN MC + # (TUNE22: FUDGE FACTORS RUN2 2015+2016 DATA, Rel 21) + #==================================================================== + + from PyUtils import AthFile + af = AthFile.fopen(svcMgr.EventSelector.InputCollections[0]) #opens the first file from the InputCollections list + af.fileinfos #this is a dict of dicts, take a look at what's available! Below are some examples: + + isMC = 'IS_SIMULATION' in af.fileinfos['evt_type'] + isFullSim = False + if isMC: + simulationFlavour = af.fileinfos['metadata']['/Simulation/Parameters']['SimulationFlavour'] + isFullSim = simulationFlavour in ('default', 'MC12G4', 'FullG4') + + print("EGammaCommon: isMC = ", isMC) + if isMC: + print("EGammaCommon: isFullSim = ", isFullSim) + + if isFullSim: + from EGammaVariableCorrection.EGammaVariableCorrectionConf import ElectronPhotonVariableCorrectionTool + EGVariableCorrectionTool = ElectronPhotonVariableCorrectionTool(name = 'EGVariableCorrectionTool', + ConfigFile = 'EGammaVariableCorrection/TUNE22/ElPhVariableNominalCorrection.conf') + ToolSvc += EGVariableCorrectionTool + print(EGVariableCorrectionTool) + + #==================================================================== + # ELECTRON LH SELECTORS + # see http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py on how to configure the selectors + #==================================================================== + from ROOT import LikeEnum + + from ElectronPhotonSelectorTools.ConfiguredAsgElectronLikelihoodTools import ConfiguredAsgElectronLikelihoodTool + + # Very Loose + ElectronLHSelectorVeryLoose = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorVeryLoose", LikeEnum.VeryLoose) + ElectronLHSelectorVeryLoose.primaryVertexContainer = "PrimaryVertices" + ToolSvc += ElectronLHSelectorVeryLoose + + # Loose + ElectronLHSelectorLoose = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorLoose", LikeEnum.Loose) + ElectronLHSelectorLoose.primaryVertexContainer = "PrimaryVertices" + ToolSvc += ElectronLHSelectorLoose + + # Medium + ElectronLHSelectorMedium = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorMedium", LikeEnum.Medium) + ElectronLHSelectorMedium.primaryVertexContainer = "PrimaryVertices" + ToolSvc += ElectronLHSelectorMedium + + # Tight + ElectronLHSelectorTight = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelectorTight", LikeEnum.Tight) + ElectronLHSelectorTight.primaryVertexContainer = "PrimaryVertices" + ToolSvc += ElectronLHSelectorTight + + # LooseBL + from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronLikelihoodTool + ElectronLHSelectorLooseBL = AsgElectronLikelihoodTool("ElectronLHSelectorLooseBL", WorkingPoint="LooseBLLHElectron") + ElectronLHSelectorLooseBL.primaryVertexContainer = "PrimaryVertices" + ToolSvc += ElectronLHSelectorLooseBL + + #==================================================================== + # ELECTRON CHARGE SELECTION + #==================================================================== + from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronChargeIDSelectorTool + ElectronChargeIDSelector = AsgElectronChargeIDSelectorTool("ElectronChargeIDSelectorLoose") + ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices" + ElectronChargeIDSelector.TrainingFile = "ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root" + ToolSvc += ElectronChargeIDSelector + + #==================================================================== + # FWD ELECTRON LH SELECTORS + #==================================================================== + from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgForwardElectronLikelihoodTool + + ForwardElectronLHSelectorLoose = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorLoose", WorkingPoint="LooseLHForwardElectron") + ToolSvc += ForwardElectronLHSelectorLoose + + ForwardElectronLHSelectorMedium = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorMedium", WorkingPoint="MediumLHForwardElectron") + ToolSvc += ForwardElectronLHSelectorMedium + + ForwardElectronLHSelectorTight = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorTight", WorkingPoint="TightLHForwardElectron") + ToolSvc += ForwardElectronLHSelectorTight + + + #==================================================================== + # PHOTON SELECTION (loose and tight cut-based) + #==================================================================== + from ROOT import egammaPID + + from ElectronPhotonSelectorTools.ConfiguredAsgPhotonIsEMSelectors import ConfiguredAsgPhotonIsEMSelector + from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu + + # Loose + PhotonIsEMSelectorLoose = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorLoose", egammaPID.PhotonIDLoose) + ToolSvc += PhotonIsEMSelectorLoose + + # Tight (default == pt-dependent) + PhotonIsEMSelectorTight = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTight", egammaPID.PhotonIDTight) + ToolSvc += PhotonIsEMSelectorTight + + # Tight (pt-inclusive) + # To be removed when pt-dependent menu above is supported with scale factors + PhotonIsEMSelectorTightPtIncl = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTightPtIncl", egammaPID.PhotonIDTight,menu=photonPIDmenu.menuPtInclJan2018) + ToolSvc += PhotonIsEMSelectorTightPtIncl + + + + #==================================================================== + # RECTANGULAR CLUSTER TOOLS + #==================================================================== + + from CaloClusterCorrection.CaloClusterCorrectionConf import CaloFillRectangularCluster + + EGAMCOM_caloFillRect55 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster55", + cells_name = "AllCalo", + eta_size = 5, + phi_size = 5, + fill_cluster = True) + ToolSvc += EGAMCOM_caloFillRect55 + + EGAMCOM_caloFillRect35 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster35", + cells_name = "AllCalo", + eta_size = 3, + phi_size = 5, + fill_cluster = True) + ToolSvc += EGAMCOM_caloFillRect35 + + EGAMCOM_caloFillRect37 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster37", + cells_name = "AllCalo", + eta_size = 3, + phi_size = 7, + fill_cluster = True) + ToolSvc += EGAMCOM_caloFillRect37 + + EGAMCOM_caloFillRect711 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRectangularCluster711", + cells_name = "AllCalo", + eta_size = 7, + phi_size = 11, + fill_cluster = True) + ToolSvc += EGAMCOM_caloFillRect711 + + + #==================================================================== + # AUGMENTATION TOOLS + #==================================================================== + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGSelectionToolWrapper + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronLikelihoodToolWrapper + + # decorate electrons with the output of LH very loose + ElectronPassLHVeryLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHVeryLoose", + EGammaElectronLikelihoodTool = ElectronLHSelectorVeryLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHVeryLoose", + ContainerName = "Electrons", + StoreTResult = False) + ToolSvc += ElectronPassLHVeryLoose + print(ElectronPassLHVeryLoose) + + # decorate electrons with the output of LH loose + ElectronPassLHLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHLoose", + EGammaElectronLikelihoodTool = ElectronLHSelectorLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHLoose", + ContainerName = "Electrons", + StoreTResult = False) + ToolSvc += ElectronPassLHLoose + print(ElectronPassLHLoose) + + # decorate electrons with the output of LH loose+BL + ElectronPassLHLooseBL = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHLooseBL", + EGammaElectronLikelihoodTool = ElectronLHSelectorLooseBL, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHLooseBL", + ContainerName = "Electrons", + StoreTResult = False) + ToolSvc += ElectronPassLHLooseBL + print (ElectronPassLHLooseBL) + + # decorate electrons with the output of LH medium + ElectronPassLHMedium = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHMedium", + EGammaElectronLikelihoodTool = ElectronLHSelectorMedium, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHMedium", + ContainerName = "Electrons", + StoreTResult = False) + ToolSvc += ElectronPassLHMedium + print(ElectronPassLHMedium) + + # decorate electrons with the output of LH tight + ElectronPassLHTight = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassLHTight", + EGammaElectronLikelihoodTool = ElectronLHSelectorTight, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHTight", + ContainerName = "Electrons", + StoreTResult = False) + ToolSvc += ElectronPassLHTight + print(ElectronPassLHTight) + + # decorate electrons with the output of ECIDS + ElectronPassECIDS = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassECIDS", + EGammaElectronLikelihoodTool = ElectronChargeIDSelector, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsECIDS", + ContainerName = "Electrons", + StoreTResult = True) + ToolSvc += ElectronPassECIDS + print (ElectronPassECIDS) + + # decorate forward electrons with the output of LH loose + ForwardElectronPassLHLoose = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHLoose", + EGammaElectronLikelihoodTool = ForwardElectronLHSelectorLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHLoose", + ContainerName = "ForwardElectrons") + ToolSvc += ForwardElectronPassLHLoose + print (ForwardElectronPassLHLoose) + + # decorate forward electrons with the output of LH medium + ForwardElectronPassLHMedium = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHMedium", + EGammaElectronLikelihoodTool = ForwardElectronLHSelectorMedium, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHMedium", + ContainerName = "ForwardElectrons") + ToolSvc += ForwardElectronPassLHMedium + print (ForwardElectronPassLHMedium) + + # decorate forward electrons with the output of LH tight + ForwardElectronPassLHTight = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ForwardElectronPassLHTight", + EGammaElectronLikelihoodTool = ForwardElectronLHSelectorTight, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHTight", + ContainerName = "ForwardElectrons") + ToolSvc += ForwardElectronPassLHTight + print (ForwardElectronPassLHTight) + + + # decorate photons with the output of IsEM loose + # on MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) + if isFullSim: + PhotonPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMLoose", + EGammaSelectionTool = PhotonIsEMSelectorLoose, + EGammaFudgeMCTool = EGVariableCorrectionTool, + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMLoose", + ContainerName = "Photons") + else: + PhotonPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMLoose", + EGammaSelectionTool = PhotonIsEMSelectorLoose, + EGammaFudgeMCTool = None, + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMLoose", + ContainerName = "Photons") + ToolSvc += PhotonPassIsEMLoose + print(PhotonPassIsEMLoose) + + # decorate photons with the output of IsEM tight + # on full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) + if isFullSim: + PhotonPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTight", + EGammaSelectionTool = PhotonIsEMSelectorTight, + EGammaFudgeMCTool = EGVariableCorrectionTool, + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMTight", + ContainerName = "Photons") + else: + PhotonPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTight", + EGammaSelectionTool = PhotonIsEMSelectorTight, + EGammaFudgeMCTool = None, + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMTight", + ContainerName = "Photons") + ToolSvc += PhotonPassIsEMTight + print(PhotonPassIsEMTight) + + # decorate photons with the output of IsEM tight pt-inclusive menu + # Can be removed once pt-dependent cuts are fully supported. + # On full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) + PhotonPassIsEMTightPtIncl = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTightPtIncl", + EGammaSelectionTool = PhotonIsEMSelectorTightPtIncl, + EGammaFudgeMCTool = (EGVariableCorrectionTool if isFullSim else None), + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMTightPtIncl", + ContainerName = "Photons") + ToolSvc += PhotonPassIsEMTightPtIncl + print (PhotonPassIsEMTightPtIncl) + + # decorate photons with the photon cleaning flags + # on MC, fudge the shower shapes before computing the flags + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGPhotonCleaningWrapper + if isFullSim: + PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", + EGammaFudgeMCTool = EGVariableCorrectionTool, + StoreGateEntryName = "DFCommonPhotonsCleaning", + ContainerName = "Photons") + else: + PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", + EGammaFudgeMCTool = None, + StoreGateEntryName = "DFCommonPhotonsCleaning", + ContainerName = "Photons") + ToolSvc += PhotonPassCleaning + print (PhotonPassCleaning) + + # decorate central electrons and photons with a flag to tell the the candidates are affected by the crack bug in mc16a and data 2015+2016 + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGCrackVetoCleaningTool as DF_EGCVCT + PhotonPassCrackVeto = DF_EGCVCT(name = "PhotonPassCrackVeto", + StoreGateEntryName = "DFCommonCrackVetoCleaning", + ContainerName = "Photons") + ElectronPassCrackVeto = DF_EGCVCT(name = "ElectronPassCrackVeto", + StoreGateEntryName = "DFCommonCrackVetoCleaning", + ContainerName = "Electrons") + ToolSvc += [PhotonPassCrackVeto,ElectronPassCrackVeto] + + # decorate some electrons with an additional ambiguity flag against internal and early material conversion + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronAmbiguityTool as DF_EGEAT + ElectronAmbiguity = DF_EGEAT(name = "ElectronAdditionnalAmbiguity", + isMC = (globalflags.DataSource()!='data')) + ToolSvc += ElectronAmbiguity + + # + # Commented ForwardElectronPassLHLoose, ForwardElectronPassLHMedium, ForwardElectronPassLHTight tools due to they are not available in R22 yet + # + # list of all the decorators so far + EGAugmentationTools = [DFCommonPhotonsDirection, + ElectronPassLHVeryLoose, ElectronPassLHLoose, ElectronPassLHLooseBL, ElectronPassLHMedium, ElectronPassLHTight, + ForwardElectronPassLHLoose, ForwardElectronPassLHMedium, ForwardElectronPassLHTight, + ElectronPassECIDS, + PhotonPassIsEMLoose, PhotonPassIsEMTight, + PhotonPassIsEMTightPtIncl, + PhotonPassCleaning, + PhotonPassCrackVeto,ElectronPassCrackVeto, + ElectronAmbiguity] + + #================================================== + # Truth Related tools + from RecExConfig.RecFlags import rec + if rec.doTruth(): + + # Decorate Electron with bkg electron type/origin + from MCTruthClassifier.MCTruthClassifierBase import MCTruthClassifier as BkgElectronMCTruthClassifier + BkgElectronMCTruthClassifier.barcodeG4Shift=(DerivationFrameworkSimBarcodeOffset+1) + BkgElectronMCTruthClassifier.ParticleCaloExtensionTool="" + + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__BkgElectronClassification + BkgElectronClassificationTool = DerivationFramework__BkgElectronClassification (name = "BkgElectronClassificationTool", + MCTruthClassifierTool = BkgElectronMCTruthClassifier, + barcodeCut=DerivationFrameworkSimBarcodeOffset) + ToolSvc += BkgElectronClassificationTool + print(BkgElectronClassificationTool) + EGAugmentationTools.append(BkgElectronClassificationTool) + + # Decorate egammaTruthParticles with truth-particle-level etcone20,30,40 + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthIsolationTool as dtit + TruthEgetIsolationTool = dtit(name = "TruthEgetIsolationTool", + isoParticlesKey = "egammaTruthParticles", + allParticlesKey = "TruthParticles", + particleIDsToCalculate = [-11,11,22], + IsolationConeSizes = [0.2,0.3,0.4], + excludeIDsFromCone = [-16,-14,-13,-12,12,13,14,16], + IsolationVarNamePrefix = 'etcone', + ChargedParticlesOnly = False) + ToolSvc += TruthEgetIsolationTool + print(TruthEgetIsolationTool) + EGAugmentationTools.append(TruthEgetIsolationTool) + + # Decorate egammaTruthParticles with truth-particle-level ptcone20,30,40 + TruthEgptIsolationTool = dtit(name = "TruthEgptIsolationTool", + isoParticlesKey = "egammaTruthParticles", + allParticlesKey = "TruthParticles", + particleIDsToCalculate = [-11,11,22], + IsolationConeSizes = [0.2,0.3,0.4], + IsolationVarNamePrefix = 'ptcone', + ChargedParticlesOnly = True) + ToolSvc += TruthEgptIsolationTool + print(TruthEgptIsolationTool) + EGAugmentationTools.append(TruthEgptIsolationTool) + + # Compute the truth-particle-level energy density in the central eta region + from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAthAlg + from JetRec.JetRecStandard import jtm + tc=configEventDensityTool("EDTruthCentralTool", jtm.truthget.Label, + 0.5, + AbsRapidityMin = 0.0, + AbsRapidityMax = 1.5, + OutputContainer = "TruthIsoCentralEventShape", + OutputLevel = 3 + ) + ToolSvc += tc + + # Compute the truth-particle-level energy density in the forward eta region + tf=configEventDensityTool("EDTruthForwardTool", jtm.truthget.Label, + 0.5, + AbsRapidityMin = 1.5, + AbsRapidityMax = 3.0, + OutputContainer = "TruthIsoForwardEventShape", + OutputLevel = 3, + ) + ToolSvc += tf + + # Schedule the two energy density tools for running + from AthenaCommon.AlgSequence import AlgSequence + topSequence = AlgSequence() + topSequence += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc ) + topSequence += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf ) + + #======================================= + # CREATE THE DERIVATION KERNEL ALGORITHM + #======================================= + + DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("EGammaCommonKernel", + AugmentationTools = EGAugmentationTools + ) + + #======================================= + # ADD TOOLS + #======================================= + + import IsolationAlgs.IsoUpdatedTrackCones as isoCones + if not hasattr(DerivationFrameworkJob,"IsolationBuilderTight1000"): + DerivationFrameworkJob += isoCones.GetUpdatedIsoTrackCones() diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/FtagRun3DerivationConfig.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/FtagRun3DerivationConfig.py index 5c3d08aef44..856c3145f84 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/FtagRun3DerivationConfig.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkFlavourTag/python/FtagRun3DerivationConfig.py @@ -131,25 +131,26 @@ def getFtagComponent(cfgFlags, jetcol, taggerlist, OutputLevel=WARNING): # this probably only has to happen once def setupCondDb(cfgFlags, taggerlist): from AthenaCommon.AppMgr import athCondSeq - CalibrationChannelAliases = ["AntiKt4EMPFlow->AntiKt4EMPFlow,AntiKt4EMTopo,AntiKt4TopoEM,AntiKt4LCTopo"] - grades= cfgFlags.BTagging.Grades - RNNIPConfig = {'rnnip':''} - - JetTagCalibCondAlg=CompFactory.Analysis.JetTagCalibCondAlg - jettagcalibcondalg = "JetTagCalibCondAlg" - readkeycalibpath = "/GLOBAL/BTagCalib/RUN12" - connSchema = "GLOBAL_OFL" - if not cfgFlags.Input.isMC: - readkeycalibpath = readkeycalibpath.replace("/GLOBAL/BTagCalib","/GLOBAL/Onl/BTagCalib") - connSchema = "GLOBAL" - histoskey = "JetTagCalibHistosKey" - from IOVDbSvc.CondDB import conddb - - conddb.addFolder(connSchema, readkeycalibpath, className='CondAttrListCollection') - JetTagCalib = JetTagCalibCondAlg(jettagcalibcondalg, ReadKeyCalibPath=readkeycalibpath, HistosKey = histoskey, taggers = taggerlist, - channelAliases = CalibrationChannelAliases, IP2D_TrackGradePartitions = grades, RNNIP_NetworkConfig = RNNIPConfig) - - athCondSeq+=conf2toConfigurable( JetTagCalib, indent=" " ) + if not hasattr(athCondSeq,"JetTagCalibCondAlg"): + CalibrationChannelAliases = ["AntiKt4EMPFlow->AntiKt4EMPFlow,AntiKt4EMTopo,AntiKt4TopoEM,AntiKt4LCTopo"] + grades= cfgFlags.BTagging.Grades + RNNIPConfig = {'rnnip':''} + + JetTagCalibCondAlg=CompFactory.Analysis.JetTagCalibCondAlg + jettagcalibcondalg = "JetTagCalibCondAlg" + readkeycalibpath = "/GLOBAL/BTagCalib/RUN12" + connSchema = "GLOBAL_OFL" + if not cfgFlags.Input.isMC: + readkeycalibpath = readkeycalibpath.replace("/GLOBAL/BTagCalib","/GLOBAL/Onl/BTagCalib") + connSchema = "GLOBAL" + histoskey = "JetTagCalibHistosKey" + from IOVDbSvc.CondDB import conddb + + conddb.addFolder(connSchema, readkeycalibpath, className='CondAttrListCollection') + JetTagCalib = JetTagCalibCondAlg(jettagcalibcondalg, ReadKeyCalibPath=readkeycalibpath, HistosKey = histoskey, taggers = taggerlist, + channelAliases = CalibrationChannelAliases, IP2D_TrackGradePartitions = grades, RNNIP_NetworkConfig = RNNIPConfig) + + athCondSeq+=conf2toConfigurable( JetTagCalib, indent=" " ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py index 33ca5e8f94a..d0234e60bff 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkInDet/python/InDetCommon.py @@ -5,77 +5,80 @@ # Schedules all tools needed for ID track object selection and writes # results into SG. These may then be accessed along the train #******************************************************************** -from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob -# Check file contains PrimaryVertices container (protect against non-collision data) -# If running from RAW the eventdata_items are none or emtpy -from RecExConfig.InputFilePeeker import inputFileSummary -from AthenaCommon import CfgMgr -from AthenaCommon.AppMgr import ToolSvc -from AthenaCommon.BeamFlags import jobproperties -from InDetRecExample.InDetJobProperties import InDetFlags +def makeInDetDFCommon(): -have_PV_container = jobproperties.Beam.beamType()!="cosmics" \ - and (not inputFileSummary['eventdata_items'] or any('PrimaryVertices' in elements for elements in inputFileSummary['eventdata_items'])) + from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob + # Check file contains PrimaryVertices container (protect against non-collision data) + # If running from RAW the eventdata_items are none or emtpy + from RecExConfig.InputFilePeeker import inputFileSummary + from AthenaCommon import CfgMgr + from AthenaCommon.AppMgr import ToolSvc + from AthenaCommon.BeamFlags import jobproperties + from InDetRecExample.InDetJobProperties import InDetFlags -if not have_PV_container and InDetFlags.doVertexFinding() and inputFileSummary['eventdata_items']: - have_PV_container = any('PixelRDOs' in elements for elements in inputFileSummary['eventdata_items']) \ - or any('SCT_RDOs' in elements for elements in inputFileSummary['eventdata_items']) -if have_PV_container: -#==================================================================== -# LABELLING TRACKS WITH OUTCOME OF SELECTOR TOOL -#==================================================================== - from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__InDetTrackSelectionToolWrapper - DFCommonTrackSelection = DerivationFramework__InDetTrackSelectionToolWrapper(name = "DFCommonTrackSelection", - ContainerName = "InDetTrackParticles", - DecorationName = "DFCommonTightPrimary" ) - DFCommonTrackSelection.TrackSelectionTool.CutLevel = "TightPrimary" - ToolSvc += DFCommonTrackSelection - -#==================================================================== -# EXPRESSION OF Z0 AT THE PRIMARY VERTEX -#==================================================================== - from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParametersAtPV - DFCommonZ0AtPV = DerivationFramework__TrackParametersAtPV(name = "DFCommonZ0AtPV", - TrackParticleContainerName = "InDetTrackParticles", - VertexContainerName = "PrimaryVertices", - Z0SGEntryName = "DFCommonInDetTrackZ0AtPV" ) - ToolSvc += DFCommonZ0AtPV - -#==================================================================== -# DECORATE THE HARDSCATTER VERTEX WITH A FLAG -#==================================================================== - from InDetHardScatterSelectionTool.InDetHardScatterSelectionToolConf import InDet__InDetHardScatterSelectionTool - DFCommonHSSelectionTool = InDet__InDetHardScatterSelectionTool(name = "DFCommonHSSelectionTool") - ToolSvc += DFCommonHSSelectionTool - - from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__HardScatterVertexDecorator - DFCommonHSDecorator = DerivationFramework__HardScatterVertexDecorator(name = "DFCommonHSDecorator", - VertexContainerName = "PrimaryVertices", - HardScatterDecoName = "hardScatterVertexLink", - HardScatterSelectionTool = ToolSvc.DFCommonHSSelectionTool ) - ToolSvc += DFCommonHSDecorator - -#==================================================================== -# DECORATE THE TRACKS WITH USED-IN-FIT TTVA VARIABLES -#==================================================================== - from InDetUsedInFitTrackDecoratorTool.InDetUsedInFitTrackDecoratorToolConf import InDet__InDetUsedInFitTrackDecoratorTool - DFCommonUsedInFitDecoratorTool = InDet__InDetUsedInFitTrackDecoratorTool(name = "DFCommonUsedInFitDecoratorTool", - AMVFVerticesDecoName = "TTVA_AMVFVertices", - AMVFWeightsDecoName = "TTVA_AMVFWeights", - TrackContainer = "InDetTrackParticles", - VertexContainer = "PrimaryVertices" ) - ToolSvc += DFCommonUsedInFitDecoratorTool - - from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__UsedInVertexFitTrackDecorator - DFCommonUsedInFitDecorator = DerivationFramework__UsedInVertexFitTrackDecorator(name = "DFCommonUsedInFitDecorator", - UsedInFitDecoratorTool = ToolSvc.DFCommonUsedInFitDecoratorTool ) - ToolSvc += DFCommonUsedInFitDecorator - -#======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM -#======================================= - - DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("InDetCommonKernel", - AugmentationTools = [DFCommonTrackSelection, DFCommonZ0AtPV, DFCommonHSDecorator, DFCommonUsedInFitDecorator] ) + have_PV_container = jobproperties.Beam.beamType()!="cosmics" \ + and (not inputFileSummary['eventdata_items'] or any('PrimaryVertices' in elements for elements in inputFileSummary['eventdata_items'])) + + if not have_PV_container and InDetFlags.doVertexFinding() and inputFileSummary['eventdata_items']: + have_PV_container = any('PixelRDOs' in elements for elements in inputFileSummary['eventdata_items']) \ + or any('SCT_RDOs' in elements for elements in inputFileSummary['eventdata_items']) + + if have_PV_container: + #==================================================================== + # LABELLING TRACKS WITH OUTCOME OF SELECTOR TOOL + #==================================================================== + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__InDetTrackSelectionToolWrapper + DFCommonTrackSelection = DerivationFramework__InDetTrackSelectionToolWrapper(name = "DFCommonTrackSelection", + ContainerName = "InDetTrackParticles", + DecorationName = "DFCommonTightPrimary" ) + DFCommonTrackSelection.TrackSelectionTool.CutLevel = "TightPrimary" + ToolSvc += DFCommonTrackSelection + + #==================================================================== + # EXPRESSION OF Z0 AT THE PRIMARY VERTEX + #==================================================================== + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParametersAtPV + DFCommonZ0AtPV = DerivationFramework__TrackParametersAtPV(name = "DFCommonZ0AtPV", + TrackParticleContainerName = "InDetTrackParticles", + VertexContainerName = "PrimaryVertices", + Z0SGEntryName = "DFCommonInDetTrackZ0AtPV" ) + ToolSvc += DFCommonZ0AtPV + + #==================================================================== + # DECORATE THE HARDSCATTER VERTEX WITH A FLAG + #==================================================================== + from InDetHardScatterSelectionTool.InDetHardScatterSelectionToolConf import InDet__InDetHardScatterSelectionTool + DFCommonHSSelectionTool = InDet__InDetHardScatterSelectionTool(name = "DFCommonHSSelectionTool") + ToolSvc += DFCommonHSSelectionTool + + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__HardScatterVertexDecorator + DFCommonHSDecorator = DerivationFramework__HardScatterVertexDecorator(name = "DFCommonHSDecorator", + VertexContainerName = "PrimaryVertices", + HardScatterDecoName = "hardScatterVertexLink", + HardScatterSelectionTool = ToolSvc.DFCommonHSSelectionTool ) + ToolSvc += DFCommonHSDecorator + + #==================================================================== + # DECORATE THE TRACKS WITH USED-IN-FIT TTVA VARIABLES + #==================================================================== + from InDetUsedInFitTrackDecoratorTool.InDetUsedInFitTrackDecoratorToolConf import InDet__InDetUsedInFitTrackDecoratorTool + DFCommonUsedInFitDecoratorTool = InDet__InDetUsedInFitTrackDecoratorTool(name = "DFCommonUsedInFitDecoratorTool", + AMVFVerticesDecoName = "TTVA_AMVFVertices", + AMVFWeightsDecoName = "TTVA_AMVFWeights", + TrackContainer = "InDetTrackParticles", + VertexContainer = "PrimaryVertices" ) + ToolSvc += DFCommonUsedInFitDecoratorTool + + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__UsedInVertexFitTrackDecorator + DFCommonUsedInFitDecorator = DerivationFramework__UsedInVertexFitTrackDecorator(name = "DFCommonUsedInFitDecorator", + UsedInFitDecoratorTool = ToolSvc.DFCommonUsedInFitDecoratorTool ) + ToolSvc += DFCommonUsedInFitDecorator + + #======================================= + # CREATE THE DERIVATION KERNEL ALGORITHM + #======================================= + + DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("InDetCommonKernel", + AugmentationTools = [DFCommonTrackSelection, DFCommonZ0AtPV, DFCommonHSDecorator, DFCommonUsedInFitDecorator] ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMuons/python/MuonsCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMuons/python/MuonsCommon.py index fc85c794d85..40b2cdcc05f 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMuons/python/MuonsCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkMuons/python/MuonsCommon.py @@ -6,88 +6,89 @@ # results into SG. These may then be accessed along the train #******************************************************************** from __future__ import print_function +def makeMuonsDFCommon(): -from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob -from DerivationFrameworkMuons import DFCommonMuonsConfig -from AthenaCommon.AppMgr import ToolSvc -from AthenaCommon import CfgMgr -DFCommonMuonsTrtCutOff = DFCommonMuonsConfig.TrtCutOff - -#==================================================================== -# MCP GROUP TOOLS -#==================================================================== - -#==================================================================== -# AUGMENTATION TOOLS -#==================================================================== -from MuonSelectorTools.MuonSelectorToolsConf import CP__MuonSelectionTool -from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__AsgSelectionToolWrapper -DFCommonMuonToolWrapperTools = [] - -### IDHits -DFCommonMuonsSelector = CP__MuonSelectionTool(name = "DFCommonMuonsSelector") -DFCommonMuonsSelector.MaxEta = 3. -DFCommonMuonsSelector.MuQuality = 3 -# turn of the momentum correction which is not needed for IDHits cut and Preselection -DFCommonMuonsSelector.TurnOffMomCorr = True - -if DFCommonMuonsTrtCutOff is not None: DFCommonMuonsSelector.TrtCutOff = DFCommonMuonsTrtCutOff -ToolSvc += DFCommonMuonsSelector -print (DFCommonMuonsSelector) - -DFCommonMuonToolWrapperIDCuts = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonMuonToolWrapperIDCuts", - AsgSelectionTool = DFCommonMuonsSelector, - CutType = "IDHits", - StoreGateEntryName = "DFCommonMuonPassIDCuts", - ContainerName = "Muons") -#preselection -ToolSvc += DFCommonMuonToolWrapperIDCuts -print (DFCommonMuonToolWrapperIDCuts) -DFCommonMuonToolWrapperTools.append(DFCommonMuonToolWrapperIDCuts) - -DFCommonMuonToolWrapperPreselection = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonMuonToolWrapperPreselection", - AsgSelectionTool = DFCommonMuonsSelector, - CutType = "Preselection", - StoreGateEntryName = "DFCommonMuonPassPreselection", - ContainerName = "Muons") - -ToolSvc += DFCommonMuonToolWrapperPreselection -print (DFCommonMuonToolWrapperPreselection) -DFCommonMuonToolWrapperTools.append(DFCommonMuonToolWrapperPreselection) -### Decoration of the muon objects with the ID track covariances -#from DerivationFrameworkMuons.DerivationFrameworkMuonsConf import DerivationFramework__MuonIDCovMatrixDecorator -#DFCommonMuonIDCovMatrixDecorator = DerivationFramework__MuonIDCovMatrixDecorator( name = "DFCommonMuonIDCovMatrixDecorator") -#ToolSvc += DFCommonMuonIDCovMatrixDecorator -#print (DFCommonMuonIDCovMatrixDecorator) -#DFCommonMuonToolWrapperTools.append(DFCommonMuonIDCovMatrixDecorator) - -############# -# Add tools -############# -DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("DFCommonMuonsKernel", - AugmentationTools = DFCommonMuonToolWrapperTools - ) - -from IsolationAlgs.IsoUpdatedTrackCones import GetUpdatedIsoTrackCones -if not hasattr(DerivationFrameworkJob,"IsolationBuilderLoose1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Loose") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNominal1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nominal") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderTight1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Tight") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderPrompt_D0Sig1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Prompt_D0Sig") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Hard_D0Sig1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Hard_D0Sig") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Medium_D0Sig1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Medium_D0Sig") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_All_D0Sig1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_All_D0Sig") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderPrompt_MaxWeight1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Prompt_MaxWeight") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Hard_MaxWeight1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Hard_MaxWeight") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Medium_MaxWeight1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Medium_MaxWeight") -if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_All_MaxWeight1000"): - DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_All_MaxWeight") + from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkJob + from DerivationFrameworkMuons import DFCommonMuonsConfig + from AthenaCommon.AppMgr import ToolSvc + from AthenaCommon import CfgMgr + DFCommonMuonsTrtCutOff = DFCommonMuonsConfig.TrtCutOff + + #==================================================================== + # MCP GROUP TOOLS + #==================================================================== + + #==================================================================== + # AUGMENTATION TOOLS + #==================================================================== + from MuonSelectorTools.MuonSelectorToolsConf import CP__MuonSelectionTool + from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__AsgSelectionToolWrapper + DFCommonMuonToolWrapperTools = [] + + ### IDHits + DFCommonMuonsSelector = CP__MuonSelectionTool(name = "DFCommonMuonsSelector") + DFCommonMuonsSelector.MaxEta = 3. + DFCommonMuonsSelector.MuQuality = 3 + # turn of the momentum correction which is not needed for IDHits cut and Preselection + DFCommonMuonsSelector.TurnOffMomCorr = True + + if DFCommonMuonsTrtCutOff is not None: DFCommonMuonsSelector.TrtCutOff = DFCommonMuonsTrtCutOff + ToolSvc += DFCommonMuonsSelector + print (DFCommonMuonsSelector) + + DFCommonMuonToolWrapperIDCuts = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonMuonToolWrapperIDCuts", + AsgSelectionTool = DFCommonMuonsSelector, + CutType = "IDHits", + StoreGateEntryName = "DFCommonMuonPassIDCuts", + ContainerName = "Muons") + #preselection + ToolSvc += DFCommonMuonToolWrapperIDCuts + print (DFCommonMuonToolWrapperIDCuts) + DFCommonMuonToolWrapperTools.append(DFCommonMuonToolWrapperIDCuts) + + DFCommonMuonToolWrapperPreselection = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonMuonToolWrapperPreselection", + AsgSelectionTool = DFCommonMuonsSelector, + CutType = "Preselection", + StoreGateEntryName = "DFCommonMuonPassPreselection", + ContainerName = "Muons") + + ToolSvc += DFCommonMuonToolWrapperPreselection + print (DFCommonMuonToolWrapperPreselection) + DFCommonMuonToolWrapperTools.append(DFCommonMuonToolWrapperPreselection) + ### Decoration of the muon objects with the ID track covariances + #from DerivationFrameworkMuons.DerivationFrameworkMuonsConf import DerivationFramework__MuonIDCovMatrixDecorator + #DFCommonMuonIDCovMatrixDecorator = DerivationFramework__MuonIDCovMatrixDecorator( name = "DFCommonMuonIDCovMatrixDecorator") + #ToolSvc += DFCommonMuonIDCovMatrixDecorator + #print (DFCommonMuonIDCovMatrixDecorator) + #DFCommonMuonToolWrapperTools.append(DFCommonMuonIDCovMatrixDecorator) + + ############# + # Add tools + ############# + DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("DFCommonMuonsKernel", + AugmentationTools = DFCommonMuonToolWrapperTools + ) + + from IsolationAlgs.IsoUpdatedTrackCones import GetUpdatedIsoTrackCones + if not hasattr(DerivationFrameworkJob,"IsolationBuilderLoose1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Loose") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNominal1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nominal") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderTight1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Tight") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderPrompt_D0Sig1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Prompt_D0Sig") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Hard_D0Sig1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Hard_D0Sig") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Medium_D0Sig1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Medium_D0Sig") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_All_D0Sig1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_All_D0Sig") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderPrompt_MaxWeight1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Prompt_MaxWeight") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Hard_MaxWeight1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Hard_MaxWeight") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_Medium_MaxWeight1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_Medium_MaxWeight") + if not hasattr(DerivationFrameworkJob,"IsolationBuilderNonprompt_All_MaxWeight1000"): + DerivationFrameworkJob += GetUpdatedIsoTrackCones(WP="Nonprompt_All_MaxWeight") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py new file mode 100644 index 00000000000..ad72d252729 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py @@ -0,0 +1,168 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +#==================================================================== +# PhysCommon.py +# This defines all of the containers needed both in PHYS and PHYSLITE +# Using it avoids name clashes when running in trains +# In principle it can also be used by other formats who want to take +# advantage of PHYS/PHYSLITE containers +#==================================================================== +from AthenaCommon.AppMgr import ToolSvc +from AthenaCommon import CfgMgr +from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkIsMonteCarlo, DerivationFrameworkJob +from DerivationFrameworkInDet import InDetCommon +from DerivationFrameworkEGamma import EGammaCommon +from DerivationFrameworkMuons import MuonsCommon +# Common augmentations ("DFCommon") +InDetCommon.makeInDetDFCommon() +EGammaCommon.makeEGammaDFCommon() +MuonsCommon.makeMuonsDFCommon() +from DerivationFrameworkJetEtMiss.JetCommon import OutputJets +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets, addDefaultTrimmedJets, addJetTruthLabel, addQGTaggerTool, getPFlowfJVT +from TriggerMenuMT.TriggerAPI.TriggerAPI import TriggerAPI +from TriggerMenuMT.TriggerAPI.TriggerEnums import TriggerPeriod, TriggerType +from DerivationFrameworkTrigger.TriggerMatchingHelper import TriggerMatchingHelper +import re + +### Augmentation tools lists +AugmentationTools = [] + +#DerivationFrameworkJob = CfgMgr.AthSequencer("DerivationFrameworkJob") +#DerivationFrameworkJob += DerivationFrameworkJob + +#==================================================================== +# MONTE CARLO TRUTH +#==================================================================== +if (DerivationFrameworkIsMonteCarlo): + from DerivationFrameworkMCTruth.MCTruthCommon import addStandardTruthContents,addMiniTruthCollectionLinks,addHFAndDownstreamParticles,addPVCollection + #import DerivationFrameworkHiggs.TruthCategories + # Add charm quark collection + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthCollectionMaker + PhysCommonTruthCharmTool = DerivationFramework__TruthCollectionMaker(name = "PhysCommonTruthCharmTool", + NewCollectionName = "TruthCharm", + KeepNavigationInfo = False, + ParticleSelectionString = "(abs(TruthParticles.pdgId) == 4)", + Do_Compress = True) + ToolSvc += PhysCommonTruthCharmTool + DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("PhysCommonTruthCharmKernel",AugmentationTools=[PhysCommonTruthCharmTool]) + # Add HF particles + addHFAndDownstreamParticles(DerivationFrameworkJob) + # Add standard truth + addStandardTruthContents(DerivationFrameworkJob,prefix='DFCommon_') + # Update to include charm quarks and HF particles - require a separate instance to be train safe + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthNavigationDecorator + PhysCommonTruthNavigationDecorator = DerivationFramework__TruthNavigationDecorator( name="PhysCommonTruthNavigationDecorator", + InputCollections=["TruthElectrons", "TruthMuons", "TruthPhotons", "TruthTaus", "TruthNeutrinos", "TruthBSM", "TruthBottom", "TruthTop", "TruthBoson","TruthCharm","TruthHFWithDecayParticles"]) + ToolSvc += PhysCommonTruthNavigationDecorator + DerivationFrameworkJob.DFCommon_MCTruthNavigationDecoratorKernel.AugmentationTools = [PhysCommonTruthNavigationDecorator] + # Re-point links on reco objects + addMiniTruthCollectionLinks(DerivationFrameworkJob) + addPVCollection(DerivationFrameworkJob) + # Set appropriate truth jet collection for tau truth matching + ToolSvc.DFCommonTauTruthMatchingTool.TruthJetContainerName = "AntiKt4TruthDressedWZJets" + +#==================================================================== +# TRIGGER CONTENT +#==================================================================== +## See https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerAPI +## Get single and multi mu, e, photon triggers +## Jet, tau, multi-object triggers not available in the matching code +allperiods = TriggerPeriod.y2015 | TriggerPeriod.y2016 | TriggerPeriod.y2017 | TriggerPeriod.y2018 | TriggerPeriod.future2e34 +trig_el = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, livefraction=0.8) +trig_mu = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, livefraction=0.8) +trig_g = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.g, livefraction=0.8) +trig_tau = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, livefraction=0.8) +## Add cross-triggers for some sets +trig_em = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.mu, livefraction=0.8) +trig_et = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.tau, livefraction=0.8) +trig_mt = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, additionalTriggerType=TriggerType.tau, livefraction=0.8) +## Note that this seems to pick up both isolated and non-isolated triggers already, so no need for extra grabs +trig_txe = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, additionalTriggerType=TriggerType.xe, livefraction=0.8) +# +## Merge and remove duplicates +trigger_names_full_notau = list(set(trig_el+trig_mu+trig_g+trig_em+trig_et+trig_mt)) +trigger_names_full_tau = list(set(trig_tau+trig_txe)) +# +## Now reduce the list... +trigger_names_notau = [] +trigger_names_tau = [] +from AthenaConfiguration.AutoConfigFlags import GetFileMD +from AthenaConfiguration.AllConfigFlags import ConfigFlags + +if ConfigFlags.Trigger.EDMVersion == 3: + r_tau = re.compile("HLT_.*tau.*") + r_notau = re.compile("HLT_[1-9]*(e|mu|g).*") + r_veto = re.compile("HLT_.*(LRT).*") + for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: + result_tau = r_tau.match(chain_name) + result_notau = r_notau.match(chain_name) + result_veto = r_veto.match(chain_name) + if result_tau is not None and result_veto is None: trigger_names_tau.append(chain_name) + if result_notau is not None and result_veto is None: trigger_names_notau.append(chain_name) + trigger_names_notau = set(trigger_names_notau) - set(trigger_names_tau) + trigger_names_notau = list(trigger_names_notau) +else: + for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: + if chain_name in trigger_names_full_notau: trigger_names_notau.append(chain_name) + if chain_name in trigger_names_full_tau: trigger_names_tau.append(chain_name) +# Create trigger matching decorations +PhysCommon_trigmatching_helper_notau = TriggerMatchingHelper(name='PhysCommonTriggerMatchingToolNoTau', + trigger_list = trigger_names_notau, add_to_df_job=True) +PhysCommon_trigmatching_helper_tau = TriggerMatchingHelper(name='PhysCommonTriggerMatchingToolTau', + trigger_list = trigger_names_tau, add_to_df_job=True, DRThreshold=0.2) + +#==================================================================== +# JET/MET +#==================================================================== + +# TODO: UFO jets to be added in the future +largeRJetCollections = [ + "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" #, "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" +] + +OutputJets["PhysCommon"] = largeRJetCollections +reducedJetList = ["AntiKt2PV0TrackJets","AntiKt4PV0TrackJets", "AntiKtVR30Rmax4Rmin02PV0TrackJets"] + +if (DerivationFrameworkIsMonteCarlo): + OutputJets["PhysCommon"].append("AntiKt10TruthTrimmedPtFrac5SmallR20Jets") + +replaceAODReducedJets(reducedJetList,DerivationFrameworkJob,"PhysCommon") +add_largeR_truth_jets = DerivationFrameworkIsMonteCarlo and not hasattr(DerivationFrameworkJob,'jetalgAntiKt10TruthTrimmedPtFrac5SmallR20') +addDefaultTrimmedJets(DerivationFrameworkJob,"PhysCommon",dotruth=add_largeR_truth_jets, linkVRGhosts=True) + +# Add large-R jet truth labeling +if (DerivationFrameworkIsMonteCarlo): + addJetTruthLabel(jetalg="AntiKt10LCTopoTrimmedPtFrac5SmallR20",sequence=DerivationFrameworkJob,algname="JetTruthLabelingAlg",labelname="R10TruthLabel_R21Consolidated") + +addQGTaggerTool(jetalg="AntiKt4EMTopo",sequence=DerivationFrameworkJob,algname="QGTaggerToolAlg") +addQGTaggerTool(jetalg="AntiKt4EMPFlow",sequence=DerivationFrameworkJob,algname="QGTaggerToolPFAlg") + +# fJVT +getPFlowfJVT(jetalg='AntiKt4EMPFlow',sequence=DerivationFrameworkJob, algname='PHYSJetForwardPFlowJvtToolAlg') + +#==================================================================== +# EGAMMA +#==================================================================== + +if DerivationFrameworkIsMonteCarlo: + # Schedule the two energy density tools for running after the pseudojets are created. + for alg in ['EDTruthCentralAlg', 'EDTruthForwardAlg']: + if hasattr(DerivationFrameworkJob, alg): + edtalg = getattr(DerivationFrameworkJob, alg) + delattr(DerivationFrameworkJob, alg) + DerivationFrameworkJob += edtalg + +#==================================================================== +# Tau +#==================================================================== + +# Add low-pt di-tau reconstruction +from DerivationFrameworkTau.TauCommon import addDiTauLowPt +addDiTauLowPt(Seq=DerivationFrameworkJob) + +#==================================================================== +# FLAVOUR TAGGING +#==================================================================== +from DerivationFrameworkFlavourTag.FtagRun3DerivationConfig import FtagJetCollections +FtagJetCollections(['AntiKt4EMPFlowJets'],DerivationFrameworkJob) + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py index b77f231c007..7850c197bb8 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py @@ -8,18 +8,22 @@ # It requires the reductionConf flag PHYS in Reco_tf.py #==================================================================== -from DerivationFrameworkCore.DerivationFrameworkMaster import buildFileName, DerivationFrameworkIsMonteCarlo, DerivationFrameworkJob -from DerivationFrameworkInDet import InDetCommon -from DerivationFrameworkEGamma import EGammaCommon +from AthenaCommon import Logging +nanolog = Logging.logging.getLogger('PHYS') + +from DerivationFrameworkCore.DerivationFrameworkMaster import buildFileName +from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkIsMonteCarlo, DerivationFrameworkJob +from DerivationFrameworkPhys import PhysCommon from DerivationFrameworkEGamma import ElectronsCPDetailedContent -from DerivationFrameworkMuons import MuonsCommon -from DerivationFrameworkJetEtMiss.JetCommon import OutputJets -from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets, addDefaultTrimmedJets, addJetTruthLabel, addQGTaggerTool, getPFlowfJVT from DerivationFrameworkJetEtMiss import METCommon -from TriggerMenuMT.TriggerAPI.TriggerAPI import TriggerAPI -from TriggerMenuMT.TriggerAPI.TriggerEnums import TriggerPeriod, TriggerType -from DerivationFrameworkTrigger.TriggerMatchingHelper import TriggerMatchingHelper -import re +from DerivationFrameworkJetEtMiss.METCommon import scheduleMETAssocAlg +from DerivationFrameworkCore import LHE3WeightMetadata + +#==================================================================== +# Set up sequence for this format and add to the top sequence +#==================================================================== +SeqPHYS = CfgMgr.AthSequencer("SeqPHYS") +DerivationFrameworkJob += SeqPHYS #==================================================================== # SET UP STREAM @@ -37,98 +41,9 @@ AugmentationTools = [] SeqPHYS = CfgMgr.AthSequencer("SeqPHYS") #==================================================================== -# MONTE CARLO TRUTH +# THINNING #==================================================================== -if (DerivationFrameworkIsMonteCarlo): - from DerivationFrameworkMCTruth.MCTruthCommon import addStandardTruthContents,addMiniTruthCollectionLinks,addHFAndDownstreamParticles,addPVCollection - #import DerivationFrameworkHiggs.TruthCategories - # Add charm quark collection - from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthCollectionMaker - PHYSTruthCharmTool = DerivationFramework__TruthCollectionMaker(name = "PHYSTruthCharmTool", - NewCollectionName = "TruthCharm", - KeepNavigationInfo = False, - ParticleSelectionString = "(abs(TruthParticles.pdgId) == 4)", - Do_Compress = True) - ToolSvc += PHYSTruthCharmTool - #from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation - SeqPHYS += CfgMgr.DerivationFramework__CommonAugmentation("PHYSTruthCharmKernel",AugmentationTools=[PHYSTruthCharmTool]) - # Add HF particles - addHFAndDownstreamParticles(SeqPHYS) - # Add standard truth - addStandardTruthContents(SeqPHYS,prefix='PHYS_') - # Update to include charm quarks and HF particles - require a separate instance to be train safe - from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthNavigationDecorator - PHYSTruthNavigationDecorator = DerivationFramework__TruthNavigationDecorator( name="PHYSTruthNavigationDecorator", - InputCollections=["TruthElectrons", "TruthMuons", "TruthPhotons", "TruthTaus", "TruthNeutrinos", "TruthBSM", "TruthBottom", "TruthTop", "TruthBoson","TruthCharm","TruthHFWithDecayParticles"]) - ToolSvc += PHYSTruthNavigationDecorator - SeqPHYS.PHYS_MCTruthNavigationDecoratorKernel.AugmentationTools = [PHYSTruthNavigationDecorator] - # Re-point links on reco objects - addMiniTruthCollectionLinks(SeqPHYS) - addPVCollection(SeqPHYS) - # Set appropriate truth jet collection for tau truth matching - ToolSvc.DFCommonTauTruthMatchingTool.TruthJetContainerName = "AntiKt4TruthDressedWZJets" - # Add sumOfWeights metadata for LHE3 multiweights ======= - from DerivationFrameworkCore.LHE3WeightMetadata import * - - - -#==================================================================== -# TRIGGER CONTENT -#==================================================================== -## See https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerAPI -## Get single and multi mu, e, photon triggers -## Jet, tau, multi-object triggers not available in the matching code -allperiods = TriggerPeriod.y2015 | TriggerPeriod.y2016 | TriggerPeriod.y2017 | TriggerPeriod.y2018 | TriggerPeriod.future2e34 -trig_el = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, livefraction=0.8) -trig_mu = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, livefraction=0.8) -trig_g = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.g, livefraction=0.8) -trig_tau = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, livefraction=0.8) -## Add cross-triggers for some sets -trig_em = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.mu, livefraction=0.8) -trig_et = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.tau, livefraction=0.8) -trig_mt = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, additionalTriggerType=TriggerType.tau, livefraction=0.8) -## Note that this seems to pick up both isolated and non-isolated triggers already, so no need for extra grabs -trig_txe = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, additionalTriggerType=TriggerType.xe, livefraction=0.8) -# -## Merge and remove duplicates -trigger_names_full_notau = list(set(trig_el+trig_mu+trig_g+trig_em+trig_et+trig_mt)) -trigger_names_full_tau = list(set(trig_tau+trig_txe)) -# -## Now reduce the list... -trigger_names_notau = [] -trigger_names_tau = [] -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaConfiguration.AutoConfigFlags import GetFileMD -from AthenaConfiguration.AllConfigFlags import ConfigFlags - -if ConfigFlags.Trigger.EDMVersion == 3: - r_tau = re.compile("HLT_.*tau.*") - r_notau = re.compile("HLT_[1-9]*(e|mu|g).*") - r_veto = re.compile("HLT_.*(LRT).*") - for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: - result_tau = r_tau.match(chain_name) - result_notau = r_notau.match(chain_name) - result_veto = r_veto.match(chain_name) - if result_tau is not None and result_veto is None: trigger_names_tau.append(chain_name) - if result_notau is not None and result_veto is None: trigger_names_notau.append(chain_name) - trigger_names_notau = set(trigger_names_notau) - set(trigger_names_tau) - trigger_names_notau = list(trigger_names_notau) -else: - for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: - if chain_name in trigger_names_full_notau: trigger_names_notau.append(chain_name) - if chain_name in trigger_names_full_tau: trigger_names_tau.append(chain_name) -# Create trigger matching decorations -trigmatching_helper_notau = TriggerMatchingHelper(name='PHYSTriggerMatchingToolNoTau', - trigger_list = trigger_names_notau, add_to_df_job=True) -trigmatching_helper_tau = TriggerMatchingHelper(name='PHYSTriggerMatchingToolTau', - trigger_list = trigger_names_tau, add_to_df_job=True, DRThreshold=0.2) - - - -#==================================================================== -# INNER DETECTOR TRACK THINNING -#==================================================================== -# See recommedations here: +# ID tracks: See recommedations here: # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations # Inner detector group recommendations for indet tracks in analysis @@ -183,61 +98,6 @@ PHYSDiTauTPThinningTool = DerivationFramework__DiTauTrackParticleThinning(name ToolSvc += PHYSDiTauTPThinningTool thinningTools.append(PHYSDiTauTPThinningTool) -#==================================================================== -# JET/MET -#==================================================================== - -# TODO: UFO jets to be added in the future -largeRJetCollections = [ - "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" #, "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" -] - -OutputJets["PHYS"] = largeRJetCollections -reducedJetList = ["AntiKt2PV0TrackJets","AntiKt4PV0TrackJets", "AntiKtVR30Rmax4Rmin02PV0TrackJets"] - -if (DerivationFrameworkIsMonteCarlo): - OutputJets["PHYS"].append("AntiKt10TruthTrimmedPtFrac5SmallR20Jets") - -replaceAODReducedJets(reducedJetList,SeqPHYS,"PHYS") -add_largeR_truth_jets = DerivationFrameworkIsMonteCarlo and not hasattr(SeqPHYS,'jetalgAntiKt10TruthTrimmedPtFrac5SmallR20') -addDefaultTrimmedJets(SeqPHYS,"PHYS",dotruth=add_largeR_truth_jets, linkVRGhosts=True) - -# Add large-R jet truth labeling -if (DerivationFrameworkIsMonteCarlo): - addJetTruthLabel(jetalg="AntiKt10LCTopoTrimmedPtFrac5SmallR20",sequence=SeqPHYS,algname="JetTruthLabelingAlg",labelname="R10TruthLabel_R21Consolidated") - -addQGTaggerTool(jetalg="AntiKt4EMTopo",sequence=SeqPHYS,algname="QGTaggerToolAlg") -addQGTaggerTool(jetalg="AntiKt4EMPFlow",sequence=SeqPHYS,algname="QGTaggerToolPFAlg") - -# fJVT -getPFlowfJVT(jetalg='AntiKt4EMPFlow',sequence=SeqPHYS, algname='PHYSJetForwardPFlowJvtToolAlg') - -#==================================================================== -# EGAMMA -#==================================================================== - -if DerivationFrameworkIsMonteCarlo: - # Schedule the two energy density tools for running after the pseudojets are created. - for alg in ['EDTruthCentralAlg', 'EDTruthForwardAlg']: - if hasattr(topSequence, alg): - edtalg = getattr(topSequence, alg) - delattr(topSequence, alg) - SeqPHYS += edtalg - -#==================================================================== -# Add our sequence to the top sequence -#==================================================================== -# Ideally, this should come at the end of the job -DerivationFrameworkJob += SeqPHYS - -#==================================================================== -# Tau -#==================================================================== - -# Add low-pt di-tau reconstruction -from DerivationFrameworkTau.TauCommon import addDiTauLowPt -addDiTauLowPt(Seq=SeqPHYS) - # Low-pt di-tau thinning from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__GenericObjectThinning PHYSDiTauLowPtThinningTool = DerivationFramework__GenericObjectThinning(name = "PHYSDiTauLowPtThinningTool", @@ -265,22 +125,6 @@ thinningTools.append(PHYSDiTauLowPtTPThinningTool) SeqPHYS += CfgMgr.DerivationFramework__DerivationKernel("PHYSKernel", ThinningTools = thinningTools) - -#==================================================================== -# FLAVOUR TAGGING -#==================================================================== -from DerivationFrameworkFlavourTag.FtagRun3DerivationConfig import FtagJetCollections -FtagJetCollections(['AntiKt4EMPFlowJets','AntiKtVR30Rmax4Rmin02TrackJets'],SeqPHYS) - -#==================================================================== -# TC-LVT Vertices -#==================================================================== - -# from SoftBVrtClusterTool.SoftBVrtConfig import addSoftBVrt -# addSoftBVrt(SeqPHYS,'Loose') -# addSoftBVrt(SeqPHYS,'Medium') -# addSoftBVrt(SeqPHYS,'Tight') - #==================================================================== # CONTENTS #==================================================================== @@ -329,9 +173,6 @@ PHYSSlimmingHelper.IncludeBJetTriggerContent = False PHYSSlimmingHelper.IncludeBPhysTriggerContent = False PHYSSlimmingHelper.IncludeMinBiasTriggerContent = False -# Add the jet containers to the stream (defined in JetCommon if import needed) -#addJetOutputs(PHYSSlimmingHelper,["PHYS"]) - # Truth containers if DerivationFrameworkIsMonteCarlo: PHYSSlimmingHelper.AppendToDictionary = {'TruthEvents':'xAOD::TruthEventContainer','TruthEventsAux':'xAOD::TruthEventAuxContainer', @@ -376,8 +217,8 @@ PHYSSlimmingHelper.ExtraVariables += ["AntiKt10TruthTrimmedPtFrac5SmallR20Jets.T "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights"] # Add trigger matching -trigmatching_helper_notau.add_to_slimming(PHYSSlimmingHelper) -trigmatching_helper_tau.add_to_slimming(PHYSSlimmingHelper) +PhysCommon.PhysCommon_trigmatching_helper_notau.add_to_slimming(PHYSSlimmingHelper) +PhysCommon.PhysCommon_trigmatching_helper_tau.add_to_slimming(PHYSSlimmingHelper) # Final construction of output stream PHYSSlimmingHelper.AppendContentToStream(PHYSStream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py index 50df7cd000a..97cd3638dda 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYSLITE.py @@ -7,17 +7,13 @@ from AthenaCommon import Logging nanolog = Logging.logging.getLogger('PHYSLITE') -from DerivationFrameworkCore.DerivationFrameworkMaster import buildFileName, DerivationFrameworkIsMonteCarlo, DerivationFrameworkJob -from DerivationFrameworkInDet import InDetCommon -from DerivationFrameworkEGamma import EGammaCommon +from DerivationFrameworkCore.DerivationFrameworkMaster import buildFileName +from DerivationFrameworkCore.DerivationFrameworkMaster import DerivationFrameworkIsMonteCarlo, DerivationFrameworkJob +from DerivationFrameworkPhys import PhysCommon from DerivationFrameworkEGamma import ElectronsCPDetailedContent -from DerivationFrameworkMuons import MuonsCommon -from DerivationFrameworkJetEtMiss.JetCommon import OutputJets -from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets, addDefaultTrimmedJets, addJetTruthLabel, addQGTaggerTool, getPFlowfJVT -from DerivationFrameworkJetEtMiss.METCommon import scheduleMETAssocAlg -from TriggerMenuMT.TriggerAPI.TriggerAPI import TriggerAPI -from TriggerMenuMT.TriggerAPI.TriggerEnums import TriggerPeriod, TriggerType -from DerivationFrameworkTrigger.TriggerMatchingHelper import TriggerMatchingHelper +from DerivationFrameworkJetEtMiss import METCommon +from DerivationFrameworkJetEtMiss.METCommon import scheduleMETAssocAlg +from DerivationFrameworkCore import LHE3WeightMetadata import re #==================================================================== @@ -29,45 +25,10 @@ PHYSLITEStream = MSMgr.NewPoolRootStream( streamName, fileName ) PHYSLITEStream.AcceptAlgs(["PHYSLITEKernel"]) thinningTools = [] -AugmentationTools = [] + # Special sequence SeqPHYSLITE = CfgMgr.AthSequencer("SeqPHYSLITE") -#==================================================================== -# TRUTH CONTENT -#==================================================================== -if (DerivationFrameworkIsMonteCarlo): - from DerivationFrameworkMCTruth.MCTruthCommon import addStandardTruthContents,addMiniTruthCollectionLinks,addHFAndDownstreamParticles,addPVCollection - #import DerivationFrameworkHiggs.TruthCategories - # Add charm quark collection - from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthCollectionMaker - PHYSLITETruthCharmTool = DerivationFramework__TruthCollectionMaker(name = "PHYSLITETruthCharmTool", - NewCollectionName = "TruthCharm", - KeepNavigationInfo = False, - ParticleSelectionString = "(abs(TruthParticles.pdgId) == 4)", - Do_Compress = True) - ToolSvc += PHYSLITETruthCharmTool - #from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation - SeqPHYSLITE += CfgMgr.DerivationFramework__CommonAugmentation("PHYSLITETruthCharmKernel",AugmentationTools=[PHYSLITETruthCharmTool]) - # Add HF particles - addHFAndDownstreamParticles(SeqPHYSLITE) - # Add standard truth - addStandardTruthContents(SeqPHYSLITE,prefix='PHYSLITE_') - # Update to include charm quarks and HF particles - require a separate instance to be train safe - from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthNavigationDecorator - PHYSLITETruthNavigationDecorator = DerivationFramework__TruthNavigationDecorator( name="PHYSLITETruthNavigationDecorator", - InputCollections=["TruthElectrons", "TruthMuons", "TruthPhotons", "TruthTaus", "TruthNeutrinos", "TruthBSM", "TruthBottom", "TruthTop", "TruthBoson","TruthCharm","TruthHFWithDecayParticles"]) - ToolSvc += PHYSLITETruthNavigationDecorator - SeqPHYSLITE.PHYSLITE_MCTruthNavigationDecoratorKernel.AugmentationTools = [PHYSLITETruthNavigationDecorator] - # Re-point links on reco objects - addMiniTruthCollectionLinks(SeqPHYSLITE) - addPVCollection(SeqPHYSLITE) - # Set appropriate truth jet collection for tau truth matching - ToolSvc.DFCommonTauTruthMatchingTool.TruthJetContainerName = "AntiKt4TruthDressedWZJets" - # Add sumOfWeights metadata for LHE3 multiweights ======= - from DerivationFrameworkCore.LHE3WeightMetadata import * - - ''' from DerivationFrameworkMCTruth.HFHadronsCommon import * # Extra classifiers for the Higgs group @@ -115,9 +76,9 @@ if DerivationFrameworkIsMonteCarlo: ''' #==================================================================== -# INNER DETECTOR TRACK THINNING +# THINNING #==================================================================== -# See recommedations here: +# ID tracks: See recommedations here: # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/DaodRecommendations # Inner detector group recommendations for indet tracks in analysis @@ -172,55 +133,6 @@ PHYSLITEDiTauTPThinningTool = DerivationFramework__DiTauTrackParticleThinning(na ToolSvc += PHYSLITEDiTauTPThinningTool thinningTools.append(PHYSLITEDiTauTPThinningTool) -#==================================================================== -# JET/MET -#==================================================================== - -# TODO: UFO jets to be added in the future -largeRJetCollections = [ - "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" #, "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" -] - -OutputJets["PHYSLITE"] = largeRJetCollections -reducedJetList = ["AntiKt2PV0TrackJets","AntiKt4PV0TrackJets", "AntiKtVR30Rmax4Rmin02PV0TrackJets"] - -if (DerivationFrameworkIsMonteCarlo): - OutputJets["PHYSLITE"].append("AntiKt10TruthTrimmedPtFrac5SmallR20Jets") - -replaceAODReducedJets(reducedJetList,SeqPHYSLITE,"PHYSLITE") -add_largeR_truth_jets = DerivationFrameworkIsMonteCarlo and not hasattr(SeqPHYSLITE,'jetalgAntiKt10TruthTrimmedPtFrac5SmallR20') -addDefaultTrimmedJets(SeqPHYSLITE,"PHYSLITE",dotruth=add_largeR_truth_jets, linkVRGhosts=True) - -# Add large-R jet truth labeling -if (DerivationFrameworkIsMonteCarlo): - addJetTruthLabel(jetalg="AntiKt10LCTopoTrimmedPtFrac5SmallR20",sequence=SeqPHYSLITE,algname="JetTruthLabelingAlg",labelname="R10TruthLabel_R21Consolidated") - -addQGTaggerTool(jetalg="AntiKt4EMTopo",sequence=SeqPHYSLITE,algname="QGTaggerToolAlg") -addQGTaggerTool(jetalg="AntiKt4EMPFlow",sequence=SeqPHYSLITE,algname="QGTaggerToolPFAlg") - -# fJVT -getPFlowfJVT(jetalg='AntiKt4EMPFlow',sequence=SeqPHYSLITE, algname='PHYSLITEJetForwardPFlowJvtToolAlg') - -#==================================================================== -# EGAMMA -#==================================================================== - -if DerivationFrameworkIsMonteCarlo: - # Schedule the two energy density tools for running after the pseudojets are created. - for alg in ['EDTruthCentralAlg', 'EDTruthForwardAlg']: - if hasattr(topSequence, alg): - edtalg = getattr(topSequence, alg) - delattr(topSequence, alg) - SeqPHYSLITE += edtalg - -#==================================================================== -# Tau -#==================================================================== - -# Add low-pt di-tau reconstruction -from DerivationFrameworkTau.TauCommon import addDiTauLowPt -addDiTauLowPt(Seq=SeqPHYSLITE) - # Low-pt di-tau thinning from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__GenericObjectThinning PHYSLITEDiTauLowPtThinningTool = DerivationFramework__GenericObjectThinning(name = "PHYSLITEDiTauLowPtThinningTool", @@ -239,19 +151,6 @@ PHYSLITEDiTauLowPtTPThinningTool = DerivationFramework__DiTauTrackParticleThinni ToolSvc += PHYSLITEDiTauLowPtTPThinningTool thinningTools.append(PHYSLITEDiTauLowPtTPThinningTool) -#==================================================================== -# FLAVOUR TAGGING -#==================================================================== - -from DerivationFrameworkFlavourTag.FtagRun3DerivationConfig import FtagJetCollection - -FtagJetCollection('AntiKt4EMPFlowJets',SeqPHYSLITE) - - - - - - #============================================================================== # Analysis-level variables #============================================================================== @@ -334,57 +233,6 @@ PHYSLITE_cfg = METAssocConfig('AnalysisMET', METCommon.customMETConfigs.setdefault('AnalysisMET',{})[PHYSLITE_cfg.suffix] = PHYSLITE_cfg scheduleMETAssocAlg(sequence=SeqPHYSLITE,configlist="AnalysisMET") -#==================================================================== -# TRIGGER CONTENT -#==================================================================== -## See https://twiki.cern.ch/twiki/bin/view/Atlas/TriggerAPI -## Get single and multi mu, e, photon triggers -## Jet, tau, multi-object triggers not available in the matching code -allperiods = TriggerPeriod.y2015 | TriggerPeriod.y2016 | TriggerPeriod.y2017 | TriggerPeriod.y2018 | TriggerPeriod.future2e34 -trig_el = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, livefraction=0.8) -trig_mu = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, livefraction=0.8) -trig_g = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.g, livefraction=0.8) -trig_tau = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, livefraction=0.8) -## Add cross-triggers for some sets -trig_em = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.mu, livefraction=0.8) -trig_et = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.tau, livefraction=0.8) -trig_mt = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, additionalTriggerType=TriggerType.tau, livefraction=0.8) -## Note that this seems to pick up both isolated and non-isolated triggers already, so no need for extra grabs -trig_txe = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, additionalTriggerType=TriggerType.xe, livefraction=0.8) -# -## Merge and remove duplicates -trigger_names_full_notau = list(set(trig_el+trig_mu+trig_g+trig_em+trig_et+trig_mt)) -trigger_names_full_tau = list(set(trig_tau+trig_txe)) -# -## Now reduce the list... -trigger_names_notau = [] -trigger_names_tau = [] -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -from AthenaConfiguration.AutoConfigFlags import GetFileMD -from AthenaConfiguration.AllConfigFlags import ConfigFlags - -if ConfigFlags.Trigger.EDMVersion == 3: - r_tau = re.compile("HLT_.*tau.*") - r_notau = re.compile("HLT_[1-9]*(e|mu|g).*") - r_veto = re.compile("HLT_.*(LRT).*") - for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: - result_tau = r_tau.match(chain_name) - result_notau = r_notau.match(chain_name) - result_veto = r_veto.match(chain_name) - if result_tau is not None and result_veto is None: trigger_names_tau.append(chain_name) - if result_notau is not None and result_veto is None: trigger_names_notau.append(chain_name) - trigger_names_notau = set(trigger_names_notau) - set(trigger_names_tau) - trigger_names_notau = list(trigger_names_notau) -else: - for chain_name in GetFileMD(ConfigFlags.Input.Files)['TriggerMenu']['HLTChains']: - if chain_name in trigger_names_full_notau: trigger_names_notau.append(chain_name) - if chain_name in trigger_names_full_tau: trigger_names_tau.append(chain_name) -# Create trigger matching decorations -trigmatching_helper_notau = TriggerMatchingHelper(name='PHYSLITETriggerMatchingToolNoTau', - trigger_list = trigger_names_notau, add_to_df_job=True) -trigmatching_helper_tau = TriggerMatchingHelper(name='PHYSLITETriggerMatchingToolTau', - trigger_list = trigger_names_tau, add_to_df_job=True, DRThreshold=0.2) - # Create trigger matching decorations #trigmatching_helper_notau = TriggerMatchingHelper(name='PHSYLITETriggerMatchingToolNoTau', # OutputContainerPrefix = "Analysis", @@ -408,7 +256,6 @@ DerivationFrameworkJob += SeqPHYSLITE from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel SeqPHYSLITE += CfgMgr.DerivationFramework__DerivationKernel( "PHYSLITEKernel", - AugmentationTools = AugmentationTools, ThinningTools = thinningTools, ) #==================================================================== @@ -492,7 +339,7 @@ if DerivationFrameworkIsMonteCarlo: addTruth3ContentToSlimmerTool(PHYSLITESlimmingHelper) # Add trigger matching -trigmatching_helper_notau.add_to_slimming(PHYSLITESlimmingHelper) -trigmatching_helper_tau.add_to_slimming(PHYSLITESlimmingHelper) +PhysCommon.PhysCommon_trigmatching_helper_notau.add_to_slimming(PHYSLITESlimmingHelper) +PhysCommon.PhysCommon_trigmatching_helper_tau.add_to_slimming(PHYSLITESlimmingHelper) PHYSLITESlimmingHelper.AppendContentToStream(PHYSLITEStream) -- GitLab From fe7864475b29cb28a39b9dea01e6a6afd4705272 Mon Sep 17 00:00:00 2001 From: James Richard Catmore Date: Sat, 12 Jun 2021 17:12:19 +0200 Subject: [PATCH 2/2] Restoring `AntiKtVR30Rmax4Rmin02TrackJets` to the flavour tagging, as per the discussion. --- .../DerivationFrameworkPhys/python/PhysCommon.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py index ad72d252729..4fdaa4bfd52 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/python/PhysCommon.py @@ -27,9 +27,6 @@ import re ### Augmentation tools lists AugmentationTools = [] -#DerivationFrameworkJob = CfgMgr.AthSequencer("DerivationFrameworkJob") -#DerivationFrameworkJob += DerivationFrameworkJob - #==================================================================== # MONTE CARLO TRUTH #==================================================================== @@ -164,5 +161,5 @@ addDiTauLowPt(Seq=DerivationFrameworkJob) # FLAVOUR TAGGING #==================================================================== from DerivationFrameworkFlavourTag.FtagRun3DerivationConfig import FtagJetCollections -FtagJetCollections(['AntiKt4EMPFlowJets'],DerivationFrameworkJob) +FtagJetCollections(['AntiKt4EMPFlowJets','AntiKtVR30Rmax4Rmin02TrackJets'],DerivationFrameworkJob) -- GitLab