Strange behaviour with pointers to ROOT defined objects

Hi r@@ters,

I was wondering why I get a warning with a code of this sort:

[code]class Particles{
public:
TH1D *Position_h1;

void LoadProton();
void LoadHelium();

}

void LoadProton(){
Position_h1 = new TH1D(“Proton_pos”,“title”,100,0,11);

}

void LoadHelium(){
Position_h1 = new TH1D(“Helium_pos”,“title”,100,0,11);

}

int main(){
Particles Proton;
Proton.LoadProton();

Particles Helium;
Helium.LoadHelium();
...

}
[/code]

The output warning is:

How can I circumvent this?

Thanks in advance for your help

It seems that you are trying to create the “Helium_pos” histogram more than once (e.g. maybe you create a “helium-like” particle again).
Right after “Position_h1 = new TH1D(…);” add:
Position_h1->SetDirectory(0);