7 #include <gsl/gsl_rng.h>
8 #include <gsl/gsl_randist.h>
15 int main(
int argc,
char** argv)
18 vector<stdhep_entry> new_event;
19 vector<stdhep_entry> sig_event;
21 double signal_prob = 0.001;
22 int n_events = 500000;
28 while ((c = getopt(argc,argv,
"hm:s:n:")) != -1)
32 printf(
"-h: print this help\n");
33 printf(
"-m: probability of a signal event\n");
34 printf(
"-s: RNG seed\n");
35 printf(
"-n: which signal event to use\n");
39 signal_prob = atof(optarg);
45 signal_n = atoi(optarg);
48 printf(
"Invalid option or missing option argument; -h to list options\n");
54 printf(
"Mixing in the %dth signal event, with probability %f\n", signal_n, signal_prob);
56 if (argc - optind != 3)
58 printf(
"<input background stdhep filename> <input signal stdhep filename> <output stdhep filename>\n");
63 const gsl_rng_type * T;
68 r = gsl_rng_alloc (T);
69 gsl_rng_set(r, rseed);
77 for (
int i = 0; i < signal_n; i++) {
88 bool sig_used =
false;
93 if (!sig_used && gsl_rng_uniform(r) < signal_prob) {
104 printf(
"Counted %d events\n", evcount);
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)