Skip to content

Commit 232a8c6

Browse files
authored
Merge 64df0ad into sapling-pr-archive-ehellbar
2 parents b460f6d + 64df0ad commit 232a8c6

File tree

197 files changed

+12753
-1019
lines changed

Some content is hidden

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

197 files changed

+12753
-1019
lines changed

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
/DataFormats/Detectors/TRD @f3sch @bazinski @wille10
4444
/DataFormats/Detectors/Upgrades @mconcas
4545
/DataFormats/Detectors/Upgrades/ITS3 @fgrosa @arossi81
46-
/DataFormats/Detectors/ZDC @coppedis
46+
/DataFormats/Detectors/ZDC @coppedis @cortesep
4747

4848
#/DataFormats/Headers
4949
#/DataFormats/Legacy
@@ -75,7 +75,7 @@
7575
/Detectors/Upgrades @mconcas
7676
/Detectors/Upgrades/ALICE3 @mconcas @njacazio
7777
/Detectors/Upgrades/ITS3 @fgrosa @arossi81 @mconcas @f3sch
78-
/Detectors/ZDC @coppedis
78+
/Detectors/ZDC @coppedis @cortesep
7979
/Detectors/CTF @shahor02
8080
/Detectors/Raw @shahor02
8181
/Detectors/StrangenessTracking @mconcas @mpuccio @fmazzasc

Common/DCAFitter/include/DCAFitter/DCAFitterN.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ GPUd() o2::math_utils::SMatrix<double, 3, 3, o2::math_utils::MatRepSym<double, 3
818818
MatSym3D covmSum;
819819
for (int i = N; i--;) {
820820
MatSym3D covTr = o2::math_utils::Similarity(getTrackRotMatrix(i), getTrackCovMatrix(i, cand));
821+
covmSum += covTr;
821822
}
822823
return covmSum;
823824
}

Common/Utils/include/CommonUtils/ConfigurableParam.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ class ConfigurableParam
187187
// writes a human readable INI file of all parameters
188188
static void writeINI(std::string const& filename, std::string const& keyOnly = "");
189189

190+
// writes a human readable INI or JSON file depending on the extension
191+
static void write(std::string const& filename, std::string const& keyOnly = "");
192+
190193
// can be used instead of using API on concrete child classes
191194
template <typename T>
192195
static T getValueAs(std::string key)

Common/Utils/include/CommonUtils/NameConf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
103103
// Default CCDB server
104104
static std::string getCCDBServer();
105105

106+
// create name to dump config file
107+
static std::string getConfigOutputFileName(const std::string& procName, const std::string& confName = "", bool json = true);
108+
106109
protected:
107110
// helper method to build filenames
108111
static std::string buildFileName(const std::string_view prefix, const std::string_view delimiter, const std::string_view defPrefix, const std::string_view defName,

Common/Utils/include/CommonUtils/StringUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ struct Str {
136136
// return vector of tokens from the string with provided delimiter. If requested, trim the spaces from tokens
137137
static std::vector<std::string> tokenize(const std::string& src, char delim, bool trimToken = true, bool skipEmpty = true);
138138

139+
// return vector of tokens from the string with provided delimiters. If requested, trim the spaces from tokens
140+
static std::vector<std::string> tokenize(const std::string& src, const std::string& delim, bool trimToken = true, bool skipEmpty = true);
141+
139142
// concatenate arbitrary number of strings
140143
template <typename... Ts>
141144
static std::string concat_string(Ts const&... ts)

Common/Utils/src/ConfigurableParam.cxx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ int EnumLegalValues::getIntValue(const std::string& value) const
192192

193193
// -----------------------------------------------------------------
194194

195+
void ConfigurableParam::write(std::string const& filename, std::string const& keyOnly)
196+
{
197+
if (o2::utils::Str::endsWith(filename, ".ini")) {
198+
writeINI(filename, keyOnly);
199+
} else if (o2::utils::Str::endsWith(filename, ".json")) {
200+
writeJSON(filename, keyOnly);
201+
} else {
202+
throw std::invalid_argument(fmt::format("ConfigurabeParam output file name {} extension is neither .json nor .ini", filename));
203+
}
204+
}
205+
206+
// -----------------------------------------------------------------
207+
195208
void ConfigurableParam::writeINI(std::string const& filename, std::string const& keyOnly)
196209
{
197210
if (sOutputDir == "/dev/null") {
@@ -203,7 +216,10 @@ void ConfigurableParam::writeINI(std::string const& filename, std::string const&
203216
if (!keyOnly.empty()) { // write ini for selected key only
204217
try {
205218
boost::property_tree::ptree kTree;
206-
kTree.add_child(keyOnly, sPtree->get_child(keyOnly));
219+
auto keys = o2::utils::Str::tokenize(keyOnly, " ,;", true, true);
220+
for (const auto& k : keys) {
221+
kTree.add_child(k, sPtree->get_child(k));
222+
}
207223
boost::property_tree::write_ini(outfilename, kTree);
208224
} catch (const boost::property_tree::ptree_bad_path& err) {
209225
LOG(fatal) << "non-existing key " << keyOnly << " provided to writeINI";
@@ -284,7 +300,10 @@ void ConfigurableParam::writeJSON(std::string const& filename, std::string const
284300
if (!keyOnly.empty()) { // write ini for selected key only
285301
try {
286302
boost::property_tree::ptree kTree;
287-
kTree.add_child(keyOnly, sPtree->get_child(keyOnly));
303+
auto keys = o2::utils::Str::tokenize(keyOnly, " ,;", true, true);
304+
for (const auto& k : keys) {
305+
kTree.add_child(k, sPtree->get_child(k));
306+
}
288307
boost::property_tree::write_json(outfilename, kTree);
289308
} catch (const boost::property_tree::ptree_bad_path& err) {
290309
LOG(fatal) << "non-existing key " << keyOnly << " provided to writeJSON";

Common/Utils/src/NameConf.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,12 @@ std::string NameConf::getCCDBServer()
111111
{
112112
return Instance().mCCDBServer;
113113
}
114+
115+
std::string NameConf::getConfigOutputFileName(const std::string& procName, const std::string& confName, bool json)
116+
{
117+
std::string nm = procName;
118+
if (!confName.empty()) {
119+
nm += '_' + confName;
120+
}
121+
return fmt::format("ConfigParam_{}.{}", nm, json ? "json" : "ini");
122+
}

Common/Utils/src/StringUtils.cxx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <fmt/format.h>
1818
#endif
1919
#include <unistd.h>
20+
#include <cstring>
2021

2122
using namespace o2::utils;
2223

@@ -37,6 +38,35 @@ std::vector<std::string> Str::tokenize(const std::string& src, char delim, bool
3738
return tokens;
3839
}
3940

41+
std::vector<std::string> Str::tokenize(const std::string& src, const std::string& delim, bool trimToken, bool skipEmpty)
42+
{
43+
std::string inptStr{src};
44+
char* input = inptStr.data();
45+
auto mystrtok = [&]() -> char* {
46+
input += std::strspn(input, delim.c_str());
47+
if (*input == '\0') {
48+
return nullptr;
49+
}
50+
char* const token = input;
51+
input += std::strcspn(input, delim.c_str());
52+
if (*input != '\0') {
53+
*input++ = '\0';
54+
}
55+
return token;
56+
};
57+
std::vector<std::string> tokens;
58+
while (*input != '\0') {
59+
std::string token = mystrtok();
60+
if (trimToken) {
61+
trim(token);
62+
}
63+
if (!token.empty() || !skipEmpty) {
64+
tokens.push_back(std::move(token));
65+
}
66+
}
67+
return tokens;
68+
}
69+
4070
// replace all occurencies of from by to, return count
4171
int Str::replaceAll(std::string& s, const std::string& from, const std::string& to)
4272
{

DataFormats/Detectors/TOF/include/DataFormatsTOF/Diagnostic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ class Diagnostic
4444
uint32_t fillEmptyTOF(uint32_t frequency = 1) { return fill(1, frequency); }
4545
static ULong64_t getEmptyCrateKey(int crate);
4646
static ULong64_t getNoisyChannelKey(int channel);
47+
static ULong64_t getDRMKey(int crate) { return 1000000 + crate * 1000; }
48+
static ULong64_t getDRMerrorKey(int crate, int error) { return getDRMKey(crate) + error; }
49+
uint32_t getFrequencyDRM(int crate) const { return getFrequency(getDRMKey(crate)); }
50+
uint32_t getFrequencyDRMerror(int crate, int error) const { return getFrequency(getDRMerrorKey(crate, error)); }
51+
uint32_t fillDRM(int crate, uint32_t frequency) { return fill(getDRMKey(crate), frequency); }
52+
uint32_t fillDRMerror(int crate, int error, uint32_t frequency) { return fill(getDRMerrorKey(crate, error), frequency); }
53+
4754
static ULong64_t getTRMKey(int crate, int trm);
4855
void print(bool longFormat = false) const;
4956
void clear() { mVector.clear(); }

DataFormats/Detectors/TRD/include/DataFormatsTRD/CalGain.h

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,52 @@ class CalGain
3333

3434
void setMPVdEdx(int iDet, float mpv) { mMPVdEdx[iDet] = mpv; }
3535

36-
float getMPVdEdx(int iDet) const { return mMPVdEdx[iDet]; }
36+
float getMPVdEdx(int iDet, bool defaultAvg = true) const
37+
{
38+
// if defaultAvg = false, we take the value stored whatever it is
39+
// if defaultAvg = true and we have default value or bad value stored, we take the average on all chambers instead
40+
if (!defaultAvg || isGoodGain(iDet))
41+
return mMPVdEdx[iDet];
42+
else {
43+
if (TMath::Abs(mMeanGain + 999.) < 1e-6)
44+
mMeanGain = getAverageGain();
45+
return mMeanGain;
46+
}
47+
}
48+
49+
float getAverageGain() const
50+
{
51+
float averageGain = 0.;
52+
int ngood = 0;
53+
54+
for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
55+
if (isGoodGain(iDet)) {
56+
// The chamber has correct calibration
57+
ngood++;
58+
averageGain += mMPVdEdx[iDet];
59+
}
60+
}
61+
if (ngood == 0) {
62+
// we should make sure it never happens
63+
return constants::MPVDEDXDEFAULT;
64+
}
65+
averageGain /= ngood;
66+
return averageGain;
67+
}
68+
69+
bool isGoodGain(int iDet) const
70+
{
71+
if (TMath::Abs(mMPVdEdx[iDet] - constants::MPVDEDXDEFAULT) > 1e-6)
72+
return true;
73+
else
74+
return false;
75+
}
3776

3877
private:
3978
std::array<float, constants::MAXCHAMBER> mMPVdEdx{}; ///< Most probable value of dEdx distribution per TRD chamber
79+
mutable float mMeanGain{-999.}; ///! average gain, calculated only once
4080

41-
ClassDefNV(CalGain, 1);
81+
ClassDefNV(CalGain, 2);
4282
};
4383

4484
} // namespace trd

0 commit comments

Comments
 (0)