Skip to content
Snippets Groups Projects
Commit 8582d334 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

new file: results/.gitignore

	renamed:    neutrons_zdc.cxx -> zdc_neutrons.cxx
	new file:   zdc_neutrons_reader.cxx
parent 5a37e82e
No related branches found
No related tags found
No related merge requests found
File moved
#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 zdc_neutrons_reader(){
//-------------------------------------
ReaderAscii hepmc_input("data/neutrons_zdc.hepmc");
int events_parsed = 0;
GenEvent evt(Units::GEV, Units::MM);
TH1F* h_neutron_energy = new TH1F("n energy","; E [GeV]",100,0,200);
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() == 2112) {
h_neutron_energy->Fill(p->momentum().e());
}
}
}
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/zdc_neutrons_reader.png");
c->SaveAs("results/zdc_neutrons_reader.pdf");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment