Skip to content

Commit e41656b

Browse files
authored
Refactor FastTracker to use member variables
1 parent 3e9db0f commit e41656b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ALICE3/Core/FastTracker.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,32 @@ class GeometryContainer
4242
* @param layers Vector to store the order of the layers as they appear in the file
4343
* @return A map where each key is a layer name and the value is another map of key-value pairs for that layer
4444
*/
45-
static std::map<std::string, std::map<std::string, std::string>> parseTEnvConfiguration(std::string filename, std::vector<std::string>& layers);
45+
static std::map<std::string, std::map<std::string, std::string>> parseTEnvConfiguration(std::string& filename, std::vector<std::string>& layers);
4646

4747
// A container for the geometry info
4848
struct GeometryEntry {
4949
// Default constructor
5050
GeometryEntry() = default;
51-
explicit GeometryEntry(std::string filename) : name(filename)
51+
explicit GeometryEntry(std::string filename)
5252
{
53-
mConfigurations = GeometryContainer::parseTEnvConfiguration(filename, layerNames);
53+
mFileName = filename;
54+
mConfigurations = GeometryContainer::parseTEnvConfiguration(mFileName, mLayerNames);
55+
LOG(info) << "Loaded geometry configuration from file: " << filename << " with " << mLayerNames.size() << " layers.";
5456
}
5557
std::map<std::string, std::map<std::string, std::string>> getConfigurations() const { return mConfigurations; }
5658
std::map<std::string, std::string> getConfiguration(const std::string& layerName) const;
57-
std::vector<std::string> getLayerNames() const { return layerNames; }
59+
std::vector<std::string> getLayerNames() const { return mLayerNames; }
60+
bool hasValue(const std::string& layerName, const std::string& key) const;
5861
std::string getValue(const std::string& layerName, const std::string& key, bool require = true) const;
62+
void setValue(const std::string& layerName, const std::string& key, const std::string& value) { mConfigurations[layerName][key] = value; }
63+
void replaceValue(const std::string& layerName, const std::string& key, const std::string& value);
5964
float getFloatValue(const std::string& layerName, const std::string& key) const { return std::stof(getValue(layerName, key)); }
6065
int getIntValue(const std::string& layerName, const std::string& key) const { return std::stoi(getValue(layerName, key)); }
6166

6267
private:
63-
std::string name; // Filename of the geometry
64-
std::map<std::string, std::map<std::string, std::string>> mConfigurations;
65-
std::vector<std::string> layerNames; // Ordered names of the layers
68+
std::string mFileName; // Filename of the geometry
69+
std::map<std::string, std::map<std::string, std::string>> mConfigurations; // Layer configurations
70+
std::vector<std::string> mLayerNames; // Ordered names of the layers
6671
};
6772

6873
// Add a geometry entry from a configuration file
@@ -79,6 +84,7 @@ class GeometryContainer
7984
std::map<std::string, std::string> getConfiguration(const int id, const std::string& layerName) const { return entries.at(id).getConfiguration(layerName); }
8085

8186
// Get specific values
87+
std::string getValue(const int id, const std::string& layerName, const std::string& key, bool require = true) const { return entries.at(id).getValue(layerName, key, require); };
8288
float getFloatValue(const int id, const std::string& layerName, const std::string& key) const { return entries.at(id).getFloatValue(layerName, key); }
8389

8490
private:

0 commit comments

Comments
 (0)