-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathPlotMCParentPosZ.C
More file actions
45 lines (36 loc) · 1.38 KB
/
PlotMCParentPosZ.C
File metadata and controls
45 lines (36 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// An example of how to plot the initial z-position of MCParticle muons
// This uses cut functions defined in common_cuts.hh
//
#include "EventNtuple/rooutil/inc/RooUtil.hh"
#include "EventNtuple/rooutil/inc/common_cuts.hh"
#include "TH1F.h"
using namespace rooutil;
void PlotMCParentPosZ(std::string filename) {
// Create the histogram you want to fill
TH1F* hParentPosZ = new TH1F("hParentPosZ", "", 700,3000,10000);
// Set up RooUtil
RooUtil util(filename);
// util.Debug(true);
// Loop through the events
for (int i_event = 0; i_event < util.GetNEvents(); ++i_event) {
// Get the next event
auto& event = util.GetEvent(i_event);
// Get the e_minus tracks from the event
auto e_minus_tracks = event.GetTracks(is_e_minus);
// Loop through the e_minus tracks
std::cout << "AE: n_e_minus_tracks = " << e_minus_tracks.size() << std::endl;
for (auto& track : e_minus_tracks) {
// Get the track segments at the tracker entrance and has an MC step
auto parent_particles = track.GetMCParticles(is_track_parent);
// Loop through the tracker entrance track segments
std::cout << "AE: n_parents = " << parent_particles.size() << std::endl;
for (auto& particle : parent_particles) {
// Fill the histogram
hParentPosZ->Fill(particle.mcsim->pos.z());
}
}
}
// Draw the histogram
hParentPosZ->Draw("HIST E");
}