5 '''@file ExampleMonitorAlgorithm.py
9 @brief Example python configuration for the Run III AthenaMonitoring package
13 '''Function to configures some algorithms in the monitoring system.'''
24 from AthenaMonitoring
import AthMonitorCfgHelper
25 helper = AthMonitorCfgHelper(flags,
'ExampleAthMonitorCfg')
35 from AthenaConfiguration.ComponentFactory
import CompFactory
36 exampleMonAlg = helper.addAlgorithm(CompFactory.ExampleMonitorAlgorithm,
'ExampleMonAlg')
40 anotherExampleMonAlg = helper.addAlgorithm(CompFactory.ExampleMonitorAlgorithm,
'AnotherExampleMonAlg')
66 myGroup = helper.addGroup(
73 anotherGroup = helper.addGroup(anotherExampleMonAlg,
'ExampleMonitor')
78 myGroup.defineHistogram(
'lumiPerBCID',title=
'Luminosity,WithCommaInTitle;L/BCID;Events',
79 path=
'ToRuleThemAll',xbins=40,xmin=0.0,xmax=80.0)
80 myGroup.defineHistogram(
'lb', title=
'Luminosity Block;lb;Events',
81 path=
'ToFindThem',xbins=1000,xmin=-0.5,xmax=999.5,weight=
'testweight')
82 myGroup.defineHistogram(
'random;random2', title=
'LB;x;Events',
83 path=
'ToBringThemAll',xbins=30,xmin=0,xmax=1,opt=
'kLBNHistoryDepth=10')
84 myGroup.defineHistogram(
'random', title=
'title;x;y',path=
'ToBringThemAll',
85 xbins=[0,.1,.2,.4,.8,1.6])
86 myGroup.defineHistogram(
'random,pT', type=
'TH2F', title=
'title;x;y',path=
'ToBringThemAll',
87 xbins=[0,.1,.2,.4,.8,1.6],ybins=[0,10,30,40,60,70,90])
89 myGroup.defineHistogram(
'lumiPerBCID;lumiPerBCID_merge',title=
'Luminosity,WithCommaInTitle;L/BCID;Events',
90 path=
'ToRuleThemAll',xbins=40,xmin=0.0,xmax=80.0, merge=
'weightedAverage')
92 myGroup.defineHistogram(
'evtstr', title=
'Event number as string;Event number;Events',
93 xbins=2500, path=
'ToRuleThemAll', merge=
'merge')
95 myGroup.defineHistogram(
'pT_passed,pT', type=
'TEfficiency', title=
'Test TEfficiency;x;Eff',
96 path=
'AndInTheDarkness', xbins=100, xmin=0.0, xmax=50.0)
97 myGroup.defineHistogram(
'pT_passed,pT,random', type=
'TEfficiency', title=
'Test TEfficiency 2D;x;y;Eff',
98 path=
'AndInTheDarkness', xbins=100, xmin=0.0, xmax=50.0,
99 ybins=10, ymin=0.0, ymax=2.0)
101 myGroup.defineHistogram(
'pT;pT_with_cut', title=
'p_{T};p_{T};Events', path=
'AndInTheDarkness',
102 xbins=50, xmin=0, xmax=50, cutmask=
'pT_passed')
104 myGroup.defineHistogram(
'dummy;alwaysempty', title=
'Plot is always empty', path=
'AndInTheDarkness',
105 xbins=50, xmin=0, xmax=50, opt=
'kAlwaysCreate')
107 myGroup.defineTree(
'pT,lb,pT_vec,strvec,str;testtree', path=
'BindThem',
108 treedef=
'pT/F:lb/i:pT_vec/vector<float>:strvec/vector<string>:str/string')
110 anotherGroup.defineHistogram(
'lbWithFilter',title=
'Lumi;lb;Events',
111 path=
'top',xbins=1000,xmin=-0.5,xmax=999.5)
112 anotherGroup.defineHistogram(
'run',title=
'Run Number;run;Events',
113 path=
'top',xbins=1000000,xmin=-0.5,xmax=999999.5)
119 for alg
in [exampleMonAlg, anotherExampleMonAlg]:
121 topPath =
'OneRing' if alg == exampleMonAlg
else 'top'
122 array = helper.addArray([2],alg,
'ExampleMonitor', topPath=topPath)
123 array.defineHistogram(
'a,b',title=
'AB',type=
'TH2F',path=
'Eta',
124 xbins=10,xmin=0.0,xmax=10.0,
125 ybins=10,ymin=0.0,ymax=10.0)
126 array.defineHistogram(
'c',title=
'C',path=
'Eta',
127 xbins=10,xmin=0.0,xmax=10.0)
128 array = helper.addArray([4,2],alg,
'ExampleMonitor', topPath=topPath)
129 array.defineHistogram(
'a',title=
'A',path=
'EtaPhi',
130 xbins=10,xmin=0.0,xmax=10.0)
133 layerList = [
'layer1',
'layer2']
134 clusterList = [
'clusterX',
'clusterB']
135 array1D = helper.addArray([layerList], alg,
'ExampleMonitor', topPath=topPath)
136 array1D.defineHistogram(
'c', title=
'C', path=
'Layer',
137 xbins=10, xmin=0, xmax=10.0)
138 array2D = helper.addArray([layerList, clusterList], alg,
'ExampleMonitor', topPath=topPath)
139 array2D.defineHistogram(
'c', title=
'C', path=
'LayerCluster',
140 xbins=10, xmin=0, xmax=10.0)
143 array1D.defineHistogram(
'c', title=
'Layer {0}', path=
'Keys', xmax=3.)
144 array1D.defineHistogram(
'c;c_alternate', title=
'Layer', path=
'Keys/{0}', xmax=3.)
145 array1D.defineHistogram(
'c;c_{0}_formatted', path=
'Keys', xmax=3.)
146 array2D.defineHistogram(
'c', title=
'Cluster {1}, Layer {0}', path=
'Keys/{1}', xmax=3.)
149 array2D.defineHistogram(
'c;c_restricted', path=
'Keys', pattern=[(
'layer1',
'clusterB'), (
'layer2',
'clusterX')])
156 return helper.result()
163 if __name__==
'__main__':
165 from AthenaCommon.Logging
import log
170 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
173 nightly =
'/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/CommonInputs/'
174 file =
'data16_13TeV.00311321.physics_Main.recon.AOD.r9264/AOD.11038520._000001.pool.root.1'
175 flags.Input.Files = [nightly+file]
176 flags.Input.isMC =
False
177 flags.Output.HISTFileName =
'ExampleMonitorOutput.root'
178 flags.fillFromArgs(sys.argv[1:])
183 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
184 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
189 cfg.merge(exampleMonitorAcc)
193 cfg.printConfig(withDetails=
False)