Dear experts,
I recently ran into these two problems when doing a fit with multithreading. I’m not sure if they’re kind of related so I’m just putting them under this same topic. I’m sorry if they turn out unrelated.
- In TH1 histogram fit, the option “I” produces errors when implicit MT is enabled. The error produced can be kind of random. But it works just fine in single thread.
void test0() {
ROOT::EnableImplicitMT();
for (int i = 0; i < 1000; i++)
{
TH1D h{"h", "h", 100, -5, 5};
for (int j = 0; j < 1000; j++)
h.Fill(gRandom->Gaus());
// Histogram fit option "I" produces errors with implicit MT enabled
h.Fit("gaus", "IQ0", "", -5, 5);
}
}
- Fit doesn’t seem to work well for me in RDataFrame with implicit MT enabled, even without option “I”. The following code would again give kind of random errors, but works well in a single thread.
void test() {
ROOT::EnableImplicitMT();
ROOT::RDataFrame df(100);
auto df2 = df
.DefineSlotEntry("h", [] (unsigned int slot, ULong64_t entry)
{
TString name{"h_"};
name += std::to_string(entry);
TH1D h{name, name, 100, -5, 5};
for (int i = 0; i < 1000; i++)
h.Fill(gRandom->Gaus());
return h;
}, {})
.DefineSlotEntry("fGaus", [] (unsigned int slot, ULong64_t entry, TH1D &h)
{
TString name{"fGaus_"};
name += std::to_string(entry);
TF1 fGaus{name, "[0] * TMath::Gaus(x, [1], [2])", -5., 5.};
fGaus.SetParameters(40, 0, 1);
h.Fit(&fGaus, "Q0", "", -5, 5);
return fGaus;
}, {"h"});
df2.Snapshot("t", "test.root");
}
Thank you!
Best,
Kevin
ROOT Version: 6.16.00
Platform: CentOS Linux 7 (lxplus)
Compiler: gcc 4.8.5
