23#include "G4ThreeVector.hh"
24#include "G4TwoVector.hh"
29#include <unordered_map>
40typedef CLHEP::HepRotation G4RotationMatrix;
55 G4bool operator()(
char c);
59 G4bool
StrContains(
const G4String& str,
const G4String& test);
62 G4int
StrCompare(
const G4String& str,
const G4String&, G4String::caseCompare mode=G4String::ignoreCase);
76 G4String
StrStrip(
const G4String& str,
88 std::pair<G4ThreeVector,G4ThreeVector>
CalculateFaces(G4double angleInIn,
93 void EnsureInLimits(G4double& value, G4double lowerLimit, G4double upperLimit);
118 G4String
GetFullPath(G4String filename,
bool excludeNameFromPath=
false,
bool useCWDForPrefix=
false);
129 G4String& extension);
140 G4double tolerance = std::numeric_limits<double>::epsilon());
143 G4bool
IsFinite(
const G4ThreeVector& variable,
144 G4double tolerance = std::numeric_limits<double>::epsilon());
147 G4bool
NonZero(G4double value);
155 G4bool
IsInteger(
const char* s,
int& convertedInteger);
158 G4bool
IsNumber(
const char* s,
double& convertedNumber);
160 template <
typename T>
162 {
return G4int((T(0) < val) - (val < T(0)));}
164 inline G4String BoolToString(G4bool in)
165 {
return in ?
"true" :
"false";}
193 G4TwoVector
Rotate(
const G4TwoVector& vec,
const G4double& angle);
199 const G4ThreeVector& outgoingNormal,
200 const G4double& zSeparation,
208 const G4double& angleOut,
209 const G4double& horizontalWidth,
210 const G4double& length);
225 std::pair<G4String, G4String>
SplitOnColon(
const G4String& formatAndPath);
235 G4double fraction = 1.6);
242 char delimiter =
':');
247 template <
typename K,
typename V>
250 typename std::map<K,V>::const_iterator it = m.find(key);
251 return it == m.end() ? defaultValue : it->second;
253 template <
typename K,
typename V>
254 V
MapGetWithDefault(
const std::unordered_map <K,V>& m,
const K& key,
const V& defaultValue)
256 typename std::unordered_map<K,V>::const_iterator it = m.find(key);
257 return it == m.end() ? defaultValue : it->second;
263 G4int verboseEventContinueFor);
271 G4double
Rigidity(G4double momentumMagnitude,
276 const std::string& prefix) {
return expression.size() >= prefix.size() &&
277 expression.rfind(prefix, 0) == 0;}
280 inline G4bool
EndsWith(
const std::string& expression,
281 const std::string& suffix) {
return expression.size() >= suffix.size() &&
282 expression.compare(expression.size() - suffix.size(), suffix.size(), suffix) == 0;}
288 G4double containerWidth,
289 G4double containerHeight=0);
293 G4ThreeVector outputfaceIn,
295 G4double containerWidth,
296 G4double containerHeight=0);
Holder for +- extents in 3 dimensions.
Return either G4Tubs or G4CutTubs depending on flat face.
G4double Rigidity(G4double momentumMagnitude, G4double charge)
Calculate the rigidity for a total momentum and charge.
G4TwoVector Rotate(const G4TwoVector &vec, const G4double &angle)
Rotate a two vector in polar coordinates by an angle.
G4bool WillIntersect(const G4ThreeVector &incomingNormal, const G4ThreeVector &outgoingNormal, const G4double &zSeparation, const BDSExtent &incomingExtent, const BDSExtent &outgoingExtent)
G4String GetParameterValueString(G4String spec, G4String name)
Get parameter value from the specification ('spec') string.
std::pair< G4String, G4String > SplitOnColon(const G4String &formatAndPath)
void SplitFileAndExtension(const G4String &fileName, G4String &file, G4String &extension)
Split a filename.ext into filename and extension. Extension includes '.'.
std::string GetCurrentDir()
Get the current dir the program was executed from.
G4String PrepareSafeName(G4String name)
Remove white space and special characters in the name.
G4bool NonZero(G4double value)
Test whether a number is non-zero - ie abs(number) > minimum number.
G4bool StrContains(const G4String &str, const G4String &test)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4ThreeVector RotateToReferenceFrame(G4ThreeVector faceNormal, G4double fullAngle)
V MapGetWithDefault(const std::map< K, V > &m, const K &key, const V &defaultValue)
G4String GetFullPath(G4String filename, bool excludeNameFromPath=false, bool useCWDForPrefix=false)
G4double GetZOfPointOnPlane(const G4ThreeVector &normal, G4double x, G4double y)
G4bool EndsWith(const std::string &expression, const std::string &suffix)
Return true if a string "expression" ends with "suffix".
G4double GetMemoryUsage()
Get the current memory usage.
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4UserLimits * CreateUserLimits(G4UserLimits *defaultUL, G4double length, G4double fraction=1.6)
G4bool DirectoryExists(const G4String &path)
Check if directory exists.
void PrintRotationMatrix(G4RotationMatrix *rm, G4String keyName="unknown")
G4bool Geant4EnvironmentIsSet()
Check if the geant4 environmental variables necessary for a run are set.
void EnsureInLimits(G4double &value, G4double lowerLimit, G4double upperLimit)
std::string GetBDSIMLibraryPath()
Returns the path from which the BDSIM library is loaded.
G4bool FileExists(const G4String &filename)
Checks if filename exists.
void CheckHighPrecisionDataExists(const G4String &physicsListName)
G4bool StartsWith(const std::string &expression, const std::string &prefix)
Return true if a string "expression" starts with "prefix".
G4bool VerboseThisEvent(G4int eventIndex, G4int eventStart, G4int eventStop)
Logic of whether this event should be verbose or not. Code here so it's not duplicated.
void HandleAborts(int signal_number)
std::vector< G4String > SplitOnWhiteSpace(const G4String &input)
Split a string on whitespace and return a vector of these 'words'.
G4double CalculateSafeAngledVolumeLength(G4double angleIn, G4double angleOut, G4double length, G4double containerWidth, G4double containerHeight=0)
Calculate safe length of an angled volume so it fills the length of its container.
G4bool IsNumber(const char *s, double &convertedNumber)
Check if character array is an integer, and returns the double by reference.
G4int VerboseEventStop(G4int verboseEventStart, G4int verboseEventContinueFor)
void CheckLowEnergyNeutronDataExists(const G4String &phhysicsListName)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())
G4bool IsFiniteStrength(G4double variable)
G4double ArcLengthFromChordLength(G4double chordLength, G4double angle)
Calculate the arc length from the chord length for a given angle.
void SplitPathAndFileName(const G4String &filePath, G4String &path, G4String &filename)
std::string GetBDSIMExecPath()
G4bool IsInteger(const char *s, int &convertedInteger)
Check if character array is an integer, and returns the integer by reference.
G4int GetParameterValueInt(G4String spec, G4String name)
Get parameter value from the specification ('spec') string.
std::map< G4String, G4String > GetUserParametersMap(const G4String &userParameters, char delimiter=':')
Take one long string and split on space and then on colon. "key1:value1 key2:value2" etc.
G4int StrCompare(const G4String &str, const G4String &, G4String::caseCompare mode=G4String::ignoreCase)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4String StrStrip(const G4String &str, char ch, StringStripType stripType=StringStripType::both)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4int CalculateOrientation(G4double angle)
std::pair< G4ThreeVector, G4ThreeVector > CalculateFaces(G4double angleInIn, G4double angleOutIn)
Calculate input and output normal vector.
G4double GetParameterValueDouble(G4String spec, G4String name)
Get parameter value from the specification ('spec') string.
Logical not for isalpha UnaryPredicate as needed for string manipulations.