File tree Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 55
55
" nqueries" ,
56
56
" ntuples" ,
57
57
" numpy" ,
58
+ " opendata" ,
58
59
" pathlib" ,
60
+ " PHYSLITE" ,
59
61
" pnfs" ,
60
62
" posix" ,
61
63
" Powheg" ,
94
96
" unittests" ,
95
97
" URL's" ,
96
98
" xaod" ,
99
+ " xaodr" ,
97
100
" xrootd"
98
101
],
99
102
"python.analysis.typeCheckingMode" : " basic" ,
Original file line number Diff line number Diff line change @@ -59,6 +59,34 @@ from the ``CollectionTree`` tree in ATLAS PHYSLITE OpenData Dataset.
59
59
:language: yaml
60
60
61
61
62
+ Func_ADL xAOD Query Example
63
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
+
65
+ The two following examples read columns of data from an ATLAS PHYSLITE xAOD file
66
+ (released by the experiment as OpenData). It uses the internal C++ framework, EventLoop, to read this data.
67
+ EventLoop can be used to read xAOD files in general, not just PHYSLITE.
68
+
69
+ THe first example uses the very simple model that is built into ServiceX:
70
+
71
+ .. tabs ::
72
+
73
+ .. tab :: *Python Dict*
74
+
75
+ .. literalinclude :: ../examples/func_adl_xAOD_simple.py
76
+ :language: python
77
+
78
+ The second example uses the full type information, allowing one to
79
+ access everything that could be translated in the xAOD (including ElementLink following):
80
+
81
+ .. tabs ::
82
+
83
+ .. tab :: *Python Dict*
84
+
85
+ .. literalinclude :: ../examples/func_adl_xAOD_typed.py
86
+ :language: python
87
+
88
+ For this second example, make sure the extra package `func_adl_servicex_xaodr22 ` is installed!
89
+
62
90
Python Function Query Example
63
91
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
92
This example uses an uproot python function to extract the ``AnalysisElectronsAuxDyn.pt `` branch
Original file line number Diff line number Diff line change
1
+ from servicex import query as q , deliver , dataset
2
+
3
+
4
+ def func_adl_xaod_simple ():
5
+ query = q .FuncADL_ATLASr22 () # type: ignore
6
+ jets_per_event = query .Select (lambda e : e .Jets ('AnalysisJets' ))
7
+ jet_info_per_event = jets_per_event .Select (
8
+ lambda jets : {
9
+ 'pt' : jets .Select (lambda j : j .pt ()),
10
+ 'eta' : jets .Select (lambda j : j .eta ())
11
+ }
12
+ )
13
+
14
+ spec = {
15
+ 'Sample' : [{
16
+ 'Name' : "func_adl_xAOD_simple" ,
17
+ 'Dataset' : dataset .FileList (
18
+ [
19
+ "root://eospublic.cern.ch//eos/opendata/atlas/rucio/mc20_13TeV/DAOD_PHYSLITE.37622528._000013.pool.root.1" , # noqa: E501
20
+ ]
21
+ ),
22
+ 'Query' : jet_info_per_event
23
+ }]
24
+ }
25
+ files = deliver (spec , servicex_name = "servicex-uc-af" )
26
+ assert files is not None , "No files returned from deliver! Internal error"
27
+ return files
28
+
29
+
30
+ if __name__ == "__main__" :
31
+ files = func_adl_xaod_simple ()
32
+ assert len (files ['func_adl_xAOD_simple' ]) == 1
Original file line number Diff line number Diff line change
1
+ from servicex import deliver , dataset
2
+ from func_adl_servicex_xaodr22 import FuncADLQueryPHYSLITE , cpp_float
3
+
4
+
5
+ def func_adl_xaod_typed ():
6
+ query = FuncADLQueryPHYSLITE () # type: ignore
7
+ jets_per_event = query .Select (lambda e : e .Jets ('AnalysisJets' ))
8
+ jet_info_per_event = jets_per_event .Select (
9
+ lambda jets : {
10
+ 'pt' : jets .Select (lambda j : j .pt ()),
11
+ 'eta' : jets .Select (lambda j : j .eta ()),
12
+ 'emf' : jets .Select (lambda j : j .getAttribute [cpp_float ]('EMFrac' )) # type: ignore
13
+ }
14
+ )
15
+
16
+ spec = {
17
+ 'Sample' : [{
18
+ 'Name' : "func_adl_xAOD_simple" ,
19
+ 'Dataset' : dataset .FileList (
20
+ [
21
+ "root://eospublic.cern.ch//eos/opendata/atlas/rucio/mc20_13TeV/DAOD_PHYSLITE.37622528._000013.pool.root.1" , # noqa: E501
22
+ ]
23
+ ),
24
+ 'Query' : jet_info_per_event ,
25
+ 'Codegen' : 'atlasr22' ,
26
+ }]
27
+ }
28
+ files = deliver (spec , servicex_name = "servicex-uc-af" )
29
+ assert files is not None , "No files returned from deliver! Internal error"
30
+ return files
31
+
32
+
33
+ if __name__ == "__main__" :
34
+ files = func_adl_xaod_typed ()
35
+ assert len (files ['func_adl_xAOD_simple' ]) == 1
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ docs = [
84
84
" furo>=2023.5.20" ,
85
85
" sphinx-code-include>=1.4.0" ,
86
86
" myst-parser>=3.0.1" ,
87
+ " func-adl-servicex-xaodr22" ,
87
88
" autodoc-pydantic==2.2.0" ,
88
89
" sphinx-tabs>=3.4.5"
89
90
]
You can’t perform that action at this time.
0 commit comments