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
optionParse.h File Reference

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...
 

Detailed Description

Handling flags and option parameters.

In this file are defined the functions used in order to handle flags and command line options.

Function Documentation

◆ conversionErrorHandling()

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.

Parameters
optoption in case (e.g. depth, fitFunction, etc...)
rangetype accepted for the option (e.g. float for ym)
errinvalid argument raised by the standard library
Returns
error exit

◆ outOfRangeErrorHandling()

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.

Parameters
optoption in case (e.g. depth, fitFunction, etc...)
rangerange accepted of the desired option (e.g. 0,1,2 for depth)
insrtvlinvalid value entered by the user in the command line stream
Returns
error exit

◆ PrintHelp()

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.

◆ ProcessArgs()

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() .

Parameters
argccommand line arguments number
argvarray of command line arguments passed
frreference of fitFunction defined in main
pmrrecerence of ptm (minimum pt) defined in main
pMrrecerence of ptM (maximum pt) defined in main
ymrrecerence of ym (minimum rapidity) defined in main
yMrrecerence of yM (maximum rapidity) defined in main
nfrrecerence of nameFile defined in main
vrreference of varaible verbose defined in main
mrreference of option mode
crreference of canvas flag: if on, do not display application

◆ unknownErrorHandling()

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.

Returns
error exit