Store Histograms in Map as Vectors and Store as ROOT-File

Hi, I’m at the beginning of my C++/ROOT career and this may be quite basic, but thanks for any help!

I’m looking at the hit data of a pixel sensor (50000 pix) and I have data in form of row, column and tot (energy deposition) stored in a data file (5GB).
The goal is to have a tot-histogram for every single pixel.

My approach is to create a map with key {column, row} and value std::vector tot.
Afterwards I want to store this map as a root-file to read it out in later work steps.

Below there is a try, but already the definition of the map doesn’t work out.
So my questions:

  1. should the idea itself work? Especially the storing of the histograms to a ROOT-File afterwards?
  2. how do i initialise the map correctly?
  3. what is a clever way of storing the map as a root file?
std::vector<Pixel> LoadFile(std::string filename)
         std::fstream f;, std::ios::in);
         typedef std::array<int,2> pix_value;

	 std::map<pix_value,vector<int>> Array_of_ToT_Hist;

	std::string line;
	std::getline(f, line);
		Pixel pix;

		f >> pix.column >> pix.row >> pix.tot;

		std::getline(f, line);

		Array_of_ToT_Hist.insert(std::pair<pix_value,std::vector<int>> ({pix.column,pix.row},pix.tot));

        //TFile *outputFile = newTFile("tot_hists","RECREATE");

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22
Platform: Centos7


You can store in a ROOT file a map of histograms and names, for example, but you would need to define a dictionary for that type and you cannot use directly the Write method as you would do for a TObject. It is a bit more complicated. A simpler solution for storing histograms in a file is either store them directly, calling Write() on them, or add in one of the ROOT container, such as TList or TMap or THashTable and store them in the file