Skip to content

Commit

Permalink
updateing some variables to nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
martinunland committed Jun 10, 2024
1 parent b8cc15b commit 5da75ee
Show file tree
Hide file tree
Showing 25 changed files with 463 additions and 563 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ include(${ROOT_USE_FILE})

add_subdirectory(common)
add_subdirectory(effective_area)
add_subdirectory(radioactive_decays)
add_subdirectory(supernova)
#add_subdirectory(radioactive_decays)
#add_subdirectory(supernova)

# Copy auxiliary files from source directory to binary directory
set(mdom_aux
Expand Down
17 changes: 8 additions & 9 deletions common/framework/include/OMSim.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ namespace po = boost::program_options;
class OMSim
{
public:

OMSim();
~OMSim();

void ensureOutputDirectoryExists(const std::string &filepath);
void initialiseSimulation(OMSimDetectorConstruction* pDetectorConstruction);
void initialiseSimulation(OMSimDetectorConstruction *pDetectorConstruction);
void configureLogger();
bool handleArguments(int pArgumentCount, char *pArgumentVector[]);
void startVisualisationIfRequested();
//OMSimDetectorConstruction* getDetectorConstruction();


G4Navigator* getNavigator(){return mNavigator;};
// OMSimDetectorConstruction* getDetectorConstruction();

G4Navigator *getNavigator() { return mNavigator; };
void extendOptions(po::options_description pNewOptions);
po::options_description mGeneralOptions;

private:
void initialLoggerConfiguration();
po::variables_map parseArguments(int pArgumentCount, char *pArgumentVector[]);
void setUserArgumentsToArgTable(po::variables_map pVariablesMap);
void setGeneralOptions();

G4RunManager *mRunManager = nullptr;
G4VisExecutive *mVisManager = nullptr;
Expand All @@ -73,9 +74,7 @@ private:
G4UserSteppingAction *mStepping = nullptr;
G4TouchableHistory *mHistory = nullptr;



G4double mStartingTime=0;
G4double mStartingTime = 0;
};

#endif // OMSIM_H
73 changes: 37 additions & 36 deletions common/framework/include/OMSimCommandArgsTable.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
* @ingroup common
*/

#ifndef OMSIMCOMMANDARGSTABLE_H
#define OMSIMCOMMANDARGSTABLE_H

/**
* @brief Writes a key-value pair to a JSON file if the value type matches TYPE.
* @note This macro is used inside the `OMSimCommandArgsTable::writeToJson()` method.
*/
#ifndef OMSIMCOMMANDARGSTABLE_H
#define OMSIMCOMMANDARGSTABLE_H
#define WRITE_TO_JSON_IF_TYPE_MATCHES(VARIANT, TYPE) \
if (type == typeid(TYPE)) \
{ \
outFile << "\t\"" << kv.first << "\": "; \
lOutputFile << "\t\"" << kv.first << "\": "; \
if (typeid(TYPE) == typeid(std::string)) \
{ \
outFile << "\"" << boost::any_cast<TYPE>(VARIANT) << "\""; \
lOutputFile << "\"" << boost::any_cast<TYPE>(VARIANT) << "\""; \
} \
else \
{ \
outFile << boost::any_cast<TYPE>(VARIANT); \
lOutputFile << boost::any_cast<TYPE>(VARIANT); \
} \
}

Expand All @@ -32,14 +33,19 @@

/**
* @class OMSimCommandArgsTable
* @brief A singleton class used to hold and manipulate OMSim command arguments.
* @brief A singleton class used to hold OMSim command arguments.
*
* This class uses a map to hold key-value pairs of simulation command arguments. In principle it is just a wrapper around the map created by the boost library to avoid users changing the arg values after initialisation.
* The class also provides a method to write the parameters to a JSON file.
* Provides a method to write the parameters to a JSON file.
* @ingroup common
*/
class OMSimCommandArgsTable
{
OMSimCommandArgsTable() = default;
OMSimCommandArgsTable(const OMSimCommandArgsTable &) = delete;
OMSimCommandArgsTable &operator=(const OMSimCommandArgsTable &) = delete;
~OMSimCommandArgsTable() = default;

public:
using Key = std::string;
using Value = boost::any; // Using boost::any to hold any type
Expand All @@ -56,47 +62,47 @@ public:

/**
* @brief Sets a parameter in the arg table.
* @param key The key for the parameter.
* @param value The value for the parameter.
* @param pKey The key for the parameter.
* @param pValue The value for the parameter.
* @throw std::runtime_error If the table is already finalized (i.e. somebody is trying to set a new arg parameter after args were parsed (?!)).
*/
void setParameter(const Key &key, const Value &value)
void setParameter(const Key &pKey, const Value &pValue)
{
if (mFinalized)
{
throw std::runtime_error("Cannot modify OMSimCommandArgsTable after it's been finalized!");
}
mParameters[key] = value;
mParameters[pKey] = pValue;
}

/**
* @brief Retrieves a parameter from the table.
* @param key The key for the parameter.
* @param pKey The key for the parameter.
* @return The parameter value.
* @throw std::invalid_argument If the parameter is not of type T, or if the key does not exist.
*/
template <typename T>
T get(const std::string &key)
T get(const std::string &pKey)
{
try
{
return boost::any_cast<T>(mParameters.at(key));
return boost::any_cast<T>(mParameters.at(pKey));
}
catch (const boost::bad_any_cast &e)
{
log_error(("Failed to get parameter " + key + " as type " + typeid(T).name()).c_str());
throw std::invalid_argument("Failed to get parameter " + key + " as type " + typeid(T).name());
log_error(("Failed to get parameter " + pKey + " as type " + typeid(T).name()).c_str());
throw std::invalid_argument("Failed to get parameter " + pKey + " as type " + typeid(T).name());
}
catch (const std::out_of_range &e)
{
log_error(("Parameter " + key + " does not exist").c_str());
throw std::invalid_argument("Parameter " + key + " does not exist");
log_error(("Parameter " + pKey + " does not exist").c_str());
throw std::invalid_argument("Parameter " + pKey + " does not exist");
}
}

bool keyExists(const Key &key) const
bool keyExists(const Key &pKey) const
{
return mParameters.find(key) != mParameters.end();
return mParameters.find(pKey) != mParameters.end();
}

/**
Expand All @@ -106,22 +112,22 @@ public:
*/
void writeToJson(std::string pFileName)
{
std::ofstream outFile(pFileName);
std::ofstream lOutputFile(pFileName);

if (!outFile.is_open())
if (!lOutputFile.is_open())
{
throw std::runtime_error("Failed to open file " + pFileName);
}

outFile << "{\n";
size_t count = mParameters.size();
lOutputFile << "{\n";
size_t lCount = mParameters.size();
for (const auto &kv : mParameters)
{
--count; // Decrease count for each iteration
--lCount; // Decrease count for each iteration

if (kv.second.empty())
{
outFile << "\t\"" << kv.first << "\": \"\"";
lOutputFile << "\t\"" << kv.first << "\": \"\"";
}
else
{
Expand All @@ -135,15 +141,15 @@ public:
}

// Append comma if it's not the last item
if (count != 0)
if (lCount != 0)
{
outFile << ",";
lOutputFile << ",";
}

outFile << "\n";
lOutputFile << "\n";
}
outFile << "}\n";
outFile.close();
lOutputFile << "}\n";
lOutputFile.close();
}

/**
Expand All @@ -163,11 +169,6 @@ public:
}

private:
OMSimCommandArgsTable() = default;
~OMSimCommandArgsTable() = default;
OMSimCommandArgsTable(const OMSimCommandArgsTable &) = delete;
OMSimCommandArgsTable &operator=(const OMSimCommandArgsTable &) = delete;

bool mFinalized = false;
std::map<Key, Value> mParameters;
};
Expand Down
38 changes: 12 additions & 26 deletions common/framework/include/OMSimDataFileTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class ParameterTable;
*
* @details Derived classes should implement specific functionality for reading and writing different types of data files.
* This class contains a pointer to a ParameterTable, used for storing file data, and a string for the file name.
*
* @note This class is not meant to be instantiated directly, but should be subclassed. Methods in this class are to be
* overridden in the subclass for specific behavior.
* @ingroup common
*/
class abcDataFile
Expand All @@ -50,24 +47,17 @@ public:
protected:
void sortVectorByReference(std::vector<G4double> &referenceVector, std::vector<G4double> &sortVector);

virtual void extractInformation() = 0; // abstract method you have to define for a derived class
const G4double mHC_eVnm = 1239.84193 * eV; // h*c in eV * nm
virtual void extractInformation() = 0; ///< abstract method you have to define for a derived class
const G4double mHC_eVnm = 1239.84193 * eV; ///< h*c in eV * nm
boost::property_tree::ptree mJsonTree;
ParameterTable *mFileData;
};

/**
* @class abcMaterialData
* @brief Abstract base class for material data extraction from a json file.
*
* abcMaterialData class is derived from abcDataFile class. It is designed to manage
* the material data, such as refractive index and absorption length.
*
* @note This class is abstract and cannot be instantiated directly. Instead, use one
* of the derived classes: RefractionAndAbsorption, RefractionOnly, NoOptics, or IceCubeIce.
*
* The method extractInformation is a pure virtual function that should be implemented by the derived classes.
* It is intended for the specific extraction of data required by each derived class.
* @ingroup common
*/
class abcMaterialData : public abcDataFile
Expand All @@ -84,14 +74,14 @@ public:

protected:
G4State getState(G4String pState);
virtual void extractInformation() = 0; // abstract method
virtual void extractInformation() = 0; ///< abstract method that has to be defined in derived classes
};

// Derived Classes

/**
* @class RefractionAndAbsorption
* @brief This class is responsible for handling materials with both a defined refractive index and absorption length.
* @brief Materials with defined refractive index and absorption length.
* @inherit abcMaterialData
* @ingroup common
*/
Expand All @@ -104,7 +94,7 @@ public:

/**
* @class RefractionOnly
* @brief This class is responsible for handling materials with only defined refractive index.
* @brief Materials only with refractive index defined.
* @inherit abcMaterialData
* @ingroup common
*/
Expand All @@ -117,7 +107,7 @@ public:

/**
* @class NoOptics
* @brief This class is responsible for handling materials without defined optical properties.
* @brief Materials without optical properties defined.
* @inherit abcMaterialData
* @ingroup common
*/
Expand All @@ -130,7 +120,7 @@ public:

/**
* @class IceCubeIce
* @brief This class is responsible for the creation and property extraction of IceCube's ice.
* @brief Creation and extraction of IceCube's ice optical properties.
* @inherit abcMaterialData
* @ingroup common
*/
Expand All @@ -144,7 +134,7 @@ public:
private:
int mSpiceDepth_pos;

G4double spiceTemperature(G4double depth);
G4double spiceTemperature(G4double pDepth);
G4double spiceAbsorption(G4double pLambd);
G4double spiceRefraction(G4double pLambd);
G4double mieScattering(G4double pLambd);
Expand All @@ -153,12 +143,12 @@ private:
std::vector<G4double> mSpice_a400inv;
std::vector<G4double> mSpiceDepth;
const G4double mMieSpiceConst[3] = {0.972, 0.0000001, 1};
G4double mInnerColumn_b_inv = 3 * cm; // Eff. scattering lenght of bubble column (if placed)
G4double mInnerColumn_b_inv = 3 * cm; ///< Eff. scattering lenght of bubble column (if placed)
};

/**
* @class ReflectiveSurface
* @brief This class is responsible for defining new reflective surfaces using data parsed from a JSON file.
* @brief Reflective surfaces parsed from a JSON file.
* @inherit abcDataFile
* @ingroup common
*/
Expand All @@ -176,11 +166,7 @@ public:

/**
* @class ScintillationProperties
* @brief Class to extract and apply scintillation properties to existing materials.
*
* This class is responsible for extracting scintillation properties from a data file
* and applying them to a Geant4 material's properties table.
*
* @brief Scintillation properties extraction for existing materials.
* @ingroup common
*/
class ScintillationProperties : public abcDataFile
Expand All @@ -204,7 +190,7 @@ private:

/**
* @class CustomProperties
* @brief This class adds user defined properties to already defined materials
* @brief Adds user defined properties to already defined materials
* @ingroup common
*/
class CustomProperties : public abcDataFile
Expand Down
Loading

0 comments on commit 5da75ee

Please sign in to comment.