Skip to content

Commit 1a36b08

Browse files
authored
Merge 1e7eb11 into sapling-pr-archive-ktf
2 parents 645d99e + 1e7eb11 commit 1a36b08

File tree

13 files changed

+538
-29
lines changed

13 files changed

+538
-29
lines changed

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void TrackerTraits::computeLayerTracklets(const int iteration, int iROFslice, in
7171
const Vertex diamondVert({mTrkParams[iteration].Diamond[0], mTrkParams[iteration].Diamond[1], mTrkParams[iteration].Diamond[2]}, {25.e-6f, 0.f, 0.f, 25.e-6f, 0.f, 36.f}, 1, 1.f);
7272
gsl::span<const Vertex> diamondSpan(&diamondVert, 1);
7373
int startROF{mTrkParams[iteration].nROFsPerIterations > 0 ? iROFslice * mTrkParams[iteration].nROFsPerIterations : 0};
74-
int endROF{mTrkParams[iteration].nROFsPerIterations > 0 ? (iROFslice + 1) * mTrkParams[iteration].nROFsPerIterations + mTrkParams[iteration].DeltaROF : tf->getNrof()};
74+
int endROF{gpu::GPUCommonMath::Min(mTrkParams[iteration].nROFsPerIterations > 0 ? (iROFslice + 1) * mTrkParams[iteration].nROFsPerIterations + mTrkParams[iteration].DeltaROF : tf->getNrof(), tf->getNrof())};
7575
for (int rof0{startROF}; rof0 < endROF; ++rof0) {
7676
gsl::span<const Vertex> primaryVertices = mTrkParams[iteration].UseDiamond ? diamondSpan : tf->getPrimaryVertices(rof0);
7777
const int startVtx{iVertex >= 0 ? iVertex : 0};

Detectors/MUON/MCH/Geometry/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
add_subdirectory(MisAligner)
1313
add_subdirectory(Transformer)
1414
add_subdirectory(Creator)
15-
if (BUILD_TESTING)
15+
if (BUILD_TESTING AND GLFW_FOUND)
1616
add_subdirectory(Test)
1717
endif()
1818

Framework/Core/include/Framework/ASoA.h

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,7 @@ using PresliceOptional = PresliceBase<T, true, true>;
14511451

14521452
namespace o2::soa
14531453
{
1454-
template <typename T>
1455-
class FilteredBase;
1456-
template <typename T>
1457-
class Filtered;
1458-
1459-
template <typename T>
1454+
template <soa::is_table T>
14601455
class FilteredBase;
14611456
template <typename T>
14621457
class Filtered;
@@ -1728,7 +1723,8 @@ class Table
17281723
using columns_t = typename Parent::columns_t;
17291724
using external_index_columns_t = typename Parent::external_index_columns_t;
17301725
using bindings_pack_t = decltype([]<typename... C>(framework::pack<C...>) -> framework::pack<typename C::binding_t...> {}(external_index_columns_t{}));
1731-
static constexpr const std::array<TableRef, sizeof...(T)> originals{T::ref...};
1726+
// static constexpr const std::array<TableRef, sizeof...(T)> originals{T::ref...};
1727+
static constexpr auto originals = Parent::originals;
17321728
using policy_t = IP;
17331729
using parent_t = Parent;
17341730

@@ -1741,7 +1737,7 @@ class Table
17411737

17421738
template <typename P, typename... Os>
17431739
TableIteratorBase& operator=(TableIteratorBase<IP, P, Os...> other)
1744-
requires(P::ref::signature == Parent::ref::signature)
1740+
requires(P::ref.desc_hash == Parent::ref.desc_hash)
17451741
{
17461742
static_cast<base_iterator<IP>&>(*this) = static_cast<base_iterator<IP>>(other);
17471743
return *this;
@@ -1762,16 +1758,16 @@ class Table
17621758
return *this;
17631759
}
17641760

1765-
template <typename P, typename... Os>
1766-
TableIteratorBase(TableIteratorBase<IP, P, Os...> const& other)
1767-
requires(P::ref::signature == Parent::ref::signature)
1761+
template <typename P, typename O1, typename... Os>
1762+
TableIteratorBase(TableIteratorBase<IP, P, O1, Os...> const& other)
1763+
requires(P::ref.desc_hash == Parent::ref.desc_hash)
17681764
{
17691765
*this = other;
17701766
}
17711767

1772-
template <typename P, typename... Os>
1773-
TableIteratorBase(TableIteratorBase<IP, P, Os...>&& other) noexcept
1774-
requires(P::ref::signature == Parent::ref::signature)
1768+
template <typename P, typename O1, typename... Os>
1769+
TableIteratorBase(TableIteratorBase<IP, P, O1, Os...>&& other) noexcept
1770+
requires(P::ref.desc_hash == Parent::ref.desc_hash)
17751771
{
17761772
*this = other;
17771773
}
@@ -2503,7 +2499,7 @@ consteval auto getIndexTargets()
25032499
for (auto const& i : *mColumnIterator) { \
25042500
auto pos = mBinding.get<T>()->isInSelectedRows(i); \
25052501
if (pos > 0) { \
2506-
result.push_back(mBinding.get<T>()->iteratorAt(pos)); \
2502+
result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
25072503
} \
25082504
} \
25092505
return result; \
@@ -3061,9 +3057,6 @@ consteval auto getIndexTargets()
30613057

30623058
namespace o2::soa
30633059
{
3064-
// template <typename T>
3065-
// class FilteredBase;
3066-
30673060
template <typename D, typename... Ts>
30683061
struct JoinFull : Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
30693062
using base = Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...>;
@@ -3201,7 +3194,7 @@ constexpr auto concat(Ts const&... t)
32013194
return Concat<Ts...>{t...};
32023195
}
32033196

3204-
template <typename T>
3197+
template <soa::is_table T>
32053198
class FilteredBase : public T
32063199
{
32073200
public:
@@ -3473,7 +3466,8 @@ class Filtered : public FilteredBase<T>
34733466
public:
34743467
using base_t = T;
34753468
using self_t = Filtered<T>;
3476-
using table_t = typename FilteredBase<T>::table_t;
3469+
using table_t = typename T::table_t;
3470+
using columns_t = typename T::columns_t;
34773471

34783472
using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
34793473
using unfiltered_iterator = T::template iterator_template_o<DefaultIndexPolicy, self_t>;
@@ -3633,9 +3627,10 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
36333627
using self_t = Filtered<Filtered<T>>;
36343628
using base_t = T;
36353629
using table_t = typename FilteredBase<typename T::table_t>::table_t;
3630+
using columns_t = typename T::columns_t;
36363631

3637-
using iterator = FilteredBase<typename T::table_t>::iterator;
3638-
using unfiltered_iterator = FilteredBase<typename T::table_t>::unfiltered_iterator;
3632+
using iterator = typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3633+
using unfiltered_iterator = typename T::template iterator_template_o<DefaultIndexPolicy, self_t>;
36393634
using const_iterator = iterator;
36403635

36413636
iterator begin()

Framework/Core/test/test_GroupSlicer.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "Framework/ASoA.h"
13+
#include "Framework/AnalysisDataModel.h"
1314
#include "Framework/TableBuilder.h"
1415
#include "Framework/GroupSlicer.h"
1516
#include "Framework/ArrowTableSlicingCache.h"
1617
#include <arrow/util/config.h>
18+
#include <iostream>
1719

1820
#include <catch_amalgamated.hpp>
1921

@@ -85,6 +87,13 @@ DECLARE_SOA_COLUMN(Lst, lst, std::vector<double>);
8587
DECLARE_SOA_TABLE(EventExtra, "AOD", "EVTSXTRA", test::Arr, test::Boo, test::Lst);
8688

8789
} // namespace o2::aod
90+
TEST_CASE("RelatedByIndex")
91+
{
92+
using Trks = soa::Join<aod::Tracks, aod::TracksExtra>;
93+
CHECK(soa::relatedByIndex<aod::Collision, Trks>() == true);
94+
CHECK(soa::relatedByIndex<aod::Collision, aod::Tracks>() == true);
95+
}
96+
8897
TEST_CASE("GroupSlicerOneAssociated")
8998
{
9099
TableBuilder builderE;

Generators/include/Generators/GeneratorFromFile.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
#include "FairGenerator.h"
1818
#include "Generators/Generator.h"
1919
#include "Generators/GeneratorFromO2KineParam.h"
20+
#include "SimulationDataFormat/MCEventHeader.h"
2021
#include <TRandom3.h>
21-
#include <TGrid.h>
22+
#include <random>
2223

2324
class TBranch;
2425
class TFile;
2526
class TParticle;
27+
class TGrid;
2628

2729
namespace o2
2830
{
@@ -109,6 +111,52 @@ class GeneratorFromO2Kine : public o2::eventgen::Generator
109111
ClassDefOverride(GeneratorFromO2Kine, 2);
110112
};
111113

114+
/// Special generator for event pools.
115+
/// What do we like to have:
116+
/// - ability to give a file which contains the list of files to read
117+
/// - ability to give directly a file to read the event from
118+
/// - ability to give a pool path and to find the top N list of files closest to myself
119+
/// - ability to select itself one file from the pool
120+
class GeneratorFromEventPool : public o2::eventgen::Generator
121+
{
122+
public:
123+
constexpr static std::string_view eventpool_filename = "evtpool.root";
124+
constexpr static std::string_view alien_protocol_prefix = "alien://";
125+
126+
GeneratorFromEventPool() = default; // mainly for ROOT IO
127+
GeneratorFromEventPool(EventPoolGenConfig const& pars);
128+
129+
bool Init() override;
130+
131+
// the o2 Generator interface methods
132+
bool generateEvent() override
133+
{ /* trivial - actual work in importParticles */
134+
return mO2KineGenerator->generateEvent();
135+
}
136+
bool importParticles() override
137+
{
138+
auto import_good = mO2KineGenerator->importParticles();
139+
// transfer the particles (could be avoided)
140+
mParticles = mO2KineGenerator->getParticles();
141+
return import_good;
142+
}
143+
144+
// determine the collection of available files
145+
std::vector<std::string> setupFileUniverse(std::string const& path) const;
146+
147+
std::vector<std::string> const& getFileUniverse() const { return mPoolFilesAvailable; }
148+
149+
private:
150+
EventPoolGenConfig mConfig; //! Configuration object
151+
std::unique_ptr<o2::eventgen::GeneratorFromO2Kine> mO2KineGenerator = nullptr; //! actual generator doing the work
152+
std::vector<std::string> mPoolFilesAvailable; //! container keeping the collection of files in the event pool
153+
std::string mFileChosen; //! the file chosen for the pool
154+
// random number generator to determine a concrete file name
155+
std::mt19937 mRandomEngine; //!
156+
157+
ClassDefOverride(GeneratorFromEventPool, 1);
158+
};
159+
112160
} // end namespace eventgen
113161
} // end namespace o2
114162

Generators/include/Generators/GeneratorFromO2KineParam.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ struct O2KineGenConfig {
4949
std::string fileName = ""; // filename to read from - takes precedence over SimConfig if given
5050
};
5151

52+
struct EventPoolGenConfig {
53+
std::string eventPoolPath = ""; // In that order: The path where an event pool can be found ;
54+
// or .. a local file containing a list of files to use
55+
// or .. a concrete file path to a kinematics file
56+
bool skipNonTrackable = true; // <--- do we need this?
57+
bool roundRobin = false; // read events with period boundary conditions
58+
bool randomize = true; // randomize the order of events
59+
unsigned int rngseed = 0; // randomizer seed, 0 for random value
60+
bool randomphi = false; // randomize phi angle; rotates tracks in events by some phi-angle
61+
};
62+
63+
// construct a configurable param singleton out of the
64+
struct GeneratorEventPoolParam : public o2::conf::ConfigurableParamPromoter<GeneratorEventPoolParam, EventPoolGenConfig> {
65+
O2ParamDef(GeneratorEventPoolParam, "GeneratorEventPool");
66+
};
67+
5268
} // end namespace eventgen
5369
} // end namespace o2
5470

Generators/include/Generators/GeneratorHybrid.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class GeneratorHybrid : public Generator
6363
private:
6464
o2::eventgen::Generator* currentgen = nullptr;
6565
std::vector<std::unique_ptr<o2::eventgen::Generator>> gens;
66-
const std::vector<std::string> generatorNames = {"extkinO2", "boxgen", "external", "hepmc", "pythia8", "pythia8pp", "pythia8hi", "pythia8hf", "pythia8powheg"};
66+
const std::vector<std::string> generatorNames = {"extkinO2", "evtpool", "boxgen", "external", "hepmc", "pythia8", "pythia8pp", "pythia8hi", "pythia8hf", "pythia8powheg"};
6767
std::vector<std::string> mInputGens;
6868
std::vector<std::string> mGens;
6969
std::vector<std::string> mConfigs;
@@ -73,12 +73,14 @@ class GeneratorHybrid : public Generator
7373
std::vector<std::unique_ptr<o2::eventgen::BoxGenConfig>> mBoxGenConfigs;
7474
std::vector<std::unique_ptr<o2::eventgen::Pythia8GenConfig>> mPythia8GenConfigs;
7575
std::vector<std::unique_ptr<o2::eventgen::O2KineGenConfig>> mO2KineGenConfigs;
76+
std::vector<o2::eventgen::EventPoolGenConfig> mEventPoolConfigs;
7677
std::vector<std::unique_ptr<o2::eventgen::ExternalGenConfig>> mExternalGenConfigs;
7778
std::vector<std::unique_ptr<o2::eventgen::FileOrCmdGenConfig>> mFileOrCmdGenConfigs;
7879
std::vector<std::unique_ptr<o2::eventgen::HepMCGenConfig>> mHepMCGenConfigs;
7980

8081
bool mRandomize = false;
8182
std::vector<int> mFractions;
83+
std::vector<float> mRngFractions;
8284
int mseqCounter = 0;
8385
int mCurrentFraction = 0;
8486
int mIndex = 0;

Generators/src/GeneratorFactory.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
175175
}
176176
}
177177
LOG(info) << "using external O2 kinematics";
178+
} else if (genconfig.compare("evtpool") == 0) {
179+
// case of an "event-pool" which is a specialization of extkinO2
180+
// with some additional logic in file management and less configurability
181+
// and not features such as "continue transport"
182+
auto extGen = new o2::eventgen::GeneratorFromEventPool(o2::eventgen::GeneratorEventPoolParam::Instance().detach());
183+
primGen->AddGenerator(extGen);
184+
LOG(info) << "using the eventpool generator";
178185
} else if (genconfig.compare("tparticle") == 0) {
179186
// External ROOT file(s) with tree of TParticle in clones array,
180187
// or external program generating such a file

0 commit comments

Comments
 (0)