24#include "G4ThreeVector.hh"
25#include "G4TwoVector.hh"
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);
115 G4String
GetFullPath(G4String filename,
bool excludeNameFromPath=
false,
bool useCWDForPrefix=
false);
126 G4String& extension);
137 G4double tolerance = std::numeric_limits<double>::epsilon());
140 G4bool
IsFinite(
const G4ThreeVector& variable,
141 G4double tolerance = std::numeric_limits<double>::epsilon());
144 G4bool
NonZero(G4double value);
152 G4bool
IsInteger(
const char* s,
int& convertedInteger);
155 G4bool
IsNumber(
const char* s,
double& convertedNumber);
157 template <
typename T>
159 {
return G4int((T(0) < val) - (val < T(0)));}
161 inline G4String BoolToString(G4bool in)
162 {
return in ?
"true" :
"false";}
190 G4TwoVector
Rotate(
const G4TwoVector& vec,
const G4double& angle);
196 const G4ThreeVector& outgoingNormal,
197 const G4double& zSeparation,
205 const G4double& angleOut,
206 const G4double& horizontalWidth,
207 const G4double& length);
222 std::pair<G4String, G4String>
SplitOnColon(
const G4String& formatAndPath);
232 G4double fraction = 1.6);
239 char delimiter =
':');
244 template <
typename K,
typename V>
247 typename std::map<K,V>::const_iterator it = m.find(key);
248 return it == m.end() ? defaultValue : it->second;
254 G4int verboseEventContinueFor);
262 G4double
Rigidity(G4double momentumMagnitude,
267 const std::string& prefix) {
return expression.size() >= prefix.size() &&
268 expression.rfind(prefix, 0) == 0;}
271 inline G4bool
EndsWith(
const std::string& expression,
272 const std::string& suffix) {
return expression.size() >= suffix.size() &&
273 expression.compare(expression.size() - suffix.size(), suffix.size(), suffix) == 0;}
279 G4double containerWidth,
280 G4double containerHeight=0);
284 G4ThreeVector outputfaceIn,
286 G4double containerWidth,
287 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)
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.