16 int main(
int argc,
char** argv)
19 vector<stdhep_entry> new_event;
29 while ((c = getopt(argc,argv,
"hi1:i2:")) != -1)
33 printf(
"-h: print this help\n");
34 printf(
"-i: PDG ID of mother\n");
38 id_beam = atoi(optarg);
41 id_pair = atoi(optarg);
44 printf(
"Invalid option or missing option argument; -h to list options\n");
52 printf(
"<input stdhep filename> <input lhe filename> <output stdhep filename>\n");
60 n_events =
open_read(argv[optind], istream);
64 FILE * in_file = fopen(argv[optind+1],
"r");
83 temp1->
idhep = id_beam;
84 for (
int j = 0; j < 2; j++) temp1->
jmohep[j] = 0;
85 for (
int j = 0; j < 2; j++) temp1->
jdahep[j] = 0;
86 for (
int j = 0; j < 5; j++) temp1->
phep[j] = 0.0;
87 temp1->
phep[3] += energy;
88 temp1->
phep[4] += mass;
89 for (
int j = 0; j < 4; j++) temp1->
vhep[j] = 0.0;
90 new_event.push_back(*temp1);
94 temp2->
idhep = id_pair;
95 for (
int j = 0; j < 2; j++) temp2->
jmohep[j] = 0;
96 for (
int j = 0; j < 2; j++) temp2->
jdahep[j] = 0;
97 for (
int j = 0; j < 5; j++) temp2->
phep[j] = 0.0;
98 temp2->
phep[3] += energy;
99 temp2->
phep[4] += mass;
100 for (
int j = 0; j < 4; j++) temp2->
vhep[j] = 0.0;
101 new_event.push_back(*temp2);
108 bool found_event =
false;
109 while (fgets(
line, 1000, in_file) != NULL) {
110 if (strstr(
line,
"<event") != NULL) {
125 fgets(
line, 1000, in_file);
126 sscanf(
line,
"%d %*d %*f %*f %*f %*f", &nup);
127 for (
int i = 0; i < nup; i++) {
129 fgets(
line, 1000, in_file);
130 int icolup0, icolup1;
131 double phep0 = 100.0;
133 sscanf(
line,
"%d %d %d %d %*d %*d %lf %lf %lf %lf %lf %*f %*f", &(temp->
idhep), &(temp->
isthep), &(temp->
jmohep[0]), &(temp->
jmohep[1]), &(temp->
phep[0]), &(temp->
phep[1]), &(temp->
phep[2]), &(temp->
phep[3]), &(temp->
phep[4]));
137 if((nup == 6 && temp->
idhep == 11) || (nup == 7 && temp->
idhep == 611)) temp3 = temp;
140 else if((nup == 6 && temp->
idhep == -11) || (nup == 7 && temp->
idhep == -611)) temp4 = temp;
145 for (
int i = 2; i < new_event.size(); i++) {
146 if (new_event[i].
jmohep[0] == 1 + offset) {
147 new_event[i].
jmohep[0] = 2;
148 if (new_event[1].
jdahep[0] == 0) {
149 new_event[1].jdahep[0] = i+1;
150 for (
int j = 0; j < 4; j++) new_event[1].
vhep[j] = new_event[i].
vhep[j];
152 new_event[1].phep[0] = temp3->
phep[0] + temp4->
phep[0];
153 new_event[1].phep[1] = temp3->
phep[1] + temp4->
phep[1];
154 new_event[1].phep[2] = temp3->
phep[2] + temp4->
phep[2];
155 new_event[1].phep[3] = temp3->
phep[3] + temp4->
phep[3];
156 new_event[1].phep[4] = sqrt(pow(new_event[1].
phep[3], 2) - pow(new_event[1].
phep[2], 2) - pow(new_event[1].
phep[1], 2) - pow(new_event[1].
phep[0], 2));
158 new_event[1].jdahep[1] = i+1;
160 else if (new_event[i].
jmohep[0] == 0) {
161 new_event[i].jmohep[0] = 1;
162 if (new_event[0].
jdahep[0] == 0) new_event[0].jdahep[0] = i+1;
163 new_event[0].jdahep[1] = i+1;
int main(int argc, char **argv)
void open_write(char *filename, int ostream, int n_events)
int open_read(char *filename, int istream, int n_events)
void write_stdhep(vector< stdhep_entry > *new_event, int nevhep)
int read_stdhep(vector< stdhep_entry > *new_event)
bool read_next(int istream)
void close_read(int istream)
void write_file(int ostream)
void close_write(int ostream)