Skip to content

Commit 27338ac

Browse files
authored
Merge branch 'master' into tpccdbfix
2 parents 62933cc + 8aeef94 commit 27338ac

File tree

539 files changed

+60850
-28176
lines changed

Some content is hidden

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

539 files changed

+60850
-28176
lines changed

.clang-tidy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
CheckOptions:
2-
- { key: CheckPathRegex, value: ".*/O2/.*" }
32
# Naming conventions
43
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
54
- { key: readability-identifier-naming.ClassMemberPrefix, value: m }
65
- { key: readability-identifier-naming.ConceptCase, value: CamelCase }
76
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
8-
- { key: readability-identifier-naming.ConstexprVariableIgnoredRegexp, value: "^k[A-Z].*$" } # Allow "k" prefix.
97
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
108
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
11-
- { key: readability-identifier-naming.EnumConstantIgnoredRegexp, value: "^k[A-Z].*$" } # Allow "k" prefix.
9+
- { key: readability-identifier-naming.EnumConstantIgnoredRegexp, value: "^k?[A-Z][a-zA-Z0-9_]*$" } # Allow "k" prefix and non-trailing underscores in PDG names.
1210
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
1311
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
14-
- { key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: "^[A-Z]+(_[A-Z]+)*_$" } # Allow the trailing underscore in header guards.
12+
- { key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: "^[A-Z][A-Z0-9_]*_$" } # Allow the trailing underscore in header guards.
1513
- { key: readability-identifier-naming.MemberCase, value: camelBack }
1614
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
1715
- { key: readability-identifier-naming.ParameterCase, value: camelBack }

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
# Upload MegaLinter artifacts
5151
- name: Archive production artifacts
52-
uses: actions/upload-artifact@v4
52+
uses: actions/upload-artifact@v5
5353
if: success() || failure()
5454
with:
5555
name: MegaLinter reports

.mega-linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ PYTHON_PYRIGHT_CONFIG_FILE: pyproject.toml
3939
PYTHON_RUFF_CONFIG_FILE: pyproject.toml
4040
CPP_CPPLINT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
4141
CPP_CLANG_FORMAT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
42+
CPP_CPPCHECK_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", ".cuh", ".cxx", ".cxx.in", ".h", ".h++", ".hh", ".h.in", ".hpp", ".hxx", ".inc", ".inl", ".macro"]
4243
CPP_CPPCHECK_ARGUMENTS: --language=c++ --std=c++20 --check-level=exhaustive --suppressions-list=cppcheck_config
4344
REPOSITORY_GITLEAKS_PR_COMMITS_SCAN: true

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,18 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
105105
mLUTHeader[ipdg] = nullptr;
106106
return false;
107107
}
108-
if (mLUTHeader[ipdg]->pdg != pdg) {
108+
bool specialPdgCase = false;
109+
switch (pdg) { // Handle special cases
110+
case o2::constants::physics::kAlpha: // Special case: Allow Alpha particles to use He3 LUT
111+
specialPdgCase = (mLUTHeader[ipdg]->pdg == o2::constants::physics::kHelium3);
112+
if (specialPdgCase)
113+
LOG(info)
114+
<< " --- Alpha particles (PDG " << pdg << ") will use He3 LUT data (PDG " << mLUTHeader[ipdg]->pdg << ")" << std::endl;
115+
break;
116+
default:
117+
break;
118+
}
119+
if (mLUTHeader[ipdg]->pdg != pdg && !specialPdgCase) {
109120
LOG(info) << " --- LUT header PDG mismatch: expected/detected = " << pdg << "/" << mLUTHeader[ipdg]->pdg << std::endl;
110121
delete mLUTHeader[ipdg];
111122
mLUTHeader[ipdg] = nullptr;
@@ -142,12 +153,13 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
142153

143154
/*****************************************************************/
144155

145-
lutEntry_t*
146-
TrackSmearer::getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff)
156+
lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff)
147157
{
148-
auto ipdg = getIndexPDG(pdg);
149-
if (!mLUTHeader[ipdg])
158+
const int ipdg = getIndexPDG(pdg);
159+
if (!mLUTHeader[ipdg]) {
160+
LOG(error) << " --- getLUTEntry: LUT header not loaded for pdg=" << pdg << ". Returning nullptr.";
150161
return nullptr;
162+
}
151163
auto inch = mLUTHeader[ipdg]->nchmap.find(nch);
152164
auto irad = mLUTHeader[ipdg]->radmap.find(radius);
153165
auto ieta = mLUTHeader[ipdg]->etamap.find(eta);
@@ -279,56 +291,56 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch)
279291
}
280292
auto eta = o2track.getEta();
281293
float interpolatedEff = 0.0f;
282-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
294+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
283295
if (!lutEntry || !lutEntry->valid)
284296
return false;
285297
return smearTrack(o2track, lutEntry, interpolatedEff);
286298
}
287299

288300
/*****************************************************************/
289301
// relative uncertainty on pt
290-
double TrackSmearer::getPtRes(int pdg, float nch, float eta, float pt)
302+
double TrackSmearer::getPtRes(const int pdg, const float nch, const float eta, const float pt)
291303
{
292304
float dummy = 0.0f;
293-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
305+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
294306
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt;
295307
return val;
296308
}
297309

298310
/*****************************************************************/
299311
// relative uncertainty on eta
300-
double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt)
312+
double TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, const float pt)
301313
{
302314
float dummy = 0.0f;
303-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
315+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
304316
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
305317
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
306318
etaRes /= lutEntry->eta; // relative uncertainty
307319
return etaRes;
308320
}
309321
/*****************************************************************/
310322
// absolute uncertainty on pt
311-
double TrackSmearer::getAbsPtRes(int pdg, float nch, float eta, float pt)
323+
double TrackSmearer::getAbsPtRes(const int pdg, const float nch, const float eta, const float pt)
312324
{
313325
float dummy = 0.0f;
314-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
326+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
315327
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * lutEntry->pt;
316328
return val;
317329
}
318330

319331
/*****************************************************************/
320332
// absolute uncertainty on eta
321-
double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt)
333+
double TrackSmearer::getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt)
322334
{
323335
float dummy = 0.0f;
324-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
336+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
325337
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
326338
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
327339
return etaRes;
328340
}
329341
/*****************************************************************/
330342
// efficiency
331-
double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
343+
double TrackSmearer::getEfficiency(const int pdg, const float nch, const float eta, const float pt)
332344
{
333345
float efficiency = 0.0f;
334346
getLUTEntry(pdg, nch, 0., eta, pt, efficiency);
@@ -349,7 +361,7 @@ double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
349361
// return true;
350362

351363
// #if 0
352-
// auto lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
364+
// lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
353365
// if (!lutEntry)
354366
// return;
355367

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <TRandom.h>
3131

32+
#include <cstdio>
3233
#include <fstream>
3334
#include <iostream>
3435
#include <map>
@@ -179,23 +180,24 @@ class TrackSmearer
179180

180181
/** LUT methods **/
181182
bool loadTable(int pdg, const char* filename, bool forceReload = false);
182-
void useEfficiency(bool val) { mUseEfficiency = val; } //;
183-
void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; } //;
184-
void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; } //;
185-
void setWhatEfficiency(int val) { mWhatEfficiency = val; } //;
186-
lutHeader_t* getLUTHeader(int pdg) { return mLUTHeader[getIndexPDG(pdg)]; } //;
187-
lutEntry_t* getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff);
183+
bool hasTable(int pdg) { return (mLUTHeader[getIndexPDG(pdg)] != nullptr); } //;
184+
void useEfficiency(bool val) { mUseEfficiency = val; } //;
185+
void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; } //;
186+
void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; } //;
187+
void setWhatEfficiency(int val) { mWhatEfficiency = val; } //;
188+
lutHeader_t* getLUTHeader(int pdg) { return mLUTHeader[getIndexPDG(pdg)]; } //;
189+
lutEntry_t* getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff);
188190

189191
bool smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float interpolatedEff);
190192
bool smearTrack(O2Track& o2track, int pdg, float nch);
191193
// bool smearTrack(Track& track, bool atDCA = true); // Only in DelphesO2
192-
double getPtRes(int pdg, float nch, float eta, float pt);
193-
double getEtaRes(int pdg, float nch, float eta, float pt);
194-
double getAbsPtRes(int pdg, float nch, float eta, float pt);
195-
double getAbsEtaRes(int pdg, float nch, float eta, float pt);
196-
double getEfficiency(int pdg, float nch, float eta, float pt);
194+
double getPtRes(const int pdg, const float nch, const float eta, const float pt);
195+
double getEtaRes(const int pdg, const float nch, const float eta, const float pt);
196+
double getAbsPtRes(const int pdg, const float nch, const float eta, const float pt);
197+
double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt);
198+
double getEfficiency(const int pdg, const float nch, const float eta, const float pt);
197199

198-
int getIndexPDG(int pdg)
200+
int getIndexPDG(const int pdg)
199201
{
200202
switch (abs(pdg)) {
201203
case 11:
@@ -214,6 +216,8 @@ class TrackSmearer
214216
return 6; // Triton
215217
case 1000020030:
216218
return 7; // Helium3
219+
case 1000020040:
220+
return 8; // Alphas
217221
default:
218222
return 2; // Default: pion
219223
}
@@ -238,6 +242,8 @@ class TrackSmearer
238242
return "triton";
239243
case 1000020030:
240244
return "helium3";
245+
case 1000020040:
246+
return "alpha";
241247
default:
242248
return "pion"; // Default: pion
243249
}
@@ -246,7 +252,7 @@ class TrackSmearer
246252
void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //;
247253

248254
protected:
249-
static constexpr unsigned int nLUTs = 8; // Number of LUT available
255+
static constexpr unsigned int nLUTs = 9; // Number of LUT available
250256
lutHeader_t* mLUTHeader[nLUTs] = {nullptr};
251257
lutEntry_t***** mLUTEntry[nLUTs] = {nullptr};
252258
bool mUseEfficiency = true;

ALICE3/Core/DetLayer.cxx

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
/// \brief Basic struct to hold information regarding a detector layer to be used in fast simulation
1717
///
1818

19-
#include <vector>
20-
#include <string>
21-
2219
#include "DetLayer.h"
2320

21+
#include <CommonConstants/MathConstants.h>
22+
#include <Framework/Logger.h>
23+
24+
#include <string>
25+
#include <vector>
26+
2427
namespace o2::fastsim
2528
{
2629

@@ -51,6 +54,62 @@ DetLayer::DetLayer(const DetLayer& other)
5154
{
5255
}
5356

57+
void DetLayer::addDeadPhiRegion(float phiStart, float phiEnd)
58+
{
59+
static constexpr float kDefaultValue = 2.f;
60+
static constexpr float kPhiTolerance = 1e-4f;
61+
if (mDeadPhiRegions == nullptr) {
62+
mDeadPhiRegions = new TGraph();
63+
mDeadPhiRegions->SetNameTitle(Form("deadPhiRegions_%s", name.Data()), Form("Dead phi regions for layer %s", name.Data()));
64+
mDeadPhiRegions->AddPoint(0, kDefaultValue);
65+
mDeadPhiRegions->AddPoint(o2::constants::math::TwoPI, kDefaultValue);
66+
}
67+
if (phiStart < 0 || phiStart >= o2::constants::math::TwoPI || phiEnd < 0 || phiEnd >= o2::constants::math::TwoPI) {
68+
LOG(fatal) << "Cannot add dead phi region with invalid range [" << phiStart << ", " << phiEnd << "] to layer " << name;
69+
return;
70+
}
71+
mDeadPhiRegions->AddPoint(phiStart, kDefaultValue);
72+
mDeadPhiRegions->AddPoint(phiEnd, kDefaultValue);
73+
mDeadPhiRegions->AddPoint(phiStart + kPhiTolerance, 0.f);
74+
mDeadPhiRegions->AddPoint(phiEnd - kPhiTolerance, 0.f);
75+
mDeadPhiRegions->Sort();
76+
}
77+
78+
void DetLayer::setDeadPhiRegions(TGraph* graph)
79+
{
80+
LOG(debug) << "Setting dead phi regions for layer " << name << " with graph " << (graph ? graph->GetName() : "nullptr");
81+
if (mDeadPhiRegions != nullptr) {
82+
LOG(warning) << "Overriding existing dead phi regions for layer " << name;
83+
delete mDeadPhiRegions;
84+
}
85+
mDeadPhiRegions = graph;
86+
if (mDeadPhiRegions->GetN() == 0) {
87+
LOG(warning) << "Dead phi regions graph for layer " << name << " is empty, clearing dead regions";
88+
mDeadPhiRegions = nullptr;
89+
return; // cleared the dead regions
90+
}
91+
// Check sanity of the graph
92+
if (mDeadPhiRegions != nullptr) {
93+
for (int i = 0; i < mDeadPhiRegions->GetN(); i++) {
94+
const float x = mDeadPhiRegions->GetX()[i];
95+
const float y = mDeadPhiRegions->GetY()[i];
96+
// First point has to be at 0, last point has to be at 2PI
97+
if ((i == 0 && x != 0.f) || (i == mDeadPhiRegions->GetN() - 1 && x != o2::constants::math::TwoPI)) {
98+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i << ", first point should be 0 and last point should be 2PI";
99+
}
100+
LOG(debug) << "Point " << i << ": (" << x << ", " << y << ")";
101+
if (x < 0 || x > o2::constants::math::TwoPI) {
102+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i;
103+
}
104+
if (y != 0.f && y != 2.f) {
105+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid y value " << y << " at point " << i << ", should be 0 or 2";
106+
}
107+
}
108+
} else {
109+
LOG(info) << "Cleared dead phi regions for layer " << name;
110+
}
111+
}
112+
54113
std::string DetLayer::toString() const
55114
{
56115
std::string out = "";

ALICE3/Core/DetLayer.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#ifndef ALICE3_CORE_DETLAYER_H_
2020
#define ALICE3_CORE_DETLAYER_H_
2121

22-
#include <string>
22+
#include <TGraph.h>
23+
#include <TString.h>
2324

24-
#include "TString.h"
25+
#include <string>
2526

2627
namespace o2::fastsim
2728
{
@@ -47,6 +48,17 @@ struct DetLayer {
4748
void setEfficiency(float eff_) { eff = eff_; }
4849
void setType(int type_) { type = type_; }
4950

51+
// Dead areas
52+
53+
/// @brief Add a dead region in phi for this layer
54+
/// @param phiStart starting angle in radians of the dead region
55+
/// @param phiEnd ending angle in radians of the dead region
56+
void addDeadPhiRegion(float phiStart, float phiEnd);
57+
58+
/// @brief Set the dead regions in phi for this layer with a TGraph containing all regions. The graph should have y=2 for dead regions and y=0 for alive regions.
59+
/// @param graph graph of the dead regions. Can be nullptr to clear the dead regions.
60+
void setDeadPhiRegions(TGraph* graph);
61+
5062
// Getters
5163
float getRadius() const { return r; }
5264
float getZ() const { return z; }
@@ -57,6 +69,7 @@ struct DetLayer {
5769
float getEfficiency() const { return eff; }
5870
int getType() const { return type; }
5971
const TString& getName() const { return name; }
72+
const TGraph* getDeadPhiRegions() const { return mDeadPhiRegions; }
6073

6174
// Check layer type
6275
bool isInert() const { return type == layerInert; }
@@ -70,6 +83,15 @@ struct DetLayer {
7083
os << layer.toString();
7184
return os;
7285
}
86+
/// @brief Check if a given phi angle is in a dead region
87+
/// @param phi The phi angle to check
88+
/// @return True if the phi angle is in a dead region, false otherwise
89+
bool isInDeadPhiRegion(float phi) const
90+
{
91+
if (mDeadPhiRegions == nullptr)
92+
return false;
93+
return mDeadPhiRegions->Eval(phi) > 1.f;
94+
};
7395

7496
private:
7597
// TString for holding name
@@ -90,6 +112,9 @@ struct DetLayer {
90112
// efficiency
91113
float eff; // detection efficiency
92114

115+
// dead regions in phi (in radians)
116+
TGraph* mDeadPhiRegions = nullptr;
117+
93118
// layer type
94119
int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc
95120
static constexpr int layerInert = 0; // inert/undefined layer

0 commit comments

Comments
 (0)