Hello,
I have a code which is almost like this:
class HistoContainer {
std::vector<TH1F *> mass;
HistoContainer(TString name = "TMP") {
for (int i = 0; i < 10; i++)
mass[i] = new TH1F(TString::Format("%s_mass_%d", name.Data(), i), "", 100, 0, 1);
}
};
std::map<TString, HistoContainer> map;
map["one"] = HistoContainer("one");
map["another"] = HistoContainer("another");
TH1F *the_fifth_one = map["one"].mass[4];
std::cerr << "test #1: " << the_fifth_one << " = " << map["one"].mass[4] << std::endl;
std::cerr << "test #2: binwidth[raw] = " << " << map["one"].mass[4]->GetBinWidth(3) << std::endl;
std::cerr << "test #3: binwidth[pnt] = " << " << the_fifth_one->GetBinWidth(3) << std::endl;
but crashes when printing test #3.
Do you have any idea why?