Array of Histograms can't be filled with Draw statement?

When using the Draw() function, how do I write to an array of histograms?

I declare my histograms in a loop:

TH1F *TwoDHistArray[5][20];

for (blah; blah; blah) {
sprintf(name, “TwoDHist_%d_%d”,i,j);
TwoDHistArray[i][j]=new TH1F(name,name,256,0,4096);


Now, I have TTree open and I want to use the Operator >> in the first argument in order to fill the Histogram (I’m doing it this way because I can’t seem to loop over the events of a chain of TTree’s with multiple branches… look at my other post for a description) :

for (blah;blah;blah) {



So, what type of argument can be put into this statement to make it work? Declaring a TString doesn’t work, char[256] doesn’t work, the code above doesn’t work… Using a TString before the operator is just fine, but what can I use for the Histogram?


The first argument to TTree::Draw must be a const char* with a syntax like
var1:var2>>histname , etc

So, in your loop, you should process like in your first loop, with, eg a sprintf statement like

or as an alternative