# Attach metadata to TH1s, TObjects?

**URL:** <https://root-forum.cern.ch/t/attach-metadata-to-th1s-tobjects/32463>\
**Category:** ROOT\
**Created:** [January 28, 2019, 1:47am UTC](https://root-forum.cern.ch/t/attach-metadata-to-th1s-tobjects/32463 "2019-01-28T01:47:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ychiu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/b782af/32.png) [@ychiu](https://root-forum.cern.ch/u/ychiu)\
**Post date:** [January 28, 2019, 8:53am UTC](https://root-forum.cern.ch/t/attach-metadata-to-th1s-tobjects/32463/3 "2019-01-28T08:53:12Z")

</div>

Thank you for the suggestion. Do you think inserting a TMap – that I populate with `TMap::Add(keyTString, valueTString)` – into the TList returned by `TH1::GetListOfFunctions` is a good solution? Perhaps you can think of something better?

I was also exploring writing a `std::map<std::string, std::string>` or even a `std::map<std::string, myMetadataStruct>` to the TFile.

I understand that dictionaries for some STL containers are available by default with ROOT [1].  
How can I get the list of them – i.e. what types T for `std::vector<T>` and `std::map<Key, T>` can I write to a TFile without setting up a dictionary entry for Key and T?

How would I merge the metadata together from multiple files? E.g. if I have a TList with one TMap in each file, then the merged result (`hadd`) will be one TList with multiple TMaps. Then I will have to merge the TMaps together manually. Or, if I have `std::map<Key, T>`, then I will have to implement `std::map<Key, T>::Merge(TCollection *maplist)`. Is this correct?

Thanks,  
Justin

[1] [https://root.cern.ch/notebooks/HowTos/write-objects-to-a-file.html](https://root.cern.ch/notebooks/HowTos/write-objects-to-a-file.html)  
[Writting and Getting a std::vector from a TFile](https://root-forum.cern.ch/t/writting-and-getting-a-std-vector-from-a-tfile/26207)  
[https://root.cern.ch/root/html/tutorials/math/mathcoreVectorCollection.C.html](https://root.cern.ch/root/html/tutorials/math/mathcoreVectorCollection.C.html)

---

_[View the full topic](https://root-forum.cern.ch/t/attach-metadata-to-th1s-tobjects/32463)._
