Std::map in TTree::Draw

Hi, I have a TTree with a branch that contains an std::map<int,Hot> where a Hot is a POD struct with only numerical values:

struct Hot
{
  Double_t doca;
  Double_t delta_doca;
  Bool_t excluded;
  Double_t chi2_contribution;
};

Is it possible to use TTree::Draw to access the members of the Hots in the std::map? I probably need to load a dictionary or something, but when I do “.L JFTrackFit.C+” (which contains the Hot definition) it doesn’t seem to change the error messages I get. Perhaps I also do not have the right syntax for accessing the std::map elements. I tried:

root [3] Proto2Analyzed->Draw("track_hots[12].doca")
root [4] Proto2Analyzed->Draw("(track_hots[12]).doca")
root [5] Proto2Analyzed->Draw("track_hots.at(12).doca")
root [6] Proto2Analyzed->Draw("(track_hots.at(12)).doca")
root [7] Proto2Analyzed->Draw("*(track_hots.find(12)).doca")
root [8] Proto2Analyzed->Draw("track_hots.find(12)->doca")
root [9] Proto2Analyzed->Draw("(*track_hots.find(12))doca")

but I just get different errors about either syntax, unknown method, or “We thought we had a function but we don’t”.

Thanks for any help getting this to work.

Jean-François

I think I figured it out. My std::map<Int_t,Hot> branch is called “track_hots”.

If I do t.Draw(“track_hots.something”), this is already looping over the elements of track_hots, without needing to index it explicitly. Elements of a std::map<Foo,Bar> are pair<Foo,Bar>, so “something” better be either “first” or “second”.

E.g.: t.Draw(“track_hots.first”) draws the indexes of all the elements in track_hots for all the entries in the TTree. t.Draw(“track_hots.second.doca”) is how I would draw the doca member of the Hots in the maps. In my case, I wanted to access the index 12 (if present), so I ended up doing t.Draw(“track_hots.second.doca”,“track_hots.first == 12”).

Hopefully someone in the future will find this useful.

Jean-François