Skip to content

Commit 164a463

Browse files
authored
Update 01-dd4hep.md
1 parent 74e6cb4 commit 164a463

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

_episodes/01-dd4hep.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ else:
7070
> -__Open a simulation campaign file__
7171
```console
7272
fname = eic_server+fpath+'e-_10GeV_130to177deg.0307.eicrecon.tree.edm4eic.root'
73-
tree_name = "events" #"podio_metadata"
73+
tree_name = "events"
74+
# tree_name = "podio_metadata"
7475
tree = ur.open(fname)[tree_name]
7576
print(f"Read {fname}:{tree_name}. \n {tree.num_entries} events in total")
7677
```
@@ -90,26 +91,26 @@ print(df)
9091

9192

9293
> Exercise 1.3: extract momentum distribution of primary electrons
93-
>
94-
> Make selection
95-
> ```console
96-
from particle import Particle
97-
part = Particle.from_name("e-")
98-
pdg_id = part.pdgid.abspid
99-
condition1 = df["MCParticles.PDG"]==pdg_id # select electrons
100-
condition2 = df["MCParticles.generatorStatus"]==1 # select primary particles
101-
```
102-
> extract momentum
103-
> ```console
104-
df_new = df[condition1] # all electrons
105-
mom = np.sqrt(df_new["MCParticles.momentum.x"]**2+df_new["MCParticles.momentum.y"]**2+df_new["MCParticles.momentum.z"]**2)
106-
bins = np.arange(0,20)
107-
_ = plt.hist(mom,bins=bins,alpha=0.5)
108-
109-
df_new = df[condition1&condition2] # primary electrons
110-
mom = np.sqrt(df_new["MCParticles.momentum.x"]**2+df_new["MCParticles.momentum.y"]**2+df_new["MCParticles.momentum.z"]**2)
111-
_ = plt.hist(mom,bins=bins,histtype="step", color='r')
112-
```
94+
```console
95+
# select electrons
96+
from particle import Particle
97+
part = Particle.from_name("e-")
98+
pdg_id = part.pdgid.abspid
99+
condition1 = df["MCParticles.PDG"]==pdg_id
100+
# select primary particles
101+
condition2 = df["MCParticles.generatorStatus"]==1
102+
103+
# extract momentum and plot
104+
# all electrons
105+
df_new = df[condition1]
106+
mom = np.sqrt(df_new["MCParticles.momentum.x"]**2+df_new["MCParticles.momentum.y"]**2+df_new["MCParticles.momentum.z"]**2)
107+
bins = np.arange(0,20)
108+
_ = plt.hist(mom,bins=bins,alpha=0.5)
109+
# primary electrons
110+
df_new = df[condition1&condition2]
111+
mom = np.sqrt(df_new["MCParticles.momentum.x"]**2+df_new["MCParticles.momentum.y"]**2+df_new["MCParticles.momentum.z"]**2)
112+
_ = plt.hist(mom,bins=bins,histtype="step", color='r')
113+
```
113114
{: .challenge}
114115

115116
{% include links.md %}

0 commit comments

Comments
 (0)