Monitor save files

From: Flemming Videbaek (videbaek@sgs1.hirg.bnl.gov)
Date: Wed Apr 12 2000 - 10:38:26 EDT

  • Next message: Christian Holm Christensen: "BRAT version 1.5.4 - Monitor changes"

    independent of Ian Mail which just arrived in my mail box, I struggled a bit to find a 'temporary' solution to
    saving histograms from the monitor. The  listed macro file) does the Job. It is by no way
    carefully tested- It will only do one level of subdirs, it is not stresse tested in any way. 
    It is though general and can be used to save any memory hsitograms saved files without opening the root TFile first.
    
    Flemming
    
    void SaveHist(const char * file)
    {
    // usage  .x SaveHist.C("Filename.root");
    //
      TList *l = gROOT->GetList();
    
      TFile *hfile = new TFile(file,"RECREATE","");
      l = gROOT->GetList();
      TIter next(l);
      TObject *obj;
      while((obj = (TObject*) next()))
        {
          if (obj->InheritsFrom("TDirectory")){
     cout << "Directory"<<endl;
     TList *ls = ((TDirectory*) obj)->GetList();
     TIter nextsub(ls);
     TObject *objs;
     while((objs = (TObject*) nextsub()))
       { objs->Write();
       }
          }
          if (obj->InheritsFrom("TH1")) obj->Write();
        }
      hfile->ls();
      hfile->Close();
      delete hfile;
    }
    
    
    --------------------------------------------------------
    Flemming Videbaek
    Physics Department
    Brookhaven national Lab
    
    tlf: 516-344-4106
    fax: 516-344-1334
    
    email: videbaek@bnl.gov
    



    This archive was generated by hypermail 2b29 : Wed Apr 12 2000 - 09:29:31 EDT