From 1738515ecacd9d2d57236d252a456af52735f0e0 Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:49:10 -0400 Subject: [PATCH 1/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/AsgAnalysisAlgorithmsTest.py | 174 ++++++++++++++++++ .../share/EventAlgorithmsTest_eljob.py | 44 +---- .../share/EventAlgorithmsTest_jobOptions.py | 45 +---- .../share/OverlapAlgorithmsTest_eljob.py | 145 +-------------- .../share/OverlapAlgorithmsTest_jobOptions.py | 143 +------------- 5 files changed, 190 insertions(+), 361 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..3640921d33a6 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisAlgorithmsTest.py @@ -0,0 +1,174 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Nils Krumnack +# @author Tadej Novak + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeOverlapSequence (dataType) : + algSeq = AlgSequence() + + # Skip events with no primary vertex: + algSeq += createAlgorithm( 'CP::VertexSelectionAlg', + 'PrimaryVertexSelectorAlg' ) + algSeq.PrimaryVertexSelectorAlg.VertexContainer = 'PrimaryVertices' + algSeq.PrimaryVertexSelectorAlg.MinVertices = 1 + + # Set up the systematics loader/handler algorithm: + algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + algSeq.SysLoaderAlg.sigmaRecommended = 1 + + # Include, and then set up the pileup analysis sequence: + from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ + makePileupAnalysisSequence + pileupSequence = makePileupAnalysisSequence( dataType ) + pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) + algSeq += pileupSequence + + # Include, and then set up the electron analysis sequence: + from EgammaAnalysisAlgorithms.ElectronAnalysisSequence import \ + makeElectronAnalysisSequence + electronSequence = makeElectronAnalysisSequence( dataType, 'LooseLHElectron.GradientLoose', + recomputeLikelihood = True ) + electronSequence.configure( inputName = 'Electrons', + outputName = 'AnalysisElectrons_%SYS%' ) + algSeq += electronSequence + + # Include, and then set up the photon analysis sequence: + from EgammaAnalysisAlgorithms.PhotonAnalysisSequence import \ + makePhotonAnalysisSequence + photonSequence = makePhotonAnalysisSequence( dataType, 'Tight.FixedCutTight', recomputeIsEM = True ) + photonSequence.configure( inputName = 'Photons', + outputName = 'AnalysisPhotons_%SYS%' ) + algSeq += photonSequence + + # Include, and then set up the muon analysis algorithm sequence: + from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence + muonSequence = makeMuonAnalysisSequence( dataType, 'Tight.Iso' ) + muonSequence.configure( inputName = 'Muons', + outputName = 'AnalysisMuons_%SYS%' ) + algSeq += muonSequence + + # Include, and then set up the jet analysis algorithm sequence: + jetContainer = 'AntiKt4EMTopoJets' + from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence + jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) + jetSequence.configure( inputName = jetContainer, + outputName = 'AnalysisJets_%SYS%' ) + algSeq += jetSequence + + # Include, and then set up the tau analysis algorithm sequence: + from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence + tauSequence = makeTauAnalysisSequence( dataType, 'Tight' ) + tauSequence.configure( inputName = 'TauJets', + outputName = 'AnalysisTauJets_%SYS%' ) + algSeq += tauSequence + + # Include, and then set up the overlap analysis algorithm sequence: + from AsgAnalysisAlgorithms.OverlapAnalysisSequence import \ + makeOverlapAnalysisSequence + overlapSequence = makeOverlapAnalysisSequence( dataType ) + overlapSequence.configure( + inputName = { + 'electrons' : 'AnalysisElectrons_%SYS%', + 'photons' : 'AnalysisPhotons_%SYS%', + 'muons' : 'AnalysisMuons_%SYS%', + 'jets' : 'AnalysisJets_%SYS%', + 'taus' : 'AnalysisTauJets_%SYS%' }, + outputName = { + 'electrons' : 'AnalysisElectronsOR_%SYS%', + 'photons' : 'AnalysisPhotonsOR_%SYS%', + 'muons' : 'AnalysisMuonsOR_%SYS%', + 'jets' : 'AnalysisJetsOR_%SYS%', + 'taus' : 'AnalysisTauJetsOR_%SYS%' }, + affectingSystematics = { + 'electrons' : electronSequence.affectingSystematics(), + 'photons' : photonSequence.affectingSystematics(), + 'muons' : muonSequence.affectingSystematics(), + 'jets' : jetSequence.affectingSystematics(), + 'taus' : tauSequence.affectingSystematics() } ) + algSeq += overlapSequence + + # Set up an ntuple to check the job with: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'particles' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) + ntupleMaker.TreeName = 'particles' + ntupleMaker.Branches = [ + 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', + 'AnalysisElectrons_%SYS%.eta -> el_%SYS%_eta', + 'AnalysisElectrons_%SYS%.phi -> el_%SYS%_phi', + 'AnalysisElectrons_%SYS%.pt -> el_%SYS%_pt', + 'AnalysisElectronsOR_%SYS%.eta -> el_OR_%SYS%_eta', + 'AnalysisElectronsOR_%SYS%.phi -> el_OR_%SYS%_phi', + 'AnalysisElectronsOR_%SYS%.pt -> el_OR_%SYS%_pt', + 'AnalysisPhotons_%SYS%.eta -> ph_%SYS%_eta', + 'AnalysisPhotons_%SYS%.phi -> ph_%SYS%_phi', + 'AnalysisPhotons_%SYS%.pt -> ph_%SYS%_pt', + 'AnalysisPhotonsOR_%SYS%.eta -> ph_OR_%SYS%_eta', + 'AnalysisPhotonsOR_%SYS%.phi -> ph_OR_%SYS%_phi', + 'AnalysisPhotonsOR_%SYS%.pt -> ph_OR_%SYS%_pt', + 'AnalysisMuons_%SYS%.eta -> mu_%SYS%_eta', + 'AnalysisMuons_%SYS%.phi -> mu_%SYS%_phi', + 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', + 'AnalysisMuonsOR_%SYS%.eta -> mu_OR_%SYS%_eta', + 'AnalysisMuonsOR_%SYS%.phi -> mu_OR_%SYS%_phi', + 'AnalysisMuonsOR_%SYS%.pt -> mu_OR_%SYS%_pt', + 'AnalysisJets_%SYS%.eta -> jet_%SYS%_eta', + 'AnalysisJets_%SYS%.phi -> jet_%SYS%_phi', + 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', + 'AnalysisJetsOR_%SYS%.eta -> jet_OR_%SYS%_eta', + 'AnalysisJetsOR_%SYS%.phi -> jet_OR_%SYS%_phi', + 'AnalysisJetsOR_%SYS%.pt -> jet_OR_%SYS%_pt', + 'AnalysisTauJets_%SYS%.eta -> tau_%SYS%_eta', + 'AnalysisTauJets_%SYS%.phi -> tau_%SYS%_phi', + 'AnalysisTauJets_%SYS%.pt -> tau_%SYS%_pt', + 'AnalysisTauJetsOR_%SYS%.eta -> tau_OR_%SYS%_eta', + 'AnalysisTauJetsOR_%SYS%.phi -> tau_OR_%SYS%_phi', + 'AnalysisTauJetsOR_%SYS%.pt -> tau_OR_%SYS%_pt' ] + ntupleMaker.systematicsRegex = '.*' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'particles' + algSeq += treeFiller + + return algSeq + +def makeEventAlgorithmsSequence (dataType) : + + # Config: + GRLFiles = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml'] + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + algSeq.SysLoaderAlg.sigmaRecommended = 1 + + # Include, and then set up the pileup analysis sequence: + from AsgAnalysisAlgorithms.EventSelectionAnalysisSequence import \ + makeEventSelectionAnalysisSequence + eventSelectionSequence = \ + makeEventSelectionAnalysisSequence( dataType, userGRLFiles=GRLFiles ) + algSeq += eventSelectionSequence + + # Set up an ntuple to check the job with: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'events' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) + ntupleMaker.TreeName = 'events' + ntupleMaker.Branches = [ + 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', + ] + ntupleMaker.systematicsRegex = '.*' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'events' + algSeq += treeFiller + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_eljob.py index 9442ce1df183..e2f4929de9a2 100755 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_eljob.py @@ -52,47 +52,9 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Config: -GRLFiles = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml'] - -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.EventSelectionAnalysisSequence import \ - makeEventSelectionAnalysisSequence -eventSelectionSequence = \ - makeEventSelectionAnalysisSequence( dataType, userGRLFiles=GRLFiles ) -algSeq += eventSelectionSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'events' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'events' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', -] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'events' -algSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. +from AsgAnalysisAlgorithms.AsgAnalysisAlgorithmsTest import makeEventAlgorithmsSequence +algSeq = makeEventAlgorithmsSequence (dataType) +print algSeq # For debugging for alg in algSeq: job.algsAdd( alg ) pass diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_jobOptions.py index 51ff6adecae4..11d48f64c18c 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/EventAlgorithmsTest_jobOptions.py @@ -17,48 +17,9 @@ theApp.EvtMax = 500 testFile = os.getenv ( inputfile[dataType] ) svcMgr.EventSelector.InputCollections = [testFile] -# Config: -GRLFiles = ['GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml'] - -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.EventSelectionAnalysisSequence import \ - makeEventSelectionAnalysisSequence -eventSelectionSequence = \ - makeEventSelectionAnalysisSequence( dataType, userGRLFiles=GRLFiles ) -algSeq += eventSelectionSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'events' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'events' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', -] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'events' -algSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. -athAlgSeq += algSeq +from AsgAnalysisAlgorithms.AsgAnalysisAlgorithmsTest import makeEventAlgorithmsSequence +algSeq = makeEventAlgorithmsSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_eljob.py index 0516d4249453..9e84437af87f 100755 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_eljob.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -52,147 +52,14 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Skip events with no primary vertex: -algSeq += createAlgorithm( 'CP::VertexSelectionAlg', - 'PrimaryVertexSelectorAlg' ) -algSeq.PrimaryVertexSelectorAlg.VertexContainer = 'PrimaryVertices' -algSeq.PrimaryVertexSelectorAlg.MinVertices = 1 - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -algSeq += pileupSequence - -# Include, and then set up the electron analysis sequence: -from EgammaAnalysisAlgorithms.ElectronAnalysisSequence import \ - makeElectronAnalysisSequence -electronSequence = makeElectronAnalysisSequence( dataType, 'LooseLHElectron.GradientLoose', - recomputeLikelihood = True ) -electronSequence.configure( inputName = 'Electrons', - outputName = 'AnalysisElectrons_%SYS%' ) -algSeq += electronSequence - -# Include, and then set up the photon analysis sequence: -from EgammaAnalysisAlgorithms.PhotonAnalysisSequence import \ - makePhotonAnalysisSequence -photonSequence = makePhotonAnalysisSequence( dataType, 'Tight.FixedCutTight', recomputeIsEM = True ) -photonSequence.configure( inputName = 'Photons', - outputName = 'AnalysisPhotons_%SYS%' ) -algSeq += photonSequence - -# Include, and then set up the muon analysis algorithm sequence: -from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence -muonSequence = makeMuonAnalysisSequence( dataType, 'Tight.Iso' ) -muonSequence.configure( inputName = 'Muons', - outputName = 'AnalysisMuons_%SYS%' ) -algSeq += muonSequence - -# Include, and then set up the jet analysis algorithm sequence: -jetContainer = 'AntiKt4EMTopoJets' -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, - outputName = 'AnalysisJets_%SYS%' ) -algSeq += jetSequence - -# Include, and then set up the tau analysis algorithm sequence: -from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence -tauSequence = makeTauAnalysisSequence( dataType, 'Tight' ) -tauSequence.configure( inputName = 'TauJets', - outputName = 'AnalysisTauJets_%SYS%' ) -algSeq += tauSequence - -# Include, and then set up the overlap analysis algorithm sequence: -from AsgAnalysisAlgorithms.OverlapAnalysisSequence import \ - makeOverlapAnalysisSequence -overlapSequence = makeOverlapAnalysisSequence( dataType ) -overlapSequence.configure( - inputName = { - 'electrons' : 'AnalysisElectrons_%SYS%', - 'photons' : 'AnalysisPhotons_%SYS%', - 'muons' : 'AnalysisMuons_%SYS%', - 'jets' : 'AnalysisJets_%SYS%', - 'taus' : 'AnalysisTauJets_%SYS%' }, - outputName = { - 'electrons' : 'AnalysisElectronsOR_%SYS%', - 'photons' : 'AnalysisPhotonsOR_%SYS%', - 'muons' : 'AnalysisMuonsOR_%SYS%', - 'jets' : 'AnalysisJetsOR_%SYS%', - 'taus' : 'AnalysisTauJetsOR_%SYS%' }, - affectingSystematics = { - 'electrons' : electronSequence.affectingSystematics(), - 'photons' : photonSequence.affectingSystematics(), - 'muons' : muonSequence.affectingSystematics(), - 'jets' : jetSequence.affectingSystematics(), - 'taus' : tauSequence.affectingSystematics() } ) -algSeq += overlapSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'particles' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'particles' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisElectrons_%SYS%.eta -> el_%SYS%_eta', - 'AnalysisElectrons_%SYS%.phi -> el_%SYS%_phi', - 'AnalysisElectrons_%SYS%.pt -> el_%SYS%_pt', - 'AnalysisElectronsOR_%SYS%.eta -> el_OR_%SYS%_eta', - 'AnalysisElectronsOR_%SYS%.phi -> el_OR_%SYS%_phi', - 'AnalysisElectronsOR_%SYS%.pt -> el_OR_%SYS%_pt', - 'AnalysisPhotons_%SYS%.eta -> ph_%SYS%_eta', - 'AnalysisPhotons_%SYS%.phi -> ph_%SYS%_phi', - 'AnalysisPhotons_%SYS%.pt -> ph_%SYS%_pt', - 'AnalysisPhotonsOR_%SYS%.eta -> ph_OR_%SYS%_eta', - 'AnalysisPhotonsOR_%SYS%.phi -> ph_OR_%SYS%_phi', - 'AnalysisPhotonsOR_%SYS%.pt -> ph_OR_%SYS%_pt', - 'AnalysisMuons_%SYS%.eta -> mu_%SYS%_eta', - 'AnalysisMuons_%SYS%.phi -> mu_%SYS%_phi', - 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', - 'AnalysisMuonsOR_%SYS%.eta -> mu_OR_%SYS%_eta', - 'AnalysisMuonsOR_%SYS%.phi -> mu_OR_%SYS%_phi', - 'AnalysisMuonsOR_%SYS%.pt -> mu_OR_%SYS%_pt', - 'AnalysisJets_%SYS%.eta -> jet_%SYS%_eta', - 'AnalysisJets_%SYS%.phi -> jet_%SYS%_phi', - 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', - 'AnalysisJetsOR_%SYS%.eta -> jet_OR_%SYS%_eta', - 'AnalysisJetsOR_%SYS%.phi -> jet_OR_%SYS%_phi', - 'AnalysisJetsOR_%SYS%.pt -> jet_OR_%SYS%_pt', - 'AnalysisTauJets_%SYS%.eta -> tau_%SYS%_eta', - 'AnalysisTauJets_%SYS%.phi -> tau_%SYS%_phi', - 'AnalysisTauJets_%SYS%.pt -> tau_%SYS%_pt', - 'AnalysisTauJetsOR_%SYS%.eta -> tau_OR_%SYS%_eta', - 'AnalysisTauJetsOR_%SYS%.phi -> tau_OR_%SYS%_phi', - 'AnalysisTauJetsOR_%SYS%.pt -> tau_OR_%SYS%_pt' ] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'particles' -algSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. -for alg in algSeq: +from AsgAnalysisAlgorithms.AsgAnalysisAlgorithmsTest import makeOverlapSequence +algSeq = makeOverlapSequence (dataType) +print algSeq # For debugging +for alg in algSeq : job.algsAdd( alg ) pass + # Set up an output file for the job: job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) ) diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_jobOptions.py index 74ef215612dd..5ae88bd73113 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/share/OverlapAlgorithmsTest_jobOptions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -17,144 +17,9 @@ theApp.EvtMax = 500 testFile = os.getenv ( inputfile[dataType] ) svcMgr.EventSelector.InputCollections = [testFile] -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Skip events with no primary vertex: -algSeq += createAlgorithm( 'CP::VertexSelectionAlg', - 'PrimaryVertexSelectorAlg' ) -algSeq.PrimaryVertexSelectorAlg.VertexContainer = 'PrimaryVertices' -algSeq.PrimaryVertexSelectorAlg.MinVertices = 1 - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -algSeq += pileupSequence - -# Include, and then set up the electron analysis sequence: -from EgammaAnalysisAlgorithms.ElectronAnalysisSequence import \ - makeElectronAnalysisSequence -electronSequence = makeElectronAnalysisSequence( dataType, 'LooseLHElectron.GradientLoose', - recomputeLikelihood = True ) -electronSequence.configure( inputName = 'Electrons', - outputName = 'AnalysisElectrons_%SYS%' ) -algSeq += electronSequence - -# Include, and then set up the photon analysis sequence: -from EgammaAnalysisAlgorithms.PhotonAnalysisSequence import \ - makePhotonAnalysisSequence -photonSequence = makePhotonAnalysisSequence( dataType, 'Tight.FixedCutTight', recomputeIsEM = True ) -photonSequence.configure( inputName = 'Photons', - outputName = 'AnalysisPhotons_%SYS%' ) -algSeq += photonSequence - -# Include, and then set up the muon analysis algorithm sequence: -from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence -muonSequence = makeMuonAnalysisSequence( dataType, 'Tight.Iso' ) -muonSequence.configure( inputName = 'Muons', - outputName = 'AnalysisMuons_%SYS%' ) -algSeq += muonSequence - -# Include, and then set up the jet analysis algorithm sequence: -jetContainer = 'AntiKt4EMTopoJets' -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, - outputName = 'AnalysisJets_%SYS%' ) -algSeq += jetSequence - -# Include, and then set up the tau analysis algorithm sequence: -from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence -tauSequence = makeTauAnalysisSequence( dataType, 'Tight' ) -tauSequence.configure( inputName = 'TauJets', - outputName = 'AnalysisTauJets_%SYS%' ) -algSeq += tauSequence - -# Include, and then set up the overlap analysis algorithm sequence: -from AsgAnalysisAlgorithms.OverlapAnalysisSequence import \ - makeOverlapAnalysisSequence -overlapSequence = makeOverlapAnalysisSequence( dataType ) -overlapSequence.configure( - inputName = { - 'electrons' : 'AnalysisElectrons_%SYS%', - 'photons' : 'AnalysisPhotons_%SYS%', - 'muons' : 'AnalysisMuons_%SYS%', - 'jets' : 'AnalysisJets_%SYS%', - 'taus' : 'AnalysisTauJets_%SYS%' }, - outputName = { - 'electrons' : 'AnalysisElectronsOR_%SYS%', - 'photons' : 'AnalysisPhotonsOR_%SYS%', - 'muons' : 'AnalysisMuonsOR_%SYS%', - 'jets' : 'AnalysisJetsOR_%SYS%', - 'taus' : 'AnalysisTauJetsOR_%SYS%' }, - affectingSystematics = { - 'electrons' : electronSequence.affectingSystematics(), - 'photons' : photonSequence.affectingSystematics(), - 'muons' : muonSequence.affectingSystematics(), - 'jets' : jetSequence.affectingSystematics(), - 'taus' : tauSequence.affectingSystematics() } ) -algSeq += overlapSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'particles' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'particles' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisElectrons_%SYS%.eta -> el_%SYS%_eta', - 'AnalysisElectrons_%SYS%.phi -> el_%SYS%_phi', - 'AnalysisElectrons_%SYS%.pt -> el_%SYS%_pt', - 'AnalysisElectronsOR_%SYS%.eta -> el_OR_%SYS%_eta', - 'AnalysisElectronsOR_%SYS%.phi -> el_OR_%SYS%_phi', - 'AnalysisElectronsOR_%SYS%.pt -> el_OR_%SYS%_pt', - 'AnalysisPhotons_%SYS%.eta -> ph_%SYS%_eta', - 'AnalysisPhotons_%SYS%.phi -> ph_%SYS%_phi', - 'AnalysisPhotons_%SYS%.pt -> ph_%SYS%_pt', - 'AnalysisPhotonsOR_%SYS%.eta -> ph_OR_%SYS%_eta', - 'AnalysisPhotonsOR_%SYS%.phi -> ph_OR_%SYS%_phi', - 'AnalysisPhotonsOR_%SYS%.pt -> ph_OR_%SYS%_pt', - 'AnalysisMuons_%SYS%.eta -> mu_%SYS%_eta', - 'AnalysisMuons_%SYS%.phi -> mu_%SYS%_phi', - 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', - 'AnalysisMuonsOR_%SYS%.eta -> mu_OR_%SYS%_eta', - 'AnalysisMuonsOR_%SYS%.phi -> mu_OR_%SYS%_phi', - 'AnalysisMuonsOR_%SYS%.pt -> mu_OR_%SYS%_pt', - 'AnalysisJets_%SYS%.eta -> jet_%SYS%_eta', - 'AnalysisJets_%SYS%.phi -> jet_%SYS%_phi', - 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', - 'AnalysisJetsOR_%SYS%.eta -> jet_OR_%SYS%_eta', - 'AnalysisJetsOR_%SYS%.phi -> jet_OR_%SYS%_phi', - 'AnalysisJetsOR_%SYS%.pt -> jet_OR_%SYS%_pt', - 'AnalysisTauJets_%SYS%.eta -> tau_%SYS%_eta', - 'AnalysisTauJets_%SYS%.phi -> tau_%SYS%_phi', - 'AnalysisTauJets_%SYS%.pt -> tau_%SYS%_pt', - 'AnalysisTauJetsOR_%SYS%.eta -> tau_OR_%SYS%_eta', - 'AnalysisTauJetsOR_%SYS%.phi -> tau_OR_%SYS%_phi', - 'AnalysisTauJetsOR_%SYS%.pt -> tau_OR_%SYS%_pt' ] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'particles' -algSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. -athAlgSeq += algSeq +from AsgAnalysisAlgorithms.AsgAnalysisAlgorithmsTest import makeOverlapSequence +algSeq = makeOverlapSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab From e1a5eb123cfe95ec15002c2c938ff1fe3ad09fdd Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:52:55 -0400 Subject: [PATCH 2/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/FTagAnalysisAlgorithmsTest.py | 30 +++++++++++++++++++ .../share/FTagAnalysisAlgorithmsTest_eljob.py | 24 ++++----------- .../FTagAnalysisAlgorithmsTest_jobOptions.py | 25 +++------------- 3 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..194c018f396c --- /dev/null +++ b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/python/FTagAnalysisAlgorithmsTest.py @@ -0,0 +1,30 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Nils Krumnack + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + + # config parameters + jetContainer = "AntiKt4EMTopoJets" + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + sysLoader = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + sysLoader.sigmaRecommended = 1 + algSeq += sysLoader + + # Include, and then set up the jet analysis algorithm sequence: + from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence + jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) + from FTagAnalysisAlgorithms.FTagAnalysisSequence import makeFTagAnalysisSequence + makeFTagAnalysisSequence( jetSequence, dataType, jetContainer, noEfficiency = True ) + jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) + + # Add the sequence to the job: + algSeq += jetSequence + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_eljob.py index c2e9d96977c9..b584d43df2eb 100755 --- a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_eljob.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -39,8 +39,6 @@ inputfile = {"data": 'ASG_TEST_FILE_DATA', "mc": 'ASG_TEST_FILE_MC', "afii": 'ASG_TEST_FILE_MC_AFII'} -jetContainer = "AntiKt4EMTopoJets" - if not dataType in ["data", "mc", "afii"] : raise ValueError ("invalid data type: " + dataType) @@ -59,22 +57,10 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Set up the systematics loader/handler algorithm: -from AnaAlgorithm.AnaAlgorithmConfig import AnaAlgorithmConfig -config = AnaAlgorithmConfig( 'CP::SysListLoaderAlg/SysLoaderAlg' ) -config.sigmaRecommended = 1 -job.algsAdd( config ) - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -from FTagAnalysisAlgorithms.FTagAnalysisSequence import makeFTagAnalysisSequence -makeFTagAnalysisSequence( jetSequence, dataType, jetContainer, noEfficiency = True ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) -print( jetSequence ) # For debugging - -# Add all algorithms to the job: -for alg in jetSequence: +from FTagAnalysisAlgorithms.FTagAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging +for alg in algSeq: job.algsAdd( alg ) pass diff --git a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_jobOptions.py index 2640da0d5dc2..5d497900c833 100644 --- a/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/FTagAnalysisAlgorithms/share/FTagAnalysisAlgorithmsTest_jobOptions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -10,7 +10,6 @@ dataType = "data" inputfile = {"data": 'ASG_TEST_FILE_DATA', "mc": 'ASG_TEST_FILE_MC', "afii": 'ASG_TEST_FILE_MC_AFII'} -jetContainer = "AntiKt4EMTopoJets" # Set up the reading of the input file: import AthenaRootComps.ReadAthenaxAODHybrid @@ -18,25 +17,9 @@ theApp.EvtMax = 500 testFile = os.getenv ( inputfile[dataType] ) svcMgr.EventSelector.InputCollections = [testFile] -# Access the main algorithm sequence of the job: -from AthenaCommon.AlgSequence import AlgSequence -algSeq = AlgSequence() - -# Set up the systematics loader/handler algorithm: -sysLoader = CfgMgr.CP__SysListLoaderAlg( 'SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -algSeq += sysLoader - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -from FTagAnalysisAlgorithms.FTagAnalysisSequence import makeFTagAnalysisSequence -makeFTagAnalysisSequence( jetSequence, dataType, jetContainer, noEfficiency = True ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) -print( jetSequence ) # For debugging - -# Add the sequence to the job: -algSeq += jetSequence +from FTagAnalysisAlgorithms.FTagAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab From 407ed4316173e86f34ec3d74b97a380da3a23a9a Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:54:22 -0400 Subject: [PATCH 3/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/JetAnalysisAlgorithmsTest.py | 71 +++++++++++++++++++ .../share/JetAnalysisAlgorithmsTest_eljob.py | 67 ++--------------- .../JetAnalysisAlgorithmsTest_jobOptions.py | 64 +---------------- 3 files changed, 78 insertions(+), 124 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/python/JetAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/python/JetAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/python/JetAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..5951ef18a650 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/python/JetAnalysisAlgorithmsTest.py @@ -0,0 +1,71 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Nils Krumnack + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + + # config + jetContainer = "AntiKt4EMTopoJets" + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + sysLoader = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + sysLoader.sigmaRecommended = 1 + algSeq += sysLoader + + # Include, and then set up the pileup analysis sequence: + from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ + makePileupAnalysisSequence + pileupSequence = makePileupAnalysisSequence( dataType ) + pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) + print( pileupSequence ) # For debugging + + # Include, and then set up the jet analysis algorithm sequence: + from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence + jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) + jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJetsBase' ) + print( jetSequence ) # For debugging + + # Include, and then set up the jet analysis algorithm sequence: + from JetAnalysisAlgorithms.JetJvtAnalysisSequence import makeJetJvtAnalysisSequence + jvtSequence = makeJetJvtAnalysisSequence( dataType, jetContainer ) + jvtSequence.configure( inputName = { 'eventInfo' : 'EventInfo_%SYS%', + 'jets' : 'AnalysisJetsBase_%SYS%' }, + outputName = { 'jets' : 'AnalysisJets_%SYS%' }, + affectingSystematics = { 'jets' : jetSequence.affectingSystematics() } ) + print( jvtSequence ) # For debugging + + # Add the sequences to the job: + algSeq += pileupSequence + algSeq += jetSequence + algSeq += jvtSequence + + # Set up an ntuple to check the job with: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'jets' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) + ntupleMaker.TreeName = 'jets' + ntupleMaker.Branches = [ + 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', + 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', + ] + if dataType != 'data': + ntupleMaker.Branches += [ + # 'EventInfo.jvt_effSF_%SYS% -> jvtSF_%SYS%', + # 'EventInfo.fjvt_effSF_%SYS% -> fjvtSF_%SYS%', + 'AnalysisJets_%SYS%.jvt_effSF_NOSYS -> jet_%SYS%_jvtEfficiency', + 'AnalysisJets_%SYS%.fjvt_effSF_NOSYS -> jet_%SYS%_fjvtEfficiency', + ] + ntupleMaker.systematicsRegex = '(^$)|(^JET_.*)' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'jets' + algSeq += treeFiller + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_eljob.py index 07b432b352ce..44a51e538611 100755 --- a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_eljob.py @@ -59,72 +59,13 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Set up the systematics loader/handler algorithm: -from AnaAlgorithm.AnaAlgorithmConfig import AnaAlgorithmConfig -config = AnaAlgorithmConfig( 'CP::SysListLoaderAlg/SysLoaderAlg' ) -config.sigmaRecommended = 1 -job.algsAdd( config ) - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -print( pileupSequence ) # For debugging - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJetsBase' ) -print( jetSequence ) # For debugging - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetJvtAnalysisSequence import makeJetJvtAnalysisSequence -jvtSequence = makeJetJvtAnalysisSequence( dataType, jetContainer ) -jvtSequence.configure( inputName = { 'eventInfo' : 'EventInfo_%SYS%', - 'jets' : 'AnalysisJetsBase_%SYS%' }, - outputName = { 'jets' : 'AnalysisJets_%SYS%' }, - affectingSystematics = { 'jets' : jetSequence.affectingSystematics() } ) -print( jvtSequence ) # For debugging - -# Add all algorithms to the job: -for alg in pileupSequence: +from JetAnalysisAlgorithms.JetAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging +for alg in algSeq: job.algsAdd( alg ) pass -for alg in jetSequence: - job.algsAdd( alg ) - pass - -for alg in jvtSequence: - job.algsAdd( alg ) - pass - -# Set up an ntuple to check the job with: -from AnaAlgorithm.DualUseConfig import createAlgorithm -treeMaker = AnaAlgorithmConfig( 'CP::TreeMakerAlg/TreeMaker' ) -treeMaker.TreeName = 'jets' -job.algsAdd( treeMaker ) -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'jets' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', -] -if dataType != 'data': - ntupleMaker.Branches += [ - # 'EventInfo.jvt_effSF_%SYS% -> jvtSF_%SYS%', - # 'EventInfo.fjvt_effSF_%SYS% -> fjvtSF_%SYS%', - 'AnalysisJets_%SYS%.jvt_effSF_NOSYS -> jet_%SYS%_jvtEfficiency', - 'AnalysisJets_%SYS%.fjvt_effSF_NOSYS -> jet_%SYS%_fjvtEfficiency', - ] -ntupleMaker.systematicsRegex = '(^$)|(^JET_.*)' -job.algsAdd( ntupleMaker ) -treeFiller = AnaAlgorithmConfig( 'CP::TreeFillerAlg/TreeFiller' ) -treeFiller.TreeName = 'jets' -job.algsAdd( treeFiller ) - # Set up an output file for the job: job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) ) diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_jobOptions.py index e4e0c297b4b8..6a73a2851f97 100644 --- a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/share/JetAnalysisAlgorithmsTest_jobOptions.py @@ -10,7 +10,6 @@ dataType = "mc" inputfile = {"data": 'ASG_TEST_FILE_DATA', "mc": 'ASG_TEST_FILE_MC', "afii": 'ASG_TEST_FILE_MC_AFII'} -jetContainer = "AntiKt4EMTopoJets" # Set up the reading of the input file: import AthenaRootComps.ReadAthenaxAODHybrid @@ -18,66 +17,9 @@ theApp.EvtMax = 500 testFile = os.getenv ( inputfile[dataType] ) svcMgr.EventSelector.InputCollections = [testFile] -# Access the main algorithm sequence of the job: -from AthenaCommon.AlgSequence import AlgSequence -algSeq = AlgSequence() - -# Set up the systematics loader/handler algorithm: -sysLoader = CfgMgr.CP__SysListLoaderAlg( 'SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -algSeq += sysLoader - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -print( pileupSequence ) # For debugging - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJetsBase' ) -print( jetSequence ) # For debugging - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetJvtAnalysisSequence import makeJetJvtAnalysisSequence -jvtSequence = makeJetJvtAnalysisSequence( dataType, jetContainer ) -jvtSequence.configure( inputName = { 'eventInfo' : 'EventInfo_%SYS%', - 'jets' : 'AnalysisJetsBase_%SYS%' }, - outputName = { 'jets' : 'AnalysisJets_%SYS%' }, - affectingSystematics = { 'jets' : jetSequence.affectingSystematics() } ) -print( jvtSequence ) # For debugging - -# Add the sequences to the job: -algSeq += pileupSequence -algSeq += jetSequence -algSeq += jvtSequence - -# Set up an ntuple to check the job with: -from AnaAlgorithm.DualUseConfig import createAlgorithm -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'jets' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'jets' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisJets_%SYS%.pt -> jet_%SYS%_pt', -] -if dataType != 'data': - ntupleMaker.Branches += [ - # 'EventInfo.jvt_effSF_%SYS% -> jvtSF_%SYS%', - # 'EventInfo.fjvt_effSF_%SYS% -> fjvtSF_%SYS%', - 'AnalysisJets_%SYS%.jvt_effSF_NOSYS -> jet_%SYS%_jvtEfficiency', - 'AnalysisJets_%SYS%.fjvt_effSF_NOSYS -> jet_%SYS%_fjvtEfficiency', - ] -ntupleMaker.systematicsRegex = '(^$)|(^JET_.*)' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'jets' -algSeq += treeFiller +from JetAnalysisAlgorithms.JetAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab From e6d17b76f361d2f855357d509782c2e901b389ca Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:55:07 -0400 Subject: [PATCH 4/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/MetAnalysisAlgorithmsTest.py | 78 ++++++++++++++++++ .../share/MetAnalysisAlgorithmsTest_eljob.py | 79 ++----------------- .../MetAnalysisAlgorithmsTest_jobOptions.py | 75 +----------------- 3 files changed, 88 insertions(+), 144 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..a8d263ca2919 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/python/MetAnalysisAlgorithmsTest.py @@ -0,0 +1,78 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + algSeq = AlgSequence() + + from AnaAlgorithm.DualUseConfig import createAlgorithm + + # Set up the systematics loader/handler algorithm: + sysLoader = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + sysLoader.sigmaRecommended = 1 + algSeq += sysLoader + + # Include, and then set up the jet analysis algorithm sequence: + from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence + jetContainer = 'AntiKt4EMTopoJets' + jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) + jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) + + # Add all algorithms to the job: + algSeq += jetSequence + + # Set up a selection alg for demonstration purposes + # Also to avoid warnings from building MET with very soft electrons + from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool + selalg = createAlgorithm( 'CP::AsgSelectionAlg', 'METEleSelAlg' ) + addPrivateTool( selalg, 'selectionTool', 'CP::AsgPtEtaSelectionTool' ) + selalg.selectionTool.minPt = 10e3 + selalg.selectionTool.maxEta = 2.47 + selalg.selectionDecoration = 'selectPtEta' + selalg.particles = 'Electrons' + # We need to copy here, because w/o an output container, it's assumed + # that the input container is non-const + selalg.particlesOut = 'DecorElectrons_%SYS%' + algSeq += selalg + + # Now make a view container holding only the electrons for the MET calculation + viewalg = createAlgorithm( 'CP::AsgViewFromSelectionAlg','METEleViewAlg' ) + viewalg.selection = [ 'selectPtEta' ] + viewalg.input = 'DecorElectrons_%SYS%' + viewalg.output = 'METElectrons_%SYS%' + algSeq += viewalg + + # Include, and then set up the met analysis algorithm sequence: + from MetAnalysisAlgorithms.MetAnalysisSequence import makeMetAnalysisSequence + metSequence = makeMetAnalysisSequence( dataType, metSuffix = jetContainer[:-4] ) + metSequence.configure( inputName = { 'jets' : 'AnalysisJets_%SYS%', + 'muons' : 'Muons', + 'electrons' : 'METElectrons_%SYS%' }, + outputName = 'AnalysisMET_%SYS%', + affectingSystematics = { 'jets' : jetSequence.affectingSystematics(), + 'muons' : '(^$)', + 'electrons' : '(^$)' } ) + + # Add the sequence to the job: + algSeq += metSequence + + # Write the freshly produced MET object(s) to an output file: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'met' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) + ntupleMaker.TreeName = 'met' + ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', + 'AnalysisMET_%SYS%.mpx -> met_%SYS%_mpx', + 'AnalysisMET_%SYS%.mpy -> met_%SYS%_mpy', + 'AnalysisMET_%SYS%.sumet -> met_%SYS%_sumet', + 'AnalysisMET_%SYS%.name -> met_%SYS%_name', ] + ntupleMaker.systematicsRegex = '.*' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'met' + algSeq += treeFiller + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_eljob.py index 513fc3a09ed0..8599ff5aa033 100755 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_eljob.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -59,82 +59,15 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Set up the systematics loader/handler algorithm: -sysLoader = AnaAlgorithmConfig( 'CP::SysListLoaderAlg/SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -job.algsAdd( sysLoader ) - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetContainer = 'AntiKt4EMTopoJets' -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) -print( jetSequence ) # For debugging - -# Add all algorithms to the job: -for alg in jetSequence: - job.algsAdd( alg ) - pass - -# Set up a selection alg for demonstration purposes -# Also to avoid warnings from building MET with very soft electrons -from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool -selalg = createAlgorithm( 'CP::AsgSelectionAlg', 'METEleSelAlg' ) -addPrivateTool( selalg, 'selectionTool', 'CP::AsgPtEtaSelectionTool' ) -selalg.selectionTool.minPt = 10e3 -selalg.selectionTool.maxEta = 2.47 -selalg.selectionDecoration = 'selectPtEta' -selalg.particles = 'Electrons' -# We need to copy here, because w/o an output container, it's assumed -# that the input container is non-const -selalg.particlesOut = 'DecorElectrons_%SYS%' -job.algsAdd( selalg ) -print( selalg ) # For debugging - -# Now make a view container holding only the electrons for the MET calculation -viewalg = createAlgorithm( 'CP::AsgViewFromSelectionAlg','METEleViewAlg' ) -viewalg.selection = [ 'selectPtEta' ] -viewalg.input = 'DecorElectrons_%SYS%' -viewalg.output = 'METElectrons_%SYS%' -job.algsAdd( viewalg ) -print( viewalg ) # For debugging - -# Include, and then set up the met analysis algorithm sequence: -from MetAnalysisAlgorithms.MetAnalysisSequence import makeMetAnalysisSequence -metSequence = makeMetAnalysisSequence( dataType, metSuffix = jetContainer[:-4] ) -metSequence.configure( inputName = { 'jets' : 'AnalysisJets_%SYS%', - 'muons' : 'Muons', - 'electrons' : 'METElectrons_%SYS%' }, - outputName = 'AnalysisMET_%SYS%', - affectingSystematics = { 'jets' : jetSequence.affectingSystematics(), - 'muons' : '(^$)', - 'electrons' : '(^$)' } ) -print( metSequence ) # For debugging +job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) ) -# Add all algorithms to the job: -for alg in metSequence: +from MetAnalysisAlgorithms.MetAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging +for alg in algSeq: job.algsAdd( alg ) pass -# Write the freshly produced MET object(s) to an output file: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'met' -job.algsAdd( treeMaker ) -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'met' -ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisMET_%SYS%.mpx -> met_%SYS%_mpx', - 'AnalysisMET_%SYS%.mpy -> met_%SYS%_mpy', - 'AnalysisMET_%SYS%.sumet -> met_%SYS%_sumet', - 'AnalysisMET_%SYS%.name -> met_%SYS%_name', ] -ntupleMaker.systematicsRegex = '.*' -job.algsAdd( ntupleMaker ) -job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) ) -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'met' -job.algsAdd( treeFiller ) - # Find the right output directory: submitDir = options.submission_dir if options.unit_test: diff --git a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_jobOptions.py index e9b9a9a2447f..5c52cbae376b 100644 --- a/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/MetAnalysisAlgorithms/share/MetAnalysisAlgorithmsTest_jobOptions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -18,76 +18,9 @@ dataType = "data" #dataType = "mc" #dataType = "afii" -# Set up the systematics loader/handler algorithm: -sysLoader = CfgMgr.CP__SysListLoaderAlg( 'SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -algSeq += sysLoader - -# Include, and then set up the jet analysis algorithm sequence: -from JetAnalysisAlgorithms.JetAnalysisSequence import makeJetAnalysisSequence -jetContainer = 'AntiKt4EMTopoJets' -jetSequence = makeJetAnalysisSequence( dataType, jetContainer ) -jetSequence.configure( inputName = jetContainer, outputName = 'AnalysisJets' ) -print( jetSequence ) # For debugging - -# Add all algorithms to the job: -algSeq += jetSequence - -# Set up a selection alg for demonstration purposes -# Also to avoid warnings from building MET with very soft electrons -from AnaAlgorithm.DualUseConfig import createAlgorithm, addPrivateTool -selalg = createAlgorithm( 'CP::AsgSelectionAlg', 'METEleSelAlg' ) -addPrivateTool( selalg, 'selectionTool', 'CP::AsgPtEtaSelectionTool' ) -selalg.selectionTool.minPt = 10e3 -selalg.selectionTool.maxEta = 2.47 -selalg.selectionDecoration = 'selectPtEta' -selalg.particles = 'Electrons' -# We need to copy here, because w/o an output container, it's assumed -# that the input container is non-const -selalg.particlesOut = 'DecorElectrons_%SYS%' -algSeq += selalg -print( selalg ) # For debugging - -# Now make a view container holding only the electrons for the MET calculation -viewalg = createAlgorithm( 'CP::AsgViewFromSelectionAlg','METEleViewAlg' ) -viewalg.selection = [ 'selectPtEta' ] -viewalg.input = 'DecorElectrons_%SYS%' -viewalg.output = 'METElectrons_%SYS%' -algSeq += viewalg -print( viewalg ) # For debugging - -# Include, and then set up the met analysis algorithm sequence: -from MetAnalysisAlgorithms.MetAnalysisSequence import makeMetAnalysisSequence -metSequence = makeMetAnalysisSequence( dataType, metSuffix = jetContainer[:-4] ) -metSequence.configure( inputName = { 'jets' : 'AnalysisJets_%SYS%', - 'muons' : 'Muons', - 'electrons' : 'METElectrons_%SYS%' }, - outputName = 'AnalysisMET_%SYS%', - affectingSystematics = { 'jets' : jetSequence.affectingSystematics(), - 'muons' : '(^$)', - 'electrons' : '(^$)' } ) -print( metSequence ) # For debugging - -# Add the sequence to the job: -algSeq += metSequence - -# Write the freshly produced MET object(s) to an output file: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'met' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'met' -ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', - 'AnalysisMET_%SYS%.mpx -> met_%SYS%_mpx', - 'AnalysisMET_%SYS%.mpy -> met_%SYS%_mpy', - 'AnalysisMET_%SYS%.sumet -> met_%SYS%_sumet', - 'AnalysisMET_%SYS%.name -> met_%SYS%_name', ] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'met' -algSeq += treeFiller +from MetAnalysisAlgorithms.MetAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab From 11f364e13262df9c72e55f3e79a45d0e585d6b61 Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:56:13 -0400 Subject: [PATCH 5/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/MuonAnalysisAlgorithmsTest.py | 68 ++++++++++++++++ .../share/MuonAnalysisAlgorithmsTest_eljob.py | 78 ++----------------- .../MuonAnalysisAlgorithmsTest_jobOptions.py | 64 +-------------- 3 files changed, 77 insertions(+), 133 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..c5608c84c481 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisAlgorithmsTest.py @@ -0,0 +1,68 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Nils Krumnack + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + sysLoader = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + sysLoader.sigmaRecommended = 1 + algSeq += sysLoader + + + # Include, and then set up the pileup analysis sequence: + from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ + makePileupAnalysisSequence + pileupSequence = makePileupAnalysisSequence( dataType ) + pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) + + # Add the pileup sequence to the job: + algSeq += pileupSequence + + # Include, and then set up the muon analysis algorithm sequence: + from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence + muonSequenceMedium = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, + workingPoint = 'Medium.Iso', postfix = 'medium' ) + muonSequenceMedium.configure( inputName = 'Muons', + outputName = 'AnalysisMuonsMedium_%SYS%' ) + + # Add the sequence to the job: + algSeq += muonSequenceMedium + + muonSequenceTight = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, + workingPoint = 'Tight.Iso', postfix = 'tight' ) + muonSequenceTight.removeStage ("calibration") + muonSequenceTight.configure( inputName = 'AnalysisMuonsMedium_%SYS%', + outputName = 'AnalysisMuons_%SYS%', + affectingSystematics = muonSequenceMedium.affectingSystematics()) + + # Add the sequence to the job: + algSeq += muonSequenceTight + + # Add an ntuple dumper algorithm: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'muons' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerEventInfo' ) + ntupleMaker.TreeName = 'muons' + ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', ] + ntupleMaker.systematicsRegex = '(^$)' + algSeq += ntupleMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerMuons' ) + ntupleMaker.TreeName = 'muons' + ntupleMaker.Branches = [ 'AnalysisMuons_NOSYS.eta -> mu_eta', + 'AnalysisMuons_NOSYS.phi -> mu_phi', + 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', ] + ntupleMaker.systematicsRegex = '(^MUON_.*)' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'muons' + algSeq += treeFiller + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_eljob.py index 05416046d0c7..76cbf2f37a5f 100755 --- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_eljob.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -56,82 +56,14 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Set up the systematics loader/handler algorithm: -from AnaAlgorithm.AnaAlgorithmConfig import AnaAlgorithmConfig -sysLoader = AnaAlgorithmConfig( 'CP::SysListLoaderAlg/SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -job.algsAdd( sysLoader ) -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -print( pileupSequence ) # For debugging - -# Add the pileup algorithm(s) to the job: -for alg in pileupSequence: - job.algsAdd( alg ) - pass - -# Include, and then set up the muon analysis algorithm sequence: -from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence -muonSequenceMedium = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, - workingPoint = 'Medium.Iso', postfix = 'medium' ) -muonSequenceMedium.configure( inputName = 'Muons', - outputName = 'AnalysisMuonsMedium_%SYS%' ) -print( muonSequenceMedium ) # For debugging - -# Add all algorithms to the job: -for alg in muonSequenceMedium: +from MuonAnalysisAlgorithms.MuonAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging +for alg in algSeq: job.algsAdd( alg ) pass -muonSequenceTight = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, - workingPoint = 'Tight.Iso', postfix = 'tight' ) -muonSequenceTight.removeStage ("calibration") -muonSequenceTight.configure( inputName = 'AnalysisMuonsMedium_%SYS%', - outputName = 'AnalysisMuons_%SYS%', - affectingSystematics = muonSequenceMedium.affectingSystematics()) -print( muonSequenceTight ) # For debugging - -# Add all algorithms to the job: -for alg in muonSequenceTight: - job.algsAdd( alg ) - pass - -# Add ntuple dumper algorithms: -from AnaAlgorithm.DualUseConfig import createAlgorithm -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'muons' -job.algsAdd( treeMaker ) -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerEventInfo' ) -ntupleMaker.TreeName = 'muons' -ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', ] -ntupleMaker.systematicsRegex = '(^$)' -job.algsAdd( ntupleMaker ) -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerMuons' ) -ntupleMaker.TreeName = 'muons' -ntupleMaker.Branches = [ 'AnalysisMuons_NOSYS.eta -> mu_eta', - 'AnalysisMuons_NOSYS.phi -> mu_phi', - 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', ] -ntupleMaker.systematicsRegex = '(^MUON_.*)' -job.algsAdd( ntupleMaker ) -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'muons' -job.algsAdd( treeFiller ) - -# Set up a mini-xAOD writer algorithm: -xaodWriter = AnaAlgorithmConfig( 'CP::xAODWriterAlg/xAODWriter' ) -xaodWriter.ItemList = \ - [ 'xAOD::EventInfo#EventInfo', - 'xAOD::EventAuxInfo#EventInfoAux.-', - 'xAOD::MuonContainer#AnalysisMuons_NOSYS', - 'xAOD::AuxContainerBase#AnalysisMuons_NOSYSAux.eta.phi.pt' ] -xaodWriter.systematicsRegex = '.*' -job.algsAdd( xaodWriter ) - # Make sure that both the ntuple and the xAOD dumper have a stream to write to. job.outputAdd( ROOT.EL.OutputStream( 'ANALYSIS' ) ) diff --git a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_jobOptions.py index 695adade2709..b985c22d01c0 100644 --- a/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/share/MuonAnalysisAlgorithmsTest_jobOptions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack, Will Buttinger @@ -42,66 +42,10 @@ elif dataType=="afii": jps.AthenaCommonFlags.FilesInput = [testFile] -# Set up the systematics loader/handler algorithm: -sysLoader = CfgMgr.CP__SysListLoaderAlg( 'SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -athAlgSeq += sysLoader - -# Include, and then set up the pileup analysis sequence: -from AsgAnalysisAlgorithms.PileupAnalysisSequence import \ - makePileupAnalysisSequence -pileupSequence = makePileupAnalysisSequence( dataType ) -pileupSequence.configure( inputName = 'EventInfo', outputName = 'EventInfo' ) -print( pileupSequence ) # For debugging - -# Add the pileup sequence to the job: -athAlgSeq += pileupSequence - -# Include, and then set up the muon analysis algorithm sequence: -from MuonAnalysisAlgorithms.MuonAnalysisSequence import makeMuonAnalysisSequence -muonSequenceMedium = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, - workingPoint = 'Medium.Iso', postfix = 'medium' ) -muonSequenceMedium.configure( inputName = 'Muons', - outputName = 'AnalysisMuonsMedium_%SYS%' ) -print( muonSequenceMedium ) # For debugging - -# Add the sequence to the job: -athAlgSeq += muonSequenceMedium - -muonSequenceTight = makeMuonAnalysisSequence( dataType, deepCopyOutput = True, shallowViewOutput = False, - workingPoint = 'Tight.Iso', postfix = 'tight' ) -muonSequenceTight.removeStage ("calibration") -muonSequenceTight.configure( inputName = 'AnalysisMuonsMedium_%SYS%', - outputName = 'AnalysisMuons_%SYS%', - affectingSystematics = muonSequenceMedium.affectingSystematics()) -print( muonSequenceTight ) # For debugging - -# Add the sequence to the job: -athAlgSeq += muonSequenceTight - -# Add an ntuple dumper algorithm: -from AnaAlgorithm.DualUseConfig import createAlgorithm -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'muons' -athAlgSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerEventInfo' ) -ntupleMaker.TreeName = 'muons' -ntupleMaker.Branches = [ 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', ] -ntupleMaker.systematicsRegex = '(^$)' -athAlgSeq += ntupleMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMakerMuons' ) -ntupleMaker.TreeName = 'muons' -ntupleMaker.Branches = [ 'AnalysisMuons_NOSYS.eta -> mu_eta', - 'AnalysisMuons_NOSYS.phi -> mu_phi', - 'AnalysisMuons_%SYS%.pt -> mu_%SYS%_pt', ] -ntupleMaker.systematicsRegex = '(^MUON_.*)' -athAlgSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'muons' -athAlgSeq += treeFiller - +from MuonAnalysisAlgorithms.MuonAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Write a mini-xAOD if requested: if athArgs.write_xaod: -- GitLab From 6043c33d2ceb2e5aade07dc0f93d109b5c2cd03d Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:57:04 -0400 Subject: [PATCH 6/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/TauAnalysisAlgorithmsTest.py | 34 +++++++++++++++++++ .../share/TauAnalysisAlgorithmsTest_eljob.py | 32 +++-------------- .../TauAnalysisAlgorithmsTest_jobOptions.py | 27 +++------------ 3 files changed, 43 insertions(+), 50 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..58ff38f97429 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/python/TauAnalysisAlgorithmsTest.py @@ -0,0 +1,34 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Nils Krumnack + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + sysLoader = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + sysLoader.sigmaRecommended = 1 + algSeq += sysLoader + + # Include, and then set up the tau analysis algorithm sequence: + from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence + tauSequence = makeTauAnalysisSequence( dataType, 'Tight', postfix = 'tight' ) + tauSequence.configure( inputName = 'TauJets', outputName = 'AnalysisTauJets' ) + + # Add the sequence to the job: + algSeq += tauSequence + + # Include, and then set up the tau analysis algorithm sequence: + from TauAnalysisAlgorithms.DiTauAnalysisSequence import makeDiTauAnalysisSequence + diTauSequence = makeDiTauAnalysisSequence( dataType, 'Tight', postfix = 'tight' ) + diTauSequence.configure( inputName = 'DiTauJets', outputName = 'AnalysisDiTauJets' ) + + # Add the sequence to the job: + # disabling this, the standard test files don't have DiTauJets + # algSeq += diTauSequence + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_eljob.py index 80139ad8b6ac..2abbf38e0291 100755 --- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_eljob.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -61,35 +61,13 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Set up the systematics loader/handler algorithm: -from AnaAlgorithm.AnaAlgorithmConfig import AnaAlgorithmConfig -config = AnaAlgorithmConfig( 'CP::SysListLoaderAlg/SysLoaderAlg' ) -config.sigmaRecommended = 1 -job.algsAdd( config ) - -# Include, and then set up the tau analysis algorithm sequence: -from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence -tauSequence = makeTauAnalysisSequence( dataType, 'Tight', postfix = 'tight', deepCopyOutput = True ) -tauSequence.configure( inputName = 'TauJets', outputName = 'AnalysisTauJets' ) -print( tauSequence ) # For debugging - -# Add all algorithms to the job: -for alg in tauSequence: +from TauAnalysisAlgorithms.TauAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging +for alg in algSeq: job.algsAdd( alg ) pass -# Include, and then set up the di-tau analysis algorithm sequence: -from TauAnalysisAlgorithms.DiTauAnalysisSequence import makeDiTauAnalysisSequence -diTauSequence = makeDiTauAnalysisSequence( dataType, 'Tight', postfix = 'tight', deepCopyOutput = True ) -diTauSequence.configure( inputName = 'DiTauJets', outputName = 'AnalysisDiTauJets' ) -print( diTauSequence ) # For debugging - -# Add all algorithms to the job: -for alg in diTauSequence: - # disabling this, the standard test files don't have DiTauJets - # job.algsAdd( alg ) - pass - # Find the right output directory: submitDir = options.submission_dir if options.unit_test: diff --git a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_jobOptions.py index fe2b4b2e1444..90d55476bd9c 100644 --- a/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/TauAnalysisAlgorithms/share/TauAnalysisAlgorithmsTest_jobOptions.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # # @author Nils Krumnack @@ -18,29 +18,10 @@ dataType = "data" #dataType = "mc" #dataType = "afii" -# Set up the systematics loader/handler algorithm: -sysLoader = CfgMgr.CP__SysListLoaderAlg( 'SysLoaderAlg' ) -sysLoader.sigmaRecommended = 1 -algSeq += sysLoader -# Include, and then set up the tau analysis algorithm sequence: -from TauAnalysisAlgorithms.TauAnalysisSequence import makeTauAnalysisSequence -tauSequence = makeTauAnalysisSequence( dataType, 'Tight', postfix = 'tight' ) -tauSequence.configure( inputName = 'TauJets', outputName = 'AnalysisTauJets' ) -print( tauSequence ) # For debugging - -# Add the sequence to the job: -algSeq += tauSequence - -# Include, and then set up the tau analysis algorithm sequence: -from TauAnalysisAlgorithms.DiTauAnalysisSequence import makeDiTauAnalysisSequence -diTauSequence = makeDiTauAnalysisSequence( dataType, 'Tight', postfix = 'tight' ) -diTauSequence.configure( inputName = 'DiTauJets', outputName = 'AnalysisDiTauJets' ) -print( diTauSequence ) # For debugging - -# Add the sequence to the job: -# disabling this, the standard test files don't have DiTauJets -# algSeq += diTauSequence +from TauAnalysisAlgorithms.TauAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab From 6ab590107da568333b76623de92603860a970d6e Mon Sep 17 00:00:00 2001 From: Nils Krumnack <krumnack@iastate.edu> Date: Sat, 22 Jun 2019 11:58:48 -0400 Subject: [PATCH 7/7] merge algorithm test code between EventLoop and Athena So far the algorithm test sequence was duplicated between EventLoop and Athena. Keeping them in sync was needlessly error-prone, so I now merged them. --- .../python/TriggerAnalysisAlgorithmsTest.py | 49 +++++++++++++++++++ .../share/TriggerAlgorithmsTest_eljob.py | 48 ++---------------- .../share/TriggerAlgorithmsTest_jobOptions.py | 49 ++----------------- 3 files changed, 55 insertions(+), 91 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/python/TriggerAnalysisAlgorithmsTest.py diff --git a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/python/TriggerAnalysisAlgorithmsTest.py b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/python/TriggerAnalysisAlgorithmsTest.py new file mode 100644 index 000000000000..c0d82335ddd0 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/python/TriggerAnalysisAlgorithmsTest.py @@ -0,0 +1,49 @@ +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# +# @author Tadej Novak +# @author Nils Krumnack + +from AnaAlgorithm.AlgSequence import AlgSequence +from AnaAlgorithm.DualUseConfig import createAlgorithm + +def makeSequence (dataType) : + + # Config: + triggerChains = [ + 'HLT_2mu14', + 'HLT_mu20_mu8noL1', + 'HLT_2e17_lhvloose_nod0' + ] + + + algSeq = AlgSequence() + + # Set up the systematics loader/handler algorithm: + alg = createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) + alg.sigmaRecommended = 1 + algSeq += alg + + # Include, and then set up the pileup analysis sequence: + from TriggerAnalysisAlgorithms.TriggerAnalysisSequence import \ + makeTriggerAnalysisSequence + triggerSequence = makeTriggerAnalysisSequence( dataType, triggerChains=triggerChains ) + algSeq += triggerSequence + + # Set up an ntuple to check the job with: + treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) + treeMaker.TreeName = 'events' + algSeq += treeMaker + ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) + ntupleMaker.TreeName = 'events' + ntupleMaker.Branches = [ + 'EventInfo.runNumber -> runNumber', + 'EventInfo.eventNumber -> eventNumber', + ] + ntupleMaker.Branches += ['EventInfo.trigPassed_' + t + ' -> trigPassed_' + t for t in triggerChains] + ntupleMaker.systematicsRegex = '.*' + algSeq += ntupleMaker + treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) + treeFiller.TreeName = 'events' + algSeq += treeFiller + + return algSeq diff --git a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_eljob.py b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_eljob.py index 60373bbff543..dc2771ea81da 100755 --- a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_eljob.py +++ b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_eljob.py @@ -52,51 +52,9 @@ job = ROOT.EL.Job() job.sampleHandler( sh ) job.options().setDouble( ROOT.EL.Job.optMaxEvents, 500 ) -# Config: -triggerChains = [ - 'HLT_2mu14', - 'HLT_mu20_mu8noL1', - 'HLT_2e17_lhvloose_nod0' -] - -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from TriggerAnalysisAlgorithms.TriggerAnalysisSequence import \ - makeTriggerAnalysisSequence -triggerSequence = makeTriggerAnalysisSequence( dataType, triggerChains=triggerChains ) -algSeq += triggerSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'events' -algSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'events' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', -] -ntupleMaker.Branches += ['EventInfo.trigPassed_' + t + ' -> trigPassed_' + t for t in triggerChains] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'events' -algSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. +from TriggerAnalysisAlgorithms.TriggerAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging for alg in algSeq: job.algsAdd( alg ) pass diff --git a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_jobOptions.py b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_jobOptions.py index 19eba0065dad..b36f226e6262 100644 --- a/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_jobOptions.py +++ b/PhysicsAnalysis/Algorithms/TriggerAnalysisAlgorithms/share/TriggerAlgorithmsTest_jobOptions.py @@ -17,52 +17,9 @@ theApp.EvtMax = 500 testFile = os.getenv ( inputfile[dataType] ) svcMgr.EventSelector.InputCollections = [testFile] -# Config: -triggerChains = [ - 'HLT_2mu14', - 'HLT_mu20_mu8noL1', - 'HLT_2e17_lhvloose_nod0' -] - -# Import(s) needed for the job configuration. -from AnaAlgorithm.AlgSequence import AlgSequence -from AnaAlgorithm.DualUseConfig import createAlgorithm - -# Set up the main analysis algorithm sequence. -algSeq = AlgSequence( 'AnalysisSequence' ) - -# Set up the systematics loader/handler algorithm: -algSeq += createAlgorithm( 'CP::SysListLoaderAlg', 'SysLoaderAlg' ) -algSeq.SysLoaderAlg.sigmaRecommended = 1 - -# Include, and then set up the pileup analysis sequence: -from TriggerAnalysisAlgorithms.TriggerAnalysisSequence import \ - makeTriggerAnalysisSequence -triggerSequence = makeTriggerAnalysisSequence( dataType, triggerChains=triggerChains ) -algSeq += triggerSequence - -# Set up an ntuple to check the job with: -treeMaker = createAlgorithm( 'CP::TreeMakerAlg', 'TreeMaker' ) -treeMaker.TreeName = 'events' -athAlgSeq += treeMaker -ntupleMaker = createAlgorithm( 'CP::AsgxAODNTupleMakerAlg', 'NTupleMaker' ) -ntupleMaker.TreeName = 'events' -ntupleMaker.Branches = [ - 'EventInfo.runNumber -> runNumber', - 'EventInfo.eventNumber -> eventNumber', -] -ntupleMaker.Branches += ['EventInfo.trigPassed_' + t + ' -> trigPassed_' + t for t in triggerChains] -ntupleMaker.systematicsRegex = '.*' -algSeq += ntupleMaker -treeFiller = createAlgorithm( 'CP::TreeFillerAlg', 'TreeFiller' ) -treeFiller.TreeName = 'events' -athAlgSeq += treeFiller - -# For debugging. -print( algSeq ) - -# Add all algorithms from the sequence to the job. -athAlgSeq += algSeq +from TriggerAnalysisAlgorithms.TriggerAnalysisAlgorithmsTest import makeSequence +algSeq = makeSequence (dataType) +print algSeq # For debugging # Set up a histogram output file for the job: ServiceMgr += CfgMgr.THistSvc() -- GitLab