Skip to content

Commit 730ed68

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents 9662815 + ead329b commit 730ed68

File tree

236 files changed

+6342
-19901
lines changed

Some content is hidden

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

236 files changed

+6342
-19901
lines changed

CCDB/src/CcdbApi.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void CcdbApi::init(std::string const& host)
232232
deploymentMode == o2::framework::DeploymentMode::FST) {
233233
mCurlTimeoutDownload = 15;
234234
} else if (deploymentMode == o2::framework::DeploymentMode::Local) {
235-
mCurlTimeoutDownload = 1;
235+
mCurlTimeoutDownload = 5;
236236
}
237237
}
238238

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ enum Pdg {
5151
kDSBar = -431,
5252
kDSStar = 433,
5353
kDS1 = 10433,
54+
kDS1Star2700 = 30433,
55+
kDS1Star2860 = 40433,
5456
kDS2Star = 435,
57+
kDS3Star2860 = 437,
5558
kDStar = 413,
5659
kDStar0 = 423,
5760
kChiC1 = 20443,
@@ -72,10 +75,15 @@ enum Pdg {
7275
kXiCCPlusPlus = 4422,
7376
kXiCPlus = 4232,
7477
kXiC0 = 4132,
78+
kXiC3055Plus = 4325,
79+
kXiC3080Plus = 4326,
80+
kXiC3055_0 = 4315,
81+
kXiC3080_0 = 4316,
7582
kDeuteron = 1000010020,
7683
kTriton = 1000010030,
7784
kHelium3 = 1000020030,
7885
kAlpha = 1000020040,
86+
kLithium4 = 1000030040,
7987
kHyperTriton = 1010010030,
8088
kHyperHydrogen4 = 1010010040,
8189
kHyperHelium4 = 1010020040,
@@ -104,7 +112,10 @@ constexpr double MassDS = 1.96835;
104112
constexpr double MassDSBar = 1.96835;
105113
constexpr double MassDSStar = 2.1122;
106114
constexpr double MassDS1 = 2.53511;
115+
constexpr double MassDS1Star2700 = 2.714;
116+
constexpr double MassDS1Star2860 = 2.859;
107117
constexpr double MassDS2Star = 2.5691;
118+
constexpr double MassDS3Star2860 = 2.86;
108119
constexpr double MassDStar = 2.01026;
109120
constexpr double MassDStar0 = 2.00685;
110121
constexpr double MassChiC1 = 3.51067;
@@ -125,14 +136,19 @@ constexpr double MassXiB0 = 5.7919;
125136
constexpr double MassXiCCPlusPlus = 3.62155;
126137
constexpr double MassXiCPlus = 2.46771;
127138
constexpr double MassXiC0 = 2.47044;
139+
constexpr double MassXiC3055Plus = 3.0559;
140+
constexpr double MassXiC3080Plus = 3.0772;
141+
constexpr double MassXiC3055_0 = 3.059;
142+
constexpr double MassXiC3080_0 = 3.0799;
128143
constexpr double MassDeuteron = 1.87561294257;
129144
constexpr double MassTriton = 2.80892113298;
130145
constexpr double MassHelium3 = 2.80839160743;
131146
constexpr double MassAlpha = 3.7273794066;
132-
constexpr double MassHyperTriton = 2.99131;
133-
constexpr double MassHyperHydrogen4 = 3.9226;
134-
constexpr double MassHyperHelium4 = 3.9217;
135-
constexpr double MassHyperHelium5 = 4.841;
147+
constexpr double MassLithium4 = 3.7513;
148+
constexpr double MassHyperTriton = 2.991134;
149+
constexpr double MassHyperHydrogen4 = 3.922434;
150+
constexpr double MassHyperHelium4 = 3.921728;
151+
constexpr double MassHyperHelium5 = 4.839961;
136152
constexpr double MassHyperHelium4Sigma = 3.995;
137153

138154
/// \brief Declarations of masses for particles in ROOT PDG_t

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ class Pdg(Enum):
106106
kDSBar = -431
107107
kDSStar = 433
108108
kDS1 = 10433
109+
kDS1Star2700 = 30433
110+
kDS1Star2860 = 40433
109111
kDS2Star = 435
112+
kDS3Star2860 = 437
110113
kDStar = 413
111114
kDStar0 = 423
112115
kChiC1 = 20443
@@ -127,10 +130,15 @@ class Pdg(Enum):
127130
kXiCCPlusPlus = 4422
128131
kXiCPlus = 4232
129132
kXiC0 = 4132
133+
kXiC3055Plus = 4325
134+
kXiC3080Plus = 4326
135+
kXiC3055_0 = 4315
136+
kXiC3080_0 = 4316
130137
kDeuteron = 1000010020
131138
kTriton = 1000010030
132139
kHelium3 = 1000020030
133140
kAlpha = 1000020040
141+
kLithium4 = 1000030040
134142
kHyperTriton = 1010010030
135143
kHyperHydrogen4 = 1010010040
136144
kHyperHelium4 = 1010020040

Common/ML/include/ML/3rdparty/GPUORTFloat16.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,11 @@ GPUdi() uint16_t BFloat16Impl<Derived>::ToUint16Impl(float v) noexcept
568568
template <class Derived>
569569
GPUdi() float BFloat16Impl<Derived>::ToFloatImpl() const noexcept
570570
{
571+
#ifndef __FAST_MATH__
571572
if (IsNaN()) {
572573
return o2::gpu::CAMath::QuietNaN();
573574
}
575+
#endif
574576
float result;
575577
char* const first = reinterpret_cast<char*>(&result);
576578
char* const second = first + sizeof(uint16_t);

Common/ML/include/ML/OrtInterface.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ struct MemoryInfo;
3434
struct Env;
3535
} // namespace Ort
3636

37-
namespace o2
38-
{
39-
40-
namespace ml
37+
namespace o2::ml
4138
{
4239

4340
class OrtModel
@@ -127,8 +124,6 @@ class OrtModel
127124
std::string printShape(const std::vector<std::vector<int64_t>>&, std::vector<std::string>&);
128125
};
129126

130-
} // namespace ml
131-
132-
} // namespace o2
127+
} // namespace o2::ml
133128

134129
#endif // O2_ML_ORTINTERFACE_H

Common/ML/src/OrtInterface.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ std::vector<O> OrtModel::inference(std::vector<I>& input)
287287
return outputValuesVec;
288288
}
289289

290-
template std::vector<float> OrtModel::inference<float, float>(std::vector<float>&);
291-
template std::vector<float> OrtModel::inference<OrtDataType::Float16_t, float>(std::vector<OrtDataType::Float16_t>&);
292-
template std::vector<OrtDataType::Float16_t> OrtModel::inference<OrtDataType::Float16_t, OrtDataType::Float16_t>(std::vector<OrtDataType::Float16_t>&);
290+
template std::vector<float> o2::ml::OrtModel::inference<float, float>(std::vector<float>&);
291+
template std::vector<float> o2::ml::OrtModel::inference<OrtDataType::Float16_t, float>(std::vector<OrtDataType::Float16_t>&);
292+
template std::vector<OrtDataType::Float16_t> o2::ml::OrtModel::inference<OrtDataType::Float16_t, OrtDataType::Float16_t>(std::vector<OrtDataType::Float16_t>&);
293293

294294
template <class I, class O>
295295
void OrtModel::inference(I* input, int64_t input_size, O* output)

Common/MathUtils/include/MathUtils/fit.h

Lines changed: 171 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <algorithm>
2121
#include <vector>
2222
#include <array>
23+
#include <thread>
2324

2425
#include "Rtypes.h"
2526
#include "TLinearFitter.h"
@@ -69,9 +70,9 @@ TFitResultPtr fit(const size_t nBins, const T* arr, const T xMin, const T xMax,
6970
// create an empty TFitResult
7071
std::shared_ptr<TFitResult> tfr(new TFitResult());
7172
// create the fitter from an empty fit result
72-
//std::shared_ptr<ROOT::Fit::Fitter> fitter(new ROOT::Fit::Fitter(std::static_pointer_cast<ROOT::Fit::FitResult>(tfr) ) );
73+
// std::shared_ptr<ROOT::Fit::Fitter> fitter(new ROOT::Fit::Fitter(std::static_pointer_cast<ROOT::Fit::FitResult>(tfr) ) );
7374
ROOT::Fit::Fitter fitter(tfr);
74-
//ROOT::Fit::FitConfig & fitConfig = fitter->Config();
75+
// ROOT::Fit::FitConfig & fitConfig = fitter->Config();
7576

7677
const double binWidth = double(xMax - xMin) / double(nBins);
7778

@@ -225,8 +226,8 @@ bool medmadGaus(size_t nBins, const T* arr, const T xMin, const T xMax, std::arr
225226
/// -1: only one point has been used for the calculation - center of gravity was uesed for calculation
226227
/// -4: invalid result!!
227228
///
228-
//template <typename T>
229-
//Double_t fitGaus(const size_t nBins, const T *arr, const T xMin, const T xMax, std::vector<T>& param);
229+
// template <typename T>
230+
// Double_t fitGaus(const size_t nBins, const T *arr, const T xMin, const T xMax, std::vector<T>& param);
230231
template <typename T>
231232
Double_t fitGaus(const size_t nBins, const T* arr, const T xMin, const T xMax, std::vector<T>& param)
232233
{
@@ -301,7 +302,7 @@ Double_t fitGaus(const size_t nBins, const T* arr, const T xMin, const T xMax, s
301302
Double_t chi2 = 0;
302303
if (npoints >= 3) {
303304
if (npoints == 3) {
304-
//analytic calculation of the parameters for three points
305+
// analytic calculation of the parameters for three points
305306
A.Invert();
306307
TMatrixD res(1, 3);
307308
res.Mult(A, b);
@@ -334,7 +335,7 @@ Double_t fitGaus(const size_t nBins, const T* arr, const T xMin, const T xMax, s
334335
}
335336

336337
if (npoints == 2) {
337-
//use center of gravity for 2 points
338+
// use center of gravity for 2 points
338339
meanCOG /= sumCOG;
339340
rms2COG /= sumCOG;
340341
param[0] = max;
@@ -524,7 +525,7 @@ R median(std::vector<T> v)
524525
auto n = v.size() / 2;
525526
nth_element(v.begin(), v.begin() + n, v.end());
526527
auto med = R{v[n]};
527-
if (!(v.size() & 1)) { //If the set size is even
528+
if (!(v.size() & 1)) { // If the set size is even
528529
auto max_it = max_element(v.begin(), v.begin() + n);
529530
med = R{(*max_it + med) / 2.0};
530531
}
@@ -788,6 +789,169 @@ T MAD2Sigma(int np, T* y)
788789
return median * 1.4826; // convert to Gaussian sigma
789790
}
790791

792+
/// \return returns the index of the closest timestamps to the left and right of the given timestamp
793+
/// \param timestamps vector of timestamps
794+
/// \param timestamp the timestamp to find the closest timestamps for
795+
template <typename DataTimeType, typename DataTime>
796+
std::optional<std::pair<size_t, size_t>> findClosestIndices(const std::vector<DataTimeType>& timestamps, DataTime timestamp)
797+
{
798+
if (timestamps.empty()) {
799+
LOGP(warning, "Timestamp vector is empty!");
800+
return std::nullopt;
801+
}
802+
803+
if (timestamp <= timestamps.front()) {
804+
return std::pair{0, 0};
805+
} else if (timestamp >= timestamps.back()) {
806+
return std::pair{timestamps.size() - 1, timestamps.size() - 1};
807+
}
808+
809+
const auto it = std::lower_bound(timestamps.begin(), timestamps.end(), timestamp);
810+
const size_t idx = std::distance(timestamps.begin(), it);
811+
const auto prevTimestamp = timestamps[idx - 1];
812+
const auto nextTimestamp = timestamps[idx];
813+
return std::pair{(idx - 1), idx};
814+
}
815+
816+
struct RollingStats {
817+
RollingStats() = default;
818+
RollingStats(const int nValues)
819+
{
820+
median.resize(nValues);
821+
std.resize(nValues);
822+
nPoints.resize(nValues);
823+
closestDistanceL.resize(nValues);
824+
closestDistanceR.resize(nValues);
825+
}
826+
827+
std::vector<float> median; ///< median of rolling data
828+
std::vector<float> std; ///< std of rolling data
829+
std::vector<int> nPoints; ///< number of points used for the calculation
830+
std::vector<float> closestDistanceL; ///< distance of closest point to the left
831+
std::vector<float> closestDistanceR; ///< distance of closest point to the right
832+
833+
ClassDefNV(RollingStats, 1);
834+
};
835+
836+
/// \brief calculates the rolling statistics of the input data
837+
/// \return returns the rolling statistics
838+
/// \param timeData times of the input data (assumed to be sorted)
839+
/// \param data values of the input data
840+
/// \param times times for which to calculate the rolling statistics
841+
/// \param deltaMax time range for which the rolling statistics is calculated
842+
/// \param mNthreads number of threads to use for the calculation
843+
/// \param minPoints minimum number of points to use for the calculation of the statistics - otherwise use nearest nClosestPoints points weighted with distance
844+
/// \param nClosestPoints number of closest points in case of number of points in given range is smaller than minPoints
845+
template <typename DataTimeType, typename DataType, typename DataTime>
846+
RollingStats getRollingStatistics(const DataTimeType& timeData, const DataType& data, const DataTime& times, const double deltaMax, const int mNthreads, const size_t minPoints = 4, const size_t nClosestPoints = 4)
847+
{
848+
// output statistics
849+
const size_t vecSize = times.size();
850+
RollingStats stats(vecSize);
851+
852+
if (!std::is_sorted(timeData.begin(), timeData.end())) {
853+
LOGP(error, "Input data is NOT sorted!");
854+
return stats;
855+
}
856+
857+
if (timeData.empty()) {
858+
LOGP(error, "Input data is empty!");
859+
return stats;
860+
}
861+
862+
const size_t dataSize = data.size();
863+
const size_t timeDataSize = timeData.size();
864+
if (timeDataSize != dataSize) {
865+
LOGP(error, "Input data has different sizes {}!={}", timeDataSize, dataSize);
866+
return stats;
867+
}
868+
869+
auto myThread = [&](int iThread) {
870+
// data in given time window for median calculation
871+
DataType window;
872+
for (size_t i = iThread; i < vecSize; i += mNthreads) {
873+
const double timeI = times[i];
874+
875+
// lower index
876+
const double timeStampLower = timeI - deltaMax;
877+
const auto lower = std::lower_bound(timeData.begin(), timeData.end(), timeStampLower);
878+
size_t idxStart = std::distance(timeData.begin(), lower);
879+
880+
// upper index
881+
const double timeStampUpper = timeI + deltaMax;
882+
const auto upper = std::lower_bound(timeData.begin(), timeData.end(), timeStampUpper);
883+
size_t idxEnd = std::distance(timeData.begin(), upper);
884+
885+
// closest data point
886+
if (auto idxClosest = findClosestIndices(timeData, timeI)) {
887+
auto [idxLeft, idxRight] = *idxClosest;
888+
const auto closestL = std::abs(timeData[idxLeft] - timeI);
889+
const auto closestR = std::abs(timeData[idxRight] - timeI);
890+
stats.closestDistanceL[i] = closestL;
891+
stats.closestDistanceR[i] = closestR;
892+
893+
// if no points are in the range use the n closest points - n from the left and n from the right
894+
const size_t reqSize = idxEnd - idxStart;
895+
if (reqSize < minPoints) {
896+
// calculate weighted average
897+
idxStart = (idxRight > nClosestPoints) ? (idxRight - nClosestPoints) : 0;
898+
idxEnd = std::min(data.size(), idxRight + nClosestPoints);
899+
constexpr float epsilon = 1e-6f;
900+
double weightedSum = 0.0;
901+
double weightTotal = 0.0;
902+
for (size_t j = idxStart; j < idxEnd; ++j) {
903+
const double dist = std::abs(timeI - timeData[j]);
904+
const double weight = 1.0 / (dist + epsilon);
905+
weightedSum += weight * data[j];
906+
weightTotal += weight;
907+
}
908+
stats.median[i] = (weightTotal > 0.) ? (weightedSum / weightTotal) : 0.0f;
909+
} else {
910+
// calculate statistics
911+
stats.nPoints[i] = reqSize;
912+
913+
if (idxStart >= data.size()) {
914+
stats.median[i] = data.back();
915+
continue;
916+
}
917+
918+
if (reqSize <= 1) {
919+
stats.median[i] = data[idxStart];
920+
continue;
921+
}
922+
923+
// calculate median
924+
window.clear();
925+
if (reqSize > window.capacity()) {
926+
window.reserve(static_cast<size_t>(reqSize * 1.5));
927+
}
928+
window.insert(window.end(), data.begin() + idxStart, data.begin() + idxEnd);
929+
const size_t middle = window.size() / 2;
930+
std::nth_element(window.begin(), window.begin() + middle, window.end());
931+
stats.median[i] = (window.size() % 2 == 1) ? window[middle] : ((window[middle - 1] + window[middle]) / 2.0);
932+
933+
// calculate the stdev
934+
const float mean = std::accumulate(window.begin(), window.end(), 0.0f) / window.size();
935+
std::transform(window.begin(), window.end(), window.begin(), [mean](const float val) { return val - mean; });
936+
const float sqsum = std::inner_product(window.begin(), window.end(), window.begin(), 0.0f);
937+
const float stdev = std::sqrt(sqsum / window.size());
938+
stats.std[i] = stdev;
939+
}
940+
}
941+
}
942+
};
943+
944+
std::vector<std::thread> threads(mNthreads);
945+
for (int i = 0; i < mNthreads; i++) {
946+
threads[i] = std::thread(myThread, i);
947+
}
948+
949+
for (auto& th : threads) {
950+
th.join();
951+
}
952+
return stats;
953+
}
954+
791955
} // namespace math_utils
792956
} // namespace o2
793957
#endif

Common/MathUtils/src/MathUtilsLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
#pragma link C++ class o2::math_utils::Legendre1DPolynominal + ;
4747
#pragma link C++ class o2::math_utils::Legendre2DPolynominal + ;
4848

49+
#pragma link C++ class o2::math_utils::RollingStats + ;
50+
4951
#endif

0 commit comments

Comments
 (0)