Global variables in ROOT7?

I read some old slides from ROOT7 ( … -Intro.pdf) which mentioned interoperability with STL and “no context state: gDirectory […]”

I’d like to raise an old suggestion which seems to contradict with current ROOT design: is it possible to make the copy constructor of histograms copy their directory, so I can put them into std::vector? (TH1I copy constructor does not copy current directory)

The example code on

TFilePtr file = TFile::Recreate("jetmuontag.root"); file->Write("hist_mupt", hMuPtTag); file->Write("hist_jetet", hJetEtTag);
makes it seem to me that this is still implemented effectively with some global variable (or static member of some class).

PS: I just subscribed to the root7-discussion mail list but it doesn’t allow me (lightweight account to read the archive.


We indeed need to think this through.

As a side, we also don’t have a move construction in the v6 histogram so even if the directory was copied, adding them to a vector could still be expansive (copying all the data). So alternatively, you use a std::vector<std::unique_ptr>.