#include #include #include #include #include #include #include #include #include #include #include "myHist.h" using namespace std ; //______________________________________________________________________________ inline TObject* GetFromFile( char* hname , char* fname, char* newname= 0 ) { TFile* f = new TFile( fname ) ; if( f == 0 ) { cout << " file " << fname << " not found "<< endl ; return 0 ; } gROOT->cd(); TObject* h = dynamic_cast (f->Get( hname ))->Clone(newname) ; f->Close() ; if( h == 0 ) { cout << " histogram " << hname << " does not exist "<< endl ;} else { cout << " histogram " << h->GetName() << " loaded with success " << endl ;} return h ; } //______________________________________________________________________________ inline TObject* GetHist( char* hname ) { TObject* h = (TObject*) gDirectory->Get( hname ) ; if( h == 0 ) { cout << " histogram " << hname << " does not exist "<< endl ;} return h ; } //______________________________________________________________________________ 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 i = 0 ; i< (int) hList->GetSize() ; i++ ) { TObject* h = hList->At( i ) ; const char* hNam = h->GetName() ; cout << hNam << "\t" ; h->Write() ; } f->Close() ; cout << endl ; } inline int Hfill() { return 0 ; } //______________________________________________________________________________ // 1DH //______________________________________________________________________________ inline int Hfill( char* hName , double var, int n, double xmin, double xmax, double w ) { int val(1) ; TH1D* h = (TH1D*) gDirectory->Get( hName ) ; if( h == 0 ) { cout << "create non existing histogram " << hName << endl ; h = new TH1D( hName , hName, n, xmin, xmax ) ; h->Sumw2() ; val = 0 ; } h->Fill( var, w ) ; return val ; } //______________________________________________________________________________ // 2DH //______________________________________________________________________________ inline int Hfill( char* hName , double x, int nx, double xmin, double xmax, double y, int ny, double ymin, double ymax, double w ) { int val(1) ; TH2D* h = (TH2D*) gDirectory->Get( hName ) ; if( h == 0 ) { cout << "create non existing histogram " << hName << endl ; h = new TH2D( hName , hName, nx, xmin, xmax, ny, ymin, ymax ) ; h->Sumw2() ; val = 0 ; } h->Fill( x, y, w ) ; return val ; } //______________________________________________________________________________ // 3DH //______________________________________________________________________________ inline int Hfill( char* hName , double x, int nx, double xmin, double xmax, double y, int ny, double ymin, double ymax, double z, int nz, double zmin, double zmax, double w ) { int val(1) ; TH3D* h = (TH3D*) gDirectory->Get( hName ) ; if( h == 0 ) { cout << "create non existing histogram " << hName << endl ; h = new TH3D( hName , hName, nx, xmin, xmax, ny, ymin, ymax, nz, zmin, zmax ) ; val = 0 ; h->Sumw2() ; } h->Fill( x, y, z, w ) ; return val ; }