Skip to content

Commit a141261

Browse files
authored
Merge branch 'AliceO2Group:master' into NetChargeFluctuations3
2 parents d6ad72c + 211d2df commit a141261

559 files changed

Lines changed: 55117 additions & 25901 deletions

File tree

Some content is hidden

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

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ WarningsAsErrors: >-
111111
*,
112112
-readability-braces-around-statements,
113113
-readability-suspicious-call-argument,
114+
-modernize-*,
115+
-readability-*,
114116
CheckOptions:
115117
modernize-avoid-c-arrays.AllowStringArrays: true
116118
# Common tolerated conversions

.mega-linter.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ DISABLE_LINTERS:
1919
- PYTHON_FLAKE8
2020
- PYTHON_ISORT
2121
- REPOSITORY_DEVSKIM
22-
- REPOSITORY_GITLEAKS
23-
- REPOSITORY_KICS
2422
- REPOSITORY_OSV_SCANNER
2523
- REPOSITORY_SECRETLINT
2624
- REPOSITORY_TRIVY
@@ -43,5 +41,4 @@ CPP_CPPLINT_FILE_EXTENSIONS: [".C", ".c", ".c++", ".cc", ".cl", ".cpp", ".cu", "
4341
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"]
4442
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"]
4543
CPP_CPPCHECK_ARGUMENTS: --language=c++ --std=c++20 --enable=style --check-level=exhaustive --suppressions-list=cppcheck_suppressions --inline-suppr --force
46-
REPOSITORY_GITLEAKS_PR_COMMITS_SCAN: true
4744
ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES: [GITHUB_TOKEN]

ALICE3/Core/Decayer.h

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
#include <TLorentzVector.h>
3232
#include <TRandom3.h>
3333

34+
#include <array>
3435
#include <cmath>
3536
#include <cstddef>
3637
#include <vector>
3738

38-
namespace o2
39-
{
40-
namespace upgrade
39+
namespace o2::upgrade
4140
{
4241

4342
class Decayer
@@ -47,44 +46,27 @@ class Decayer
4746
Decayer() = default;
4847

4948
template <typename TDatabase>
50-
std::vector<o2::upgrade::OTFParticle> decayParticle(const TDatabase& pdgDB, const OTFParticle& particle)
49+
std::vector<o2::upgrade::OTFParticle> decayParticle(const OTFParticle& particle, const TDatabase& pdgDB)
5150
{
52-
const auto& particleInfo = pdgDB->GetParticle(particle.pdgCode());
51+
auto particleInfo = pdgDB->GetParticle(particle.pdgCode());
5352
if (!particleInfo) {
5453
return {};
5554
}
5655

5756
const int charge = particleInfo->Charge() / 3;
5857
const double mass = particleInfo->Mass();
59-
60-
const double u = mRand3.Uniform(0.001, 0.999);
61-
const double ctau = o2::constants::physics::LightSpeedCm2S * particleInfo->Lifetime(); // cm
62-
const double betaGamma = particle.p() / mass;
63-
const double rxyz = -betaGamma * ctau * std::log(1 - u);
64-
double px, py, e;
58+
std::array<double, 3> decayVtx = generateDecayVertex<double>(particle, pdgDB);
59+
mVx = decayVtx[0];
60+
mVy = decayVtx[1];
61+
mVz = decayVtx[2];
62+
double px{}, py{}, e{};
6563

6664
if (!charge) {
67-
mVx = particle.vx() + rxyz * (particle.px() / particle.p());
68-
mVy = particle.vy() + rxyz * (particle.py() / particle.p());
69-
mVz = particle.vz() + rxyz * (particle.pz() / particle.p());
7065
px = particle.px();
7166
py = particle.py();
7267
} else {
73-
o2::track::TrackParCov track;
74-
o2::math_utils::CircleXYf_t circle;
75-
o2::upgrade::convertOTFParticleToO2Track(particle, track, pdgDB);
76-
77-
float sna{}, csa{};
78-
track.getCircleParams(mBz, circle, sna, csa);
79-
const double rxy = rxyz / std::sqrt(1. + track.getTgl() * track.getTgl());
80-
const double theta = rxy / circle.rC;
81-
82-
mVx = ((particle.vx() - circle.xC) * std::cos(theta) - (particle.vy() - circle.yC) * std::sin(theta)) + circle.xC;
83-
mVy = ((particle.vy() - circle.yC) * std::cos(theta) + (particle.vx() - circle.xC) * std::sin(theta)) + circle.yC;
84-
mVz = particle.vz() + rxyz * (particle.pz() / track.getP());
85-
86-
px = particle.px() * std::cos(theta) - particle.py() * std::sin(theta);
87-
py = particle.py() * std::cos(theta) + particle.px() * std::sin(theta);
68+
px = particle.px() * std::cos(mTheta) - particle.py() * std::sin(mTheta);
69+
py = particle.py() * std::cos(mTheta) + particle.px() * std::sin(mTheta);
8870
}
8971

9072
double brTotal = 0.;
@@ -133,6 +115,42 @@ class Decayer
133115
return decayProducts;
134116
}
135117

118+
template <typename T = float, typename TDatabase, typename TParticle>
119+
std::array<T, 3> generateDecayVertex(const TParticle& particle, const TDatabase& pdgDB)
120+
{
121+
std::array<T, 3> decayVertex{};
122+
auto particleInfo = pdgDB->GetParticle(particle.pdgCode());
123+
if (!particleInfo) {
124+
return {};
125+
}
126+
127+
const int charge = particleInfo->Charge() / 3;
128+
const double mass = particleInfo->Mass();
129+
const double u = mRand3.Uniform(0.001, 0.999);
130+
const double ctau = o2::constants::physics::LightSpeedCm2S * particleInfo->Lifetime(); // cm
131+
const double betaGamma = particle.p() / mass;
132+
const double rxyz = -betaGamma * ctau * std::log(1 - u);
133+
134+
if (!charge) {
135+
decayVertex[0] = particle.vx() + rxyz * (particle.px() / particle.p());
136+
decayVertex[1] = particle.vy() + rxyz * (particle.py() / particle.p());
137+
decayVertex[2] = particle.vz() + rxyz * (particle.pz() / particle.p());
138+
} else {
139+
o2::math_utils::CircleXYf_t circle;
140+
o2::track::TrackParCov track = o2::upgrade::convertMCParticleToO2Track(particle, pdgDB);
141+
142+
float sna{}, csa{};
143+
track.getCircleParams(mBz, circle, sna, csa);
144+
const double rxy = rxyz / std::sqrt(1. + track.getTgl() * track.getTgl());
145+
mTheta = rxy / circle.rC;
146+
147+
decayVertex[0] = ((particle.vx() - circle.xC) * std::cos(mTheta) - (particle.vy() - circle.yC) * std::sin(mTheta)) + circle.xC;
148+
decayVertex[1] = ((particle.vy() - circle.yC) * std::cos(mTheta) + (particle.vx() - circle.xC) * std::sin(mTheta)) + circle.yC;
149+
decayVertex[2] = particle.vz() + rxyz * (particle.pz() / track.getP());
150+
}
151+
return decayVertex;
152+
}
153+
136154
// Setters
137155
void setBField(const double b) { mBz = b; }
138156
void setSeed(const int seed)
@@ -142,18 +160,18 @@ class Decayer
142160
}
143161

144162
// Getters
145-
float getSecondaryVertexX() const { return static_cast<float>(mVx); }
146-
float getSecondaryVertexY() const { return static_cast<float>(mVy); }
147-
float getSecondaryVertexZ() const { return static_cast<float>(mVz); }
148-
float getDecayRadius() const { return static_cast<float>(std::hypot(mVx, mVy)); }
163+
[[nodiscard]] float getSecondaryVertexX() const { return static_cast<float>(mVx); }
164+
[[nodiscard]] float getSecondaryVertexY() const { return static_cast<float>(mVy); }
165+
[[nodiscard]] float getSecondaryVertexZ() const { return static_cast<float>(mVz); }
166+
[[nodiscard]] float getDecayRadius() const { return static_cast<float>(std::hypot(mVx, mVy)); }
149167

150168
private:
151169
double mBz{20.}; // kG
152170
double mVx{-1.}, mVy{-1.}, mVz{-1.};
153-
TRandom3 mRand3{};
171+
double mTheta{};
172+
TRandom3 mRand3;
154173
};
155174

156-
} // namespace upgrade
157-
} // namespace o2
175+
} // namespace o2::upgrade
158176

159177
#endif // ALICE3_CORE_DECAYER_H_

ALICE3/Core/DelphesO2LutWriter.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void DelphesO2LutWriter::diagonalise(lutEntry_t& lutEntry)
376376
// m.Print();
377377
TMatrixDSymEigen eigen(m);
378378
// eigenvalues vector
379-
TVectorD eigenVal = eigen.GetEigenValues();
379+
const TVectorD& eigenVal = eigen.GetEigenValues();
380380
for (int i = 0; i < kEig; ++i)
381381
lutEntry.eigval[i] = eigenVal[i];
382382
// eigenvectors matrix

ALICE3/Core/FastTracker.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace fastsim
5151

5252
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
5353

54-
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
54+
DetLayer* FastTracker::AddLayer(const TString& name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
5555
{
5656
LOG(debug) << "Adding layer " << name << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type;
5757
DetLayer newLayer(name, r, z, x0, xrho, resRPhi, resZ, eff, type);
@@ -154,7 +154,7 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
154154
}
155155
}
156156

157-
void FastTracker::AddGenericDetector(o2::fastsim::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
157+
void FastTracker::AddGenericDetector(const o2::fastsim::GeometryEntry& configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
158158
{
159159
// Layers
160160
for (const auto& layer : configMap.getLayerNames()) {
@@ -586,7 +586,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
586586
m.SetMatrixArray(reinterpret_cast<double*>(fcovm));
587587
TMatrixDSymEigen eigen(m);
588588
TMatrixD eigVec = eigen.GetEigenVectors();
589-
TVectorD eigVal = eigen.GetEigenValues();
589+
const TVectorD& eigVal = eigen.GetEigenValues();
590590
bool negEigVal = false;
591591
for (int ii = 0; ii < 5; ii++) {
592592
if (eigVal[ii] < 0.0f)

ALICE3/Core/FastTracker.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class FastTracker
4646
virtual ~FastTracker() {}
4747

4848
// Layer and layer configuration
49-
DetLayer* AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
49+
DetLayer* AddLayer(const TString& name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
5050

5151
/// Add a dead region in phi for a specific layer
5252
/// \param layerName Name of the layer to modify
@@ -59,11 +59,11 @@ class FastTracker
5959
size_t GetNLayers() const { return layers.size(); }
6060
bool IsLayerInert(const int layer) const { return layers[layer].isInert(); }
6161
void ClearLayers() { layers.clear(); }
62-
void SetRadiationLength(const std::string layerName, float x0) { layers[GetLayerIndex(layerName)].setRadiationLength(x0); }
63-
void SetRadius(const std::string layerName, float r) { layers[GetLayerIndex(layerName)].setRadius(r); }
64-
void SetResolutionRPhi(const std::string layerName, float resRPhi) { layers[GetLayerIndex(layerName)].setResolutionRPhi(resRPhi); }
65-
void SetResolutionZ(const std::string layerName, float resZ) { layers[GetLayerIndex(layerName)].setResolutionZ(resZ); }
66-
void SetResolution(const std::string layerName, float resRPhi, float resZ)
62+
void SetRadiationLength(const std::string& layerName, float x0) { layers[GetLayerIndex(layerName)].setRadiationLength(x0); }
63+
void SetRadius(const std::string& layerName, float r) { layers[GetLayerIndex(layerName)].setRadius(r); }
64+
void SetResolutionRPhi(const std::string& layerName, float resRPhi) { layers[GetLayerIndex(layerName)].setResolutionRPhi(resRPhi); }
65+
void SetResolutionZ(const std::string& layerName, float resZ) { layers[GetLayerIndex(layerName)].setResolutionZ(resZ); }
66+
void SetResolution(const std::string& layerName, float resRPhi, float resZ)
6767
{
6868
SetResolutionRPhi(layerName, resRPhi);
6969
SetResolutionZ(layerName, resZ);
@@ -80,7 +80,7 @@ class FastTracker
8080
*
8181
* @param configMap Configuration map describing the detector.
8282
*/
83-
void AddGenericDetector(o2::fastsim::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
83+
void AddGenericDetector(const o2::fastsim::GeometryEntry& configMap, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
8484

8585
void Print();
8686

ALICE3/Core/FlatLutEntry.cxx

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@
2525
namespace o2::delphes
2626
{
2727

28+
void lutEntry_t::print() const
29+
{
30+
LOGF(info, " nch = %f, eta = %f, pt = %f, valid = %s\n", nch, eta, pt, valid ? "true" : "false");
31+
LOGF(info, " eff = %f, eff2 = %f, itof = %f, otof = %f\n", eff, eff2, itof, otof);
32+
LOGF(info, " covm: ");
33+
for (int i = 0; i < 15; ++i) {
34+
LOGF(info, "%f ", covm[i]);
35+
}
36+
LOGF(info, "\n");
37+
LOGF(info, " eigval: ");
38+
for (int i = 0; i < 5; ++i) {
39+
LOGF(info, "%f ", eigval[i]);
40+
}
41+
LOGF(info, "\n");
42+
LOGF(info, " eigvec:\n");
43+
for (int i = 0; i < 5; ++i) {
44+
for (int j = 0; j < 5; ++j) {
45+
LOGF(info, "%f ", eigvec[i][j]);
46+
}
47+
LOGF(info, "\n");
48+
}
49+
LOGF(info, " eiginv:\n");
50+
for (int i = 0; i < 5; ++i) {
51+
for (int j = 0; j < 5; ++j) {
52+
LOGF(info, "%f ", eiginv[i][j]);
53+
}
54+
LOGF(info, "\n");
55+
}
56+
}
57+
2858
float map_t::fracPositionWithinBin(float val) const
2959
{
3060
float width = (max - min) / nbins;
@@ -90,10 +120,10 @@ void FlatLutData::initialize(const lutHeader_t& header)
90120
mEtaBins = header.etamap.nbins;
91121
mPtBins = header.ptmap.nbins;
92122

93-
size_t headerSize = sizeof(lutHeader_t);
94-
size_t numEntries = static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins;
95-
size_t entriesSize = numEntries * sizeof(lutEntry_t);
96-
size_t totalSize = headerSize + entriesSize;
123+
const size_t headerSize = sizeof(lutHeader_t);
124+
const size_t numEntries = static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins;
125+
const size_t entriesSize = numEntries * sizeof(lutEntry_t);
126+
const size_t totalSize = headerSize + entriesSize;
97127

98128
mData.resize(totalSize);
99129
// Write header at the beginning
@@ -103,13 +133,10 @@ void FlatLutData::initialize(const lutHeader_t& header)
103133

104134
size_t FlatLutData::getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
105135
{
106-
size_t headerSize = sizeof(lutHeader_t);
107-
108-
// Linear index: nch varies slowest, pt varies fastest
109-
// idx = nch * (rad*eta*pt) + rad * (eta*pt) + eta * pt + pt
110-
size_t linearIdx = static_cast<size_t>(nch_bin) * (mRadBins * mEtaBins * mPtBins) + static_cast<size_t>(rad_bin) * (mEtaBins * mPtBins) + static_cast<size_t>(eta_bin) * mPtBins + static_cast<size_t>(pt_bin);
111-
112-
return headerSize + linearIdx * sizeof(lutEntry_t);
136+
static constexpr size_t headerSize = sizeof(lutHeader_t);
137+
const size_t linearIdx = getEntryIndex(nch_bin, rad_bin, eta_bin, pt_bin);
138+
static constexpr size_t entrySize = sizeof(lutEntry_t);
139+
return headerSize + linearIdx * entrySize;
113140
}
114141

115142
const lutEntry_t* FlatLutData::getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const

ALICE3/Core/FlatLutEntry.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ class FlatLutData
104104
*/
105105
void initialize(const lutHeader_t& header);
106106

107+
size_t getEntryIndex(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
108+
{
109+
// Linear index: nch varies slowest, pt varies fastest
110+
// idx = nch * (rad*eta*pt) + rad * (eta*pt) + eta * pt + pt
111+
return static_cast<size_t>(nch_bin) * (mRadBins * mEtaBins * mPtBins) + static_cast<size_t>(rad_bin) * (mEtaBins * mPtBins) + static_cast<size_t>(eta_bin) * mPtBins + static_cast<size_t>(pt_bin);
112+
}
113+
107114
/**
108115
* @brief Get LUT entry by bin indices (view)
109116
*/

ALICE3/Core/FlatLutWriter.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void FlatLutWriter::diagonalise(lutEntry_t& lutEntry)
392392
TMatrixDSymEigen eigen(m);
393393

394394
// Eigenvalues
395-
TVectorD eigenVal = eigen.GetEigenValues();
395+
const TVectorD& eigenVal = eigen.GetEigenValues();
396396
for (int i = 0; i < kEig; ++i)
397397
lutEntry.eigval[i] = eigenVal[i];
398398

ALICE3/Core/GeometryContainer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void GeometryEntry::replaceValue(const std::string& layerName, const std::string
159159
setValue(layerName, key, value);
160160
}
161161

162-
std::string GeometryEntry::accessFile(const std::string& path, const std::string downloadPath, o2::ccdb::BasicCCDBManager* ccdb, int timeoutSeconds)
162+
std::string GeometryEntry::accessFile(const std::string& path, const std::string& downloadPath, o2::ccdb::BasicCCDBManager* ccdb, int timeoutSeconds)
163163
{
164164

165165
if (path.rfind("ccdb:", 0) == 0) {

0 commit comments

Comments
 (0)