Is there a way of building a ‘global title’ into histograms, or other objects? I have not found one in the documentation. This should be displayed on all histograms from the same group/run, and built into the .root file in which they are saved.
I want to identify histograms in terms of the conditions under which they are filled. For example, in using a standard set of histograms (or an ntuple) with different data sets, it is essential to identify the data set on the plot.
I can do this with some gymnastics with the histogram title, but this means several lines of code for each histogram. It would be nice to be able to specify a global title and have it automatically added to the histogram plot.
As in “Events per GeV” for the title and “Lumi block NNNNN” for the global title.
[quote=“mcfarlan”]…string runBase = “Run identifying name”;
string aTitle = “Hit positions (”+runBase+");z (mm); hits/bin";
TH1F *hHitPosn = new TH1F(“hitPosn”,aTitle.c_str(), 20, 0. , 10.);
… . Is there any danger in doing it this way?
(Note: to use the ‘runBase’ elsewhere than in the scope of its definition, it is necessary to make ‘runBase’ have file or program scope, or pass it as an argument.)[/quote]No, it should not. The TNamed ( root.cern.ch/root/html/TH1.html ) creates a copy of your string. This means, it is safe to destroy the “aTitle” string instance (was it your concern?)
My concern was that constructing the string s and then using s.c_str() in the argument for TH1F might work in g++ but not in Cint. Or there may be some other fragility in the .c_str() method in the ROOT context.
[quote=“mcfarlan”]My concern was that constructing the string s and then using s.c_str() in the argument for TH1F might work in g++ but not in Cint. Or there may be some other fragility in the .c_str() method in the ROOT context. . . [/quote]I might have used “TString” rather “string”. However , “string” should be Ok too.