ATLAS Offline Software
test_athena_ntuple_filter.py
Go to the documentation of this file.
1 
2 import AthenaCommon.Constants as Lvl
3 from AthenaCommon.AppMgr import theApp
4 from AthenaCommon.AppMgr import ServiceMgr as svcMgr
5 
6 # get a handle on the job main sequence
7 from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
8 job = AlgSequence()
9 
10 
11 DOWRITE=0
12 include("AthenaRootComps/test_athena_ntuple_dumper.py")
13 
14 
18 seq = AthSequencer("AthMasterSeq")
19 
20 from GaudiSequencer.PyComps import PyEvtFilter
21 seq += PyEvtFilter(
22  'alg',
23  # the store-gate key. leave as an empty string to take any eventinfo instance
24  evt_info='TTreeEventInfo',
25  OutputLevel=Lvl.INFO)
26 
27 #seq.alg.evt_list = [1, 4, 5, 6]
28 # for the list of event numbers above, apply the following
29 # filter policy (ie: here we accept event numbers 1,4,5,6)
30 seq.alg.filter_policy = 'accept' # 'reject'
31 
32 # we could have use a lambda function selecting 'even' event numbers
33 # NOTE: you can't use both 'evt_list' and 'filter_fct'
34 # NOTE: the signature of the lambda function *has* to be 'run,evt'
35 seq.alg.filter_fct = lambda run,evt: evt%2 == 0
36 
37 
38 svcMgr += CfgMgr.DecisionSvc()
39 import AthenaRootComps.WriteAthenaRoot as arcw
40 out = arcw.createNtupleOutputStream("StreamD3PD", "d3pd.root", "egamma",
41  asAlg=True)
42 # force reading and accessing all input keys
43 # copy the whole input tree layout
44 out.ItemList = ["*"]
45 # honor the event selection
46 out.AcceptAlgs = [seq.name()]
47 
48 # we now add an event counter in the usual TopAlg sequence to see
49 # the result of the filtering above
50 job += CfgMgr.AthEventCounter('counter', OutputLevel=Lvl.INFO)
51 
52 svcMgr.MessageSvc.OutputLevel = Lvl.ERROR
53 theApp.EvtMax = 5
54 
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
Constants
some useful constants -------------------------------------------------—
python.Include.include
include
Definition: Include.py:319
python.AlgSequence.AthSequencer
AthSequencer
Definition: Control/AthenaCommon/python/AlgSequence.py:64