Hello,
I’m trying to create a list of histograms in a macro. I’ve tried a couple of ways to do this but come up against problems each time. Is there a clean way to do it?
1st attempt:
std::mapstd::string,TH2F* hist2dList;
hist2dList[“example”] = new TH2F(“exampleHist”, “exampleHist”, 120, -0.1, 1.1, 100, 0., 200.);
gives an error message
Error: Can’t call map<string,TH2F*,less,allocator<pair<const string,TH2F*> > >::operator in current scope plotWevents.C:26:
Possible candidates are…
(in map<string,TH2F*,less,allocator<pair<const string,TH2F*> > >)
Error: improper lvalue plotWevents.C:26:
(class TH2F*)0x9fdccd0
(but, for example, map<string, int> works fine).
2nd attempt:
enum hist2dTypes {example, numberOfHist2dTypes};
std::vector<TH2F*> hist2dList(numberOfHist2dTypes);
hist2dList[example] = new TH2F(“exampleHist”, “exampleHist”, 120, -0.1, 1.1, 100, 0., 200.);
gives a segmentation violation on trying to create the vector of fixed size.
Any suggestions gratefully received.
Thanks, Greg.