Semicolon in histogram name

I know I goofed up, never put semicolon in histogram names.

What I did:

char histname[128];
char newname[128];

TH2 *myHist = (TH2*) gDirectory->FindObjectAny(histname);


the problem is i accidentally forgot the “;1” in the newname, and now it is not letting me access the histograms from the command line so I can change them back. Can anyone help?

May be this can help: … s-its-name

Hi couet,

Regrettably this did not work. The key was returned as null :frowning: :frowning: :frowning:

Hi all,

It was kind of like that tutorial, he had to make some tweaks but this is how one of my colleagues fixed the issue.

   TFile* f = TFile::Open( fName, "update");
    if (!f->cd( dirName)) continue;
    TIter nextKey (gDirectory->GetListOfKeys());
    TKey* key;
    while (key = (TKey*)nextKey(), key) {
      string oldName = key->GetName();
      size_t oldLocation = oldName.find( oldPattern);
      if (oldLocation == string::npos) continue;
      string newName (oldName);
      newName.replace( oldLocation, oldPatternLength, newPattern);

      cout << setw(38) << oldName << " "
           << setw(38) << newName << " "
           << endl;

      TObject* oldObj = key->ReadObj();
      oldObj->Clone( newName.c_str());
      gDirectory->Delete( (oldName+";*").c_str());