TAxix::CanExtend() quits with crash

I am trying to write a script that employs histograms with an extendable x-axis. If the value I fill in the histogram is not within the range, then a histogram should set new limits.

However, a simple code that checks if the histogram is extendable crashes for no obvious reason. See below

{

    TH1F* h = new TH1F("fa", "fa", 10, 0, 10 );
    TAxis* xaxis = h->GetXaxis();
    xaxis->GetXmax();
    xaxis->CanExtend();

}

Am I doing something very stupid?

Many thanks for any help!

Which ROOT version are you using ? what error do you get ?
It works fine for me with ROOT 6.
But it does not with 5.34. CanExtend() is not implemented for this version.

[quote=“couet”]Which ROOT version are you using ? what error do you get ?
It works fine for me with ROOT 6.
But it does not with 5.34. CanExtend() is not implemented for this version.[/quote]

Yes, it is version 5.34. I didn’t realize I am using ROOT 5 and this method is implemented in ROOT 6 only. Is it going to be supported in version 5 sometime? Thank you.

I don’t think so … can you go to 6 ?

The broader need is that in ATLAS Offline DQ we want to have histograms that can extend their x-axis if a fill value falls out of the histogram range to accommodate the new value. This is needed for plotting monitoring parameters vs lumiblock. However the exact number of lumiblocks is not known at the time histogram is created.

At the moment, we use ROOT 5 from the Athena release. I don’t know regarding the plans of using ROOT 6 for data preparation in near future. This is a tricky question as all infrastructure is set to work with ROOT 5.

Overall my impression is that this is quite straight-forward to implement in ROOT 6. Is it correct? Also if you have any idea on how this can be done using ROOT 5, I would appreciate this very much.

Ok. I have asked Lorenzo to comment on that.

You can also do:

{
    TH1F* h = new TH1F("fa", "fa", 10, 0, 0 );
}

and forget about CanExtend

Is there a way to set up limits and number of bins after the histogram is populated? E.g. in our case, number of bins depends on the unknown ahead of time number of lumiblocks.