Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 /*
0026 Author: Susanna Guatelli, University of Wollongong, Australia
0027 */
0028 // The class G4HumanPhantomAnalysisManager creates and manages ntuples
0029 
0030 // The analysis was included in this application following the extended Geant4
0031 // example analysis/AnaEx01
0032 
0033 #include "G4HumanPhantomAnalysisManager.hh"
0034 #include "G4UnitsTable.hh"
0035 #include "G4SystemOfUnits.hh"
0036 
0037 G4HumanPhantomAnalysisManager::G4HumanPhantomAnalysisManager()
0038 {
0039 fFactoryOn = false;
0040 
0041 // Initialization ntuple
0042   for (G4int k=0; k<MaxNtCol; k++) {
0043     fNtColId[k] = 0;
0044   }  
0045 }
0046 
0047 void G4HumanPhantomAnalysisManager::book() 
0048 {  
0049   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0050   
0051   analysisManager->SetVerboseLevel(2);
0052  
0053   // Create a root file
0054   G4String fileName = "human_phantom.root";
0055 
0056   // Create directories  
0057   analysisManager->SetNtupleDirectoryName("human_phantom_ntuple");
0058   
0059   G4bool fileOpen = analysisManager->OpenFile(fileName);
0060   if (!fileOpen) {
0061     G4cout << "\n---> HistoManager::book(): cannot open " 
0062            << fileName
0063            << G4endl;
0064     return;
0065   }
0066 
0067   //creating a ntuple, containg 3D energy deposition in the phantom
0068   analysisManager->SetFirstNtupleId(1);
0069   analysisManager->CreateNtuple("1", "3Dedep");
0070   fNtColId[0] = analysisManager->CreateNtupleDColumn("organID");
0071   fNtColId[1] = analysisManager->CreateNtupleDColumn("edep");
0072 
0073   analysisManager->FinishNtuple();
0074   
0075   fFactoryOn = true;    
0076 }
0077 
0078 void G4HumanPhantomAnalysisManager::FillNtupleWithEnergyDeposition(G4int organ,G4double energyDep)
0079 {
0080   if (energyDep !=0)
0081  {
0082   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0083   analysisManager->FillNtupleDColumn(1, fNtColId[0], organ);
0084   analysisManager->FillNtupleDColumn(1, fNtColId[1], energyDep);
0085   analysisManager->AddNtupleRow(1);  
0086   G4cout << "Analysis: organ " << organ << " edep: "<< energyDep << G4endl;  
0087 }
0088  }
0089 
0090 void G4HumanPhantomAnalysisManager::save() 
0091 {  
0092  if (fFactoryOn) 
0093    {
0094     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();    
0095     analysisManager->Write();
0096     analysisManager->CloseFile();  
0097     analysisManager->Clear();  
0098     fFactoryOn = false;
0099    }
0100 }
0101 
0102 
0103 
0104 
0105 
0106 
0107 
0108 
0109 
0110 
0111 
0112