ATLAS Offline Software
TrigInDetValidation_AODtoTrkNtuple_CA.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 
4 # Run over AOD or TRIG8 to produce the TIDA track ntuple
5 # Note, to run using the python file in your current directory you need to drop 'TrigInDetValidation.'
6 # Local example:
7 # python -m TrigInDetValidation.TrigInDetValidation_AODtoTrkNtuple_CA --filesInput AOD.root
8 # Grid example:
9 # prun --exec="python -m TrigInDetValidation.TrigInDetValidation_AODtoTrkNtuple_CA --LRT=True --filesInput=%IN" --inDS=DATASETNAME --outDS=OUTPUTNAME --useAthenaPackage --outputs="TrkNtuple-0000.root"
10 
11 import sys
12 
13 from AthenaConfiguration.AllConfigFlags import initConfigFlags
14 flags = initConfigFlags()
15 
16 # Add custom options
17 parser = flags.getArgumentParser()
18 parser.add_argument('--LRT', default=False, help='Turn on LRT flag')
19 parser.add_argument('--doTIDATier0', default=False, help='Turn on Tier-0 Analysis')
20 parser.add_argument('--doNewTIDATier0', default=False, help='Turn on Tier-0 Analysis')
21 parser.add_argument('--parentpdgid', type=int, default=0, help='Set parentpdgid in TIDA')
22 parser.add_argument('--pdgid', type=int, default=0, help='Set pdgid in TIDA')
23 parser.add_argument('--ptmin', type=float, default=1000, help='Set min pT for tracks in TIDA')
24 
25 
26 args, _ = parser.parse_known_args()
27 args = flags.fillFromArgs(parser=parser)
28 
29 
30 if not (hasattr(args, "filesInput") and args.filesInput):
31  flags.Input.Files = ["AOD.pool.root"]
32 
33 flags.lock()
34 
35 from AthenaConfiguration.ComponentFactory import CompFactory
36 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
37 acc = MainServicesCfg(flags)
38 acc.EvtMax = -1 # Set to -1 for all events
39 
40 
41 # Setup to read xAOD
42 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
43 acc.merge(PoolReadCfg(flags))
44 
45 # Setup Trigger Decision Tool
46 from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg
47 tdt = acc.getPrimaryAndMerge(TrigDecisionToolCfg(flags))
48 
49 
50 
51 
52 
53 if args.doTIDATier0 or args.doNewTIDATier0:
54 
55  histsvc=CompFactory.THistSvc()
56  histsvc.Output = ["CombinedMonitoring DATAFILE='data-hists-tier0.root' OPT='RECREATE'"]
57  acc.addService(histsvc)
58 
59  # this is the new location ...
60  from TrigInDetMonitoring.TIDAMonitoring import TrigInDetMonConfig
61  acc.merge( TrigInDetMonConfig( flags ) )
62 
63 
64 
65 
66 if ( True ) :
67  TestMonTool = CompFactory.TrigR3Mon('TrigR3Mon')
68  TestMonTool.buildNtuple = True
69  TestMonTool.AnalysisConfig = "nTuple" #Change to Tier0 for T0 Analysis
70  TestMonTool.EnableLumi = False
71 # TestMonTool.RequireDecision = False
72  TestMonTool.mcTruth = True
73  TestMonTool.pTCutOffline = args.ptmin
74  TestMonTool.ntupleChainNames = []
75  TestMonTool.SelectTruthPdgId=args.pdgid
76  TestMonTool.SelectParentTruthPdgId=args.parentpdgid
77 
78  if args.LRT:
79  TestMonTool.FiducialRadius = 500.
80 
81  TestMonTool.ntupleChainNames += [
82  ":InDetLargeD0TrackParticles",
83  "Muons::LRT",
84  "Muons",
85  "Electrons::LRT"
86  ]
87 
88 
89  TestMonTool.KeepAllEvents = False
90  # TestMonTool.TrigConfigTool = "TrigConf::xAODConfigTool"
91  TestMonTool.ntupleChainNames += [
92  "Offline",
93  "Truth",
94  "Vertex",
95  "Vertex:BTagging_AntiKt4EMPFlowSecVtx",
96  # "Muons",
97  # "Muons:Tight",
98  # "Muons:Medium",
99 
100  # "HLT_j.*bperf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi:vtx=xPrimVx",
101  # "HLT_j.*bperf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi",
102  # "HLT_j.*bperf_split:key=InDetTrigTrackingxAODCnv_Bjet_IDTrig",
103  # "HLT_j.*bperf_split:key=InDetTrigTrackingxAODCnv_Bjet_FTF",
104 
105  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi:vtx=xPrimVx",
106  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi:vtx=EFHistoPrmVtx",
107  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi:vtx=xPrimVx",
108  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi:vtx=EFHistoPrmVtx",
109  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_BjetPrmVtx_FTF:roi=SuperRoi",
110  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_Bjet_IDTrig",
111  # "HLT_j.*b.*perf_split:key=InDetTrigTrackingxAODCnv_Bjet_FTF",
112 
113  "Electrons",
114 
115  "Electrons:MediumCB",
116  "Electrons:TightCB",
117  "Electrons:MediumLH",
118  "Electrons:TightLH",
119 
120  # "Taus",
121 
122  # "Taus_1Prong",
123  # "Taus_Loose_1Prong",
124  # "Taus_Medium_1Prong",
125  # "Taus_Tight_1Prong",
126  # "Taus_3Prong",
127  # "Taus_Loose_3Prong",
128  # "Taus_Medium_3Prong",
129  # "Taus_Tight_3Prong",
130 
131  "Taus:Medium:1Prong",
132  "Taus:Tight:1Prong",
133 
134  # ":HLT_IDTrack_FS_FTF",
135  # ":HLT_IDTrack_FS_FTF:roi=HLT_FSRoI:vtx=HLT_IDVertex_FS",
136 
137  "HLT_j45_subjesgscIS_ftf_boffperf_split_L1J20:key=HLT_IDTrack_Bjet_FTF",
138  "HLT_j45_subjesgscIS_ftf_boffperf_split_L1J20:key=HLT_IDTrack_Bjet_IDTrig",
139 
140  "HLT_j45_ftf_subjesgscIS_boffperf_split_L1J20:key=HLT_IDTrack_FS_FTF:roi=HLT_FSRoI:vtx=HLT_IDVertex_FS",
141 
142  "HLT_.*_presel.*:key=HLT_IDTrack_JetSuper_FTF:roi=HLT_Roi_JetSuper",
143  "HLT_.*_presel.*:key=HLT_IDTrack_JetSuper_FTF:roi=HLT_Roi_JetSuper:vtx=HLT_IDVertex_JetSuper",
144 
145  #ATR-29483: BTaggingSecVtx container is no longer produced
146  #"HLT_j45_0eta290_020jvt_boffperf_pf_ftf_L1J20:key=HLT_IDTrack_Bjet_IDTrig:roi=HLT_Roi_Bjet:vtx=HLT_AntiKt4EMPFlowJets_subresjesgscIS_ftf_BTaggingSecVtx",
147  # don't use FSJet any longer
148  # "HLT_j45_ftf_subjesgscIS_boffperf_split_L1J20:key=HLT_IDTrack_FS_FTF:roi=HLT_FSRoI:vtx=HLT_IDVertex_FSJet",
149  "HLT_j45_pf_ftf_preselj20_L1J15:key=HLT_IDTrack_FS_FTF:roi=HLT_FSRoI:vtx=HLT_IDVertex_FS",
150  # don't use FSJet any longer
151  # "HLT_j45_pf_ftf_preselj20_L1J15:key=HLT_IDTrack_FS_FTF:roi=HLT_FSRoI:vtx=HLT_IDVertex_FSJet",
152 
153  #ATR-29483: BTaggingSecVtx container is no longer produced
154  #"HLT_j45_0eta290_020jvt_boffperf_pf_ftf_L1J20:key=HLT_IDTrack_Bjet_IDTrig:roi=HLT_Roi_Bjet:vtx=HLT_AntiKt4EMPFlowJets_subresjesgscIS_ftf_BTaggingSecVtx",
155 
156  "HLT_fslrt.*:HLT_IDTrack_FSLRT_FTF;DTE",
157  "HLT_fslrt.*:HLT_IDTrack_FS_FTF;DTE",
158  "HLT_fslrt.*:HLT_IDTrack_FSLRT_IDTrig;DTE",
159 
160  "HLT_mu.*_idperf.*:HLT_IDTrack_Muon_FTF",
161  "HLT_mu.*_idperf.*:HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon",
162  "HLT_mu.*_idperf.*:HLT_IDTrack_Muon_IDTrig",
163  "HLT_mu.*_idperf.*:HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuon",
164  "HLT_mu.*iv.*:HLT_IDTrack_MuonIso_FTF:roi=HLT_Roi_MuonIso",
165  "HLT_mu.*iv.*:HLT_IDTrack_MuonIso_IDTrig:roi=HLT_Roi_MuonIso",
166 
167  "HLT_mu.*_LRT_idperf_.*:HLT_IDTrack_MuonLRT_FTF:HLT_Roi_L2SAMuon_LRT",
168  "HLT_mu.*_LRT_idperf_.*:HLT_IDTrack_MuonLRT_IDTrig:HLT_Roi_L2SAMuon_LRT",
169 
170  "HLT_b.*perf.*:HLT_IDTrack_Bjet_FTF",
171  "HLT_b.*perf.*:HLT_IDTrack_Bjet_IDTrig",
172  "HLT_j.*perf.*:HLT_IDTrack_Bjet_FTF",
173  "HLT_j.*perf.*:HLT_IDTrack_Bjet_IDTrig",
174 
175 # "HLT_e.*_etcut.*:HLT_IDTrack_Electron_FTF",
176 # "HLT_e.*_etcut.*:HLT_IDTrack_Electron_IDTrig",
177  "HLT_e.*:HLT_IDTrack_Electron_FTF:roi=HLT_Roi_FastElectron",
178  "HLT_e.*:HLT_IDTrack_Electron_IDTrig",
179  "HLT_e.*:HLT_IDTrack_Electron_GSF",
180 
181 
182  # LRT electron idperf
183  "HLT_e.*idperf.*lrt.*:HLT_IDTrack_ElecLRT_FTF:HLT_Roi_FastElectron_LRT",
184  "HLT_e.*idperf.*lrt.*:HLT_IDTrack_ElecLRT_IDTrig:HLT_Roi_FastElectron_LRT",
185  "HLT_e.*idperf.*lrt.*:HLT_IDTrack_Electron_LRTGSF:HLT_Roi_FastElectron_LRT",
186 
187  # electron lrt e tag
188  "HLT_e26_lhtight_ivarloose_e5_idperf_loose_lrtloose_probe_L1eEM26M:HLT_IDTrack_ElecLRT_FTF:roi=HLT_Roi_FastElectron_LRT:te=1",
189  "HLT_e26_lhtight_ivarloose_e5_idperf_loose_lrtloose_probe_L1eEM26M:HLT_IDTrack_ElecLRT_IDTrig:roi=HLT_Roi_FastElectron_LRT:te=1",
190 
191  "HLT_e26_lhtight_ivarloose_e30_lhloose_nopix_lrtmedium_probe_L1eEM26M:HLT_IDTrack_ElecLRT_FTF:roi=HLT_Roi_FastElectron_LRT:te=1",
192  "HLT_e26_lhtight_ivarloose_e30_lhloose_nopix_lrtmedium_probe_L1eEM26M:HLT_IDTrack_ElecLRT_IDTrig:roi=HLT_Roi_FastElectron_LRT:te=1",
193 
194  # electron lrt photon tag
195  "HLT_e5_idperf_loose_lrtloose_probe_g25_medium_L1eEM24L:HLT_IDTrack_ElecLRT_FTF:roi=HLT_Roi_FastElectron_LRT:te=0",
196  "HLT_e5_idperf_loose_lrtloose_probe_g25_medium_L1eEM24L:HLT_IDTrack_ElecLRT_IDTrig:roi=HLT_Roi_FastElectron_LRT:te=0",
197 
198  "HLT_e30_lhloose_nopix_lrtmedium_probe_g25_medium_L1eEM24L:HLT_IDTrack_ElecLRT_FTF:roi=HLT_Roi_FastElectron_LRT:te=0",
199  "HLT_e30_lhloose_nopix_lrtmedium_probe_g25_medium_L1eEM24L:HLT_IDTrack_ElecLRT_IDTrig:roi=HLT_Roi_FastElectron_LRT:te=0",
200 
201  # double electron chains for tag and probe analysis
202  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_FTF:extra=el_tag:roi=HLT_Roi_FastElectron:te=0",
203  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_FTF:extra=el_probe:roi=HLT_Roi_FastElectron:te=1",
204  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_FTF:roi=HLT_Roi_FastElectron:te=1",
205 
206  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_IDTrig:extra=el_tag:te=0",
207  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_IDTrig:extra=el_probe:te=1",
208  "HLT_e26_lhtight_e14_idperf_tight_nogsf_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_IDTrig:te=1",
209 
210  "HLT_e26_lhtight_e14_idperf_tight_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_GSF:extra=el_tag:te=0",
211  "HLT_e26_lhtight_e14_idperf_tight_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_GSF:extra=el_probe:te=1",
212  "HLT_e26_lhtight_e14_idperf_tight_probe_50invmAB130_L1eEM26M:key=HLT_IDTrack_Electron_GSF:te=1",
213 
214  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon:extra=mu_probe:te=1",
215  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_FTF:roi=HLT_Roi_L2SAMuon:extra=mu_tag:te=0",
216  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_FTF::roi=HLT_Roi_L2SAMuon:te=1",
217 
218  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuon:extra=mu_probe:te=1",
219  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuon:extra=mu_tag:te=0",
220  "HLT_mu14_mu14_idtp_idZmumu_L12MU8F:key=HLT_IDTrack_Muon_IDTrig:roi=HLT_Roi_L2SAMuon:te=1",
221 
222  # two stage tau FTF
223  "HLT_tau.*_idperf.*tracktwo.*:HLT_IDTrack_TauCore_FTF:roi=HLT_Roi_TauCore",
224  "HLT_tau.*_idperf.*tracktwo.*:HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIso",
225  "HLT_tau.*_idperf.*tracktwo.*:HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIsoBDT",
226 
227  # two stage tau precision tracking - empty ???
228  "HLT_tau.*_idperf.*tracktwo.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_TauIso",
229  "HLT_tau.*_idperf.*tracktwo.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_TauIso:vtx=HLT_IDVertex_Tau",
230 
231 
232  # should get single stage tau
233  "HLT_tau.*_idperf.*_track_.*:HLT_IDTrack_Tau_FTF:roi=HLT_Roi_Tau",
234  "HLT_tau.*_idperf.*_track_.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_Tau",
235 
236  # LRT tau
237  "HLT_tau.*trackLRT.*:HLT_IDTrack_TauLRT_FTF:roi=HLT_Roi_TauLRT",
238  "HLT_tau.*trackLRT.*:HLT_IDTrack_TauLRT_IDTrig:roi=HLT_Roi_TauLRT",
239 
240  # none of these will work
241  "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_IDTrig",
242 
243 
244  # only need one instance for the tag of the tag and probe, because we
245  # don't actually use the triggder collections at all, only the Roi and
246  # offline objects in the roi
247  # "HLT_mu.*tau.*_idperf.*:HLT_IDTrack_Muon_FTF:HLT_Roi_L2SAMuon:te=0",
248  "HLT_mu.*tau.*_idperf.*:HLT_IDTrack_Muon_IDTrig:HLT_Roi_L2SAMuon:te=0",
249 
250  "HLT_mu.*tau.*_idperf.*:HLT_IDTrack_TauCore_FTF:roi=HLT_Roi_TauCore:te=1",
251  "HLT_mu.*tau.*_idperf.*:HLT_IDTrack_TauIso_FTF:roi=HLT_Roi_TauIso:te=1",
252  "HLT_mu.*tau.*_idperf.*:HLT_IDTrack_Tau_IDTrig:roi=HLT_Roi_TauIso:te=1",
253 
254  # should work for single stage tau ???
255  # "HLT_tau.*_idperf.*:HLT_IDTrack_Tau_FTF",
256 
257  # should work for a two stage tau ??
258  # "HLT_tau.*_idperf.*:HLT_IDTrack_TauIso_FTF",
259 
260  "HLT_mu4.*_cosmic.*:HLT_IDTrack_Cosmic_FTF",
261  "HLT_mu4.*_cosmic.*:HLT_IDTrack_Cosmic_IDTrig",
262  "HLT_mu4.*_cosmic.*:HLT_IDTrack_Cosmic_EFID",
263 
264  #"HLT_mb.*:HLT_IDTrack_Cosmic_EFID",
265  #"HLT_mb.*:HLT_IDTrack_MinBias_FTF", #There are no tracks here
266  "HLT_mb.*:HLT_IDTrack_MinBias_IDTrig",
267  "HLT_mb.*:HLT_IDTrack_MinBiasPixel_IDTrig",
268  #"HLT_mb.*:HLT_IDTrack_MinBias_EFID" #There are no tracks here
269 
270  "HLT_2mu4_bBmumux_BsmumuPhi_L12MU3V:HLT_IDTrack_Bmumux_FTF",
271  "HLT_2mu4_bBmumux_BsmumuPhi_L12MU3V:HLT_IDTrack_Bmumux_IDTrig",
272  "HLT_mu11_mu6_bBmumux_Bidperf_L1MU8VF_2MU5VF:HLT_IDTrack_Bmumux_FTF",
273  "HLT_mu11_mu6_bBmumux_Bidperf_L1MU8VF_2MU5VF:HLT_IDTrack_Bmumux_IDTrig",
274 
275  #displaced jet lrt
276  "HLT_j180_.*dispjet.*_L1J100:key=HLT_IDTrack_DJLRT_FTF:roi=HLT_Roi_DJ",
277  "HLT_j180_.*dispjet.*_L1jJ160:key=HLT_IDTrack_DJLRT_FTF:roi=HLT_Roi_DJ"
278 
279  ]
280 
281  from PyUtils.Helpers import release_metadata
283  TestMonTool.releaseMetaData = d['nightly name'] + " " + d['nightly release'] + " " + d['date'] + " " + d['platform'] + " " + d['release']
284  TestMonTool.outputFileName="TrkNtuple.root"
285  acc.addEventAlgo(TestMonTool)
286  print (TestMonTool)
287 
288 
289 print ("configured everything")
290 
291 # include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above
292 
293 # Adjust message limits
294 acc.getService("MessageSvc").infoLimit = 100000000
295 
296 # Return a status code
297 sys.exit(not acc.run().isSuccess())
298 
299 
python.Helpers.release_metadata
def release_metadata()
Definition: Tools/PyUtils/python/Helpers.py:143
python.TIDAMonitoring.TrigInDetMonConfig
def TrigInDetMonConfig(flags, monlevels=None)
Definition: TIDAMonitoring.py:542
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.TriggerInterface.TrigDecisionToolCfg
def TrigDecisionToolCfg(flags)
Definition: TriggerInterface.py:14
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69