Geant4  10.00.p03
G4HumanPhantomAnalysisManager.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 /*
26 Author: Susanna Guatelli
27 */
28 // The class G4HumanPhantomAnalysisManager creates and manages ntuples
29 
30 // The analysis was included in this application following the extended Geant4
31 // example analysis/AnaEx01
32 
33 #include <stdlib.h>
35 #include "G4UnitsTable.hh"
36 #include "G4SystemOfUnits.hh"
37 
39 {
40 
41 factoryOn = false;
42 
43 // Initialization ntuple
44  for (G4int k=0; k<MaxNtCol; k++) {
45  fNtColId[k] = 0;
46  }
47 }
48 
50 {
51 }
52 
54 {
55  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
56 
57  AnalysisManager->SetVerboseLevel(2);
58 
59  // Create a root file
60  G4String fileName = "human_phantom.root";
61 
62  // Create directories
63  AnalysisManager->SetNtupleDirectoryName("human_phantom_ntuple");
64 
65 
66  G4bool fileOpen = AnalysisManager->OpenFile(fileName);
67  if (!fileOpen) {
68  G4cout << "\n---> HistoManager::book(): cannot open "
69  << fileName
70  << G4endl;
71  return;
72  }
73 
74  //creating a ntuple, containg 3D energy deposition in the phantom
75  AnalysisManager->SetFirstNtupleId(1);
76  AnalysisManager -> CreateNtuple("1", "3Dedep");
77  fNtColId[0] = AnalysisManager->CreateNtupleDColumn("organID");
78  fNtColId[1] = AnalysisManager->CreateNtupleDColumn("edep");
79 
80  AnalysisManager->FinishNtuple();
81 
82  factoryOn = true;
83 }
84 
85 
87 {
88  if (energyDep !=0)
89  {
90  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
91  AnalysisManager->FillNtupleDColumn(1, fNtColId[0], organ);
92  AnalysisManager->FillNtupleDColumn(1, fNtColId[1], energyDep);
93  AnalysisManager->AddNtupleRow(1);
94  G4cout << "Analysis: organ " << organ << " edep: "<< energyDep << G4endl;
95 }
96  }
97 
99 {
100  if (factoryOn)
101  {
102  G4AnalysisManager* AnalysisManager = G4AnalysisManager::Instance();
103  AnalysisManager->Write();
104  AnalysisManager->CloseFile();
105 
106  delete G4AnalysisManager::Instance();
107  factoryOn = false;
108  }
109 }
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
void FillNtupleWithEnergyDeposition(G4int, G4double)
void SetVerboseLevel(G4int verboseLevel)
G4bool SetNtupleDirectoryName(const G4String &dirName)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
bool G4bool
Definition: G4Types.hh:79
G4bool SetFirstNtupleId(G4int firstId)
const G4int MaxNtCol
#define G4endl
Definition: G4ios.hh:61
G4int CreateNtupleDColumn(const G4String &name)
double G4double
Definition: G4Types.hh:76