YCrossFit 1.0
A C++/ROOT Library for the analysis of the differential cross section of the Y(1S,2S,3S) resonances in two muons
|
Handling flags and option parameters. More...
#include <iostream>
#include "getopt.h"
#include <string>
#include <algorithm>
Go to the source code of this file.
Functions | |
void | PrintHelp () |
Print help stream for understanding what options and flags are available, then exit. More... | |
void | outOfRangeErrorHandling (std::string opt, std::string range, const char *insrtvl) |
Handle an exception of type "Out of Range". More... | |
void | conversionErrorHandling (std::string opt, std::string range, std::invalid_argument err) |
Handles an exception of type "conversion Error". More... | |
void | unknownErrorHandling () |
Handle an exception of type "unknown". More... | |
void | ProcessArgs (int argc, char **argv, int &fr, float &pmr, float &pMr, float &ymr, float &yMr, std::string &nfr, int &vr, int &mr, int &cr) |
Implementation of the option arguments with the library <getopt>. More... | |
Handling flags and option parameters.
In this file are defined the functions used in order to handle flags and command line options.
void conversionErrorHandling | ( | std::string | opt, |
std::string | range, | ||
std::invalid_argument | err | ||
) |
Handles an exception of type "conversion Error".
Print the type of exception (thrown by the stardard library), then it prints the accepted type for the option and exit with failure.
opt | option in case (e.g. depth, fitFunction, etc...) |
range | type accepted for the option (e.g. float for ym) |
err | invalid argument raised by the standard library |
void outOfRangeErrorHandling | ( | std::string | opt, |
std::string | range, | ||
const char * | insrtvl | ||
) |
Handle an exception of type "Out of Range".
Print the range for the option passed to the function, then prints the out-of-range value inserted by the user and ask to insert an acceptable value. Then exit with error.
opt | option in case (e.g. depth, fitFunction, etc...) |
range | range accepted of the desired option (e.g. 0,1,2 for depth) |
insrtvl | invalid value entered by the user in the command line stream |
void PrintHelp | ( | ) |
Print help stream for understanding what options and flags are available, then exit.
Print the following output:
–canvasMute [-c]: Do not display canvas
–mode [-m] <mode>: Choose functionality of the program between:
fit: execute fit with given parameters cross (default): calculate differential cross section in pt.
–fitFunction [-f] <PDFName>: Choose PDF to use as Fit Function between three options:
gaus: Gaussian PDF bw (default): Breit - Wigner PDF stud: t-Student PDF
–nameFig [-n] <figName> name of file in which the figure of the fit is going to be saved
–ptmin [-p] <val>: Set minimum cut on pt (GeV)
–ptMax [-P] <val>: Set maximum cut on pt (GeV)
–ymin [-y] <val>: Set minimum cut on rapidity
–yMax [-Y] <val>: Set maximum cut on rapidity
–help [-h]: Show help
–verbose [-v]: Verbose Fit, shows minimisation steps.
void ProcessArgs | ( | int | argc, |
char ** | argv, | ||
int & | fr, | ||
float & | pmr, | ||
float & | pMr, | ||
float & | ymr, | ||
float & | yMr, | ||
std::string & | nfr, | ||
int & | vr, | ||
int & | mr, | ||
int & | cr | ||
) |
Implementation of the option arguments with the library <getopt>.
Read options and flags from command line and store it in the function arguments passed as reference If the command line arguments do not exists, are out of range, or the format is invalid, the fucntions handles these cases as exceptions described in the functions outOfRangeErrorHandling()
, coversionErrorHandling()
, unknownErrorHandling()
.
If no command arguments are passed, the function do nothing and the values remain the same defined in main()
.
argc | command line arguments number |
argv | array of command line arguments passed |
fr | reference of fitFunction defined in main |
pmr | recerence of ptm (minimum pt) defined in main |
pMr | recerence of ptM (maximum pt) defined in main |
ymr | recerence of ym (minimum rapidity) defined in main |
yMr | recerence of yM (maximum rapidity) defined in main |
nfr | recerence of nameFile defined in main |
vr | reference of varaible verbose defined in main |
mr | reference of option mode |
cr | reference of canvas flag: if on, do not display application |
void unknownErrorHandling | ( | ) |
Handle an exception of type "unknown".
Print the string "*Unknown error occured. Please contact the authors or open an issue at https://github.com/zenith378/Y-DiMuonResonances*" and exit with error.