Skip to content

Commit 186f3d1

Browse files
authored
Merge branch 'AliceO2Group:master' into master
2 parents 5ad84be + e09d587 commit 186f3d1

24 files changed

Lines changed: 1379 additions & 306 deletions

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6666
std::string path = std::string(filename).substr(5); // Remove "ccdb:" prefix
6767
const std::string outPath = "/tmp/LUTs/";
6868
filename = Form("%s/%s/snapshot.root", outPath.c_str(), path.c_str());
69+
LOG(info) << " --- Local LUT filename will be: " << filename;
6970
std::ifstream checkFile(filename); // Check if file already exists
7071
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
7172
LOG(info) << " --- CCDB source detected for PDG " << pdg << ": " << path;

ALICE3/Core/FastTracker.cxx

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111

1212
#include "FastTracker.h"
1313

14-
#include "ReconstructionDataFormats/TrackParametrization.h"
14+
#include "Common/Core/TableHelper.h"
15+
16+
#include <ReconstructionDataFormats/TrackParametrization.h>
1517

16-
#include "TMath.h"
17-
#include "TMatrixD.h"
18-
#include "TMatrixDSymEigen.h"
19-
#include "TRandom.h"
2018
#include <TEnv.h>
2119
#include <THashList.h>
20+
#include <TMath.h>
21+
#include <TMatrixD.h>
22+
#include <TMatrixDSymEigen.h>
2223
#include <TObject.h>
24+
#include <TRandom.h>
25+
#include <TSystem.h>
2326

2427
#include <fstream>
2528
#include <map>
@@ -31,6 +34,81 @@ namespace o2
3134
namespace fastsim
3235
{
3336

37+
std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration(std::string filename, std::vector<std::string>& layers)
38+
{
39+
std::map<std::string, std::map<std::string, std::string>> configMap;
40+
filename = gSystem->ExpandPathName(filename.c_str());
41+
TEnv env(filename.c_str());
42+
THashList* table = env.GetTable();
43+
layers.clear();
44+
for (int i = 0; i < table->GetEntries(); ++i) {
45+
const std::string key = table->At(i)->GetName();
46+
// key should contain exactly one dot
47+
if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) {
48+
LOG(fatal) << "Key " << key << " does not contain exactly one dot";
49+
continue;
50+
}
51+
const std::string firstPart = key.substr(0, key.find('.'));
52+
if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) {
53+
layers.push_back(firstPart);
54+
}
55+
}
56+
env.Print();
57+
// Layers
58+
for (const auto& layer : layers) {
59+
LOG(info) << " Reading layer " << layer;
60+
for (int i = 0; i < table->GetEntries(); ++i) {
61+
const std::string key = table->At(i)->GetName();
62+
if (key.find(layer + ".") == 0) {
63+
const std::string paramName = key.substr(key.find('.') + 1);
64+
const std::string value = env.GetValue(key.c_str(), "");
65+
configMap[layer][paramName] = value;
66+
}
67+
}
68+
}
69+
return configMap;
70+
}
71+
72+
void GeometryContainer::init(o2::framework::InitContext& initContext)
73+
{
74+
std::vector<std::string> detectorConfiguration;
75+
const bool found = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
76+
if (!found) {
77+
LOG(fatal) << "Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task.";
78+
return;
79+
}
80+
LOG(info) << "Size of detector configuration: " << detectorConfiguration.size();
81+
for (const auto& configFile : detectorConfiguration) {
82+
LOG(info) << "Detector geometry configuration file used: " << configFile;
83+
addEntry(configFile);
84+
}
85+
}
86+
87+
std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration(const std::string& layerName) const
88+
{
89+
auto it = mConfigurations.find(layerName);
90+
if (it != mConfigurations.end()) {
91+
return it->second;
92+
} else {
93+
LOG(fatal) << "Layer " << layerName << " not found in geometry configurations.";
94+
return {};
95+
}
96+
}
97+
98+
std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const
99+
{
100+
auto layer = getConfiguration(layerName);
101+
auto entry = layer.find(key);
102+
if (entry != layer.end()) {
103+
return layer.at(key);
104+
} else if (require) {
105+
LOG(fatal) << "Key " << key << " not found in layer " << layerName << " configurations.";
106+
return "";
107+
} else {
108+
return "";
109+
}
110+
}
111+
34112
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
35113

36114
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: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "DetLayer.h"
1616

1717
#include <CCDB/BasicCCDBManager.h>
18+
#include <Framework/InitContext.h>
19+
#include <Framework/Logger.h>
1820
#include <ReconstructionDataFormats/Track.h>
1921

20-
#include <fairlogger/Logger.h>
21-
2222
#include <map>
2323
#include <string>
2424
#include <vector>
@@ -28,6 +28,63 @@ namespace o2
2828
namespace fastsim
2929
{
3030

31+
class GeometryContainer
32+
{
33+
public:
34+
GeometryContainer() = default;
35+
virtual ~GeometryContainer() = default;
36+
37+
void init(o2::framework::InitContext& initContext);
38+
39+
/**
40+
* @brief Parses a TEnv configuration file and returns the key-value pairs split per entry
41+
* @param filename Path to the TEnv configuration file
42+
* @param layers Vector to store the order of the layers as they appear in the file
43+
* @return A map where each key is a layer name and the value is another map of key-value pairs for that layer
44+
*/
45+
static std::map<std::string, std::map<std::string, std::string>> parseTEnvConfiguration(std::string filename, std::vector<std::string>& layers);
46+
47+
// A container for the geometry info
48+
struct GeometryEntry {
49+
// Default constructor
50+
GeometryEntry() = default;
51+
explicit GeometryEntry(std::string filename) : name(filename)
52+
{
53+
mConfigurations = GeometryContainer::parseTEnvConfiguration(filename, layerNames);
54+
}
55+
std::map<std::string, std::map<std::string, std::string>> getConfigurations() const { return mConfigurations; }
56+
std::map<std::string, std::string> getConfiguration(const std::string& layerName) const;
57+
std::vector<std::string> getLayerNames() const { return layerNames; }
58+
std::string getValue(const std::string& layerName, const std::string& key, bool require = true) const;
59+
float getFloatValue(const std::string& layerName, const std::string& key) const { return std::stof(getValue(layerName, key)); }
60+
int getIntValue(const std::string& layerName, const std::string& key) const { return std::stoi(getValue(layerName, key)); }
61+
62+
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
66+
};
67+
68+
// Add a geometry entry from a configuration file
69+
void addEntry(const std::string& filename) { entries.emplace_back(filename); }
70+
71+
// Getters
72+
int getNumberOfConfigurations() const { return entries.size(); }
73+
const std::vector<GeometryEntry>& getEntries() const { return entries; }
74+
const GeometryEntry& getEntry(const int id) const { return entries.at(id); }
75+
GeometryEntry getGeometryEntry(const int id) const { return entries.at(id); }
76+
77+
// Get configuration maps
78+
std::map<std::string, std::map<std::string, std::string>> getConfigurations(const int id) const { return entries.at(id).getConfigurations(); }
79+
std::map<std::string, std::string> getConfiguration(const int id, const std::string& layerName) const { return entries.at(id).getConfiguration(layerName); }
80+
81+
// Get specific values
82+
float getFloatValue(const int id, const std::string& layerName, const std::string& key) const { return entries.at(id).getFloatValue(layerName, key); }
83+
84+
private:
85+
std::vector<GeometryEntry> entries;
86+
};
87+
3188
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
3289

3390
// this class implements a synthetic smearer that allows

ALICE3/Core/FastTrackerLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#pragma link off all classes;
1717
#pragma link off all functions;
1818

19+
#pragma link C++ class o2::fastsim::GeometryContainer + ;
1920
#pragma link C++ class o2::fastsim::FastTracker + ;
2021
#pragma link C++ class o2::fastsim::DelphesO2LutWriter + ;
2122

ALICE3/Macros/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
install(FILES Configuration/a3geo.ini
1313
Configuration/a3geometry_v2.ini
14+
Configuration/a3geometry_v3.ini
1415
Configuration/a3geometry_v4.ini
1516
PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ
1617
DESTINATION share/alice3/)
17-
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Format:
2+
# <layer_name>.<parameter>: <value>
3+
# Example:
4+
# layer1.r: 0.5 # radius in cm
5+
# layer1.z: 250 # half-length in cm
6+
# layer1.x0: 0.001 # radiation length
7+
# layer1.xrho: 0 # density in g/cm^2
8+
# layer1.resRPhi: 0.0001 # resolution in R-Phi in cm
9+
# layer1.resZ: 0.0001 # resolution in Z in cm
10+
# layer1.eff: 1.0 # efficiency (0 to 1)
11+
# layer1.type: 1 # type of layer (0: passive, 1: active)
12+
# layer1.deadPhiRegions: /path/to/dead_regions.root # optional dead regions file
13+
14+
bpipe0.r: 0.48
15+
bpipe0.z: 250
16+
bpipe0.x0: 0.001592
17+
bpipe0.xrho: 0
18+
bpipe0.resRPhi: 0.0f
19+
bpipe0.resZ: 0.0f
20+
bpipe0.eff: 0.0f
21+
bpipe0.type: 0
22+
23+
B00.r: 0.5
24+
B00.z: 250
25+
B00.x0: 0.00076
26+
B00.xrho: 0
27+
B00.resRPhi: 0.00025
28+
B00.resZ: 0.00025
29+
B00.eff: 1.00
30+
B00.type: 1
31+
32+
B01.r 1.2
33+
B01.z 250
34+
B01.x0 0.00096
35+
B01.xrho 0
36+
B01.resRPhi 0.00025
37+
B01.resZ 0.00025
38+
B01.eff 1.00
39+
B01.type 1
40+
41+
B02.r: 2.5
42+
B02.z: 250
43+
B02.x0: 0.00167
44+
B02.xrho: 0
45+
B02.resRPhi: 0.00025
46+
B02.resZ: 0.00025
47+
B02.eff: 1.00
48+
B02.type: 1
49+
50+
coldplate.r: 2.6
51+
coldplate.z: 250
52+
coldplate.x0: 0.02f
53+
coldplate.xrho: 0
54+
coldplate.resRPhi: 0.0f
55+
coldplate.resZ: 0.0f
56+
coldplate.eff: 0.0f
57+
coldplate.type: 0
58+
59+
bpipe1.r: 5.7
60+
bpipe1.z: 250
61+
bpipe1.x0: 0.0023f
62+
bpipe1.xrho: 0
63+
bpipe1.resRPhi: 0.0f
64+
bpipe1.resZ: 0.0f
65+
bpipe1.eff: 0.0f
66+
bpipe1.type: 0
67+
68+
B03.r: 7.
69+
B03.z: 250
70+
B03.x0: 0.01
71+
B03.xrho: 2.3292e-01
72+
B03.resRPhi: 0.001
73+
B03.resZ: 0.001
74+
B03.eff: 1.00
75+
B03.type: 1
76+
77+
B04.r: 9.
78+
B04.z: 250
79+
B04.x0: 0.01
80+
B04.xrho: 2.3292e-01
81+
B04.resRPhi: 0.001
82+
B04.resZ: 0.001
83+
B04.eff: 1.00
84+
B04.type: 1
85+
86+
B05.r: 12.
87+
B05.z: 250
88+
B05.x0: 0.01
89+
B05.xrho: 2.3292e-01
90+
B05.resRPhi: 0.001
91+
B05.resZ: 0.001
92+
B05.eff: 1.00
93+
B05.type: 1
94+
95+
iTOF.r: 19
96+
iTOF.z: 250
97+
iTOF.x0: 0.01*3.
98+
iTOF.xrho: 0.03
99+
iTOF.resRPhi: 0.001
100+
iTOF.resZ: 0.001
101+
iTOF.eff: 1.00
102+
iTOF.type: 0
103+
104+
B06.r: 20.
105+
B06.z: 250
106+
B06.x0: 0.01
107+
B06.xrho: 2.3292e-01
108+
B06.resRPhi: 0.001
109+
B06.resZ: 0.001
110+
B06.eff: 1.00
111+
B06.type: 1
112+
113+
B07.r: 30.
114+
B07.z: 250
115+
B07.x0: 0.01
116+
B07.xrho: 2.3292e-01
117+
B07.resRPhi: 0.001
118+
B07.resZ: 0.001
119+
B07.eff: 1.00
120+
B07.type: 1
121+
122+
B08.r: 45.
123+
B08.z: 250
124+
B08.x0: 0.01
125+
B08.xrho: 2.3292e-01
126+
B08.resRPhi: 0.001
127+
B08.resZ: 0.001
128+
B08.eff: 1.00
129+
B08.type: 1
130+
131+
B09.r: 60.
132+
B09.z: 250
133+
B09.x0: 0.01
134+
B09.xrho: 2.3292e-01
135+
B09.resRPhi: 0.001
136+
B09.resZ: 0.001
137+
B09.eff: 1.00
138+
B09.type: 1
139+
140+
B10.r: 80.
141+
B10.z: 250
142+
B10.x0: 0.01
143+
B10.xrho: 2.3292e-01
144+
B10.resRPhi: 0.001
145+
B10.resZ: 0.001
146+
B10.eff: 1.00
147+
B10.type: 1
148+
149+
# Lookup tables
150+
global.lutEl: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/el
151+
global.lutMu: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/mu
152+
global.lutPi: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/pi
153+
global.lutKa: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/ka
154+
global.lutPr: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/pr
155+
156+
# in kGauss
157+
global.magneticfield: 20

ALICE3/TableProducer/OTF/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ o2physics_add_dpl_workflow(on-the-fly-tracker-pid
2828
SOURCES onTheFlyTrackerPid.cxx
2929
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2Physics::ALICE3Core
3030
COMPONENT_NAME Analysis)
31+
32+
o2physics_add_dpl_workflow(on-the-fly-detector-geometry-provider
33+
SOURCES onTheFlyDetectorGeometryProvider.cxx
34+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::ALICE3Core O2Physics::FastTracker
35+
COMPONENT_NAME Analysis)

0 commit comments

Comments
 (0)