Skip to content
This repository was archived by the owner on Mar 31, 2019. It is now read-only.

Commit cef509e

Browse files
committed
Change trackparams to params
1 parent bbe5511 commit cef509e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/CMSSW-with-C-interface/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ We added c2numpy to this analyzer by copying the header file into `Demo/DemoAnal
3131
3. Adding a
3232

3333
```c++
34-
c2numpy_init(&writer, "output/trackparams", 1000);
34+
c2numpy_init(&writer, "output/params", 1000);
3535
c2numpy_addcolumn(&writer, "pt", C2NUMPY_FLOAT64);
3636
c2numpy_addcolumn(&writer, "eta", C2NUMPY_FLOAT64);
3737
c2numpy_addcolumn(&writer, "phi", C2NUMPY_FLOAT64);
@@ -65,7 +65,7 @@ mkdir output
6565
cmsRun Demo/DemoAnalyzer/python/ConfFile_cfg.py
6666
```
6767

68-
When CMSSW runs over the 10-event dataset, it produces seven files in `output` named `trackparams0.npy` through `trackparams6.npy`. To make one file, increase the number of rows per file (currently 1000) in the `c2numpy_init` call, recompile, and rerun.
68+
When CMSSW runs over the 10-event dataset, it produces seven files in `output` named `params0.npy` through `params6.npy`. To make one file, increase the number of rows per file (currently 1000) in the `c2numpy_init` call, recompile, and rerun.
6969

7070
These files should match the ones in this repository.
7171

@@ -75,13 +75,13 @@ You can load any of the files in a Python session. Start a Python prompt and do
7575

7676
```python
7777
import numpy as np
78-
>>> trackparams0 = np.load("output/trackparams0.npy")
78+
>>> params0 = np.load("output/params0.npy")
7979
```
8080

8181
to get the recarray. This array represents a table of data with typed, named columns (just like a flat ROOT NTuple or a Pandas DataFrame). You can access it a column at a time:
8282

8383
```python
84-
>>> trackparams0["pt"]
84+
>>> params0["pt"]
8585
array([ 0.58615864, 0.47248294, 1.74911408, 1.04643586,
8686
0.47096605, 0.59780441, 0.88029248, 3.06881774,
8787
0.66100567, 1.33790879, 0.65042406, 0.60015372,
@@ -90,25 +90,25 @@ array([ 0.58615864, 0.47248294, 1.74911408, 1.04643586,
9090
...
9191

9292
# to see array shape we can use built in numpy functionality
93-
>>> print np.shape(trackparams0)
93+
>>> print np.shape(params0)
9494
(1000,)
9595
```
9696

9797
a row at a time:
9898

9999
```python
100-
>>> trackparams0[100]
100+
>>> params0[100]
101101
(1.384070332555011, 0.18779495889500655, -1.6946575614328503, 0.19390893548491872, 0.39640133641298614)
102-
>>> trackparams0.dtype.names
102+
>>> params0.dtype.names
103103
('pt', 'eta', 'phi', 'dxy', 'dz')
104-
>>> trackparams0.dtype["pt"]
104+
>>> params0.dtype["pt"]
105105
dtype('float64')
106106
```
107107

108108
or any combination:
109109

110110
```python
111-
>>> trackparams0["pt"][100:150]
111+
>>> params0["pt"][100:150]
112112
array([ 1.38407033, 0.5997181 , 2.64444269, 1.17549855, 2.81446767,
113113
1.41189475, 2.28960126, 0.56264374, 1.43745931, 0.78332034,
114114
1.34970658, 0.81638258, 1.52328245, 0.60757518, 1.1785421 ,
@@ -127,7 +127,7 @@ Let's convert this into pandas DataFrame and see how we can access the data
127127

128128
```python
129129
>>> import pandas as pd
130-
>>> df = pd.DataFrame(trackparams0)
130+
>>> df = pd.DataFrame(params0)
131131
>>> # access first tree rows
132132
>>> print df.iloc[:3]
133133
dxy dz

0 commit comments

Comments
 (0)