MyRoot Class Reference

#include <MyRoot.hh>

List of all members.

Public Member Functions

 MyRoot ()
 ~MyRoot ()
void OpenFile (std::string filename)
void CreateTree (std::string branchname, int fCircular=0)
void Fill ()
template<typename Type >
void SetBranch (const std::string &name, Type *var)
void SetBranch (const std::string &name, std::vector< double > *pVecD)
void SetBranch (const std::string &name, std::vector< int > *pVecI)
void SetBranch (const std::string &name, int *pI)
void SetBranch (const std::string &name, double *pD)
void SetBranch (const std::string &name, std::vector< std::string > *pVecCa)
void Save ()
int FlushBaskets ()
void Write ()
void Close ()
void SetVerbose (int val)
void SetPrintModulo (int val)

Static Public Member Functions

static MyRoot * GetMyRoot ()

Private Attributes

int fVerbose
int fPrintModulo
int nbFilled
TFile * m_file
TTree * m_tree

Static Private Attributes

static MyRoot * fMyRoot = 0

Detailed Description

Definition at line 18 of file MyRoot.hh.


Constructor & Destructor Documentation

MyRoot::MyRoot (  ) 

Definition at line 14 of file MyRoot.cc.

References fMyRoot, fPrintModulo, and fVerbose.

00015         :m_file(0)
00016 {
00017   if (fMyRoot){
00018     G4Exception("MyRoot::MyRoot()","Run0031",
00019         FatalException, "MyRoot constructed twice.");
00020   }
00021   fVerbose = 0;
00022   fPrintModulo = 0;
00023   fMyRoot = this;
00024         if ( fVerbose >= 5 ){
00025                 printf("MyRoot\n");
00026         }
00027 }

MyRoot::~MyRoot (  ) 

Definition at line 29 of file MyRoot.cc.

References fVerbose, m_file, and m_tree.

00030 {
00031         m_tree->Delete();
00032         if (m_file) delete m_file;
00033         if ( fVerbose >= 5 ){
00034                 printf("~MyRoot\n");
00035         }
00036 }


Member Function Documentation

void MyRoot::Close (  ) 

Definition at line 110 of file MyRoot.cc.

References fVerbose, and m_file.

Referenced by MyAnalysisSvc::EndOfRunAction().

00110                   {
00111   m_file->Close();
00112         if ( fVerbose >= 5 ){
00113                 std::cout<<"In MyRoot::Close"<<std::endl;
00114                 std::cout<<"  m_file->Close()"<<std::endl;
00115         }
00116 }

void MyRoot::CreateTree ( std::string  branchname,
int  fCircular = 0 
)

Definition at line 38 of file MyRoot.cc.

References fVerbose, m_tree, and nbFilled.

Referenced by MyAnalysisSvc::BeginOfRunAction().

00038                                                          {
00039   m_tree = new TTree(tree_name.c_str(),tree_name.c_str());
00040   nbFilled = 0;
00041 //  m_tree->SetName(tree_name);
00042   //set circular
00043   if (fCircular){
00044                 m_tree->SetCircular(fCircular);
00045         }
00046         if ( fVerbose >= 5 ){
00047                 std::cout<<"In MyRoot::CreateTree"<<std::endl;
00048                 std::cout<<"  New tree booked!!"<<std::endl;
00049                 std::cout<<"  Name: "<<tree_name<<std::endl;
00050                 std::cout<<"  Circular: "<<fCircular<<std::endl;
00051         }
00052 }

void MyRoot::Fill (  ) 

Definition at line 72 of file MyRoot.cc.

References fPrintModulo, fVerbose, m_tree, and nbFilled.

Referenced by MyAnalysisSvc::EndOfEventAction().

00072                  {
00073   m_tree->Fill();
00074         nbFilled++;
00075         if ( fVerbose >= 5 ){
00076                 if ( fPrintModulo ){
00077                         if ( nbFilled%fPrintModulo == 0 ){
00078                                 std::cout<<"In MyRoot::Fill"<<std::endl;
00079                                 std::cout<<"  m_tree->Fill()"<<std::endl;
00080                                 std::cout<<"  "<<nbFilled<<" times for this tree"<<std::endl;
00081                         }
00082                 }
00083         }
00084 }

int MyRoot::FlushBaskets (  ) 

Definition at line 94 of file MyRoot.cc.

References fVerbose, and m_tree.

Referenced by MyAnalysisSvc::EndOfEventAction().

00094                         {
00095         if ( fVerbose >= 5 ){
00096                 std::cout<<"In MyRoot::FlushBaskets"<<std::endl;
00097                 std::cout<<"  m_tree->FlushBaskets()"<<std::endl;
00098         }
00099         return (m_tree->FlushBaskets());
00100 }

MyRoot * MyRoot::GetMyRoot (  )  [static]

Definition at line 65 of file MyRoot.cc.

References fMyRoot.

Referenced by MyAnalysisSvc::MyAnalysisSvc(), ProcessCountingSvc::SetBranch(), MonitorSD::SetBranch(), McTruthSvc::SetBranch(), and EventHeaderSvc::SetBranch().

00065                          {
00066   if ( !fMyRoot ){
00067     fMyRoot = new MyRoot;
00068   }
00069   return fMyRoot;
00070 }

void MyRoot::OpenFile ( std::string  filename  ) 

Definition at line 54 of file MyRoot.cc.

References fVerbose, and m_file.

Referenced by MyAnalysisSvc::BeginOfRunAction().

00055 {
00056         if (m_file) delete m_file;
00057   m_file = new TFile (file_name.c_str(), "RECREATE");
00058         if ( fVerbose >= 5 ){
00059                 std::cout<<"In MyRoot::OpenFile"<<std::endl;
00060                 std::cout<<"  New file open!!"<<std::endl;
00061                 std::cout<<"  Name: "<<file_name<<std::endl;
00062         }
00063 }

void MyRoot::Save (  ) 

Definition at line 86 of file MyRoot.cc.

References fVerbose, and m_tree.

Referenced by MyAnalysisSvc::EndOfEventAction().

00086                  {
00087         m_tree->AutoSave();
00088         if ( fVerbose >= 5 ){
00089                 std::cout<<"In MyRoot::Save"<<std::endl;
00090                 std::cout<<"  m_tree->AutoSave()"<<std::endl;
00091         }
00092 }

void MyRoot::SetBranch ( const std::string &  name,
std::vector< std::string > *  pVecCa 
)

Definition at line 158 of file MyRoot.cc.

References fVerbose, and m_tree.

00158                                                                          {
00159   m_tree->Branch(name.c_str(), pVecCa);
00160         if ( fVerbose >= 5 ){
00161                 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00162                 std::cout<<"  New branch created!!"<<std::endl;
00163                 std::cout<<"  Name: "<<name<<std::endl;
00164                 std::cout<<"  Type: vector<string>"<<std::endl;
00165         }
00166 }

void MyRoot::SetBranch ( const std::string &  name,
double *  pD 
)

Definition at line 148 of file MyRoot.cc.

References fVerbose, and m_tree.

00148                                                         {
00149   m_tree->Branch(name.c_str(), pD);
00150         if ( fVerbose >= 5 ){
00151                 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00152                 std::cout<<"  New branch created!!"<<std::endl;
00153                 std::cout<<"  Name: "<<name<<std::endl;
00154                 std::cout<<"  Type: double"<<std::endl;
00155         }
00156 }

void MyRoot::SetBranch ( const std::string &  name,
int *  pI 
)

Definition at line 138 of file MyRoot.cc.

References fVerbose, and m_tree.

00138                                                      {
00139   m_tree->Branch(name.c_str(), pI);
00140         if ( fVerbose >= 5 ){
00141                 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00142                 std::cout<<"  New branch created!!"<<std::endl;
00143                 std::cout<<"  Name: "<<name<<std::endl;
00144                 std::cout<<"  Type: int"<<std::endl;
00145         }
00146 }

void MyRoot::SetBranch ( const std::string &  name,
std::vector< int > *  pVecI 
)

Definition at line 128 of file MyRoot.cc.

References fVerbose, and m_tree.

00128                                                                   {
00129   m_tree->Branch(name.c_str(), pVecI);
00130         if ( fVerbose >= 5 ){
00131                 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00132                 std::cout<<"  New branch created!!"<<std::endl;
00133                 std::cout<<"  Name: "<<name<<std::endl;
00134                 std::cout<<"  Type: vector<int>"<<std::endl;
00135         }
00136 }

void MyRoot::SetBranch ( const std::string &  name,
std::vector< double > *  pVecD 
)

Definition at line 118 of file MyRoot.cc.

References fVerbose, and m_tree.

00118                                                                      {
00119   m_tree->Branch(name.c_str(), pVecD);
00120         if ( fVerbose >= 5 ){
00121                 std::cout<<"In MyRoot::SetBranch"<<std::endl;
00122                 std::cout<<"  New branch created!!"<<std::endl;
00123                 std::cout<<"  Name: "<<name<<std::endl;
00124                 std::cout<<"  Type: vector<double>"<<std::endl;
00125         }
00126 }

template<typename Type >
void MyRoot::SetBranch ( const std::string &  name,
Type *  var 
) [inline]

Definition at line 32 of file MyRoot.hh.

References fVerbose, and m_tree.

Referenced by ProcessCountingSvc::SetBranch(), MonitorSD::SetBranch(), McTruthSvc::SetBranch(), and EventHeaderSvc::SetBranch().

00032                                                   {
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 }

void MyRoot::SetPrintModulo ( int  val  )  [inline]

Definition at line 56 of file MyRoot.hh.

References fPrintModulo.

Referenced by MyAnalysisSvc::set_out_card().

00056 {fPrintModulo = val;};

void MyRoot::SetVerbose ( int  val  )  [inline]

Definition at line 55 of file MyRoot.hh.

References fVerbose.

Referenced by MyAnalysisSvc::set_out_card().

00055 {fVerbose = val;};

void MyRoot::Write (  ) 

Definition at line 102 of file MyRoot.cc.

References fVerbose, and m_tree.

Referenced by MyAnalysisSvc::EndOfRunAction().

00102                   {
00103   m_tree->Write();
00104         if ( fVerbose >= 5 ){
00105                 std::cout<<"In MyRoot::Write"<<std::endl;
00106                 std::cout<<"  m_tree->Write()"<<std::endl;
00107         }
00108 }


Member Data Documentation

MyRoot * MyRoot::fMyRoot = 0 [static, private]

Definition at line 56 of file MyRoot.hh.

Referenced by GetMyRoot(), and MyRoot().

int MyRoot::fPrintModulo [private]

Definition at line 63 of file MyRoot.hh.

Referenced by Fill(), MyRoot(), and SetPrintModulo().

int MyRoot::fVerbose [private]
TFile* MyRoot::m_file [private]

Definition at line 67 of file MyRoot.hh.

Referenced by Close(), OpenFile(), and ~MyRoot().

TTree* MyRoot::m_tree [private]

Definition at line 68 of file MyRoot.hh.

Referenced by CreateTree(), Fill(), FlushBaskets(), Save(), SetBranch(), Write(), and ~MyRoot().

int MyRoot::nbFilled [private]

Definition at line 64 of file MyRoot.hh.

Referenced by CreateTree(), and Fill().


The documentation for this class was generated from the following files:

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1