|
| 1 | +// |
| 2 | +// An example of how to plot reco vs true |
| 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 "TCanvas.h" |
| 10 | +#include "TH1F.h" |
| 11 | +#include "TH2F.h" |
| 12 | + |
| 13 | +using namespace rooutil; |
| 14 | +void PlotVDSteps(std::string filename) { |
| 15 | + |
| 16 | + // Create the histogram you want to fill |
| 17 | + TH2F* hVD13_XY = new TH2F("hVD13_XY", "XY position at VD13 (tracker entrance)", 100,-500,500, 100,-500,500); |
| 18 | + hVD13_XY->SetXTitle("X (det. coords) [mm]"); |
| 19 | + hVD13_XY->SetYTitle("Y (det. coords) [mm]"); |
| 20 | + |
| 21 | + TH1F* hVD13_Mom = new TH1F("hVD13_Mom", "Momentum at VD13 (tracker entrance)", 120,0,120); |
| 22 | + hVD13_Mom->SetXTitle("Momentum [MeV/c]"); |
| 23 | + |
| 24 | + // Set up RooUtil |
| 25 | + RooUtil util(filename); |
| 26 | + |
| 27 | + // Loop through the events |
| 28 | + for (int i_event = 0; i_event < util.GetNEvents(); ++i_event) { |
| 29 | + // Get the next event |
| 30 | + auto& event = util.GetEvent(i_event); |
| 31 | + |
| 32 | + // Get the e_minus tracks from the event |
| 33 | + if (event.mcsteps_virtualdetector != nullptr) { |
| 34 | + for (const auto& vdstep : *(event.mcsteps_virtualdetector)) { |
| 35 | + if (vdstep.vid == mu2e::VirtualDetectorId::TT_FrontHollow) { |
| 36 | + // Fill the histogram |
| 37 | + hVD13_XY->Fill(vdstep.pos.x(), vdstep.pos.y()); |
| 38 | + |
| 39 | + hVD13_Mom->Fill(vdstep.mom.R()); |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + // Draw the histogram |
| 46 | + TCanvas* c = new TCanvas(); |
| 47 | + c->Divide(2); |
| 48 | + c->cd(1); |
| 49 | + hVD13_XY->Draw("COLZ"); |
| 50 | + c->cd(2); |
| 51 | + hVD13_Mom->Draw("HIST E"); |
| 52 | +} |
0 commit comments