a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
BOL::UsefulStuff Class Reference

#include <UsefulStuff.hpp>

Detailed Description

Definition at line 25 of file UsefulStuff.hpp.

Static Public Member Functions

static bool doublesCloseEnough (double const firstDouble, double const secondDouble, double maximumDifference)
 
static bool fileExists (std::string const &fileName)
 
static double flatRandomDouble (double const lowerLimit, double const upperLimit)
 
static int plusOrMinusOne ()
 
static void runSystemCommand (std::string const &systemCommand)
 
static int zeroOrOne ()
 

Static Public Attributes

static std::string const nanString
 
static double const notANumber
 
static double const twicePi
 

Static Private Member Functions

static void ensureRandomSeedIsSet ()
 

Static Private Attributes

static bool randomSeedNotYetSet
 

Member Function Documentation

◆ doublesCloseEnough()

bool BOL::UsefulStuff::doublesCloseEnough ( double const  firstDouble,
double const  secondDouble,
double  maximumDifference 
)
inlinestatic

Definition at line 69 of file UsefulStuff.hpp.

74 {
75 return ( abs( maximumDifference ) >= abs( firstDouble - secondDouble ) );
76 }

◆ ensureRandomSeedIsSet()

void BOL::UsefulStuff::ensureRandomSeedIsSet ( )
inlinestaticprivate

time_t currentTime = time( NULL ); srand( currentTime ); std::cout << std::endl << "currentTime = " << currentTime;

Definition at line 114 of file UsefulStuff.hpp.

116 {
118 {
119 // debugging:
123 srand( time( NULL ) );
124 randomSeedNotYetSet = false;
125 }
126 }
static bool randomSeedNotYetSet
Definition: UsefulStuff.hpp:60

◆ fileExists()

bool BOL::UsefulStuff::fileExists ( std::string const &  fileName)
inlinestatic

Definition at line 129 of file UsefulStuff.hpp.

131 {
132 std::ifstream fileStream( fileName.c_str() );
133 if( fileStream.good() )
134 {
135 fileStream.close();
136 return true;
137 }
138 else
139 {
140 return false;
141 }
142 }

◆ flatRandomDouble()

double BOL::UsefulStuff::flatRandomDouble ( double const  lowerLimit,
double const  upperLimit 
)
inlinestatic

Definition at line 79 of file UsefulStuff.hpp.

85 {
87 return ( lowerLimit + ( (double)(rand()) / (double)RAND_MAX )
88 * ( upperLimit - lowerLimit ) );
89 }
static void ensureRandomSeedIsSet()

◆ plusOrMinusOne()

int BOL::UsefulStuff::plusOrMinusOne ( )
inlinestatic

Definition at line 100 of file UsefulStuff.hpp.

102 {
103 if( 0 == zeroOrOne() )
104 {
105 return -1;
106 }
107 else
108 {
109 return 1;
110 }
111 }
static int zeroOrOne()
Definition: UsefulStuff.hpp:92

◆ runSystemCommand()

void BOL::UsefulStuff::runSystemCommand ( std::string const &  systemCommand)
inlinestatic

Definition at line 145 of file UsefulStuff.hpp.

146 {
147 int systemReturn( system( systemCommand.c_str() ) );
148 if( -1 == systemReturn )
149 {
150 throw std::runtime_error( "system( \"" + systemCommand
151 + "\" ) returned -1" );
152 }
153 }

◆ zeroOrOne()

int BOL::UsefulStuff::zeroOrOne ( )
inlinestatic

Definition at line 92 of file UsefulStuff.hpp.

94 {
96 return ( (rand()) % 2 );
97 }

Member Data Documentation

◆ nanString

std::string const BOL::UsefulStuff::nanString
static

Definition at line 29 of file UsefulStuff.hpp.

◆ notANumber

double const BOL::UsefulStuff::notANumber
static

Definition at line 28 of file UsefulStuff.hpp.

◆ randomSeedNotYetSet

bool BOL::UsefulStuff::randomSeedNotYetSet
staticprivate

Definition at line 60 of file UsefulStuff.hpp.

◆ twicePi

double const BOL::UsefulStuff::twicePi
static

Definition at line 30 of file UsefulStuff.hpp.


The documentation for this class was generated from the following files: