HPS-MC
 
Loading...
Searching...
No Matches
print_stdhep.cc
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <math.h>
4#include <string.h>
5#include <stdhep_util.hh>
6
10int main(int argc,char** argv)
11{
12 stdhep_event new_event;
13 int istream = 0;
14
15 if (argc < 2 || argc > 3)
16 {
17 printf("<input stdhep filename> [number of events to read]\n");
18 return 1;
19 }
20
21 int n_events = 0;
22 int n_read = 0;
23
24 n_events = open_read(argv[1], istream);
25
26 if (argc == 3)
27 {
28 n_read = atoi(argv[2]);
29 }
30
31 for (int i = 0; n_read ==0 || i < n_read; i++)
32 {
33 if (!read_next(istream)) {
34 close_read(istream);
35 return(0);
36 }
37
38 read_stdhep(&new_event);
39
40 printf("read event %d: nevhep = %d, nhep = %d\n", i+1, new_event.nevhep, new_event.particles.size());
41 if (new_event.has_hepev4)
42 {
43 printf("HEPEV4 information: idruplh = %d, eventweightlh = %E\n", new_event.idruplh, new_event.eventweightlh);
44 }
45 for (int j = 0; j < new_event.particles.size(); j++) {
46 print_entry(new_event.particles[j]);
47 }
48 new_event.particles.clear();
49 }
50}
int main(int argc, char **argv)
int open_read(char *filename, int istream, int n_events)
int read_stdhep(vector< stdhep_entry > *new_event)
bool read_next(int istream)
void close_read(int istream)
void print_entry(stdhep_entry entry)
vector< stdhep_entry > particles
double eventweightlh