Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MJOutputRoot.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00003 //                                                                           //
00004 //                         MAJORANA Simulation                               //
00005 //                                                                           //
00006 //      This code implementation is the intellectual property of the         //
00007 //      MAJORANA Collaboration. It is based on Geant4, an intellectual       //
00008 //      property of the RD44 GEANT4 collaboration.                           //
00009 //                                                                           //
00010 //                        *********************                              //
00011 //                                                                           //
00012 //    Neither the authors of this software system, nor their employing       //
00013 //    institutes, nor the agencies providing financial support for this      //
00014 //    work  make  any representation or  warranty, express or implied,       //
00015 //    regarding this software system or assume any liability for its use.    //
00016 //    By copying, distributing or modifying the Program (or any work based   //
00017 //    on on the Program) you indicate your acceptance of this statement,     //
00018 //    and all its terms.                                                     //
00019 //                                                                           //
00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00021 //---------------------------------------------------------------------------//
00022 //                                                          
00023 // $Id: MJOutputRoot.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJOutputRoot.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00048 //---------------------------------------------------------------------------//
00049 //
00050 
00051 #include "TFile.h"
00052 #include "TTree.h"
00053 
00054 #include "io/MJLogger.hh" 
00055 
00056 //---------------------------------------------------------------------------//
00057 
00058 #include "io/MJOutputRoot.hh"
00059 
00060 //---------------------------------------------------------------------------//
00061 
00062 TTree*    MJOutputRoot::fTree = 0;
00063 TFile*    MJOutputRoot::fRootFile = 0;
00064 
00065 //---------------------------------------------------------------------------//
00066 
00067 MJOutputRoot::MJOutputRoot(G4bool isMother):
00068   fIsMother(isMother)
00069 {;}
00070 
00071 //---------------------------------------------------------------------------//
00072 
00073 MJOutputRoot::MJOutputRoot(const MJOutputRoot &) 
00074 {;}
00075 
00076 //---------------------------------------------------------------------------//
00077 
00078 MJOutputRoot::~MJOutputRoot()
00079 {;}
00080 
00081 //---------------------------------------------------------------------------//
00082 
00083 //concrete ROOT implementation of virtual methods
00084 void MJOutputRoot::OpenFile(const char* filename)
00085 {
00086   OpenRootFile(filename);
00087 }
00088 
00089 void MJOutputRoot::CloseFile()
00090 {
00091   CloseRootFile();
00092 }
00093 
00094 //Specific methods for ROOT-based analysis
00095 
00096 void MJOutputRoot::OpenRootFile(const char* RootFileName)
00097 {
00098   if(fIsMother) {
00099     fRootFile = new TFile(RootFileName, "RECREATE");
00100     MJLog(routine)<<"Opened ROOT file for event data: "<<RootFileName<<endlog;
00101   }
00102 }
00103  
00104 void MJOutputRoot::CloseRootFile()
00105 {
00106   if(fTree) {
00107     if(MJLogger::GetSeverity() <= MJLogger::trace)
00108       fTree->Print();
00109     fTree->Write();
00110     fTree->Delete();
00111     fTree = 0;
00112   }
00113   if(fRootFile) {
00114     fRootFile->Write();
00115     fRootFile->Close();
00116     fRootFile->Delete("");
00117     fRootFile = 0;
00118     MJLog(routine) << "Root file " << GetFileName() << " closed." << endlog;
00119   }
00120 }
00121 
00122 //---------------------------------------------------------------------------//
00123 

Generated on Mon Nov 29 16:58:52 2004 for Majorana Simulation by  doxygen 1.3.9.1