Skip to content

Commit 6927303

Browse files
Merge branch 'master' into master
2 parents 35a3f69 + 89134e7 commit 6927303

File tree

208 files changed

+18901
-7483
lines changed

Some content is hidden

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

208 files changed

+18901
-7483
lines changed

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ class TrackSmearer
249249
return "pion"; // Default: pion
250250
}
251251
}
252-
void setdNdEta(float val) { mdNdEta = val; } //;
253-
void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //;
254-
void setCleanupDownloadedFile(bool val) { mCleanupDownloadedFile = val; } //;
255-
void setDownloadPath(const std::string& path) { mOutPath = "/tmp/LUTs/" + path; } //;
252+
void setdNdEta(float val) { mdNdEta = val; } //;
253+
void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //;
254+
void setCleanupDownloadedFile(bool val) { mCleanupDownloadedFile = val; } //;
255+
void setDownloadPath(const std::string& path) { mOutPath = path; } //;
256256

257257
protected:
258258
static constexpr unsigned int nLUTs = 9; // Number of LUT available
@@ -266,8 +266,8 @@ class TrackSmearer
266266

267267
private:
268268
o2::ccdb::BasicCCDBManager* mCcdbManager = nullptr;
269-
bool mCleanupDownloadedFile = true;
270-
std::string mOutPath = "/tmp/LUTs/";
269+
bool mCleanupDownloadedFile = true; // Flag to cleanup the LUT after it's used
270+
std::string mOutPath = "./.ALICE3/LUTs/"; // Path where to download LUTs from CCDB
271271
};
272272

273273
} // namespace delphes

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:

ALICE3/Core/TrackUtilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct OTFParticle {
5454

5555
// Getters
5656
int pdgCode() const { return mPdgCode; }
57-
int isAlive() const { return mIsAlive; }
57+
bool isAlive() const { return mIsAlive; }
5858
float vx() const { return mVx; }
5959
float vy() const { return mVy; }
6060
float vz() const { return mVz; }

ALICE3/Macros/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ install(FILES Configuration/a3geo.ini
1313
Configuration/a3geometry_v2_10kG.ini
1414
Configuration/a3geometry_v2_20kG_dipole.ini
1515
Configuration/a3geometry_v2_20kG.ini
16+
Configuration/a3geometry_v3_extra_ml.ini
1617
Configuration/a3geometry_v3.ini
1718
Configuration/a3geometry_v4.ini
1819
PERMISSIONS GROUP_READ GROUP_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ WORLD_EXECUTE WORLD_READ

ALICE3/Macros/Configuration/a3geo.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,10 @@ B10.resZ: 0.001
159159
B10.eff: 1.
160160
B10.type: 1
161161

162-
global.lutEl: /tmp/lutCovm.el.20kG.rmin20.geometry_v2.dat
162+
global.lutEl: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/el
163+
global.lutMu: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/mu
164+
global.lutPi: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/pi
165+
global.lutKa: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/ka
166+
global.lutPr: ccdb:/Users/j/jekarlss/LookUpTables/NoEloss/pr
167+
168+
global.magneticfield: 20

ALICE3/Macros/Configuration/a3geometry_v3.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ B10.eff: 1.00
147147
B10.type: 1
148148

149149
# Lookup tables
150-
global.lutEl: ccdb:/Users/j/jekarlss/LUTs/v3/extra_ml/el
151-
global.lutMu: ccdb:/Users/j/jekarlss/LUTs/v3/extra_ml/mu
152-
global.lutPi: ccdb:/Users/j/jekarlss/LUTs/v3/extra_ml/pi
153-
global.lutKa: ccdb:/Users/j/jekarlss/LUTs/v3/extra_ml/ka
154-
global.lutPr: ccdb:/Users/j/jekarlss/LUTs/v3/extra_ml/pr
150+
global.lutEl: ccdb:/Users/j/jekarlss/LUTs/v3/b/el
151+
global.lutMu: ccdb:/Users/j/jekarlss/LUTs/v3/b/mu
152+
global.lutPi: ccdb:/Users/j/jekarlss/LUTs/v3/b/pi
153+
global.lutKa: ccdb:/Users/j/jekarlss/LUTs/v3/b/ka
154+
global.lutPr: ccdb:/Users/j/jekarlss/LUTs/v3/b/pr
155155

156156
# in kGauss
157157
global.magneticfield: 20

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 93 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct OnTheFlyDecayer {
7373

7474
o2::upgrade::Decayer decayer;
7575
Service<o2::framework::O2DatabasePDG> pdgDB;
76-
std::map<int64_t, std::vector<o2::upgrade::OTFParticle>> mDecayDaughters;
76+
std::map<int, std::vector<o2::upgrade::OTFParticle>> mDecayDaughters;
7777

7878
Configurable<int> seed{"seed", 0, "Set seed for particle decayer"};
7979
Configurable<float> magneticField{"magneticField", 20., "Magnetic field (kG)"};
@@ -84,9 +84,62 @@ struct OnTheFlyDecayer {
8484
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
8585
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for QA histograms"};
8686

87+
struct McParticleAlice3 {
88+
McParticleAlice3() = default;
89+
~McParticleAlice3() = default;
90+
McParticleAlice3(const McParticleAlice3& src) = default;
91+
McParticleAlice3(int collisionId,
92+
int pdgCode,
93+
int statusCode,
94+
int flags,
95+
int mother0,
96+
int mother1,
97+
int daughter0,
98+
int daughter1,
99+
float weight,
100+
float px, float py, float pz, float e,
101+
float vx, float vy, float vz, float vt,
102+
float phi, float eta, float pt, float p, float y,
103+
bool isAlive, bool isPrimary) : collisionId(collisionId),
104+
pdgCode(pdgCode),
105+
statusCode(statusCode),
106+
flags(flags),
107+
mothersIds{mother0, mother1},
108+
daughtersIdSlice{daughter0, daughter1},
109+
weight(weight),
110+
px(px),
111+
py(py),
112+
pz(pz),
113+
e(e),
114+
vx(vx),
115+
vy(vy),
116+
vz(vz),
117+
vt(vt),
118+
phi(phi),
119+
eta(eta),
120+
pt(pt),
121+
p(p),
122+
y(y),
123+
isAlive(isAlive),
124+
isPrimary(isPrimary) {}
125+
int collisionId;
126+
int pdgCode;
127+
int statusCode;
128+
int flags;
129+
int mothersIds[2];
130+
int daughtersIdSlice[2];
131+
float weight;
132+
float px, py, pz, e;
133+
float vx, vy, vz, vt;
134+
float phi, eta, pt, p, y;
135+
bool isAlive;
136+
bool isPrimary;
137+
};
138+
87139
std::vector<int> mEnabledDecays;
88140
void init(o2::framework::InitContext&)
89141
{
142+
LOG(info) << "Initializing on-the-fly-decayer.";
90143
decayer.setSeed(seed);
91144
decayer.setBField(magneticField);
92145
for (int i = 0; i < NumDecays; ++i) {
@@ -115,11 +168,13 @@ struct OnTheFlyDecayer {
115168
return std::find(mEnabledDecays.begin(), mEnabledDecays.end(), pdgCode) != mEnabledDecays.end();
116169
}
117170

171+
std::vector<McParticleAlice3> mcParticlesAlice3;
118172
void process(aod::McCollision const&, aod::McParticles const& mcParticles)
119173
{
120174
mDecayDaughters.clear();
175+
mcParticlesAlice3.clear();
121176
u_int64_t nStoredDaughters = 0;
122-
for (int64_t index{0}; index < mcParticles.size(); ++index) {
177+
for (int index{0}; index < static_cast<int>(mcParticles.size()); ++index) {
123178
const auto& particle = mcParticles.iteratorAt(index);
124179
std::vector<o2::upgrade::OTFParticle> decayDaughters;
125180
static constexpr int MaxNestedDecays = 10;
@@ -129,13 +184,14 @@ struct OnTheFlyDecayer {
129184
o2::upgrade::convertMCParticleToO2Track(particle, o2track, pdgDB);
130185
decayDaughters = decayer.decayParticle(pdgDB, o2track, particle.pdgCode());
131186
for (size_t idau{0}; idau < decayDaughters.size(); ++idau) {
132-
o2::upgrade::OTFParticle& dau = decayDaughters[idau];
187+
o2::upgrade::OTFParticle dau = decayDaughters[idau];
133188
o2::track::TrackParCov dauTrack;
134189
o2::upgrade::convertOTFParticleToO2Track(dau, dauTrack, pdgDB);
135190
if (canDecay(dau.pdgCode())) {
136191
dau.setIsAlive(false);
137192
std::vector<o2::upgrade::OTFParticle> cascadingDaughers = decayer.decayParticle(pdgDB, dauTrack, dau.pdgCode());
138-
for (const auto& daudau : cascadingDaughers) {
193+
for (size_t idaudau{0}; idaudau < cascadingDaughers.size(); ++idaudau) {
194+
o2::upgrade::OTFParticle daudau = cascadingDaughers[idaudau];
139195
decayDaughters.push_back(daudau);
140196
if (MaxNestedDecays < ++nDecays) {
141197
LOG(error) << "Seemingly stuck trying to perpetually decay products from pdg: " << particle.pdgCode();
@@ -194,14 +250,13 @@ struct OnTheFlyDecayer {
194250
daughtersIdSlice[1] = static_cast<int>(particle.daughtersIds()[1]);
195251
}
196252

197-
std::span<const int> motherSpan(particle.mothersIds().data(), particle.mothersIds().size());
198253
mDecayDaughters.emplace(index, decayDaughters);
199254
nStoredDaughters += decayDaughters.size();
200255

201-
float phi = o2::constants::math::PI + std::atan2(-1.0f * particle.py(), -1.0f * particle.px());
256+
const float phi = o2::constants::math::PI + std::atan2(-1.0f * particle.py(), -1.0f * particle.px());
202257
float eta; // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1922
203-
float pt = std::sqrt(particle.px() * particle.px() + particle.py() * particle.py());
204-
float p = std::sqrt(particle.px() * particle.px() + particle.py() * particle.py() + particle.pz() * particle.pz());
258+
const float pt = std::sqrt(particle.px() * particle.px() + particle.py() * particle.py());
259+
const float p = std::sqrt(particle.px() * particle.px() + particle.py() * particle.py() + particle.pz() * particle.pz());
205260
float y; // As https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1943
206261

207262
if ((p - particle.pz()) < Tolerance) {
@@ -218,29 +273,29 @@ struct OnTheFlyDecayer {
218273

219274
// TODO: Particle status code
220275
// TODO: Expression columns
221-
tableMcParticlesWithDau(particle.mcCollisionId(), particle.pdgCode(), particle.statusCode(),
222-
particle.flags(), motherSpan, daughtersIdSlice, particle.weight(),
223-
particle.px(), particle.py(), particle.pz(), particle.e(),
224-
particle.vx(), particle.vy(), particle.vz(), particle.vt(),
225-
phi, eta, pt, p, y, !canDecay(particle.pdgCode()), true);
276+
auto mothers = particle.mothersIds();
277+
int mother0 = mothers.size() > 0 ? mothers[0] : -1;
278+
int mother1 = mothers.size() > 1 ? mothers[1] : mother0;
279+
mcParticlesAlice3.push_back(McParticleAlice3{particle.mcCollisionId(), particle.pdgCode(), particle.statusCode(),
280+
particle.flags(), mother0, mother1,
281+
daughtersIdSlice[0], daughtersIdSlice[1], particle.weight(),
282+
particle.px(), particle.py(), particle.pz(), particle.e(),
283+
particle.vx(), particle.vy(), particle.vz(), particle.vt(),
284+
phi, eta, pt, p, y, !canDecay(particle.pdgCode()), true});
226285
}
227286

228287
int daughtersIdSlice[2] = {-1, -1};
229288
for (const auto& [index, decayDaughters] : mDecayDaughters) {
230289
for (const auto& dau : decayDaughters) {
231290
if (index >= mcParticles.size()) {
232-
LOG(warn) << "--- Index " << index << " out of bounds for mcParticles table of size " << mcParticles.size();
291+
LOG(error) << "--- Index " << index << " out of bounds for mcParticles table of size " << mcParticles.size() << std::endl;
233292
continue;
234293
}
235294

236-
auto mother = mcParticles.iteratorAt(index);
237-
std::vector<int> motherIds = {static_cast<int>(index)};
238-
std::span<const int> motherSpan(motherIds.data(), motherIds.size());
239-
240-
float phi = o2::constants::math::PI + std::atan2(-1.0f * dau.py(), -1.0f * dau.px());
295+
const float phi = o2::constants::math::PI + std::atan2(-1.0f * dau.py(), -1.0f * dau.px());
241296
float eta; // Conditional as https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1922
242-
float pt = std::sqrt(dau.px() * dau.px() + dau.py() * dau.py());
243-
float p = std::sqrt(dau.px() * dau.px() + dau.py() * dau.py() + dau.pz() * dau.pz());
297+
const float pt = std::sqrt(dau.px() * dau.px() + dau.py() * dau.py());
298+
const float p = std::sqrt(dau.px() * dau.px() + dau.py() * dau.py() + dau.pz() * dau.pz());
244299
float y; // Conditional as https://github.com/AliceO2Group/AliceO2/blob/dev/Framework/Core/include/Framework/AnalysisDataModel.h#L1943
245300

246301
if ((p - dau.pz()) < Tolerance) {
@@ -283,13 +338,25 @@ struct OnTheFlyDecayer {
283338
// TODO: Particle status code
284339
// TODO: Expression columns
285340
// TODO: vt
286-
tableMcParticlesWithDau(mother.mcCollisionId(), dau.pdgCode(), 1,
287-
mother.flags(), motherSpan, daughtersIdSlice, mother.weight(),
288-
dau.px(), dau.py(), dau.pz(), dau.e(),
289-
dau.vx(), dau.vy(), dau.vz(), mother.vt(),
290-
phi, eta, pt, p, y, dau.isAlive(), false);
341+
auto mother = mcParticles.iteratorAt(index);
342+
mcParticlesAlice3.push_back(McParticleAlice3{mother.mcCollisionId(), dau.pdgCode(), 1,
343+
-1, index, index, daughtersIdSlice[0], daughtersIdSlice[1], mother.weight(),
344+
dau.px(), dau.py(), dau.pz(), dau.e(),
345+
dau.vx(), dau.vy(), dau.vz(), mother.vt(),
346+
phi, eta, pt, p, y, dau.isAlive(), false});
291347
}
292348
}
349+
350+
for (const auto& particle : mcParticlesAlice3) {
351+
std::span<const int> motherSpan(particle.mothersIds, 2);
352+
353+
tableMcParticlesWithDau(particle.collisionId, particle.pdgCode, particle.statusCode,
354+
particle.flags, motherSpan, particle.daughtersIdSlice, particle.weight,
355+
particle.px, particle.py, particle.pz, particle.e,
356+
particle.vx, particle.vy, particle.vz, particle.vt,
357+
particle.phi, particle.eta, particle.pt, particle.p, particle.y,
358+
particle.isAlive, particle.isPrimary);
359+
}
293360
}
294361
};
295362

0 commit comments

Comments
 (0)