ProjectionX requires derefercing the histogram pointer?

Hi rooters,

I’m having a serious issue and I’ve been scratching my head for quite a while - so before I lose all my hair here’s my problem.

I have a code that looks like
TCanvas c1;
c1.divide(numbins,1);
j[numbins+1]={1, blah blah…}
TH1D temp[numbins];

for(int i =0; i<numbins; i++){
c1->cd(i+1);
temp[i]=*(h->ProjectionY("",j[i],j[i+1],“o”); //h is some pointer to 2D histogram
temp[i]->draw();
}

If I don’t dereference ProjectionY step then when I refresh the canvas (either trying to save a copy or maximise the window) all that’s left is the same 1D histogram repeated in each of the pads… and if I do then that’s fine… except now I wish to set the x ranges of temp[i] to say 5sigma… and then temp[i]->GetXaxis()->SetRange(-5sigma, 5*sigma) except doing so only rescales the axis and not the data! Probably because it’s no-longer a pointer… and the data is set where it is - no?

But I’m seriously stuck as to what to do…

Cheers.
Mike

You must give a different name to each of your projections, ie replace

temp[i]=*(h->ProjectionY("",j[i],j[i+1],"o"); //h is some pointer to 2D histogram by, eg

temp[i]=*(h->ProjectionY(Form("proj%d",i),j[i],j[i+1],"o"); //h is some pointer to 2D histogram
The doc says:

[quote] // NOTE that if a TH1D named “name” exists in the current directory or pad and having
// a compatible axis, the histogram is reset and filled again with the projected contents of the TH2.
// In the case of axis incompatibility, an error is reported and a NULL pointer is returned.
[/quote]

Rene