HPS-MC
 
Loading...
Searching...
No Matches
explode.cc
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <stdhep_mcfio.h>
4#include <stdhep.h>
5#include <string.h>
6
11int main(int argc,char** argv)
12{
13 int current_nhep;
14 int split_nevhep = 0;
15 int nevhep;
16 int nhep;
17 int isthep[NMXHEP];
18 int idhep[NMXHEP];
19 int jmohep[NMXHEP][2];
20 int jdahep[NMXHEP][2];
21 double phep[NMXHEP][5];
22 double vhep[NMXHEP][4];
23
24 char outputname[200];
25 if (argc != 3)
26 {
27 printf("<input stdhep filename> <output stdhep filename>\n");
28 return 1;
29 }
30 int n_events = 1000000000;
31 printf("Reading %d events from %s\n", n_events, argv[1]);
32 int istream = 0;
33 int ostream = 1;
34 int ilbl;
35 StdHepXdrReadInit(argv[1], n_events, istream);
36
37 printf("Writing to %s\n", argv[2]);
38 StdHepXdrWriteOpen(argv[2], argv[2], n_events, ostream);
39 StdHepXdrWrite(100, ostream);
40
41 while (true) {
42 do {
43 if (StdHepXdrRead(&ilbl, istream) != 0) {
44 printf("End of file\n");
45 StdHepXdrEnd(istream);
46
47 StdHepXdrWrite(200, ostream);
48 StdHepXdrEnd(ostream);
49 return(0);
50 }
51 if (ilbl != 1)
52 printf("ilbl = %d\n", ilbl);
53 } while (ilbl != 1);
54
55 nevhep = hepevt_.nevhep;
56 nhep = hepevt_.nhep;
57 for (int i = 0; i < nhep; i++)
58 {
59 isthep[i] = hepevt_.isthep[i];
60 idhep[i] = hepevt_.idhep[i];
61 for (int j = 0; j < 2; j++) jmohep[i][j] = hepevt_.jmohep[i][j];
62 for (int j = 0; j < 2; j++) jdahep[i][j] = hepevt_.jdahep[i][j];
63 for (int j = 0; j < 5; j++) phep[i][j] = hepevt_.phep[i][j];
64 for (int j = 0; j < 4; j++) vhep[i][j] = hepevt_.vhep[i][j];
65 }
66
67 hepevt_.nhep = 1;
68
69 for (int i = 0; i < nhep; i++)
70 {
71 hepevt_.nevhep = split_nevhep++;
72 hepevt_.isthep[0] = isthep[i];
73 hepevt_.idhep[0] = idhep[i];
74 for (int j = 0; j < 2; j++) hepevt_.jmohep[0][j] = jmohep[i][j];
75 for (int j = 0; j < 2; j++) hepevt_.jdahep[0][j] = jdahep[i][j];
76 for (int j = 0; j < 5; j++) hepevt_.phep[0][j] = phep[i][j];
77 for (int j = 0; j < 4; j++) hepevt_.vhep[0][j] = vhep[i][j];
78 StdHepXdrWrite(ilbl, ostream);
79 }
80 }
81}
82
int main(int argc, char **argv)
Definition explode.cc:11
int StdHepXdrReadInit(char *filename, int ntries, int ist)
int StdHepXdrWrite(int ilbl, int ist)
int StdHepXdrRead(int *ilbl, int ist)
void StdHepXdrEnd(int ist)
int StdHepXdrWriteOpen(char *filename, char *title, int ntries, int ist)