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

modified: .gitignore

	modified:   calorimeters/zdc_neutrons_reader.cxx
parent 753f38d2
No related branches found
No related tags found
No related merge requests found
results/*
data/*
datasets/*
...@@ -5,23 +5,35 @@ ...@@ -5,23 +5,35 @@
#include "TH1F.h" #include "TH1F.h"
#include <iostream> #include <iostream>
#include <cstdlib>
using namespace HepMC3; using namespace HepMC3;
void zdc_neutrons_reader(){ void zdc_neutrons_reader(){
//------------------------------------- //-------------------------------------
ReaderAscii hepmc_input("data/neutrons_zdc.hepmc"); ReaderAscii hepmc_input("data/neutrons_zdc.hepmc");
if( hepmc_input.failed() ) {
std::cerr << " could not find data file\n";
std::quick_exit(1);
}
int events_parsed = 0; int events_parsed = 0;
GenEvent evt(Units::GEV, Units::MM); GenEvent evt(Units::GEV, Units::MM);
TH1F* h_neutron_energy = new TH1F("n energy","; E [GeV]",100,0,200); TH1F* h_neutron_energy = new TH1F("n energy","; E [GeV]",100,0,200);
// Read event from input file
hepmc_input.read_event(evt);
// If reading failed before loop then fail hard
// because the data wasn't found.
if( hepmc_input.failed() ) {
std::cerr << " could not find first event\n";
std::quick_exit(1);
}
while(!hepmc_input.failed()) { 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& v : evt.vertices() ) {
for(const auto& p : v->particles_out() ) { for(const auto& p : v->particles_out() ) {
...@@ -32,6 +44,7 @@ void zdc_neutrons_reader(){ ...@@ -32,6 +44,7 @@ void zdc_neutrons_reader(){
} }
evt.clear(); evt.clear();
events_parsed++; events_parsed++;
hepmc_input.read_event(evt);
} }
std::cout << "Events parsed and written: " << events_parsed << std::endl; std::cout << "Events parsed and written: " << events_parsed << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment