ATLAS Offline Software
L0MuonSmearingConfig.py
Go to the documentation of this file.
1 #Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentFactory import CompFactory
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 
5 from AthenaCommon.Logging import logging
6 _log = logging.getLogger(__name__)
7 
8 def L0MuonSmearingCfg(flags, name = "L0MuonSmearingAlg", **kwargs):
9 
10  result = ComponentAccumulator()
11 
12  alg = CompFactory.L0Muon.L0MuonSmearingAlg(name = name,
13  **kwargs)
14 
15  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
16  monTool = GenericMonitoringTool(flags, 'MonTool')
17  monTool.HistPath = 'L0MuonSmearing'
18  monTool.defineHistogram('track_input_eta', path='EXPERT', type='TH1F', title=';#eta_{#mu}^{truth};Muons', xbins=50, xmin=-3, xmax=3)
19  monTool.defineHistogram('track_input_phi', path='EXPERT', type='TH1F', title=';#phi_{#mu}^{truth};Muons', xbins=50, xmin=-4, xmax=4)
20  monTool.defineHistogram('track_input_pt', path='EXPERT', type='TH1F', title=';p_{T,#mu}^{truth} (GeV);Muons', xbins=50, xmin=0, xmax=250)
21  monTool.defineHistogram('track_input_curv',path='EXPERT', type='TH1F', title=';q/p_{T,#mu}^{truth} (1/GeV);Muons', xbins=50, xmin=-0.4, xmax=0.4)
22  monTool.defineHistogram('track_output_eta', path='EXPERT', type='TH1F', title=';#eta_{#mu}^{L0};Muons', xbins=50, xmin=-3, xmax=3)
23  monTool.defineHistogram('track_output_phi', path='EXPERT', type='TH1F', title=';#phi_{#mu}^{L0};Muons', xbins=50, xmin=-4, xmax=4)
24  monTool.defineHistogram('track_output_pt', path='EXPERT', type='TH1F', title=';p_{T,#mu}^{L0} (GeV);Muons', xbins=50, xmin=0, xmax=250)
25  monTool.defineHistogram('track_output_curv',path='EXPERT', type='TH1F', title=';q/p_{T,#mu}^{L0} (1/GeV);Muons', xbins=50, xmin=-0.4, xmax=0.4)
26  monTool.defineHistogram('roi_output_eta', path='EXPERT', type='TH1F', title=';#eta_{RoI}^{L0};RoIs', xbins=50, xmin=-3, xmax=3)
27  monTool.defineHistogram('roi_output_phi', path='EXPERT', type='TH1F', title=';#phi_{RoI}^{L0};RoIs', xbins=50, xmin=-4, xmax=4)
28  monTool.defineHistogram('roi_output_pt', path='EXPERT', type='TH1F', title=';p_{T,RoI}^{L0} (GeV);RoIs', xbins=64, xmin=0, xmax=128.0)
29  monTool.defineHistogram('roi_output_curv',path='EXPERT', type='TH1F', title=';q/p_{T,RoI}^{L0} (1/GeV);RoIs', xbins=50, xmin=-0.4, xmax=0.4)
30  monTool.defineHistogram('delta_eta', path='EXPERT', type='TH1F', title=';#eta_{RoI}^{L0}-#eta_{#mu}^{truth};', xbins=50, xmin=-0.005,xmax=0.005)
31  monTool.defineHistogram('delta_phi', path='EXPERT', type='TH1F', title=';#phi_{RoI}^{L0}-#phi_{#mu}^{truth};', xbins=50, xmin=-0.1,xmax=0.1)
32  monTool.defineHistogram('delta_pt', path='EXPERT', type='TH1F', title=';(p_{T}^{L0}-p_{T}^{truth})/p_{T}^{truth};', xbins=50, xmin=-1,xmax=1)
33  monTool.defineHistogram('delta_curv',path='EXPERT', type='TH1F', title=';((q/p_{T})^{L0} - (q/p_{T})^{truth}) / (q/p_{T})^{truth}',xbins=50,xmin=-1,xmax=1)
34 
35  alg.MonTool = monTool
36 
37  histSvc = CompFactory.THistSvc(Output=["EXPERT DATAFILE='" + name + ".root' OPT='RECREATE'"])
38 
39  result.addEventAlgo(alg)
40  result.addService(histSvc)
41  return result
42 
43 
44 if __name__ == "__main__":
45 
46  from AthenaConfiguration.TestDefaults import defaultTestFiles
47  from AthenaConfiguration.AllConfigFlags import initConfigFlags
48  from AthenaCommon.Constants import DEBUG
49  flags = initConfigFlags()
50  flags.Input.Files = defaultTestFiles.AOD_RUN3_MC
51  flags.Input.isMC=True
52  flags.Exec.MaxEvents = 20
53  flags.Common.MsgSuppression = False
54  flags.lock()
55 
56  # create basic infrastructure
57  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
58  acc = MainServicesCfg(flags)
59 
60  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
61  acc.merge(PoolReadCfg(flags))
62 
63  # example to smear the truth particles
64  smearerTruth = L0MuonSmearingCfg(flags,
65  name = "L0MuonTruthSmearing",
66  InputTruthParticle = "TruthParticles",
67  OutputLevel = DEBUG)
68  acc.merge(smearerTruth)
69 
70  # below is validation
71  acc.printConfig(withDetails=True, summariseProps=True)
72 
73  # run the job
74  status = acc.run()
75 
76  # report the execution status (0 ok, else error)
77  import sys
78  sys.exit(not status.isSuccess())
79 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
GenericMonitoringTool
Definition: GenericMonitoringTool.h:53
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
L0MuonSmearingConfig.L0MuonSmearingCfg
def L0MuonSmearingCfg(flags, name="L0MuonSmearingAlg", **kwargs)
Definition: L0MuonSmearingConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69