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:
- should the idea itself work? Especially the storing of the histograms to a ROOT-File afterwards?
- how do i initialise the map correctly?
- what is a clever way of storing the map as a root file?
std::vector<Pixel> LoadFile(std::string filename)
{
std::fstream f;
f.open(filename.c_str(), 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);
while(!f.eof())
{
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));
}
f.close();
//TFile *outputFile = newTFile("tot_hists","RECREATE");
//Array_of_ToT_Hist->Write();
//outputFile->Close();
}
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22
Platform: Centos7
Compiler: