45 static std::mutex
gLock;
47 static std::atomic<std::uint32_t>
gThreadId;
50 auto prng = std::make_unique<TRandom3>();
53 auto id =
entry->GetPtr<std::uint32_t>(
"id");
55 auto vpx =
entry->GetPtr<std::vector<float>>(
"vpx");
56 auto vpy =
entry->GetPtr<std::vector<float>>(
"vpy");
57 auto vpz =
entry->GetPtr<std::vector<float>>(
"vpz");
64 int npx =
static_cast<int>(
prng->Rndm(1) * 15);
66 for (
int j = 0;
j <
npx; ++
j) {
71 vpx->emplace_back(px);
72 vpy->emplace_back(py);
73 vpz->emplace_back(pz);
76 std::lock_guard<std::mutex> guard(
gLock);
86 model->MakeField<std::uint32_t>(
"id");
87 model->MakeField<std::vector<float>>(
"vpx");
88 model->MakeField<std::vector<float>>(
"vpy");
89 model->MakeField<std::vector<float>>(
"vpz");
94 std::vector<std::unique_ptr<ROOT::REntry>> entries;
95 std::vector<std::thread>
threads;
97 entries.emplace_back(
writer->CreateEntry());
99 threads.emplace_back(FillData, std::move(entries[i]),
writer.get());
116 TCanvas *
c1 =
new TCanvas(
"c2",
"Multi-Threaded Filling Example", 200, 10, 1500, 500);
120 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
129 auto nEvents =
reader->GetNEntries();
131 TH2F hFillSequence(
"",
"Entry Id vs Thread Id;Entry Sequence Number;Filling Thread", 100, 0, nEvents, 100, 0,
133 for (
auto i :
reader->GetEntryRange())
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TStyle * gStyle
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
An RNTuple that gets filled with entries (data) and writes them to storage.
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Throws an exception if the model is null.
1-D histogram with a float per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, const ROOT::Internal::RPageSource &pageSource)
Helper to get the iteration space of the given field that needs to be connected to the given page sou...