![]() |
EventMixer 1.0
An event mixer for mixing events generated by PIBIDS.
|
Main header file for the event mixer software. More...
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vector>
#include <list>
#include <utility>
#include <string>
#include "FileEventStream.hh"
#include "EventHit.hh"
Go to the source code of this file.
Defines | |
#define | DOUBLE_EPS 1E-100 |
For determining when a double is zero (printing purposes). | |
#define | MIXER_HH |
Inclusion guard. | |
Functions | |
bool | compare_eventhits (EventHit *first, EventHit *second) |
Comparator function used for sorting EventHits by time. | |
int | main (int argc, char **argv) |
Main method. | |
void | verify_input (int argc, char **argv) |
Verifies input, exists and prints a usage message if this does not conform with expected command line. | |
void | setup_eventsToMix (int argc, char **argv) |
Sets up the eventsToMix vector from input. | |
FILE * | setup_outputFile (char *filename) |
Opens output file and displays error message upon error. | |
void | print_to_outfile (EventHit *it, FILE *outFile) |
Prints the contents of EventHit to outFile, correctly formatted. | |
Variables | |
vector< pair< FileEventStream *, double > > | eventsToMix |
Vector containing the events to mix. | |
int | NumberOfTubes |
Number of scintillator tubes. |
Main header file for the event mixer software.
Definition in file mixer.hh.
Comparator function used for sorting EventHits by time.
Definition at line 4 of file mixer.cc.
References EventHit::time.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main method.
argc | Number of arguments the program was called with. |
argv | All the arguments. |
Definition at line 142 of file mixer.cc.
References NumberOfTubes, setup_eventsToMix(), setup_outputFile(), and verify_input().
{ verify_input(argc, argv); srand ( time(NULL) ); double randMax = atof(argv[1]); NumberOfTubes = atoi(argv[2]); setup_eventsToMix(argc, argv); FILE * outFile = setup_outputFile(argv[3]); //Everything should be set up for the actual mixing now. do_mixing(randMax, outFile); //Clean up. fclose(outFile); return 0; }
void print_to_outfile | ( | EventHit * | it, |
FILE * | outFile | ||
) |
Prints the contents of EventHit to outFile, correctly formatted.
it | The eventHit to print. |
outFile | The file to print to. |
Definition at line 45 of file mixer.cc.
References EventHit::A, EventHit::BSP, DOUBLE_EPS, EventHit::eventno, EventHit::Ge, EventHit::LFSP, NumberOfTubes, EventHit::time, EventHit::UFSP, and EventHit::Z.
{ fprintf(outFile,"%d %d %d %.15e ", it->eventno, it->Z, it->A, it->time); if(it->UFSP < DOUBLE_EPS) fprintf(outFile,"0 "); else fprintf(outFile,"%.15e ",it->UFSP); if(it->LFSP<DOUBLE_EPS) fprintf(outFile,"0 "); else fprintf(outFile,"%.15e ",it->LFSP); if(it->BSP<DOUBLE_EPS) fprintf(outFile,"0 "); else fprintf(outFile,"%.15e ",it->BSP); if(it->Ge<DOUBLE_EPS) fprintf(outFile,"0"); else fprintf(outFile,"%.15e",it->Ge); for(int j = 0; j<NumberOfTubes; j++) { if(it->DET[j]<DOUBLE_EPS) fprintf(outFile," 0"); else fprintf(outFile," %.15e", it->DET[j]); } fprintf(outFile,"\n"); }
void setup_eventsToMix | ( | int | argc, |
char ** | argv | ||
) |
Sets up the eventsToMix vector from input.
argc | Number of command line arguments. |
argv | The arguments themselves. |
Definition at line 19 of file mixer.cc.
References eventsToMix, and NumberOfTubes.
Referenced by main().
{ double cumSum = 0; //For norming the probabilities. for(int i = 2; i<(argc/2); i++) { eventsToMix.push_back(make_pair(new FileEventStream(argv[2*i], NumberOfTubes),atof(argv[2*i+1]))); cumSum+=eventsToMix.back().second; } //now norm the probabilities. for(vector<pair<FileEventStream*, double> >::iterator it = eventsToMix.begin(); it!=eventsToMix.end(); it++) { it->second/=cumSum; } }
void verify_input | ( | int | argc, |
char ** | argv | ||
) |
Verifies input, exists and prints a usage message if this does not conform with expected command line.
argc | Number of arguments. |
argv | The actual arguments. |
Definition at line 10 of file mixer.cc.
Referenced by main().
{ if (argc < 6 || argc % 2 == 1) { fprintf (stderr,"Usage: %s timeRandmax nTubes <outfile.txt> n*[<infile_n.txt> probability_to_selectfrom_this] \n",argv[0]); exit(1); } }