I was wondering if it were possible to set a TH2 having, say, a string and a double as coordinates of the (integer) z value.
To give a practical application, imagine a Geant4 simulation and a plot showing the “density” of the several processes ongoing on the y axis (these are strings: brehmsstrahlung “eBrehm”, ionization “eIon”, etc.) as a function of the incident particle energy on the x axis.
You can have the X and Y axis as string values (for a 2 histogram) but not the Z-axis.
The Z-Axis is always a count for the 2D histograms.
So that’s probably a trivial problem, but I probably don’t find the good constructor for it. Could you help me on this?
h2->Fill(string_name.c_str(), some_double) does not work (Error in TH2F::Fill: Invalid signature - do nothing).
Search for the section “Alphanumeric Bin Labels” at this page: http://root.cern.ch/root/html/TH1.html. Though that page is about TH1, it also applies to TH2. The alphanumeric labels are just that - labels. There is still an underlying coordinate that “carries” the label.
The Fill method that takes a string allows you to fill a specific bin that has an alphanumeric label, instead of relying on the actual axis coordinates of the bin. TH2 has a fill methods for the X bin being alphanumeric, or the Y bin, both, or neither. In any case, you can always fill using the actual axis values using the normal non-string Fill methods.
If you actually want to set labels for the “bin contents” axis (i.e. Z for TH2, Y for TH1) then this functionality is not what you want. I don’t know what you’d have to do then, probably set manual labels or play with contours?
The “bin content” axis is not a problem: those are actual integer numbers.
Anyway thanks to your link and your explanations my problem is solved! Many thanks!