70
70
> -__ Open a simulation campaign file__
71
71
``` console
72
72
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"
74
75
tree = ur.open(fname)[tree_name]
75
76
print(f"Read {fname}:{tree_name}. \n {tree.num_entries} events in total")
76
77
```
@@ -90,26 +91,26 @@ print(df)
90
91
91
92
92
93
> 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
+ ```
113
114
{: .challenge}
114
115
115
116
{% include links.md %}
0 commit comments