TList* hList ; //______________________________________________________________________________ void Test() { for( Int_t i= 0 ; i<10 ; i++ ) { char hname[100] ; int k = sprintf( hname, "h%d", i ) ; TH1F* h = new TH1F( hname,hname,100,0.,1. ) ; } gDirectory->ls() ; // SaveHist( "Test.hist") ; } //______________________________________________________________________________ inline void WriteStats( char* InputFileName ) { char FileName[100] ; strcpy( FileName, InputFileName ) ; strcat( FileName, ".hist" ) ; cout << " Input file " << FileName <<"\n" ; TFile* f = new TFile(FileName) ; char TextFile[100] ; strcpy( TextFile , InputFileName ) ; strcat( TextFile , ".stat" ) ; cout << " Output file " << TextFile <<"\n" ; ofstream fOut( TextFile , ios::out ) ; f->ReadAll() ; hList = gDirectory->GetList() ; gDirectory->Print() ; cout << " List size " << hList->GetSize() << endl ; char *OldName = " " ; for( Int_t i = 0 ; i< (Int_t) hList->GetSize() ; i++ ) { TObject* H = hList->At( i ) ; if( ! H->InheritsFrom("TH1F") ) continue ; TH1F* h = hList->At( i ) ; char* hName = h->GetName() ; if( strncmp( hName, OldName, 6 ) != 0 ) { cout << endl ; fOut << endl ; } cout << hName << " " << h->GetEntries() << "\t" ; fOut << hName << " " << h->GetEntries() << "\t" ; strcpy( OldName, hName ) ; } f->Close() ; cout << endl ; } //______________________________________________________________________________ inline void SaveHist( char* FileName ) { cout << " Output to file " << FileName <<"\t" ; TList* hList = gDirectory->GetList() ; TFile* f = new TFile(FileName,"RECREATE") ; // f->cd() ; for( Int_t i = 0 ; i< (Int_t) hList->GetSize() ; i++ ) { TObject* h = hList->At( i ) ; char* hNam = h->GetName() ; cout << hNam << "\t" ; h->Write() ; } f->Close() ; cout << endl ; } //______________________________________________________________________________ inline int Hfill( char* hName , Double_t var, Int_t n, Double_t xmin, Double_t xmax, Double_t w ) { Int_t val(1) ; TH1F* h = (TH1F*) gDirectory->Get( hName ) ; if( h == 0 ) { cout << "create non existing histogram " << hName << endl ; TH1F *h = new TH1F( hName , hName, n, xmin, xmax ) ; val = 0 ; } h->Fill( var, w ) ; return val ; } //______________________________________________________________________________ inline int Hfill( char* hName , Double_t x, Int_t nx, Double_t xmin, Double_t xmax, Double_t y, Int_t ny, Double_t ymin, Double_t ymax, Double_t w ) { Int_t val(1) ; TH2F* h = (TH2F*) gDirectory->Get( hName ) ; if( h == 0 ) { cout << "create non existing histogram " << hName << endl ; TH2F *h = new TH2F( hName , hName, nx, xmin, xmax, ny, ymin, ymax ) ; val = 0 ; } h->Fill( x, y, w ) ; return val ; } //______________________________________________________________________________ inline void zone( Int_t nx=1 , Int_t ny=1, Int_t pos=1 , char* Name="NewC",char* opt ="nessuna" ) { TCanvas *NewC = new TCanvas( "NewC", Name, 1 ) ; NewC->Divide( nx,ny ) ; NewC->cd( pos ) ; } //______________________________________________________________________________ inline void edit(char *file) { char s[64], *e; if (!strcmp(gSystem->GetName(), "WinNT")) { if (e = getenv("EDITOR")) sprintf(s, "start %s %s", e, file); else sprintf(s, "start notepad %s", file); } else { if (e = getenv("EDITOR")) sprintf(s, "%s %s", e, file); else sprintf(s, "xterm -e vi %s &", file); } gSystem->Exec(s); } //______________________________________________________________________________ inline void ls(char *path=0) { char s[256] = (!strcmp(gSystem->GetName(), "WinNT")) ? "dir /w " : "ls "; if (path) strcat(s,path); gSystem->Exec(s); } //______________________________________________________________________________ inline void dir(char *path=0) { char s[256] = (!strcmp(gSystem->GetName(), "WinNT")) ? "dir " : "ls -l "; if (path) strcat(s,path); gSystem->Exec(s); } //______________________________________________________________________________ char *pwd() { return gSystem->WorkingDirectory(); } //______________________________________________________________________________ char *cd(char *path=0) { if (path) gSystem->ChangeDirectory(path); return pwd(); } //______________________________________________________________________________ void bexec(char *macro) { if (gROOT->IsBatch()) printf("Processing benchmark: %s\n",macro); TPaveText *summary = (TPaveText*)bench->GetPrimitive("TPave"); TText *tmacro = summary->GetLineWith(macro); if (tmacro) tmacro->SetTextColor(4); bench->Modified(); bench->Update(); gROOT->Macro(macro); TPaveText *summary2 = (TPaveText*)bench->GetPrimitive("TPave"); TText *tmacro2 = summary2->GetLineWith(macro); if (tmacro2) tmacro2->SetTextColor(2); bench->Modified(); bench->Update(); }