MICC JINR Multifunctional
Information and Computing
Complex

RU

Differences between ROOT5 and ROOT6

1

Version ROOT 6.00 / 00 was released on May 30, 2014. It presents a new Cling interpreter C++ 11, replacing CINT, which has been serving ROOT for many years. (C++ 11 is a new standard of the C++ language). Working with ROOT6 also requires a C++ 11-compatible compiler, so you need to install either gcc> = 4.8, or Clang> = 3.4.

2

An ability to use templates appeared in ROOT6.

3

There are methods that have a different return type in ROOT5 and ROOT6, for example Float_t TSpectrum::GetPositionX() in ROOT5 and Double_t TSpectrum::GetPositionX() in ROOT6. So that in this case the same macro could work both in ROOT5 and ROOT6, you should add the following to the code:

#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,00)

       Double_t *x; // ROOT 6

#else

       Float_t *x; // ROOT 5

#endif 

4

Cling follows the C ++ standard much more strictly than CINT. In particular, some code that used to work with CINT will issue new warnings or new compilation errors. Support for interchangeability "." and "-> " discontinued interactively.

5

Implicit dynamic changes

CINT in ROOT5 performed an automatic upgrade to derived classes in certain contexts, for example:

TH1 * h1 = hpx

TH1F * h1f = h1; 

Cling in ROOT6 does not allow it.

6

Changes in the histogram classes in ROOT6, which can lead to different results for the same code.

Histograms with labels/ alphanumeric axis

The concept of an alphanumeric axis appeared in ROOT 6. The axis is considered alphanumeric when all bins have tags attached to them. In this case, you need to fill the histogram using TH1::Fill (label) instead of TH1::Fill(x), where the label is a string, and x is a real number. In case of the alphanumeric axis, the histogram statistics (average value, rms, etc.) is no longer calculated, and their values ​​are set to zero. Alphanumeric histograms will be combined by adding the contents to bins with the same labels. If the labels are present for each bin, and a user does not want the axis to be alphanumeric, he can call the TAxis::SetNoAlphanumeric() function.

Filling a histogram with weights other than one

A histogram filled with weights other than 1 automatically saves the sum of the square of weights for each bin. You no longer need to call the TH1::Sumw2 () function for the weighted histograms. If you want to delete the sum of the weight arrays (to save memory), you need to call TH1::Sumw2(false). The TH1::Fill (x, y) function should no longer be used to set the contents of the bin to y. Instead, TH1 should use TH1::SetBinContent (TAxis::FindBin (x), y). In case someone wants to have the same behavior and avoid the sum of the squares of the weight being stored in the histogram, even if it is filled with weights different from one, then he needs to set the histogram bit H1::kIsNotW.

TH1::Copy and TH1::Clone methods

TH1::Copy now creates the histogram contents using a copy constructor, but does not copy the contained objects (for example, TF1). TH1::Clone copies everything, but much slower, especially in multithreaded environments due to internal points of serialization. In ROOT 6, the TH1 copy constructor is no longer public. Instead, you can use a derived classes copy constructor.

TH1 outdated methods in ROOT 6

TH1::Get/SetCellContent, Get / SetCellError were removed. You need to use Get/SetBinContent and Get/SetBinError, which have exactly the same functionality.

Faster internal method to get / update the contents of a bin

TH1 now uses new protected virtual functions in its member functions (for example, TH1::Add) UpdateBinContent and RetrieveBinContent to update and retrieve the bin content. These functions have a speed advantage over public methods Get / SetBinContent. If a user has implemented a class derived from the TH1 class, it may need to reimplement these new protected virtual functions.