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

MJOutputNaIBarrel.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: MJOutputNaIBarrel.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJOutputNaIBarrel.cc
00026 //
00027 //---------------------------------------------------------------------------//
00031 // 
00032 //---------------------------------------------------------------------------//
00042 //---------------------------------------------------------------------------//
00043 //
00044 
00045 #include "TTree.h"
00046 
00047 #include "G4Event.hh"
00048 #include "G4Material.hh"
00049 
00050 #include "io/MJLogger.hh"
00051 #include "io/MJOutputNaIBarrelData.hh"
00052 
00053 //---------------------------------------------------------------------------//
00054 
00055 #include "io/MJOutputNaIBarrel.hh"
00056 
00057 //---------------------------------------------------------------------------//
00058 
00059 MJOutputNaIBarrel::MJOutputNaIBarrel(G4String name, G4bool isMother):
00060   MJOutputRoot(isMother), fData(0)
00061 {
00062   SetSchemaDefined(false);
00063 }
00064 
00065 //---------------------------------------------------------------------------//
00066 
00067 MJOutputNaIBarrel::~MJOutputNaIBarrel()
00068 {
00069   delete fData;
00070 }
00071 
00072 //---------------------------------------------------------------------------//
00073 
00074 void MJOutputNaIBarrel::BeginOfEventAction(const G4Event *event)
00075 {
00076   fData->FlagNaI = 0;
00077   fTotalEnergyDeposit = 0.0;
00078   for(G4int i = 0; i < 16; i++) 
00079     fSegEdep[i] = 0.0;
00080 }
00081 
00082 //---------------------------------------------------------------------------//
00083 
00084 void MJOutputNaIBarrel::BeginOfRunAction()
00085 {
00086   fSensitiveMaterialIndex = G4Material::GetMaterial("NaI")->GetIndex();
00087 }
00088 
00089 //---------------------------------------------------------------------------//
00090 
00091 void MJOutputNaIBarrel::DefineSchema()
00092 {
00093   if(!SchemaDefined()) {
00094     fData = new MJOutputNaIBarrelData;
00095     if(!fTree) {
00096        fTree = new TTree("fTree", "NaI Barrel Tree");
00097        if(!IsMother())
00098          MJLog(warning) << "No tree assigned to child output class." << endlog;
00099     }
00100     fTree->Branch("TotEdepNaI", &fData->TotEdepNaI, "TotEdepNaI/F");
00101     fTree->Branch("SegEdep", fData->SegEdep, "SegEdep[16]/F");
00102     fTree->Branch("FlagNaI", &fData->FlagNaI, "FlagNaI/I");
00103     SetSchemaDefined(true);
00104   }
00105 }
00106 
00107 //---------------------------------------------------------------------------//
00108 
00109 void MJOutputNaIBarrel::EndOfEventAction(const G4Event *event)
00110 {
00111   fData->TotEdepNaI = (Float_t) G4ToRoot(fTotalEnergyDeposit / keV);
00112   for(G4int i = 0; i < 16; i++)
00113     fData->SegEdep[i] = (Float_t) G4ToRoot(fSegEdep[i] / keV);
00114 
00115   if(IsMother())
00116     FillTree();
00117 }
00118 
00119 //---------------------------------------------------------------------------//
00120 
00121 void MJOutputNaIBarrel::EndOfRunAction()
00122 {
00123   if(IsMother())
00124      CloseRootFile();
00125 }
00126 
00127 //---------------------------------------------------------------------------//
00128 
00129 void MJOutputNaIBarrel::RootSteppingAction(const G4Step *step)
00130 {
00131   // Define these variables as static to avoid having to define them at
00132   // every stepping action, saving CPU cycles.
00133   static G4Track *track;
00134   static G4Material *material;
00135   static G4int i;
00136 
00137   track = step->GetTrack();
00138   material = track->GetMaterial();
00139   if(material->GetIndex() == fSensitiveMaterialIndex) {
00140     fTotalEnergyDeposit += step->GetTotalEnergyDeposit();
00141     i = (track->GetPosition().phi() + pi)* 2.5464792 ;// 22.5 degrees / segment
00142     fSegEdep[i] += step->GetTotalEnergyDeposit();
00143   }
00144 }
00145 
00146 //---------------------------------------------------------------------------//
00147 //---------------------------------------------------------------------------//
00148 

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