Skip to content

Commit 78fce6e

Browse files
authored
Merge branch 'AliceO2Group:master' into master
2 parents 803e834 + 7fd7969 commit 78fce6e

File tree

78 files changed

+1529
-1809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1529
-1809
lines changed

ALICE3/Core/FastTracker.cxx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ namespace o2
3434
namespace fastsim
3535
{
3636

37-
std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration(std::string filename, std::vector<std::string>& layers)
37+
std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration(std::string& filename, std::vector<std::string>& layers)
3838
{
3939
std::map<std::string, std::map<std::string, std::string>> configMap;
4040
filename = gSystem->ExpandPathName(filename.c_str());
41+
LOG(info) << "Parsing TEnv configuration file: " << filename;
4142
TEnv env(filename.c_str());
4243
THashList* table = env.GetTable();
4344
layers.clear();
@@ -95,6 +96,16 @@ std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfigur
9596
}
9697
}
9798

99+
bool GeometryContainer::GeometryEntry::hasValue(const std::string& layerName, const std::string& key) const
100+
{
101+
auto layerIt = mConfigurations.find(layerName);
102+
if (layerIt != mConfigurations.end()) {
103+
auto keyIt = layerIt->second.find(key);
104+
return keyIt != layerIt->second.end();
105+
}
106+
return false;
107+
}
108+
98109
std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const
99110
{
100111
auto layer = getConfiguration(layerName);
@@ -109,6 +120,14 @@ std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerN
109120
}
110121
}
111122

123+
void GeometryContainer::GeometryEntry::replaceValue(const std::string& layerName, const std::string& key, const std::string& value)
124+
{
125+
if (!hasValue(layerName, key)) { // check that the key exists
126+
LOG(fatal) << "Key " << key << " does not exist in layer " << layerName << ". Cannot replace value.";
127+
}
128+
setValue(layerName, key, value);
129+
}
130+
112131
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
113132

114133
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)

ALICE3/Core/FastTracker.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,35 @@ 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.";
56+
if (mLayerNames.empty()) {
57+
LOG(warning) << "No layers found in geometry configuration file: " << filename;
58+
}
5459
}
5560
std::map<std::string, std::map<std::string, std::string>> getConfigurations() const { return mConfigurations; }
5661
std::map<std::string, std::string> getConfiguration(const std::string& layerName) const;
57-
std::vector<std::string> getLayerNames() const { return layerNames; }
62+
std::vector<std::string> getLayerNames() const { return mLayerNames; }
63+
bool hasValue(const std::string& layerName, const std::string& key) const;
5864
std::string getValue(const std::string& layerName, const std::string& key, bool require = true) const;
65+
void setValue(const std::string& layerName, const std::string& key, const std::string& value) { mConfigurations[layerName][key] = value; }
66+
void replaceValue(const std::string& layerName, const std::string& key, const std::string& value);
5967
float getFloatValue(const std::string& layerName, const std::string& key) const { return std::stof(getValue(layerName, key)); }
6068
int getIntValue(const std::string& layerName, const std::string& key) const { return std::stoi(getValue(layerName, key)); }
6169

6270
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
71+
std::string mFileName; // Filename of the geometry
72+
std::map<std::string, std::map<std::string, std::string>> mConfigurations; // Layer configurations
73+
std::vector<std::string> mLayerNames; // Ordered names of the layers
6674
};
6775

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

8189
// Get specific values
90+
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); }
8291
float getFloatValue(const int id, const std::string& layerName, const std::string& key) const { return entries.at(id).getFloatValue(layerName, key); }
8392

8493
private:

CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/EventFiltering/PWGLF @alibuild @mpuccio @ercolessi @ChiaraDeMartin95 @lietava @fgrosa @ariedel-cern
2929
/EventFiltering/PWGCF @alibuild @lauraser @mpuccio @lietava @fgrosa @ariedel-cern
3030
/EventFiltering/PWGMM @alibuild @aortizve @mpuccio @lietava @fgrosa @ariedel-cern
31-
/EventFiltering/PWGJE @alibuild @fkrizek @nzardosh @mpuccio @lietava @fgrosa @ariedel-cern
31+
/EventFiltering/PWGJE @alibuild @fkrizek @nzardosh @raymondEhlers @mpuccio @lietava @fgrosa @ariedel-cern
3232
/EventFiltering/PWGEM @alibuild @dsekihat @nstrangm @mpuccio @lietava @fgrosa @ariedel-cern
3333

3434
/PWGCF @alibuild @victor-gonzalez @zchochul @lgraczykCern @prchakra @lauraser @ariedel-cern @EmilGorm @otonvd @shouqiye @glromane
@@ -63,14 +63,14 @@
6363
/PWGMM/UE @alibuild @omvazque @mpuccio @skundu692 @aalkin @aortizve @jgcn
6464

6565
/PWGUD @alibuild @amatyja @rolavick
66-
/PWGJE @alibuild @lhavener @maoyx @nzardosh @fjonasALICE @mfasDa @mhemmer-cern
66+
/PWGJE @alibuild @lhavener @maoyx @nzardosh @raymondEhlers @fjonasALICE @mfasDa @mhemmer-cern
6767
/Tools/PIDML @alibuild @saganatt
6868
/Tools/ML @alibuild @fcatalan92 @fmazzasc
6969
/Tutorials/PWGCF @alibuild @jgrosseo @victor-gonzalez @zchochul
7070
/Tutorials/PWGDQ @alibuild @iarsene @mcoquet @lucamicheletti93
7171
/Tutorials/PWGEM @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu
7272
/Tutorials/PWGHF @alibuild @vkucera @fcolamar @fgrosa @gluparel @xinyepeng
73-
/Tutorials/PWGJE @alibuild @lhavener @maoyx @nzardosh @mfasDa @fjonasALICE
73+
/Tutorials/PWGJE @alibuild @lhavener @maoyx @nzardosh @raymondEhlers @mfasDa @fjonasALICE
7474
/Tutorials/PWGLF @alibuild @alcaliva @lbariogl @chiarapinto @BongHwi @lbarnby @ercolessi @iravasen @njacazio @romainschotter @skundu692
7575
/Tutorials/PWGMM @alibuild @aalkin @ddobrigk
7676
/Tutorials/PWGUD @alibuild @pbuehler @amatyja

0 commit comments

Comments
 (0)