ATLAS Offline Software
Loading...
Searching...
No Matches
HIEventSelectionRun3Config.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator, ConfigurationError
4from AthenaConfiguration.ComponentFactory import CompFactory
5import AthenaCommon.SystemOfUnits as Units
6from InDetTrackSelectionTool.InDetTrackSelectionToolConfig import InDetTrackSelectionTool_HILoose_Cfg
7
9 acc = ComponentAccumulator()
10 # in future decide cut level for tracks depending on input dataset
11 # for now default to HILoose cuts set with 0.5 GeV
12 trackSelectionTool = acc.popToolsAndMerge(InDetTrackSelectionTool_HILoose_Cfg(flags,
13 minPt=0.5*Units.GeV))
14 filterTool = CompFactory.HI.HIEventSelectionToolRun3(TrackSelectionTool=trackSelectionTool)
15
16 # ZDC modules collection change its name
17 zdcKey=None
18 zdcNeeded=True # in the future add check if ZDC info is required in fact
19 if zdcNeeded and "ZDCModules" in flags.Input.Collections:
20 zdcKey="ZDCModules"
21 elif zdcNeeded and "ZdcSums" in flags.Input.Collections:
22 zdcKey="ZdcSums"
23
24 if zdcNeeded and not zdcKey:
25 raise ConfigurationError("The input file does not have any ZDCModules (any capitalisation) container and ZDC info is needed for selection")
26
27 filterAlg = CompFactory.HI.HIEventFilterAlgRun3(name="HIEventFilterAlgRun3",
28 SelectionTool=filterTool,
29 ZDC=zdcKey)
30 acc.addEventAlgo(filterAlg)
31 return acc
32
33if __name__ == '__main__':
34 from AthenaConfiguration.AllConfigFlags import initConfigFlags
35
36 from AthenaConfiguration.TestDefaults import defaultTestFiles
37 # test needs to wait for files to be on CVMFS
38 inputAOD = f"{defaultTestFiles.d}/DerivationFrameworkART/data18_hi.00365602.physics_HardProbes.merge.AOD.f1021_m2037._lb0203._0001.1"
39 # let me keep it for the moment as it helps in development
40 # inputAOD = "/ATLAS/tbold/DATA/data18_hi.00365709.physics_HardProbes.merge.AOD.r16298_p6665/AOD.45808281._001414.pool.root.1"
41 # inputAOD= "/ATLAS/tbold/DATA/data25_hi.00501879.physics_MinBias.merge.AOD.f1606_m2272/data25_hi.00501879.physics_MinBias.merge.AOD.f1606_m2272._lb0142._0040.1"
42 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
43
44 flags = initConfigFlags()
45 flags.Exec.MaxEvents=10
46 flags.Input.Files=[inputAOD]
47 flags.lock()
48
49 acc=MainServicesCfg(flags)
50 # if need to read POOL file
51 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
52 acc.merge(PoolReadCfg(flags))
53 from AthenaCommon.Constants import DEBUG
54
55 acc.merge(HIEventSelectionRun3Cfg(flags))
56 acc.foreach_component("**/AthAlgSeq/*Run3*").OutputLevel=DEBUG
57
58 filterAlg = acc.getEventAlgo("HIEventFilterAlgRun3")
59 # test if we can set custom selection (required python access to enums defined in C++)
60 import ROOT
61 filterAlg.SelectionMask=ROOT.HI.SelectionMask.NoEventError & ROOT.HI.SelectionMask.PUFCalVsZDCAny
62 # test, in order to realy run needs to wait for files to be on CVMFS,
63 filterAlg.SelectionMask=ROOT.HI.SelectionMask.NoEventError
64 filterAlg.UseIonDataTypeDefaultMask=False
65 acc.printConfig(withDetails=True)
66 # either
67 status = acc.run()
68 if status.isFailure():
69 import sys
70 sys.exit(-1)