示例#1
0
void transferMacros(TFile *inFile, TFile *outFile){
  
  TIter next(inFile->GetListOfKeys());
  TKey *key;
  while ((key = (TKey*)next())){
    if (string(key->ReadObj()->ClassName())=="TMacro") {
      //cout << key->ReadObj()->ClassName() << " : " << key->GetName() << endl;
      TMacro *macro = (TMacro*)inFile->Get(key->GetName());
      outFile->cd();
      macro->Write();
    }
  }
}
示例#2
0
void importdir(const char *dirname) {
	//Example of script showing how to create a ROOT file with subdirectories.
	//The script scans a given directory tree and recreates the
	//same structure in the ROOT file.
	//All source files of type .h,cxx,c,dat,py are imported as TMacro objects
	//see also other tutorial readCode.C
	//Author: Rene Brun
	                   
	char *slash = (char*)strrchr(dirname,'/');
	char *locdir;
	if (slash) locdir = slash+1;
	else       locdir = (char*)dirname;
	printf("processing dir %s\n",dirname);
	TDirectory *savdir = gDirectory;
	TDirectory *adir = savdir->mkdir(locdir);
	adir->cd();
	void *dirp = gSystem->OpenDirectory(dirname);
	if (!dirp) return;
	char *direntry;
	Long_t id, size,flags,modtime;
	//loop on all entries of this directory
	while ((direntry=(char*)gSystem->GetDirEntry(dirp))) {
		TString afile = Form("%s/%s",dirname,direntry);
		gSystem->GetPathInfo(afile,&id,&size,&flags,&modtime);
		if (direntry[0] == '.')             continue; //forget the "." and ".." special cases
		if (!strcmp(direntry,"CVS"))        continue; //forget some special directories
		if (!strcmp(direntry,"htmldoc"))    continue;
		if (strstr(dirname,"root/include")) continue;
		if (strstr(direntry,"G__"))         continue;
		if (strstr(direntry,".c")    ||
				strstr(direntry,".h")    ||
				strstr(direntry,".dat")  ||
				strstr(direntry,".py")   ||
				strstr(direntry,".C")) {
			TMacro *m = new TMacro(afile);
			m->Write(direntry);
			delete m;
		} else {
			if (flags != 3)                     continue; //must be a directory
			//we have found a valid sub-directory. Process it
			importdir(afile);
		}
	}
	gSystem->FreeDirectory(dirp);
	savdir->cd();
}
示例#3
0
void histobrowser(const char* name="HLT Histos")
{
   TEveManager::Create();

   // --- Create special browser

   gEve->GetBrowser()->StartEmbedding(0);
   g_hlt_browser = gEve->GetBrowser()->MakeFileBrowser();
   gEve->GetBrowser()->StopEmbedding(name);

   // --- Fill and register some lists/folders/histos

   gDirectory = 0;
   TH1F* h;

   TList* l = new TList;
   l->SetName("Cilka");
   h = new TH1F("Foo", "Bar", 51, 0, 1);
   for (Int_t i=0; i<500; ++i)
      h->Fill(gRandom->Gaus(.63, .2));
   l->Add(h);
   g_hlt_browser->Add(l);

   TFolder* f = new TFolder("Booboayes", "Statisticos");
   h = new TH1F("Fooes", "Baros", 51, 0, 1);
   for (Int_t i=0; i<2000; ++i) {
      h->Fill(gRandom->Gaus(.7, .1));
      h->Fill(gRandom->Gaus(.3, .1));
   }
   f->Add(h);
   g_hlt_browser->Add(f);

   h = new TH1F("Fooesoto", "Barosana", 51, 0, 1);
   for (Int_t i=0; i<4000; ++i) {
      h->Fill(gRandom->Gaus(.25, .02), 0.04);
      h->Fill(gRandom->Gaus(.5, .1));
      h->Fill(gRandom->Gaus(.75, .02), 0.04);
   }
   g_hlt_browser->Add(h);

   // --- Add some macros.

   TMacro* m;

   m = new TMacro;
   m->AddLine("{ g_hlt_canvas->Clear();"
              "  g_hlt_canvas->cd();"
              "  g_hlt_canvas->Update(); }");
   m->SetName("Clear Canvas");
   g_hlt_browser->Add(m);

   m = new TMacro;
   m->AddLine("{ g_hlt_canvas->Clear();"
              "  g_hlt_canvas->Divide(2,2);"
              "  g_hlt_canvas->cd(1);"
              "  g_hlt_canvas->Update(); }");
   m->SetName("Split Canvas");
   g_hlt_browser->Add(m);

   // --- Create an embedded canvas

   gEve->GetBrowser()->StartEmbedding(1);
   g_hlt_canvas = new TCanvas;
   gEve->GetBrowser()->StopEmbedding("HLT Canvas");
}