Skip to content

Commit 67a233c

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents 52d750a + da00550 commit 67a233c

File tree

165 files changed

+2695
-2331
lines changed

Some content is hidden

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

165 files changed

+2695
-2331
lines changed

Common/DCAFitter/include/DCAFitter/DCAFitterN.h

Lines changed: 100 additions & 44 deletions
Large diffs are not rendered by default.

Common/DCAFitter/include/DCAFitter/HelixHelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ struct CrossInfo {
131131
if (isCollinear) {
132132
/// for collinear tracks it is better to take
133133
/// a weighted average of the crossing points as a radius
134-
float r2r = trcA.rC + o2::gpu::GPUCommonMath::Sqrt(rBSign);
134+
float r2r = trcA.rC + rBSign;
135135
float r1_r = trcA.rC / r2r;
136-
float r2_r = o2::gpu::GPUCommonMath::Sqrt(rBSign) / r2r;
136+
float r2_r = rBSign / r2r;
137137
xDCA[0] = r2_r * trcA.xC + r1_r * (xDist + trcA.xC);
138138
yDCA[0] = r2_r * trcA.yC + r1_r * (yDist + trcA.yC);
139139
} else {

Common/DCAFitter/test/testDCAFitterN.cxx

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ TLorentzVector generate(Vec3D& vtx, std::vector<o2::track::TrackParCov>& vctr, f
134134
float rad = forceQ[i] == 0 ? 600. : TMath::Abs(1. / trc.getCurvature(bz));
135135
if (!trc.propagateTo(trc.getX() + (gRandom->Rndm() - 0.5) * rad * 0.05, bz) ||
136136
!trc.rotate(trc.getAlpha() + (gRandom->Rndm() - 0.5) * 0.2)) {
137-
printf("Failed to randomize ");
137+
LOGP(error, "Failed to randomize ");
138138
trc.print();
139139
}
140140
}
@@ -143,6 +143,22 @@ TLorentzVector generate(Vec3D& vtx, std::vector<o2::track::TrackParCov>& vctr, f
143143
return parent;
144144
}
145145

146+
static constexpr int NFitStatus{14};
147+
using FitStatusArray = std::array<std::array<int, 3>, NFitStatus>;
148+
static constexpr const char* FitStatusNames[NFitStatus] = {
149+
"None", "Converged", "MaxIter", "NoCrossing", "RejRadius", "RejTrackX", "RejTrackRoughZ", "RejChi2Max",
150+
"FailProp", "FailInvConv", "FailInvWeight", "FailInv2ndDeriv", "FailCorrTracks", "FailCloserAlt"};
151+
inline void printStat(const FitStatusArray& a)
152+
{
153+
LOGP(info, "FitStatus summary : ....A / ..AWD / ...WD (A=abs.dist;AWD=abs.wghPCA.dist;WD=wgh.dist)");
154+
for (int i{0}; i < NFitStatus; ++i) {
155+
LOGP(info, "{:2d}={:20s}: {:5d} / {:5d} / {:5d}", i, FitStatusNames[i], a[i][0], a[i][1], a[i][2]);
156+
}
157+
BOOST_CHECK(a[0][0] == 0); // ensure coverage of all possible states
158+
BOOST_CHECK(a[0][1] == 0);
159+
BOOST_CHECK(a[0][2] == 0);
160+
}
161+
146162
BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
147163
{
148164
constexpr int NTest = 10000;
@@ -159,13 +175,15 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
159175
std::vector<double> k0dec = {pion, pion};
160176
std::vector<double> dchdec = {pion, kch, pion};
161177
std::vector<o2::track::TrackParCov> vctracks;
178+
FitStatusArray fitstat;
162179
Vec3D vtxGen;
163180

164181
double bz = 5.0;
165182
// 2 prongs vertices
166183
{
167184
LOG(info) << "\n\nProcessing 2-prong Helix - Helix case";
168185
std::vector<int> forceQ{1, 1};
186+
std::memset(fitstat.data(), 0, sizeof(fitstat));
169187

170188
o2::vertexing::DCAFitterN<2> ft; // 2 prong fitter
171189
ft.setBz(bz);
@@ -196,6 +214,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
196214
meanDA += minD;
197215
nfoundA++;
198216
}
217+
++fitstat[ft.getFitStatus()][0];
199218

200219
ft.setUseAbsDCA(true);
201220
ft.setWeightedFinalPCA(true);
@@ -208,6 +227,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
208227
meanDAW += minD;
209228
nfoundAW++;
210229
}
230+
++fitstat[ft.getFitStatus()][1];
211231

212232
ft.setUseAbsDCA(false);
213233
ft.setWeightedFinalPCA(false);
@@ -220,6 +240,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
220240
meanDW += minD;
221241
nfoundW++;
222242
}
243+
++fitstat[ft.getFitStatus()][2];
223244
}
224245
// ft.print();
225246
meanDA /= nfoundA ? nfoundA : 1;
@@ -232,6 +253,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
232253
<< " mean.dist to truth: " << meanDAW << " CPU time: " << swAW.CpuTime() * 1000 << " ms";
233254
LOG(info) << "2-prongs with wgh.dist minization: eff= " << float(nfoundW) / NTest
234255
<< " mean.dist to truth: " << meanDW << " CPU time: " << swW.CpuTime() * 1000 << " ms";
256+
printStat(fitstat);
235257
BOOST_CHECK(nfoundA > 0.99 * NTest);
236258
BOOST_CHECK(nfoundAW > 0.99 * NTest);
237259
BOOST_CHECK(nfoundW > 0.99 * NTest);
@@ -245,6 +267,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
245267
{
246268
LOG(info) << "\n\nProcessing 2-prong Helix - Helix case gamma conversion";
247269
std::vector<int> forceQ{1, 1};
270+
std::memset(fitstat.data(), 0, sizeof(fitstat));
248271

249272
o2::vertexing::DCAFitterN<2> ft; // 2 prong fitter
250273
ft.setBz(bz);
@@ -254,6 +277,8 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
254277
ft.setMaxDXYIni(4); // do not consider V0 seeds with tracks XY-distance exceeding this. This is default anyway
255278
ft.setMinParamChange(1e-3); // stop iterations if max correction is below this value. This is default anyway
256279
ft.setMinRelChi2Change(0.9); // stop iterations if chi2 improves by less that this factor
280+
ft.setMaxChi2();
281+
ft.setCollinear(true);
257282

258283
std::string treeName2A = "gpr2a", treeName2AW = "gpr2aw", treeName2W = "gpr2w";
259284
TStopwatch swA, swAW, swW;
@@ -275,6 +300,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
275300
meanDA += minD;
276301
nfoundA++;
277302
}
303+
++fitstat[ft.getFitStatus()][0];
278304

279305
ft.setUseAbsDCA(true);
280306
ft.setWeightedFinalPCA(true);
@@ -287,6 +313,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
287313
meanDAW += minD;
288314
nfoundAW++;
289315
}
316+
++fitstat[ft.getFitStatus()][1];
290317

291318
ft.setUseAbsDCA(false);
292319
ft.setWeightedFinalPCA(false);
@@ -299,6 +326,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
299326
meanDW += minD;
300327
nfoundW++;
301328
}
329+
++fitstat[ft.getFitStatus()][2];
302330
}
303331
// ft.print();
304332
meanDA /= nfoundA ? nfoundA : 1;
@@ -311,6 +339,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
311339
<< " mean.dist to truth: " << meanDAW << " CPU time: " << swAW.CpuTime() * 1000 << " ms";
312340
LOG(info) << "2-prongs with wgh.dist minization: eff= " << float(nfoundW) / NTest
313341
<< " mean.dist to truth: " << meanDW << " CPU time: " << swW.CpuTime() * 1000 << " ms";
342+
printStat(fitstat);
314343
BOOST_CHECK(nfoundA > 0.99 * NTest);
315344
BOOST_CHECK(nfoundAW > 0.99 * NTest);
316345
BOOST_CHECK(nfoundW > 0.99 * NTest);
@@ -324,6 +353,8 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
324353
{
325354
std::vector<int> forceQ{1, 1};
326355
LOG(info) << "\n\nProcessing 2-prong Helix - Line case";
356+
std::memset(fitstat.data(), 0, sizeof(fitstat));
357+
327358
o2::vertexing::DCAFitterN<2> ft; // 2 prong fitter
328359
ft.setBz(bz);
329360
ft.setPropagateToPCA(true); // After finding the vertex, propagate tracks to the DCA. This is default anyway
@@ -354,6 +385,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
354385
meanDA += minD;
355386
nfoundA++;
356387
}
388+
++fitstat[ft.getFitStatus()][0];
357389

358390
ft.setUseAbsDCA(true);
359391
ft.setWeightedFinalPCA(true);
@@ -366,6 +398,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
366398
meanDAW += minD;
367399
nfoundAW++;
368400
}
401+
++fitstat[ft.getFitStatus()][1];
369402

370403
ft.setUseAbsDCA(false);
371404
ft.setWeightedFinalPCA(false);
@@ -378,6 +411,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
378411
meanDW += minD;
379412
nfoundW++;
380413
}
414+
++fitstat[ft.getFitStatus()][2];
381415
}
382416
// ft.print();
383417
meanDA /= nfoundA ? nfoundA : 1;
@@ -390,6 +424,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
390424
<< " mean.dist to truth: " << meanDAW << " CPU time: " << swAW.CpuTime() * 1000 << " ms";
391425
LOG(info) << "2-prongs with wgh.dist minization: eff= " << float(nfoundW) / NTest
392426
<< " mean.dist to truth: " << meanDW << " CPU time: " << swW.CpuTime() * 1000 << " ms";
427+
printStat(fitstat);
393428
BOOST_CHECK(nfoundA > 0.99 * NTest);
394429
BOOST_CHECK(nfoundAW > 0.99 * NTest);
395430
BOOST_CHECK(nfoundW > 0.99 * NTest);
@@ -403,6 +438,8 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
403438
{
404439
std::vector<int> forceQ{0, 0};
405440
LOG(info) << "\n\nProcessing 2-prong Line - Line case";
441+
std::memset(fitstat.data(), 0, sizeof(fitstat));
442+
406443
o2::vertexing::DCAFitterN<2> ft; // 2 prong fitter
407444
ft.setBz(bz);
408445
ft.setPropagateToPCA(true); // After finding the vertex, propagate tracks to the DCA. This is default anyway
@@ -432,6 +469,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
432469
meanDA += minD;
433470
nfoundA++;
434471
}
472+
++fitstat[ft.getFitStatus()][0];
435473

436474
ft.setUseAbsDCA(true);
437475
ft.setWeightedFinalPCA(true);
@@ -444,6 +482,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
444482
meanDAW += minD;
445483
nfoundAW++;
446484
}
485+
++fitstat[ft.getFitStatus()][1];
447486

448487
ft.setUseAbsDCA(false);
449488
ft.setWeightedFinalPCA(false);
@@ -456,6 +495,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
456495
meanDW += minD;
457496
nfoundW++;
458497
}
498+
++fitstat[ft.getFitStatus()][2];
459499
}
460500
// ft.print();
461501
meanDA /= nfoundA ? nfoundA : 1;
@@ -468,6 +508,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
468508
<< " mean.dist to truth: " << meanDAW << " CPU time: " << swAW.CpuTime() * 1000 << " ms";
469509
LOG(info) << "2-prongs with wgh.dist minization: eff= " << float(nfoundW) / NTest
470510
<< " mean.dist to truth: " << meanDW << " CPU time: " << swW.CpuTime() * 1000 << " ms";
511+
printStat(fitstat);
471512
BOOST_CHECK(nfoundA > 0.99 * NTest);
472513
BOOST_CHECK(nfoundAW > 0.99 * NTest);
473514
BOOST_CHECK(nfoundW > 0.99 * NTest);
@@ -481,6 +522,8 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
481522
{
482523
LOG(info) << "\n\nProcessing 3-prong vertices";
483524
std::vector<int> forceQ{1, 1, 1};
525+
std::memset(fitstat.data(), 0, sizeof(fitstat));
526+
484527
o2::vertexing::DCAFitterN<3> ft; // 3 prong fitter
485528
ft.setBz(bz);
486529
ft.setPropagateToPCA(true); // After finding the vertex, propagate tracks to the DCA. This is default anyway
@@ -509,6 +552,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
509552
meanDA += minD;
510553
nfoundA++;
511554
}
555+
++fitstat[ft.getFitStatus()][0];
512556

513557
ft.setUseAbsDCA(true);
514558
ft.setWeightedFinalPCA(true);
@@ -521,6 +565,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
521565
meanDAW += minD;
522566
nfoundAW++;
523567
}
568+
++fitstat[ft.getFitStatus()][1];
524569

525570
ft.setUseAbsDCA(false);
526571
ft.setWeightedFinalPCA(false);
@@ -533,6 +578,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
533578
meanDW += minD;
534579
nfoundW++;
535580
}
581+
++fitstat[ft.getFitStatus()][2];
536582
}
537583
// ft.print();
538584
meanDA /= nfoundA ? nfoundA : 1;
@@ -545,6 +591,7 @@ BOOST_AUTO_TEST_CASE(DCAFitterNProngs)
545591
<< " mean.dist to truth: " << meanDAW << " CPU time: " << swAW.CpuTime() * 1000 << " ms";
546592
LOG(info) << "3-prongs with wgh.dist minization: eff= " << float(nfoundW) / NTest
547593
<< " mean.dist to truth: " << meanDW << " CPU time: " << swW.CpuTime() * 1000 << " ms";
594+
printStat(fitstat);
548595
BOOST_CHECK(nfoundA > 0.99 * NTest);
549596
BOOST_CHECK(nfoundAW > 0.99 * NTest);
550597
BOOST_CHECK(nfoundW > 0.99 * NTest);

Common/ML/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
# or submit itself to any jurisdiction.
1111

1212
# Pass ORT variables as a preprocessor definition
13-
if(DEFINED ENV{ORT_ROCM_BUILD})
14-
add_compile_definitions(ORT_ROCM_BUILD=$ENV{ORT_ROCM_BUILD})
13+
if(ORT_ROCM_BUILD)
14+
add_compile_definitions(ORT_ROCM_BUILD=1)
1515
endif()
16-
if(DEFINED ENV{ORT_CUDA_BUILD})
17-
add_compile_definitions(ORT_CUDA_BUILD=$ENV{ORT_CUDA_BUILD})
16+
if(ORT_CUDA_BUILD)
17+
add_compile_definitions(ORT_CUDA_BUILD=1)
1818
endif()
19-
if(DEFINED ENV{ORT_MIGRAPHX_BUILD})
20-
add_compile_definitions(ORT_MIGRAPHX_BUILD=$ENV{ORT_MIGRAPHX_BUILD})
19+
if(ORT_MIGRAPHX_BUILD)
20+
add_compile_definitions(ORT_MIGRAPHX_BUILD=1)
2121
endif()
22-
if(DEFINED ENV{ORT_TENSORRT_BUILD})
23-
add_compile_definitions(ORT_TENSORRT_BUILD=$ENV{ORT_TENSORRT_BUILD})
22+
if(ORT_TENSORRT_BUILD)
23+
add_compile_definitions(ORT_TENSORRT_BUILD=1)
2424
endif()
2525

2626
o2_add_library(ML

Common/ML/src/OrtInterface.cxx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,23 @@ void OrtModel::reset(std::unordered_map<std::string, std::string> optionsMap)
5959

6060
std::string dev_mem_str = "Hip";
6161
#if defined(ORT_ROCM_BUILD)
62-
#if ORT_ROCM_BUILD == 1
63-
if (device == "ROCM") {
64-
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ROCM(pImplOrt->sessionOptions, deviceId));
65-
LOG(info) << "(ORT) ROCM execution provider set";
66-
}
67-
#endif
62+
if (device == "ROCM") {
63+
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ROCM(pImplOrt->sessionOptions, deviceId));
64+
LOG(info) << "(ORT) ROCM execution provider set";
65+
}
6866
#endif
6967
#if defined(ORT_MIGRAPHX_BUILD)
70-
#if ORT_MIGRAPHX_BUILD == 1
71-
if (device == "MIGRAPHX") {
72-
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_MIGraphX(pImplOrt->sessionOptions, deviceId));
73-
LOG(info) << "(ORT) MIGraphX execution provider set";
74-
}
75-
#endif
68+
if (device == "MIGRAPHX") {
69+
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_MIGraphX(pImplOrt->sessionOptions, deviceId));
70+
LOG(info) << "(ORT) MIGraphX execution provider set";
71+
}
7672
#endif
7773
#if defined(ORT_CUDA_BUILD)
78-
#if ORT_CUDA_BUILD == 1
79-
if (device == "CUDA") {
80-
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_CUDA(pImplOrt->sessionOptions, deviceId));
81-
LOG(info) << "(ORT) CUDA execution provider set";
82-
dev_mem_str = "Cuda";
83-
}
84-
#endif
74+
if (device == "CUDA") {
75+
Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_CUDA(pImplOrt->sessionOptions, deviceId));
76+
LOG(info) << "(ORT) CUDA execution provider set";
77+
dev_mem_str = "Cuda";
78+
}
8579
#endif
8680

8781
if (allocateDeviceMemory) {

Common/Utils/include/CommonUtils/EnumFlags.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ struct FlagsHelper final {
154154
}
155155
return values;
156156
}
157-
static constexpr auto Values{getValues(std::make_index_sequence<MaxScan - MinScan - MarginScan>())}; // Enum Values
158-
static constexpr auto count() noexcept { return Values.size(); } // Number of enum members
159-
static constexpr auto Min_v{Values.front()}; // Enum first entry
160-
static constexpr auto Max_v{Values.back()}; // Enum last entry
161-
static constexpr auto Min_u_v{static_cast<size_t>(Min_v)}; // Enum first entry as size_t
162-
static constexpr auto Max_u_v{static_cast<size_t>(Max_v)}; // Enum last entry as size_t
163-
static constexpr bool isContinuous() noexcept { return (Max_u_v - Min_u_v + 1) == count(); } // Is the enum continuous
164-
static constexpr uint64_t MaxRep{(Max_u_v >= 64) ? std::numeric_limits<uint64_t>::max() : (1ULL << Max_u_v) - 1}; // largest representable value
157+
static constexpr auto Values{getValues(std::make_index_sequence<MaxScan - MinScan - MarginScan>())}; // Enum Values
158+
static constexpr auto count() noexcept { return Values.size(); } // Number of enum members
159+
static constexpr auto Min_v{Values.front()}; // Enum first entry
160+
static constexpr auto Max_v{Values.back()}; // Enum last entry
161+
static constexpr auto Min_u_v{static_cast<size_t>(Min_v)}; // Enum first entry as size_t
162+
static constexpr auto Max_u_v{static_cast<size_t>(Max_v)}; // Enum last entry as size_t
163+
static constexpr bool isContinuous() noexcept { return (Max_u_v - Min_u_v + 1) == count(); } // Is the enum continuous
164+
static constexpr auto MaxRep{((1 << (Max_u_v - Min_u_v + 1)) - 1) << Min_u_v}; // largest representable value
165165

166166
template <E e>
167167
static constexpr std::string_view getName()
@@ -398,11 +398,14 @@ class EnumFlags
398398
// Sets flags from a string representation.
399399
// This can be either from a number representation (binary or digits) or
400400
// a concatenation of the enums members name e.g., 'Enum1|Enum2|...'
401-
void set(const std::string& s, int base = 2)
401+
void set(const std::string& s = "", int base = 2)
402402
{
403403
// on throw restore previous state and rethrow
404404
const U prev = mBits;
405405
reset();
406+
if (s.empty()) { // no-op
407+
return;
408+
}
406409
try {
407410
setImpl(s, base);
408411
} catch (const std::exception& e) {
@@ -665,15 +668,16 @@ class EnumFlags
665668
throw std::out_of_range("Values exceeds enum range.");
666669
}
667670
mBits = static_cast<U>(v);
668-
} else if (std::all_of(s.begin(), s.end(), [](unsigned char c) { return std::isalnum(c) != 0 || c == '|' || c == ' ' || c == ':'; })) {
671+
} else if (std::all_of(s.begin(), s.end(), [](unsigned char c) { return std::isalnum(c) != 0 || c == '|' || c == ' ' || c == ':' || c == ','; })) {
669672
std::string cs{s};
670673
std::transform(cs.begin(), cs.end(), cs.begin(), [](unsigned char c) { return std::tolower(c); });
671674
if (cs == H::All) {
672675
mBits = All;
673676
} else if (cs == H::None) {
674677
mBits = None;
675678
} else {
676-
for (const auto& tok : Str::tokenize(s, '|')) {
679+
char token = (s.find(',') != std::string::npos) ? ',' : '|';
680+
for (const auto& tok : Str::tokenize(s, token)) {
677681
if (auto e = H::fromString(tok)) {
678682
mBits |= to_bit(*e);
679683
} else {

0 commit comments

Comments
 (0)