|
| 1 | +// |
| 2 | +// An example of how to plot the momentum of electrons at the tracker entrance |
| 3 | +// This uses cut functions defined in common_cuts.hh |
| 4 | +// |
| 5 | + |
| 6 | +#include "EventNtuple/rooutil/inc/RooUtil.hh" |
| 7 | +#include "EventNtuple/rooutil/inc/common_cuts.hh" |
| 8 | + |
| 9 | +#include "TH1F.h" |
| 10 | + |
| 11 | +void PlotEntranceMomentumTriggeredEvents(std::string filename) { |
| 12 | + |
| 13 | + // Create the histogram you want to fill |
| 14 | + TH1F* hRecoMomAll = new TH1F("hRecoMomAll", "Reconstructed Momentum at Tracker Entrance", 50,95,110); |
| 15 | + TH1F* hRecoMom_tprDe_highP_stopTarg = new TH1F("hRecoMom_tprDe_highP_stopTarg", "Reconstructed Momentum at Tracker Entrance", 50,95,110); |
| 16 | + TH1F* hRecoMom_tprDe_highP = new TH1F("hRecoMom_tprDe_highP", "Reconstructed Momentum at Tracker Entrance", 50,95,110); |
| 17 | + |
| 18 | + // Set up RooUtil |
| 19 | + RooUtil util(filename); |
| 20 | + |
| 21 | + // Loop through the events |
| 22 | + for (int i_event = 0; i_event < util.GetNEvents(); ++i_event) { |
| 23 | + // Get the next event |
| 24 | + auto& event = util.GetEvent(i_event); |
| 25 | + |
| 26 | + // Get the e_minus tracks from the event |
| 27 | + auto e_minus_tracks = event.GetTracks(is_e_minus); |
| 28 | + |
| 29 | + // Loop through the e_minus tracks |
| 30 | + for (auto& track : e_minus_tracks) { |
| 31 | + |
| 32 | + // Get the track segments at the tracker entrance |
| 33 | + auto trk_ent_segments = track.GetSegments([](TrackSegment& segment){ return tracker_entrance(segment) && has_reco_step(segment); }); |
| 34 | + |
| 35 | + // Loop through the tracker entrance track segments |
| 36 | + for (auto& segment : trk_ent_segments) { |
| 37 | + |
| 38 | + // Fill the histogram |
| 39 | + hRecoMomAll->Fill(segment.trkseg->mom.R()); |
| 40 | + |
| 41 | + if (passes_trigger(event, "tprDe_highP_stopTarg")) { |
| 42 | + hRecoMom_tprDe_highP_stopTarg->Fill(segment.trkseg->mom.R()); |
| 43 | + } |
| 44 | + if (passes_trigger(event, "tprDe_highP_stopTarg")) { |
| 45 | + hRecoMom_tprDe_highP->Fill(segment.trkseg->mom.R()); |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + // Draw the histogram |
| 52 | + hRecoMomAll->SetLineColor(kBlack); |
| 53 | + hRecoMomAll->SetLineWidth(2); |
| 54 | + hRecoMomAll->Draw("HIST E"); |
| 55 | + |
| 56 | + hRecoMom_tprDe_highP->SetLineColor(kBlue); |
| 57 | + hRecoMom_tprDe_highP->SetLineWidth(2); |
| 58 | + hRecoMom_tprDe_highP->Draw("HIST E SAME"); |
| 59 | + |
| 60 | + hRecoMom_tprDe_highP_stopTarg->SetLineColor(kRed); |
| 61 | + hRecoMom_tprDe_highP_stopTarg->SetLineWidth(2); |
| 62 | + hRecoMom_tprDe_highP_stopTarg->Draw("HIST E SAME"); |
| 63 | + |
| 64 | +} |
0 commit comments