a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
Doxygen/examples-src/EventGeneration/EventGeneration.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
Examples
EventGeneration.cpp, libmode_config.cpp, libmode_header.cpp, MCMC.cpp, and myModel_MCMC.cpp.

Definition at line 22 of file Doxygen/examples-src/EventGeneration/EventGeneration.cpp.

23 {
24 
25  /* Necessary if MPI support is enabled during compilation. */
26 #ifdef _MPI
27  MPI_Init(&argc, &argv);
28  int rank;
29  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30 #else
31  /* In our MPI implementation the process with rank 0 is the master. */
32  int rank = 0;
33 #endif
34 
35  try {
36 
37  if(argc < 3){
38  /* Print usage and exit. */
39  if (rank == 0) std::cout << "\nusage: " << argv[0] << " ModelConf.conf nEvents [OutputFolder]\n" << std::endl;
40  return EXIT_SUCCESS;
41  }
42 
43  /* Define the model configuration file. */
44  /* Here it is passed as the first argument to the executable. The */
45  /* model configuration file provides the values with errors for the */
46  /* mandatory model parameters, as well as the list of observables, */
47  /* observables2D, correlated Gaussian observables. */
48  /* See documentation for details. */
49  std::string ModelConf = argv[1];
50 
51  /* Define the number of iterations.*/
52  int nIterations = atoi(argv[2]);
53 
54  /* Define the output folder. Results will be put in ./GeneratedEvents/<outputFolder>*/
55  std::string outputFolder = "";
56  if(argc == 4) outputFolder = argv[3];
57 
58  /* Define the seed. 0 for using processor time.*/
59  int seed = 1;
60 
61  /* Define whether weight will be calculated.*/
62  bool weight = true;
63 
64  /* Define the optional job tag. */
65  std::string JobTag = "";
66 
67  /* Create objects of the classes ModelFactory and ThObsFactory */
68  ThObsFactory ThObsF;
69  ModelFactory ModelF;
70 
71  /* register user-defined model named ModelName defined in class ModelClass using the following syntax: */
72  /* ModelF.addModelToFactory(ModelName, boost::factory<ModelClass*>() ) */
73 
74  /* register user-defined ThObservable named ThObsName defined in class ThObsClass using the following syntax: */
75  /* ThObsF.addObsToFactory(ThObsName, boost::factory<ThObsClass*>() )*/
76 
77  /* Create an object of the class GenerateEvent. */
78  GenerateEvent GE(ModelF, ThObsF, ModelConf, outputFolder, JobTag);
79 
80  /* Initiate the Mote Carlo run. */
81  GE.generate(nIterations, seed, weight);
82 
83  /* Necessary if MPI support is enabled during compilation. */
84 #ifdef _MPI
85  MPI_Finalize();
86 #endif
87 
88  return EXIT_SUCCESS;
89  } catch (const std::runtime_error& e) {
90  std::cerr << e.what() << std::endl;
91  return EXIT_FAILURE;
92  }
93 }
ModelFactory
A class for.
Definition: ModelFactory.h:25
GenerateEvent
A class for generating events.
Definition: GenerateEvent.h:41
ThObsFactory
A class for.
Definition: ThObsFactory.h:26