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