In order to manage the large amount of histograms, I am using a
map:
This allows me to store histograms by name
AND saving them using a loop.
Since I have more than one Monte Carlo type of data I end up creating
which leads to string manipulations (which are not as easy in C++):
for (short int i = 0; i < mcsize; i++) {
string histname;
histname = mclabel[i] + "_" + "neutrino_pz";
hists_[histname.c_str()] = new TH1F(histname.c_str(), "reconstructed p_z(#nu)", 50, -500, 500);
histname = mclabel[i] + "_" + "neutrino_pz_mc";
hists_[histname.c_str()] = new TH1F(histname.c_str(), "reconstructed p_z(#nu)", 50, -500, 500);;
histname = mclabel[i] + "_" + "recoWmass";
hists_[histname.c_str()] = new TH1F(histname.c_str(), "reconstructed leptonic W mass", 50, 0, 500);
}
for ( std::map<string, TH1F*>::const_iterator iter = hists_.begin();
iter != hists_.end(); ++iter )
iter->second->Sumw2();
}
Now I would like to store them as:
to store them as
This would be fine, but since I heard that maps are SLOW in C++ and
use a lot of memory,
I wonder if there is a better method to do so.
Is TMap much better?
For this I would only need to use TString instead of std::string, right?
Thank you in advance.