Lists of histograms in root macro

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.

Hi Greg,

CINT currently does not support the interpretation of arbitrary STL
container of objects. We hope to solve the problem sometimes next year.
In the meantime you need to generate the dictionary for such container,
which is as simple as using the script below the signature and loading
it via:

root [] .L mymap.C+

Or alternatively, compile your code.

Cheers,
Philippe.

[code]// File mymap.C
#include
#include “TH2F.h”
#include

#ifdef MAKECINT
#pragma link C++ class std::map<std::string, TH1F*>+;
#endif

// End of file mymap.C[/code]