ATLAS Offline Software
MuonEfficiencyCorrectionsCfg.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 
4 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 
7 def MuonScaleFactorTestAlgCfg(flags, name="MuonScaleFactorTestAlg", **kwargs):
8  result = ComponentAccumulator()
9  from MuonSelectorTools.MuonSelectorToolsConfig import MuonSelectionToolCfg
10  kwargs.setdefault("MuonSelectionTool", result.popToolsAndMerge(MuonSelectionToolCfg(flags)))
11  from AsgAnalysisAlgorithms.PileupReweightingAlgConfig import PileupReweightingToolCfg
12  kwargs.setdefault("PileupReweightingTool", result.popToolsAndMerge(PileupReweightingToolCfg(flags)))
13  the_alg = CompFactory.CP.MuonScaleFactorTestAlg(name, **kwargs)
14  result.addEventAlgo(the_alg, primary = True)
15  return result
16 
17 def MuonEfficiencyCorrectionsCfg(flags, name="MuonEffiCorrections", **kwargs):
18  result = ComponentAccumulator()
19  kwargs.setdefault("ApplyKinematicSystematic", False)
20  eff_tool = CompFactory.CP.MuonEfficiencyScaleFactors(name, **kwargs)
21  result.setPrivateTools(eff_tool)
22  return result
23 
24 def setupHistSvcCfg(flags, out_file="EffTester.root"):
25  result = ComponentAccumulator()
26  if len(out_file) == 0: return result
27  histSvc = CompFactory.THistSvc(Output=["MUONEFFTESTER DATAFILE='{out_file}', OPT='RECREATE'".format(out_file = out_file)])
28  result.addService(histSvc, primary=True)
29  return result
30 
32  from argparse import ArgumentParser
33 
34  parser = ArgumentParser()
35  parser.add_argument("--threads", type=int, help="number of threads", default=1)
36  parser.add_argument("--inputFile", "-i", default=[
37  "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/mc20_13TeV.361107.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zmumu.recon.AOD.e3601_s3681_r13167/AOD.27312826._000061.pool.root.1"
38  ],
39  help="Input file to run on ", nargs="+")
40  parser.add_argument("--outRootFile", default="EffiDump.root", help="Output ROOT file to dump the geomerty")
41  parser.add_argument("--maxEvents", type=int, help="Maximum events to run on", default = -1)
42  return parser
43 
44 
45 
46 if __name__ == "__main__":
47  from AthenaConfiguration.AllConfigFlags import initConfigFlags
48 
50 
51  flags = initConfigFlags()
52  flags.Concurrency.NumThreads = args.threads
53  flags.Concurrency.NumConcurrentEvents = args.threads # Might change this later, but good enough for the moment.
54  flags.Input.Files = args.inputFile
55  flags.Scheduler.ShowDataDeps = True
56  flags.Scheduler.ShowDataFlow = True
57  flags.lock()
58  flags.dump(evaluate=True)
59 
60 
61  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
62  cfg = MainServicesCfg(flags)
63 
64  from AthenaConfiguration.Enums import Format
65  if flags.Input.Format == Format.POOL:
66  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
67  cfg.merge(PoolReadCfg(flags))
68 
69  cfg.merge(setupHistSvcCfg(flags, out_file = args.outRootFile))
70  sf_tools= [cfg.popToolsAndMerge(MuonEfficiencyCorrectionsCfg(flags,
71  WorkingPoint="Loose"))]
72  cfg.merge(MuonScaleFactorTestAlgCfg(flags, EfficiencyTools = sf_tools))
73 
74  cfg.printConfig(withDetails=True, summariseProps=True)
75 
76  sc = cfg.run(args.maxEvents)
77  if not sc.isSuccess():
78  import sys
79  sys.exit("Execution failed")
80 
81 
82 
83 
84 
85 
86 
87 
MuonEfficiencyCorrectionsCfg.MuonEfficiencyCorrectionsCfg
def MuonEfficiencyCorrectionsCfg(flags, name="MuonEffiCorrections", **kwargs)
Definition: MuonEfficiencyCorrectionsCfg.py:17
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
MuonEfficiencyCorrectionsCfg
Definition: MuonEfficiencyCorrectionsCfg.py:1
vtune_athena.format
format
Definition: vtune_athena.py:14
MuonEfficiencyCorrectionsCfg.setupArgParser
def setupArgParser()
Definition: MuonEfficiencyCorrectionsCfg.py:31
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
MuonEfficiencyCorrectionsCfg.MuonScaleFactorTestAlgCfg
def MuonScaleFactorTestAlgCfg(flags, name="MuonScaleFactorTestAlg", **kwargs)
Definition: MuonEfficiencyCorrectionsCfg.py:7
python.MuonSelectorToolsConfig.MuonSelectionToolCfg
def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs)
Standard configuration of the MuonSelectionTool used in reconstruction & validation jobs The snippet ...
Definition: MuonSelectorToolsConfig.py:16
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
confTool.parse_args
def parse_args()
Definition: confTool.py:35
python.PileupReweightingAlgConfig.PileupReweightingToolCfg
def PileupReweightingToolCfg(flags, name="PileupReweightingTool", commonPRW=True, **kwargs)
Definition: PileupReweightingAlgConfig.py:23
MuonEfficiencyCorrectionsCfg.setupHistSvcCfg
def setupHistSvcCfg(flags, out_file="EffTester.root")
Definition: MuonEfficiencyCorrectionsCfg.py:24
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69