You are here

ROOT 7

For the first time since 20 year (i.e. ever), the ROOT team plans to break backward compatibility for crucial interfaces - once. This new major version of ROOT will make ROOT much simpler and safer to use: we want to increase clarity and usability. If you are a physicist, please read on - this is about your ROOT.

The ROOT team will be releasing parts of ROOT 7 throughout the coming years. Previews will gradually sneak into the ROOT sources, in the namespace ROOT::Experimental for those parts that are not yet cast in stone, and in the namespace ROOT for those that are. We will use standard C++ types, standard interface behavior (e.g. with respect to ownership and thread safety), good documentation and tests: we are trying to be nice!

Feedback

The main point of the meeting and this page is to solicit your feedback. Most of it has been taken care of in the code already.

Building ROOT 7

Pre-requisites

Support for the c++14 standard is required. Usage of g++ >= 5 or clang >= 3.4 is recommended.

Relevant cmake variables

The CMAKE_CXX_STANDARD cmake variables must be set to at least 14.

Building from source would look similar to this:

$ mkdir root7_build
$ cd root7_build
$ cmake -DCMAKE_CXX_STANDARD=14 path/to/root/source
$ cmake --build . -- -j4

Examples

See the relevant tutorials, for instance for drawing and styling the new histograms.

The new interfaces are not about shortening your code - but about robustness. Here are a few examples of what can go wrong with the ROOT6 interfaces:

ROOT6 interfaces, showing what can go wrong.
  1. #include "TFile.h"
  2. #include "TH2.h"
  3. #include "TTreeReader.h"
  4. #include "TTreeReaderArray.h"
  5. #include "TTree.h"
  6.  
  7. // Another function. Who knows what it does in a month from now.
  8. void someOtherFunction();
  9.  
  10. void fill(TTree* tree) {
  11. // Create the file before so it can own the histograms.
  12. TFile* file = TFile::Open("jetmuontag.root", "RECRAETE");
  13.  
  14. // Create the histograms (cannot mix fixed and variable size bins)
  15. const double muonPtBins[] = {0., 1., 10., 100.};
  16. // The axis titles might have been changed. Impossible to see.
  17. TH2* hMuPtTag = new TH2F("hMuPtTag", "muon pT versus tag value;tag value;muon pT [GeV]",
  18. 4, muonPtBins, 10, 0., 1.);
  19. TH1* hJetEt = new TH1F("hJetEt", "jet ET versus tag value;jet ET [GeV];tag value",
  20. 10, 0., 1000.);
  21.  
  22. // Set up reading from the TTree
  23. TTreeReader reader(tree);
  24. TTreeReaderArray<float> jetEt(reader, "jet.ET");
  25. TTreeReaderArray<float> muPt(reader, "jet.lead_mu.pT");
  26. TTreeReaderArray<float> tag(reader, "jet.tag");
  27.  
  28. // Fill the histograms
  29. while (reader.Next()) {
  30. for (int iJet = 0; iJet < jetEt.size(); ++iJet) {
  31. hMuPtTag->Fill(muPt[iJet], tag[iJet]);
  32. hJetEtTag->Fill(jetEt[iJet], tag[iJet]);
  33. }
  34. }
  35.  
  36. someOtherFunction();
  37.  
  38. // Store the result. Ideally using file->Write() but very few people do that.
  39. hMuPtTag->Write();
  40. hJetEtTag->Write();
  41.  
  42. delete file; // but not the histograms!
  43. }

Here are the problems:

  • Constructing the TFile, "RECRAETE" is misspelled.
  • The axis titles of hMuPtJetET are inverted.
  • The number of muonPtBins is wrong.
  • The histogram hJetEtTag is filled with weights of *tag; that might be a leftover y coordinate.
  • You get two copies of the histogram in the file, one for histogram->Write(), one because the histogram is already associated with the file and will be written on file destruction.
  • The call to someOtherFunction() might change gDirectory and thus hMuPtJetET might not be written to jetmuontag.root.

To track these problems down you'd have to spend your time debugging them. Instead, the new interfaces will simply not allow this to happen: no debugging needed!