00001
00002
00003
00004
00005
00006
00007
00008 #ifndef MyRoot_h
00009 #define MyRoot_h 1
00010
00011 #include <string>
00012
00013 #include "G4UnitsTable.hh"
00014 #include "myglobals.hh"
00015 #include "TFile.h"
00016 #include "TTree.h"
00017
00018 class MyRoot
00019 {
00020 public:
00021 MyRoot();
00022 ~MyRoot();
00023
00024 static MyRoot* GetMyRoot();
00025
00026 void OpenFile(std::string filename);
00027 void CreateTree(std::string branchname, int fCircular = 0);
00028
00029 void Fill();
00030
00031 template <typename Type>
00032 void SetBranch(const std::string& name, Type* var){
00033 m_tree->Branch(name.c_str(), var);
00034 if ( fVerbose >= 5 ){
00035 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00036 std::cout<<" New branch created!!"<<std::endl;
00037 std::cout<<" Name: "<<name<<std::endl;
00038 }
00039 }
00040
00041 void SetBranch(const std::string& name, std::vector<double>* pVecD);
00042 void SetBranch(const std::string& name, std::vector<int>* pVecI);
00043 void SetBranch(const std::string& name, int* pI);
00044 void SetBranch(const std::string& name, double* pD);
00045 void SetBranch(const std::string& name, std::vector<std::string>* pVecCa);
00046
00047 void Save();
00048
00049 int FlushBaskets();
00050
00051 void Write();
00052
00053 void Close();
00054
00055 void SetVerbose( int val ){fVerbose = val;};
00056 void SetPrintModulo( int val ){fPrintModulo = val;};
00057
00058 private:
00059
00060 static MyRoot* fMyRoot;
00061
00062 int fVerbose;
00063 int fPrintModulo;
00064 int nbFilled;
00065
00066
00067 TFile* m_file;
00068 TTree* m_tree;
00069 };
00070
00071 #endif
00072