Skip to content
Snippets Groups Projects
Commit cd0ed028 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Volker Friese
Browse files

In CbmTaskDigiEventQa, fix bins fill in Histo1D-TH1D conv. method + ROOT warn

=> protect temporary histogram in CbmTaskDigiEventQa::ToTH1D from ROOT name registration clash
parent a0a2da48
No related branches found
No related tags found
1 merge request!1212Add services main folder + histogram server binary w/o FairMQ + tester binary example
......@@ -161,12 +161,16 @@ InitStatus CbmTaskDigiEventQa::Init()
// ----- Convert CBM histogram to ROOT histogram --------------------------
TH1D* CbmTaskDigiEventQa::ToTH1D(const cbm::algo::Histo1D& source)
{
bool add = TH1::AddDirectoryStatus();
TH1::AddDirectory(false); // Needed to prevent ROOT from adding histogram to its internal registry
TH1D* result =
new TH1D(source.Name().c_str(), source.Name().c_str(), source.NumBins(), source.MinValue(), source.MaxValue());
TH1::AddDirectory(add); // Needed to prevent ROOT from adding histogram to its internal registry
for (uint32_t bin = 0; bin < source.NumBins(); bin++) {
result->SetBinContent(bin, source.Content(bin));
result->SetBinContent(1 + bin, source.Content(bin));
}
result->SetBinContent(0, source.Underflow());
result->SetBinContent(source.NumBins(), source.Overflow());
result->SetEntries(source.NumEntries());
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment