I have been able to successfully store a std::map<std::string, int> into a TTree. However, I am only able to access the map w/ a compiled script (aclic) that loops over the individual entries in the tree. My question is: are the standard Draw,Scan,GetEntries, etc. functions supported for such a map? My goal would be to have a map filled per event with string cut-name and int cut decision. I would then like to do this:
Ok I agree that this map is over-kill. We just have two pieces of code one that does our main cut-flow over a large ntuple and another piece that takes information from that code such as cut decisions and simple float variables and dumps into a simple flat ntuple. In the end I decided to just allocate X branches w/ dummy names and then call SetBranchName as soon as one piece of code was able to communicate w/ the other about what the actual cut value names would be. Thus ending up w/ 25 Bools in the tree( or whatever size the map was).
I think I may also look into this TBits class–it seems quite a bit more compact than what I am doing.
TTree::Draw does not support calling any function (besides strstr and strcmp) that do not take numerical arguments and thus you would not be able to use a map<string,int> for your purpose within TTree::Draw.
Also the operator[] is special for TTree::Draw and you would not be able to use map’s operator[], which anyway you should not use for this purpose as map’s operator[] is both an insert and a lookup, instead you ought to use map::find.
In addition, map are extremely slow to read in (compared to TBits or even an std::vector).
So for all those reasons, please follow Fons’ advice