Utils.h¶
Generally useful functions and constants.
These are not specific to one usage, and may be used in multiple files.
Functions
-
int
countLines(ifstream &inFile)¶ Count the number of lines in a file.
-
vector<double>
add(vector<double> u, vector<double> v)¶ Elementwise vector addition.
-
vector<double>
mult(vector<double> u, vector<double> v)¶ Elementwise vector multiplication.
-
double
sum(vector<double> v)¶ Sum the elements in a vector.
-
double
stddev(vector<double> v)¶ Sample standard deviation of a vector. DOF = n-1.
-
double
max(vector<double> v)¶ Maximum element of a vector.
-
double
mean(vector<double> v)¶ Mean of a vector.
-
double
min(double *v, int n)¶ Minimum element of an array of length
n.
-
double
max(double *v, int n)¶ Maximum element of an array of length
n.
-
double
mean(double *v, int n)¶ Mean of an array of length
n.
-
double
stddev(double *v, int n)¶ Sample standard deviation of an array of length
n.
-
double
square(double x)¶ Alias for
x*x.
-
double
atanh(double x)¶ Hyperbolic arctangent.
- See
- Wolfram Mathworld, Equation (1).
-
double
min(double a, double b)¶ Minimum of two numbers,
aandb.
-
double
max(double a, double b)¶ Maximum of two numbers,
aandb.
-
bool
isLess(int a, int b)¶ Is
a<b?
-
bool
isIn(int x, vector<int> v)¶ Is
xinv?
-
bool
isIn(string str, string substr)¶ Is
substra substring ofstr?
-
bool
file_exists(const char *pathname)¶ Check whether a file exists and is not a directory.
-
bool
dir_exists(const char *pathname)¶ Check whether a directory exists.
-
int
roundUp(int numToRound, int multiple)¶ Round up to nearest multiple of a number.
-
double
solveLinear(TH1D *hist, int bin1, int bin2, double yc)¶ Given a TH1D and a two bin numbers, draw a line between the points and solve for the \(x \) value where \(y=y_c \) (
ycstands fory_cutoff).
-
void
stripTrailingSlash(char *strippedPath, const char *path)¶ Remove the trailing forward slash from
pathif it is there.
-
void
joinPath(char *path, const char *prefix, const char *suffix)¶ Join two paths by a forward slash (using stripTrailingSlash)