Wrong naming convention

Hi
I did a stupid thing in naming my histogram pointers as something like ‘xxx_yy_0.01’

TH1F *xxx[3];
xxx[0] = new TH1F(“xxx_yy_0.01”, “xxx_yy_0.01”, 100, -5, 5);
xxx[1] = new TH1F(“xxx_yy_0.02”, “xxx_yy_0.02”, 100, -5, 5);
xxx[2] = new TH1F(“xxx_yy_0.03”, “xxx_yy_0.03”, 100, -5, 5);

Now when i write a macro to call this histogram and rebin it
TH1F *hnew = xxx_yy_0.01->Rebin();

I get this error

Error: Symbol xxx_yy_0 is not defined in current scope  histo2.C:32:
Error: Failed to evaluate xxx_yy_0.01
Error: Failed to evaluate xxx_yy_0.01->Rebin(grp,"hnew")

I understand i did a mistake in naming a pointer with a dot in it, but i wonder is there any way i can handle this? Because rerunning over all the datasets after correcting my mistake gonna take me another 3-4 days, which i would to avoid if there is any way around…

Hi,

When re-reading the histogram, initialize an explicit C++ variable pointing to it:

TH1F * hist = 0; gDirectory->GetObject("xxx_yy_0.01",hist); hist->Rebin();

Cheers.
Philippe.

TFile *f = new TFile(MyHistoFile.root", "READ);
TH1F *xxx[3];
f->GetObject(“xxx_yy_0.01”, xxx[0]);
f->GetObject(“xxx_yy_0.02”, xxx[1]);
f->GetObject(“xxx_yy_0.03”, xxx[2]);
if (xxx[0]) xxx[0]->Rebin(grp, “hnew_01”);
if (xxx[1]) xxx[1]->Rebin(grp, “hnew_02”);
if (xxx[2]) xxx[2]->Rebin(grp, “hnew_03”);

Thanks, that was helpful.