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
11 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
12 monTool = GenericMonitoringTool(flags, "MonTool")
13 monTool.defineHistogram( 'fcalEt,zdcE;fcalEt_vs_zdcE_all', path='EXPERT', type='TH2F', title=';FCal Et;ZDC E',
14 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=60)
15
16 monTool.defineHistogram( 'fcalEt,zdcE;fcalEt_vs_zdcE_passed', cutmask='PUFCalVsZDCAny_passed', path='EXPERT', type='TH2F', title=';FCal Et;ZDC E',
17 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=60)
18
19 monTool.defineHistogram( 'fcalEt,zdcE;fcalEt_vs_zdcE_failed', cutmask='PUFCalVsZDCAny_failed', path='EXPERT', type='TH2F', title=';FCal Et;ZDC E',
20 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=60)
21
22 monTool.defineHistogram( 'fcalEt,nTrk;fcalEt_vs_nTrk_all', path='EXPERT', type='TH2F', title=';FCal Et;nTrk',
23 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=600)
24
25 monTool.defineHistogram( 'fcalEt,nTrk;fcalEt_vs_nTrk_passed', cutmask='PUFCalVsNTrackAny_passed', path='EXPERT', type='TH2F', title=';FCal Et;nTrk',
26 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=600)
27
28 monTool.defineHistogram( 'fcalEt,nTrk;fcalEt_vs_nTrk_failed', cutmask='PUFCalVsNTrackAny_failed', path='EXPERT', type='TH2F', title=';FCal Et;nTrk',
29 xbins=160, xmin=0, xmax=1000, ybins=120, ymin=0, ymax=600)
30 prefix=flags.Input.Files[0].split("/")[-1]
31 histsvc = CompFactory.THistSvc(Output=[f"EXPERT DATAFILE='{prefix}HIEventSelectionRun3Validation.root' OPT='RECREATE'"])
32 acc.addService(histsvc)
33 acc.setPrivateTools(monTool)
34 return acc
35
36
37
38def HIEventSelectionRun3Cfg(flags, enableValidation=False):
39 acc = ComponentAccumulator()
40 # in future decide cut level for tracks depending on input dataset
41 # for now default to HILoose cuts set with 0.5 GeV
42 trackSelectionTool = acc.popToolsAndMerge(InDetTrackSelectionTool_HILoose_Cfg(flags,
43 minPt=0.5*Units.GeV))
44 filterTool = CompFactory.HI.HIEventSelectionToolRun3(TrackSelectionTool=trackSelectionTool)
45
46 # ZDC modules collection change its name
47 zdcKey=None
48 zdcNeeded=True # in the future add check if ZDC info is required in fact
49 if zdcNeeded and "ZDCModules" in flags.Input.Collections:
50 zdcKey="ZDCModules"
51 elif zdcNeeded and "ZdcSums" in flags.Input.Collections:
52 zdcKey="ZdcSums"
53
54 if zdcNeeded and not zdcKey:
55 raise ConfigurationError("The input file does not have any ZDCModules (any capitalisation) container and ZDC info is needed for selection")
56
57 monTool = acc.popToolsAndMerge(HIEventSelectionRun3MonToolCfg(flags)) if enableValidation else None
58
59 filterAlg = CompFactory.HI.HIEventFilterAlgRun3(name="HIEventFilterAlgRun3",
60 SelectionTool=filterTool,
61 ZDC=zdcKey,
62 MonTool=monTool )
63 acc.addEventAlgo(filterAlg)
64 return acc
65
66if __name__ == '__main__':
67 from AthenaConfiguration.AllConfigFlags import initConfigFlags
68
69 data_hi="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/data_hi/"
70 test_files = {"23PbPb":"data23_hi.00463364.physics_HardProbes.AOD.r16069_p6447_skim",
71 "24PbPb":"data24_hi.00490145.physics_HardProbes.AOD.f1550_m2267_skim",
72 "25OO": "data25_hi.00501859.physics_MinBias.AOD.f1606_m2272_skim",
73 "25NeNe": "data25_hi.00502008.physics_MinBias.AOD.f1606_m2272_skim",
74 "25pO": "data25_hip.00501607.physics_MinBias.AOD.f1604_m2272_skim" }
75
76 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
77
78 flags = initConfigFlags()
79 flags.addFlag("HIPeriodToTest", "23")
80 flags.Exec.MaxEvents=10
81 flags.Exec.MaxEvents=-1
82 flags.Input.Files=lambda fl: [data_hi+test_files[fl.HIPeriodToTest]]
83 flags.fillFromArgs()
84 flags.lock()
85
86 acc=MainServicesCfg(flags)
87 # if need to read POOL file
88 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
89 acc.merge(PoolReadCfg(flags))
90 from AthenaCommon.Constants import DEBUG
91
92 acc.merge(HIEventSelectionRun3Cfg(flags, enableValidation=True))
93 acc.foreach_component("**/AthAlgSeq/*Run3*").OutputLevel=DEBUG
94
95 filterAlg = acc.getEventAlgo("HIEventFilterAlgRun3")
96 # test if we can set custom selection (required python access to enums defined in C++)
97 # import ROOT
98 # filterAlg.SelectionMask=ROOT.HI.SelectionMask.NoEventError & ROOT.HI.SelectionMask.PUFCalVsZDCAny
99 filterAlg.UseIonDataTypeDefaultMask=True
100 acc.printConfig(withDetails=True)
101 # either
102 status = acc.run()
103 if status.isFailure():
104 import sys
105 sys.exit(-1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
HIEventSelectionRun3Cfg(flags, enableValidation=False)