ATLAS Offline Software
Loading...
Searching...
No Matches
EFTrackingSmearingConfig.py
Go to the documentation of this file.
2#Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3from AthenaConfiguration.ComponentFactory import CompFactory
4from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5from AthenaCommon.Logging import logging
6_log = logging.getLogger(__name__)
7
8def EFTrackingSmearingCfg(flags, name = "EFTrackingSmearingAlg", **kwargs):
9 # set common parameters
10 histSvc = CompFactory.THistSvc(Output=[name +" DATAFILE='"+name+ ".root' OPT='RECREATE'"])
11
12 result = ComponentAccumulator()
13 result.addService(histSvc)
14
15 alg = CompFactory.EFTrackingSmearingAlg(
16 name = name,
17 RootStreamName = name,
18 RootDirName = "/EFTSmearing/",
19 **kwargs
20 )
21
22 sf_str=str(kwargs['SmearingScaleFactor']).replace(".","p")
23 if kwargs['SmearTruthParticle']:
24 alg.OutputTruthParticleContainer = "TruthParticle_smeared_SF"+sf_str
25 else:
26 alg.OutputTrackParticleContainer = "InDetTrackParticles_smeared_SF"+sf_str
27
28 result.addEventAlgo(alg)
29 return result
30
31
32
33
34if __name__ == "__main__":
35
36 from AthenaConfiguration.TestDefaults import defaultTestFiles
37 from AthenaConfiguration.AllConfigFlags import initConfigFlags
38 from AthenaCommon.Constants import INFO, DEBUG
39 flags = initConfigFlags()
40 flags.Input.Files = defaultTestFiles.AOD_RUN3_MC
41 flags.Input.isMC=True
42 flags.Exec.MaxEvents = 5
43 flags.lock()
44
45 # create basic infrastructure
46 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
47 acc = MainServicesCfg(flags)
48 acc.getService("MessageSvc").debugLimit = 100000
49
50 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
51 acc.merge(PoolReadCfg(flags))
52
53 # needed to access the decorators for the truth particles
54 from InDetPhysValMonitoring.InDetPhysValDecorationConfig import AddDecoratorCfg
55 acc.merge(AddDecoratorCfg(flags))
56
57 TestsmearFactor = 2
58 TestEfficiencyFactor=1
59 # example to smear the track particles
60 smearerTrack = EFTrackingSmearingCfg(
61 flags,
62 name = "testTrack",
63 InputTrackParticleContainer = "InDetTrackParticles",
64 OutputTracksPtCutGeV = 1,
65 SmearingScaleFactor = TestsmearFactor,
66 SmearedTrackEfficiency = TestEfficiencyFactor,
67 ParameterizedTrackEfficiency = False,
68 SmearTruthParticle = False,
69 EnableMonitoring = True,
70 OutputLevel = INFO)
71 acc.merge(smearerTrack)
72
73
74 # example to smear the truth particles
75 smearerTruth = EFTrackingSmearingCfg(
76 flags,
77 name = "testTruth",
78 InputTruthParticleContainer = "TruthParticles",
79 OutputTracksPtCutGeV = 1,
80 SmearingScaleFactor = TestsmearFactor,
81 SmearedTrackEfficiency = TestEfficiencyFactor,
82 ParameterizedTrackEfficiency = False,
83 SmearTruthParticle = True,
84 ParameterizedTrackEfficiency_LRT = True,
85 SmearedTrackEfficiency_d0low_LRT = .001,
86 SmearedTrackEfficiency_d0high_LRT = 400.,
87 EnableMonitoring = True,
88 OutputLevel = DEBUG)
89 acc.merge(smearerTruth)
90
91
92 # validation of the smeared tracks and truth particles
93 validationAlg = CompFactory.EFTrackingSmearMonAlg(
94 name = "EFTrakingSmearMonAlg",
95 OutputLevel = INFO,
96 InputTrackParticleContainer = "InDetTrackParticles",
97 InputTruthParticleContainer = "TruthParticles",
98 SmearedTrackParticleContainer = "InDetTrackParticles_smeared_SF"+str(TestsmearFactor),
99 SmearedTruthParticleContainer = "TruthParticle_smeared_SF"+str(TestsmearFactor),)
100 acc.addEventAlgo(validationAlg)
101
102 acc.wasMerged()
103
104 # below is validation
105 acc.printConfig(withDetails=True, summariseProps=True)
106
107
108 # run the job
109 status = acc.run()
110
111
112 # report the execution status (0 ok, else error)
113 import sys
114 sys.exit(not status.isSuccess())
115
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
EFTrackingSmearingCfg(flags, name="EFTrackingSmearingAlg", **kwargs)