Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
runIDPVM.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 
4 from glob import glob
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 import AthenaCommon.SystemOfUnits as Units
7 
9  from argparse import ArgumentParser
10  IDPVMparser = ArgumentParser(description='Parser for IDPVM configuration')
11  IDPVMparser.add_argument("--filesInput", required=True)
12  IDPVMparser.add_argument("--maxEvents", help="Limit number of events. Default: all input events", default=-1, type=int)
13  IDPVMparser.add_argument("--skipEvents", help="Skip this number of events. Default: no events are skipped", default=0, type=int)
14  IDPVMparser.add_argument("--doLargeD0Tracks", help='also run LRT plots', action='store_true', default=False)
15  IDPVMparser.add_argument("--doLowPtRoITracks", help='also run low pt tracks', action='store_true', default=False)
16  IDPVMparser.add_argument("--doMergedLargeD0Tracks", help='also run merged STD+LRT plots', action='store_true', default=False)
17  IDPVMparser.add_argument("--doRecoOnly", help='skip truth-specific processing', action='store_true', default=False)
18  IDPVMparser.add_argument("--doLoose", help='also run loose plots', action='store_true', default=False)
19  IDPVMparser.add_argument("--doTightPrimary", help='also run tight-primary plots', action='store_true', default=False)
20  IDPVMparser.add_argument("--doHILoose", help='also run Heavy Ion loose plots', action='store_true', default=False)
21  IDPVMparser.add_argument("--doTracksInJets", help='also run tracks in jets', action='store_true', default=False)
22  IDPVMparser.add_argument("--doTracksInBJets", help='also run tracks in jets', action='store_true', default=False)
23  IDPVMparser.add_argument("--doTruthOrigin", help='make plots by track origin', action='store_true', default=False)
24  IDPVMparser.add_argument("--doDuplicate", help='make duplicate plots', action='store_true', default=False)
25  IDPVMparser.add_argument("--doHitLevelPlots", help='make hit residual / eff plots', action='store_true', default=False)
26  IDPVMparser.add_argument("--doPerAuthor", help='make plots by track author', action='store_true', default=False)
27  IDPVMparser.add_argument("--doExpertPlots", help='run additional expert-level plots', action='store_true', default=False)
28  IDPVMparser.add_argument("--doMuonMatchedTracks", help='run plots for tracks matched to true muons', action='store_true', default=False)
29  IDPVMparser.add_argument("--doElectronMatchedTracks", help='run plots for tracks matched to true electrons', action='store_true', default=False)
30  IDPVMparser.add_argument("--doTruthToRecoNtuple", help='output track-to-truth ntuple', action='store_true', default=False)
31  IDPVMparser.add_argument("--doActs", help='run plots for acts collections', action='store_true', default=False)
32  IDPVMparser.add_argument("--doHGTD", help='run plots fof HGTD collections', action='store_true', default=False)
33  IDPVMparser.add_argument("--disableDecoration", help='disable extra track and truth decoration if possible', action='store_true', default=False)
34  IDPVMparser.add_argument("--hardScatterStrategy", help='Strategy to select the hard scatter. 0 = SumPt² 1 = SumPt , 2 = Sumptw, 3 = GNN, 4 = H->yy', choices=["0","1","2","3","4"], default="0")
35  IDPVMparser.add_argument("--truthMinPt", help='minimum truth particle pT', type=float, default=None)
36  IDPVMparser.add_argument("--outputFile", help='Name of output file',default="M_output.root")
37  IDPVMparser.add_argument("--HSFlag", help='Hard-scatter flag - decides what is used for truth matching', choices=['HardScatter', 'All', 'PileUp'],default="HardScatter")
38  IDPVMparser.add_argument("--jetsNameForHardScatter", help='Name of jet collection',default="AntiKt4EMTopoJets")
39  IDPVMparser.add_argument("--ancestorIDList", help='List of ancestor truth IDs to match.', default = [], nargs='+', type=int)
40  IDPVMparser.add_argument("--requiredSiHits", help='Number of truth silicon hits', type=int, default=0)
41  IDPVMparser.add_argument("--selectedCharge", help='Charge of selected truth particles (0=inclusive)', type=int, default=0)
42  IDPVMparser.add_argument("--maxProdVertRadius", help='Maximum production radius for truth particles', type=float, default=300)
43  IDPVMparser.add_argument("--GRL", help='Which GRL(s) to use, if any, when running on data', choices=['2015', '2016', '2017', '2018', '2022', '2023', '2024'], nargs='+', default=[])
44  IDPVMparser.add_argument("--validateExtraTrackCollections", help='List of extra track collection names to be validated in addition to Tracks.', nargs='+', default=[])
45  IDPVMparser.add_argument("--doIDTIDE", help='run the output from IDTIDE derivation', action='store_true', default=False)
46  IDPVMparser.add_argument("--doTechnicalEfficiency", help='fill the technical efficiency plot (requires additional si hit information in the input file)', action='store_true', default=False)
47  IDPVMparser.add_argument("--doPRW", help='apply pileup reweight', action='store_true', default=False)
48  IDPVMparser.add_argument("--maxTrkJetDR", help='the maximum dR to jets to allow for track-in-jet plots', type=float, default=0.4)
49  IDPVMparser.add_argument("--JetAbsEtaMax", help='Maximum Eta value for jet selection', type=float, default=-1)
50  IDPVMparser.add_argument("--PrimaryVertexContainer", help='Name of the primary vertex container', choices=['PrimaryVertices', 'ActsPrimaryVertices', 'HggPrimaryVertices', 'PrimaryVertices_Grid'], default='PrimaryVertices')
51  IDPVMparser.add_argument("--OnlyTrackingPreInclude", help='Disable all flags related to detectors/domains beyond tracking', action='store_true', default=False)
52  IDPVMparser.add_argument("--jetCollection", help='Jet collection for track-in-jet plots', default="AntiKt4EMPFlowJets")
53  IDPVMparser.add_argument("--JetPtMin", help='Minimum pt for jet selection in GeV', type=float, default=100)
54  IDPVMparser.add_argument("--JetPtMax", help='Maximum pt for jet selection in GeV', type=float, default=5000)
55  IDPVMparser.add_argument("--setCSVName", help='Convert AOD to a SCV file for the track overlay ML training dataset', default="")
56  IDPVMparser.add_argument("--vetoPdgId", help='Veto a particle based on PDG ID', type=int, default=-1)
57  IDPVMparser.add_argument("--pdgId", help='Select a particle based on PDG ID', type=int, default=-1)
58  return IDPVMparser.parse_args()
59 
60 # Parse the arguments
61 MyArgs = GetCustomAthArgs()
62 
63 from AthenaConfiguration.Enums import LHCPeriod
64 from AthenaConfiguration.AllConfigFlags import initConfigFlags
65 flags = initConfigFlags()
66 
67 flags.Input.Files = []
68 for path in MyArgs.filesInput.split(','):
69  flags.Input.Files += glob(path)
70 flags.PhysVal.OutputFileName = MyArgs.outputFile
71 
72 # Set default truthMinPt depending on Run config
73 if MyArgs.truthMinPt is None:
74  MyArgs.truthMinPt = 1000 if flags.GeoModel.Run >= LHCPeriod.Run4 \
75  else 500
76 
77 flags.PhysVal.IDPVM.setTruthStrategy = MyArgs.HSFlag
78 flags.PhysVal.IDPVM.doExpertOutput = MyArgs.doExpertPlots or MyArgs.doPerAuthor
79 flags.PhysVal.IDPVM.doPhysValOutput = not MyArgs.doExpertPlots
80 flags.PhysVal.IDPVM.doValidateTruthToRecoNtuple = MyArgs.doTruthToRecoNtuple
81 flags.PhysVal.IDPVM.doIDTIDE= MyArgs.doIDTIDE
82 if MyArgs.doTracksInJets:
83  flags.PhysVal.IDPVM.doValidateTracksInJets = True
84 if MyArgs.doTracksInBJets:
85  flags.PhysVal.IDPVM.doValidateTracksInBJets = True
86 if MyArgs.setCSVName != "":
87  flags.PhysVal.IDPVM.setCSVName = MyArgs.setCSVName
88 if MyArgs.vetoPdgId > 0:
89  flags.PhysVal.IDPVM.vetoPdgId = MyArgs.vetoPdgId
90 if MyArgs.pdgId > 0:
91  flags.PhysVal.IDPVM.pdgId = MyArgs.pdgId
92 flags.PhysVal.IDPVM.doValidateLooseTracks = MyArgs.doLoose
93 flags.PhysVal.IDPVM.doValidateTightPrimaryTracks = MyArgs.doTightPrimary
94 flags.PhysVal.IDPVM.doValidateHILoose = MyArgs.doHILoose
95 flags.PhysVal.IDPVM.doTruthOriginPlots = MyArgs.doTruthOrigin
96 flags.PhysVal.IDPVM.doDuplicatePlots = MyArgs.doDuplicate
97 flags.PhysVal.IDPVM.doValidateMuonMatchedTracks = MyArgs.doMuonMatchedTracks
98 flags.PhysVal.IDPVM.doValidateElectronMatchedTracks = MyArgs.doElectronMatchedTracks
99 flags.PhysVal.IDPVM.doValidateLargeD0Tracks = MyArgs.doLargeD0Tracks
100 flags.PhysVal.IDPVM.doValidateMergedLargeD0Tracks = MyArgs.doMergedLargeD0Tracks
101 flags.PhysVal.IDPVM.doValidateLowPtRoITracks = MyArgs.doLowPtRoITracks
102 flags.PhysVal.IDPVM.doRecoOnly = MyArgs.doRecoOnly
103 flags.PhysVal.IDPVM.doPerAuthorPlots = MyArgs.doPerAuthor
104 flags.PhysVal.IDPVM.doHitLevelPlots = MyArgs.doHitLevelPlots
105 flags.PhysVal.IDPVM.runDecoration = not MyArgs.disableDecoration
106 flags.PhysVal.IDPVM.requiredSiHits = MyArgs.requiredSiHits
107 flags.PhysVal.IDPVM.selectedCharge = MyArgs.selectedCharge
108 flags.PhysVal.IDPVM.maxProdVertRadius = MyArgs.maxProdVertRadius
109 flags.PhysVal.IDPVM.ancestorIDs = MyArgs.ancestorIDList
110 flags.PhysVal.IDPVM.hardScatterStrategy = int(MyArgs.hardScatterStrategy)
111 flags.PhysVal.IDPVM.jetsNameForHardScatter = MyArgs.jetsNameForHardScatter
112 flags.PhysVal.IDPVM.truthMinPt = MyArgs.truthMinPt
113 flags.PhysVal.IDPVM.GRL = MyArgs.GRL
114 flags.PhysVal.IDPVM.validateExtraTrackCollections = MyArgs.validateExtraTrackCollections
115 flags.PhysVal.IDPVM.doTechnicalEfficiency = MyArgs.doTechnicalEfficiency
116 flags.PhysVal.IDPVM.doPRW = MyArgs.doPRW
117 flags.PhysVal.IDPVM.doActs = MyArgs.doActs
118 flags.PhysVal.IDPVM.doHGTD = MyArgs.doHGTD
119 flags.PhysVal.IDPVM.maxTrkJetDR = MyArgs.maxTrkJetDR
120 flags.PhysVal.IDPVM.PrimaryVertexContainer = MyArgs.PrimaryVertexContainer
121 flags.PhysVal.IDPVM.jetCollection = MyArgs.jetCollection
122 flags.PhysVal.IDPVM.JetPtMin = MyArgs.JetPtMin * Units.GeV
123 flags.PhysVal.IDPVM.JetPtMax = MyArgs.JetPtMax * Units.GeV
124 if MyArgs.JetAbsEtaMax != -1:
125  flags.PhysVal.IDPVM.JetAbsEtaMax = MyArgs.JetAbsEtaMax
126 
127 
128 flags.Exec.SkipEvents = MyArgs.skipEvents
129 flags.Exec.MaxEvents = MyArgs.maxEvents
130 
131 # force the vertex for hgg case
132 if flags.PhysVal.IDPVM.hardScatterStrategy == 3:
133  flags.PhysVal.IDPVM.PrimaryVertexContainer = 'HggPrimaryVertices'
134 
135 if MyArgs.OnlyTrackingPreInclude:
136  from InDetConfig.ConfigurationHelpers import OnlyTrackingPreInclude
138 
139 flags.PhysVal.doExample = False
140 
141 flags.lock()
142 
143 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
144 acc = MainServicesCfg(flags)
145 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
146 acc.merge(PoolReadCfg(flags))
147 
148 # Schedule ACTS data pool if requested
149 if flags.PhysVal.IDPVM.doActs:
150  from ActsConfig.ActsCollectionsConfig import ActsPoolReadCfg
151  acc.merge(ActsPoolReadCfg(flags))
152 
153 if flags.PhysVal.IDPVM.doPRW:
154  acc.addService(CompFactory.CP.SystematicsSvc("SystematicsSvc"))
155  from AsgAnalysisAlgorithms.PileupReweightingAlgConfig import PileupReweightingAlgCfg
156  acc.merge(PileupReweightingAlgCfg(flags))
157 
158 from InDetPhysValMonitoring.InDetPhysValMonitoringConfig import InDetPhysValMonitoringCfg
159 acc.merge(InDetPhysValMonitoringCfg(flags))
160 
161 acc.printConfig(withDetails=True)
162 
163 # Execute and finish
164 sc = acc.run()
165 
166 # Success should be 0
167 import sys
168 sys.exit(not sc.isSuccess())
SystemOfUnits
InDetPhysValMonitoringConfig.InDetPhysValMonitoringCfg
def InDetPhysValMonitoringCfg(flags)
Definition: InDetPhysValMonitoringConfig.py:406
ActsCollectionsConfig.ActsPoolReadCfg
ComponentAccumulator ActsPoolReadCfg(flags)
Definition: ActsCollectionsConfig.py:78
python.ConfigurationHelpers.OnlyTrackingPreInclude
def OnlyTrackingPreInclude(flags)
Definition: InnerDetector/InDetConfig/python/ConfigurationHelpers.py:6
python.PileupReweightingAlgConfig.PileupReweightingAlgCfg
def PileupReweightingAlgCfg(flags, name="PileupReweightingAlg", **kwargs)
Definition: PileupReweightingAlgConfig.py:39
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:262
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
runIDPVM.GetCustomAthArgs
def GetCustomAthArgs()
Definition: runIDPVM.py:8