Skip to content
Snippets Groups Projects
Commit aa7fb727 authored by Tom Polakovic's avatar Tom Polakovic
Browse files

histogram

parent 8cb66cfb
No related branches found
No related tags found
1 merge request!1Forward ions
#include "HepMC3/GenEvent.h"
#include "HepMC3/ReaderAscii.h"
#include "HepMC3/WriterAscii.h"
#include "HepMC3/Print.h"
#include "TH1F.h"
#include <iostream>
using namespace HepMC3;
void forward_ions_reader(){
//-------------------------------------
ReaderAscii hepmc_input("data/forward_ions.hepmc");
int events_parsed = 0;
GenEvent evt(Units::GEV, Units::MM);
TH1F* h_neutron_energy = new TH1F("eta","; eta",100,0,10);
while(!hepmc_input.failed()) {
// Read event from input file
hepmc_input.read_event(evt);
// If reading failed - exit loop
if( hepmc_input.failed() ) break;
for(const auto& v : evt.vertices() ) {
for(const auto& p : v->particles_out() ) {
if(p->pid() == 2212) {
h_neutron_energy->Fill(p->momentum().eta());
}
}
}
evt.clear();
events_parsed++;
}
std::cout << "Events parsed and written: " << events_parsed << std::endl;
TCanvas* c = new TCanvas();
h_neutron_energy->Draw();
c->SaveAs("results/forward_ions_reader.png");
c->SaveAs("results/forward_ions_reader.pdf");
}
File added
results/forward_ions_reader.png

7.02 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment