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
31
32
33 monTool.defineHistogram( 'zdcPreSampleA;zdcPreSampleA_all', path='EXPERT', type='TH1F', title='all;ZDCPreampleAmp side A',
34 xbins=100, xmin=-400, xmax=1000)
35
36 monTool.defineHistogram( 'zdcPreSampleC;zdcPreSampleC_all', path='EXPERT', type='TH1F', title='all;ZDCPreampleAmp side C',
37 xbins=100, xmin=-400, xmax=1000)
38
39
40 monTool.defineHistogram( 'zdcPreSampleA,zdcPreSampleC', path='EXPERT', type='TH2F', title='correlation;ZDCPreampleAmp side A;ZDCPreampleAmp side C',
41 xbins=50, xmin=-400, xmax=1000, ybins=50, ymin=-400, ymax=1000)
42
43 monTool.defineHistogram( 'zdcPreSampleA;zdcPreSampleA_failed', cutmask="NoPUZDCPresampler_failed", path='EXPERT', type='TH1F', title='failed;ZDCPreampleAmp side A',
44 xbins=100, xmin=-400, xmax=1000)
45
46 monTool.defineHistogram( 'zdcPreSampleC;zdcPreSampleC_failed', cutmask="NoPUZDCPresampler_failed", path='EXPERT', type='TH1F', title='failed;ZDCPreampleAmp side C',
47 xbins=100, xmin=-400, xmax=1000)
48
49 monTool.defineHistogram( 'fcalEt;OO_all', path='EXPERT', type='TH1F', title='all;FCal Et sum',
50 xbins=100, xmin=0, xmax=1000)
51 monTool.defineHistogram( 'fcalEt;OO_1_FCalNtrk', cutmask='OO_1_passed', path='EXPERT', type='TH1F', title='FCalNtrk;FCal Et sum',
52 xbins=100, xmin=0, xmax=1000)
53 monTool.defineHistogram( 'fcalEt;OO_2_Vtx', cutmask='OO_2_passed', path='EXPERT', type='TH1F', title='FCalNtrk and Vtx;FCal Et sum',
54 xbins=100, xmin=0, xmax=1000)
55 monTool.defineHistogram( 'fcalEt;OO_3_FCalZdc', cutmask='OO_3_passed', path='EXPERT', type='TH1F', title='FCalNtrk and Vtx and FCal ZDC;FCal Et sum',
56 xbins=100, xmin=0, xmax=1000)
57 monTool.defineHistogram( 'fcalEt;OO_4_TCFCal', cutmask='OO_4_passed', path='EXPERT', type='TH1F', title='FCalNtrk and Vtx and FCal ZDC and topoClusterInFCal;FCal Et sum',
58 xbins=100, xmin=0, xmax=1000)
59
60
61 prefix=flags.Input.Files[0].split("/")[-1]
62 histsvc = CompFactory.THistSvc(Output=[f"EXPERT DATAFILE='{prefix}HIEventSelectionRun3Validation.root' OPT='RECREATE'"])
63 acc.addService(histsvc)
64 acc.setPrivateTools(monTool)
65 return acc
66
67
68
69def HIEventSelectionRun3Cfg(flags, enableValidation=False):
70 acc = ComponentAccumulator()
71 # in future decide cut level for tracks depending on input dataset
72 # for now default to HILoose cuts set with 0.5 GeV
73 trackSelectionTool = acc.popToolsAndMerge(InDetTrackSelectionTool_HILoose_Cfg(flags,
74 minPt=0.5*Units.GeV))
75 filterTool = CompFactory.HI.HIEventSelectionToolRun3(TrackSelectionTool=trackSelectionTool)
76
77 # ZDC modules collection change its name
78 zdcKey=None
79 zdcNeeded=True # in the future add check if ZDC info is required in fact
80 if zdcNeeded and "ZdcModules" in flags.Input.Collections:
81 zdcKey="ZdcModules"
82 elif zdcNeeded and "ZDCModules" in flags.Input.Collections:
83 zdcKey="ZDCModules"
84 elif zdcNeeded and "ZdcSums" in flags.Input.Collections:
85 zdcKey="ZdcSums"
86
87 if zdcNeeded and not zdcKey:
88 raise ConfigurationError("The input file does not have any ZDCModules (any capitalisation) container and ZDC info is needed for selection")
89
90 monTool = acc.popToolsAndMerge(HIEventSelectionRun3MonToolCfg(flags)) if enableValidation else None
91
92 filterAlg = CompFactory.HI.HIEventFilterAlgRun3(name="HIEventFilterAlgRun3",
93 SelectionTool=filterTool,
94 ZDC=zdcKey,
95 MonTool=monTool )
96 acc.addEventAlgo(filterAlg)
97 return acc
98
99if __name__ == '__main__':
100 from AthenaConfiguration.AllConfigFlags import initConfigFlags
101
102 data_hi="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/data_hi/"
103 test_files = {"23PbPb":"data23_hi.00463364.physics_HardProbes.AOD.r16069_p6447_skim",
104 "24PbPb":"data24_hi.00490145.physics_HardProbes.AOD.f1550_m2267_skim",
105 "25OO": "data25_hi.00501859.physics_MinBias.AOD.f1606_m2272_skim",
106 "25NeNe": "data25_hi.00502008.physics_MinBias.AOD.f1606_m2272_skim",
107 "25pO": "data25_hip.00501607.physics_MinBias.AOD.f1604_m2272_skim" }
108
109 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
110
111 flags = initConfigFlags()
112 flags.addFlag("HIPeriodToTest", "23")
113 flags.Exec.MaxEvents=10
114 flags.Exec.MaxEvents=-1
115 flags.Input.Files=lambda fl: [data_hi+test_files[fl.HIPeriodToTest]]
116 flags.fillFromArgs()
117 flags.lock()
118
119 acc=MainServicesCfg(flags)
120 # if need to read POOL file
121 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
122 acc.merge(PoolReadCfg(flags))
123 from AthenaCommon.Constants import DEBUG
124
125 acc.merge(HIEventSelectionRun3Cfg(flags, enableValidation=True))
126 acc.foreach_component("**/AthAlgSeq/*Run3*").OutputLevel=DEBUG
127
128 filterAlg = acc.getEventAlgo("HIEventFilterAlgRun3")
129 # test if we can set custom selection (required python access to enums defined in C++)
130 # import ROOT
131 # filterAlg.SelectionMask=ROOT.HI.SelectionMask.NoEventError & ROOT.HI.SelectionMask.PUFCalVsZDCAny
132 filterAlg.UseIonDataTypeDefaultMask=True
133 acc.printConfig(withDetails=True)
134 # either
135 status = acc.run()
136 if status.isFailure():
137 import sys
138 sys.exit(-1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179
HIEventSelectionRun3Cfg(flags, enableValidation=False)