Skip to content

Commit 3971c4b

Browse files
authored
Merge 56a4389 into sapling-pr-archive-ktf
2 parents 4c1406e + 56a4389 commit 3971c4b

46 files changed

Lines changed: 829 additions & 325 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.

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ enum Pdg {
6464
kJPsi = 443,
6565
kLambdaB0 = 5122,
6666
kLambdaCPlus = 4122,
67+
kLambdaCPlus2860 = 24124,
68+
kLambdaCPlus2880 = 24126,
69+
kLambdaCPlus2940 = 4125,
6770
kOmegaC0 = 4332,
6871
kK0Star892 = 313,
6972
kKPlusStar892 = 323,
@@ -131,6 +134,9 @@ constexpr double MassChiC1 = 3.51067;
131134
constexpr double MassJPsi = 3.0969;
132135
constexpr double MassLambdaB0 = 5.6196;
133136
constexpr double MassLambdaCPlus = 2.28646;
137+
constexpr double MassLambdaCPlus2860 = 2.8561;
138+
constexpr double MassLambdaCPlus2880 = 2.8816;
139+
constexpr double MassLambdaCPlus2940 = 2.9396;
134140
constexpr double MassOmegaC0 = 2.6952;
135141
constexpr double MassK0Star892 = 0.89555;
136142
constexpr double MassKPlusStar892 = 0.89167;

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class Pdg(Enum):
122122
kJPsi = 443
123123
kLambdaB0 = 5122
124124
kLambdaCPlus = 4122
125+
kLambdaCPlus2860 = 24124
126+
kLambdaCPlus2880 = 24126
127+
kLambdaCPlus2940 = 4125
125128
kOmegaC0 = 4332
126129
kK0Star892 = 313
127130
kKPlusStar892 = 323

Common/SimConfig/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ o2_add_library(SimConfig
2020
src/MatMapParams.cxx
2121
src/InteractionDiamondParam.cxx
2222
src/GlobalProcessCutSimParam.cxx
23+
src/FluenceWeightCalculator.cxx
2324
PUBLIC_LINK_LIBRARIES O2::CommonUtils
2425
O2::DetectorsCommonDataFormats O2::SimulationDataFormat
2526
FairRoot::Base Boost::program_options)
@@ -35,7 +36,8 @@ o2_target_root_dictionary(SimConfig
3536
include/SimConfig/G4Params.h
3637
include/SimConfig/DetectorLists.h
3738
include/SimConfig/GlobalProcessCutSimParam.h
38-
include/SimConfig/MatMapParams.h)
39+
include/SimConfig/MatMapParams.h
40+
include/SimConfig/FluenceWeightCalculator.h)
3941

4042
o2_add_test(Config
4143
SOURCES test/TestConfig.cxx
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#ifndef FluenceWeightCalculator_h
13+
#define FluenceWeightCalculator_h
14+
#include <vector>
15+
#include <string>
16+
#include <memory>
17+
#include "TGraph.h"
18+
//
19+
// Static container class for damage weight funnctions in form of TGraphs
20+
// The weights can be read from a csv file and stored in the graphs.
21+
//
22+
class FluenceWeightCalculator
23+
{
24+
public:
25+
FluenceWeightCalculator() = delete;
26+
static void InitWeights(const std::string& filename);
27+
static void InitWeightsFromCSV(const std::string& filename);
28+
static double GetWeight(const int pdg, const double ekin);
29+
30+
private:
31+
static std::unique_ptr<TGraph> neutronG;
32+
static std::unique_ptr<TGraph> protonG;
33+
static std::unique_ptr<TGraph> pionG;
34+
};
35+
#endif

Common/SimConfig/include/SimConfig/G4Params.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ struct G4Params : public o2::conf::ConfigurableParamHelper<G4Params> {
4949

5050
EG4Nav navmode = EG4Nav::kTGeo; // geometry navigation mode (default TGeo)
5151

52+
std::string fluenceWeightFile = ""; // file containing the scoring weights (pdg, ekin, weight)
5253
std::string const& getPhysicsConfigString() const;
5354

55+
bool g4scoring = false;
56+
bool g4fluenceweight = false;
5457
O2ParamDef(G4Params, "G4");
5558
};
5659

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include "SimConfig/FluenceWeightCalculator.h"
13+
#include <TFile.h>
14+
#include <fstream>
15+
#include <sstream>
16+
#include <iostream>
17+
18+
std::unique_ptr<TGraph> FluenceWeightCalculator::neutronG;
19+
std::unique_ptr<TGraph> FluenceWeightCalculator::protonG;
20+
std::unique_ptr<TGraph> FluenceWeightCalculator::pionG;
21+
22+
double FluenceWeightCalculator::GetWeight(const int pdg, const double kineticEnergy)
23+
{
24+
//
25+
// Obtain weight for given particle and kinetic energy
26+
if (!neutronG || !protonG || !pionG) {
27+
std::cerr << "FluenceWeightCalculator not initialized\n";
28+
return 0.;
29+
}
30+
switch (std::abs(pdg)) {
31+
case 2112: {
32+
return neutronG->Eval(kineticEnergy, nullptr, "S");
33+
}
34+
case 2212: {
35+
return ((kineticEnergy > 1e-3) ? protonG->Eval(kineticEnergy, nullptr, "S") : 0.);
36+
}
37+
case 211: {
38+
return ((kineticEnergy > 10.) ? pionG->Eval(kineticEnergy, nullptr, "S") : 0.);
39+
}
40+
default:
41+
return 0.0;
42+
}
43+
}
44+
45+
void FluenceWeightCalculator::InitWeights(const std::string& filename)
46+
{
47+
//
48+
// Read graphs from file
49+
TFile inFile(filename.c_str(), "READ");
50+
if (inFile.IsZombie()) {
51+
std::cerr << "Cannot open " << filename << "\n";
52+
return;
53+
}
54+
//
55+
TGraph* tmp = nullptr;
56+
inFile.GetObject("neutronDW", tmp);
57+
neutronG.reset(tmp ? static_cast<TGraph*>(tmp->Clone()) : nullptr);
58+
if (!neutronG) {
59+
std::cerr << "Missing graph neutronDW\n";
60+
return;
61+
}
62+
neutronG->SetBit(TGraph::kIsSortedX);
63+
inFile.GetObject("protonDW", tmp);
64+
protonG.reset(tmp ? static_cast<TGraph*>(tmp->Clone()) : nullptr);
65+
if (!protonG) {
66+
std::cerr << "Missing graph protonDW\n";
67+
return;
68+
}
69+
protonG->SetBit(TGraph::kIsSortedX);
70+
inFile.GetObject("pionDW", tmp);
71+
pionG.reset(tmp ? static_cast<TGraph*>(tmp->Clone()) : nullptr);
72+
if (!pionG) {
73+
std::cerr << "Missing graph pionDW\n";
74+
return;
75+
}
76+
pionG->SetBit(TGraph::kIsSortedX);
77+
}
78+
79+
void FluenceWeightCalculator::InitWeightsFromCSV(const std::string& filename)
80+
{
81+
//
82+
// read the NIEL weights from input file and store them as TGraphs
83+
neutronG = std::make_unique<TGraph>();
84+
neutronG->SetName("neutronDW");
85+
auto neuN = 0;
86+
protonG = std::make_unique<TGraph>();
87+
protonG->SetName("protonDW");
88+
auto proN = 0;
89+
pionG = std::make_unique<TGraph>();
90+
pionG->SetName("pionDW");
91+
auto pioN = 0;
92+
93+
std::ifstream in(filename);
94+
if (!in.is_open()) {
95+
std::cerr << "Error: cannot open file with damage weights.\n";
96+
return;
97+
}
98+
std::string line;
99+
while (std::getline(in, line)) {
100+
if (line.empty() || line[0] == '#') {
101+
continue;
102+
}
103+
std::istringstream ss(line);
104+
std::string particle, e_str, w_str;
105+
if (!std::getline(ss, particle, ',')) {
106+
continue;
107+
}
108+
if (!std::getline(ss, e_str, ',')) {
109+
continue;
110+
}
111+
if (!std::getline(ss, w_str, ',')) {
112+
continue;
113+
}
114+
auto e = std::stod(e_str);
115+
auto w = std::stod(w_str);
116+
auto pdg = std::stoi(particle);
117+
switch (pdg) {
118+
case 2112: {
119+
neutronG->SetPoint(neuN++, e, w);
120+
break;
121+
}
122+
case 2212: {
123+
protonG->SetPoint(proN++, e, w);
124+
break;
125+
}
126+
case 211: {
127+
pionG->SetPoint(pioN++, e, w);
128+
break;
129+
}
130+
default:;
131+
}
132+
}
133+
auto fout = new TFile("rd50_niel.root", "recreate");
134+
neutronG->Write();
135+
protonG->Write();
136+
pionG->Write();
137+
fout->Close();
138+
}

DataFormats/Reconstruction/include/ReconstructionDataFormats/DCA.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,25 @@ class DCA
5454
mZ = z;
5555
}
5656

57+
GPUd() void setY(float y) { mY = y; }
58+
GPUd() void setZ(float z) { mZ = z; }
59+
GPUd() void setSigmaY2(float v) { mCov[0] = v; }
60+
GPUd() void setSigmaYZ(float v) { mCov[1] = v; }
61+
GPUd() void setSigmaZ2(float v) { mCov[2] = v; }
62+
GPUd() void addCov(const std::array<float, 3>& vadd)
63+
{
64+
mCov[0] += vadd[0];
65+
mCov[1] += vadd[1];
66+
mCov[2] += vadd[2];
67+
}
5768
GPUd() auto getY() const { return mY; }
5869
GPUd() auto getZ() const { return mZ; }
5970
GPUd() auto getR2() const { return mY * mY + mZ * mZ; }
6071
GPUd() auto getSigmaY2() const { return mCov[0]; }
6172
GPUd() auto getSigmaYZ() const { return mCov[1]; }
6273
GPUd() auto getSigmaZ2() const { return mCov[2]; }
6374
GPUd() const auto& getCovariance() const { return mCov; }
75+
GPUd() float calcChi2() const;
6476

6577
void print() const;
6678

DataFormats/Reconstruction/include/ReconstructionDataFormats/VtxTrackRef.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ class VtxTrackRef : public RangeReference<int, int>
8080
// set the last +1 element index and finalize all references
8181
void setEnd(int end);
8282

83+
const RangeReference<int, int>& getITSGloContributors() const { return mITSGloContributors; }
84+
RangeReference<int, int>& getITSGloContributors() { return mITSGloContributors; }
85+
8386
private:
8487
using RangeReference<int, int>::RangeReference;
8588
int mVtxID = -1; // vertex ID. The reference for unassigned tracks will have it negative!
8689
std::array<int, VtxTrackIndex::Source::NSources - 1> mFirstEntrySource{0};
8790

88-
ClassDefNV(VtxTrackRef, 2);
91+
RangeReference<int, int> mITSGloContributors; // optionally filled to keep ITS parts of all contributors (including ITS-only ones)
92+
93+
ClassDefNV(VtxTrackRef, 3);
8994
};
9095

9196
std::ostream& operator<<(std::ostream& os, const o2::dataformats::VtxTrackRef& v);

DataFormats/Reconstruction/src/DCA.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
#include "GPUCommonMath.h"
13+
#include "CommonConstants/MathConstants.h"
1214
#include "ReconstructionDataFormats/DCA.h"
1315
#include <iostream>
1416

@@ -20,6 +22,16 @@ namespace o2
2022
namespace dataformats
2123
{
2224

25+
float DCA::calcChi2() const
26+
{
27+
// Estimate the chi2 for DCA
28+
const auto sdd = mCov[0], sdz = mCov[1], szz = mCov[2], det = sdd * szz - sdz * sdz;
29+
if (o2::gpu::CAMath::Abs(det) < o2::constants::math::Almost0) {
30+
return constants::math::VeryBig;
31+
}
32+
return (mY * (szz * mY - sdz * mZ) + mZ * (sdd * mZ - mY * sdz)) / det;
33+
}
34+
2335
std::ostream& operator<<(std::ostream& os, const o2::dataformats::DCA& d)
2436
{
2537
// stream itself

DataFormats/Reconstruction/src/VtxTrackRef.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ std::string VtxTrackRef::asString(bool skipEmpty) const
3131
str += fmt::format(", N{:s} : {:d}", VtxTrackIndex::getSourceName(i), getEntriesOfSource(i));
3232
}
3333
}
34+
if (mITSGloContributors.getEntries()) {
35+
str += fmt::format("| ITScontributors: {} from {}", mITSGloContributors.getEntries(), mITSGloContributors.getFirstEntry());
36+
}
3437
return str;
3538
}
3639

0 commit comments

Comments
 (0)