source: trunk/examples/advanced/human_phantom/src/G4HumanPhantomAnalysisManager.cc@ 1230

Last change on this file since 1230 was 807, checked in by garnier, 17 years ago

update

File size: 5.0 KB
Line 
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//
27// Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy
28//
29// Based on code developed by the undergraduate student G. Guerrieri
30// Note: this is a preliminary beta-version of the code; an improved
31// version will be distributed in the next Geant4 public release, compliant
32// with the design in a forthcoming publication, and subject to a
33// design and code review.
34//
35#ifdef G4ANALYSIS_USE
36#include <stdlib.h>
37#include <fstream>
38#include "G4HumanPhantomAnalysisManager.hh"
39#include "G4ios.hh"
40#include <AIDA/AIDA.h>
41#include "G4RunManager.hh"
42
43G4HumanPhantomAnalysisManager* G4HumanPhantomAnalysisManager::instance = 0;
44
45G4HumanPhantomAnalysisManager::G4HumanPhantomAnalysisManager()
46 : aFact(0), treeFact(0),theTree(0), histogramFactory(0),tupFact(0),
47 ntuple(0), voxelLeftBreast(0), voxelRightBreast(0)
48{
49 aFact = AIDA_createAnalysisFactory();
50 treeFact = aFact -> createTreeFactory();
51}
52
53G4HumanPhantomAnalysisManager::~G4HumanPhantomAnalysisManager()
54{
55 delete voxelRightBreast;
56 voxelRightBreast = 0;
57
58 delete voxelLeftBreast;
59 voxelLeftBreast = 0;
60
61 delete ntuple;
62 ntuple = 0;
63
64 delete tupFact;
65 tupFact =0;
66
67 delete histogramFactory;
68 histogramFactory = 0;
69
70 delete treeFact;
71 treeFact = 0;
72
73 delete theTree;
74 theTree = 0;
75
76 delete aFact;
77 aFact = 0;
78}
79
80G4HumanPhantomAnalysisManager* G4HumanPhantomAnalysisManager::getInstance()
81{
82 if (instance == 0) instance = new G4HumanPhantomAnalysisManager;
83 return instance;
84}
85
86void G4HumanPhantomAnalysisManager::book()
87{
88 G4String fileName = "G4HumanPhantom.hbk";
89 theTree = treeFact->create(fileName,"hbook",false, true);
90
91 histogramFactory = aFact -> createHistogramFactory( *theTree );
92 tupFact = aFact -> createTupleFactory( *theTree );
93
94
95 voxelLeftBreast = histogramFactory->createHistogram2D("100",
96 "Edep(MeV) in LeftBreast, x= slice, y= sector",
97 10, -0.5, 9.5,
98 10, -0.5, 9.5);
99
100 voxelRightBreast = histogramFactory->createHistogram2D("110",
101 "Edep(MeV) in RightBreast, x= slice, y= sector",
102 10, -0.5, 9.5,
103 10, -0.5, 9.5);
104
105
106 // Defining the ntuple columns' name
107 std::string columnNames = "int id; float energy";
108 std::string options = "";
109
110 // Creating a ntuple
111 if (tupFact) ntuple = tupFact -> create("1","1",columnNames, options);
112
113 G4cout<<"Booking !!!!"<<G4endl;
114 }
115
116void G4HumanPhantomAnalysisManager::bodyPartEnergyDeposit(G4int bodyPartID,
117 G4double eDep)
118{
119 if (ntuple == 0)
120 {
121 G4cout << "AAAAAAAGH..... The Ntuple is 0" << G4endl;
122 return;
123 }
124
125 // Fill the ntuple
126
127 // Each organ is identified with an integer
128 G4int indexX = ntuple -> findColumn( "id" );
129 G4int indexEnergy = ntuple -> findColumn( "energy" );
130
131 ntuple -> fill(indexX, bodyPartID);
132 ntuple -> fill(indexEnergy, eDep);
133
134 ntuple->addRow();
135}
136
137void G4HumanPhantomAnalysisManager::voxelLeftBreastEnergyDeposit(G4int slice, G4int sector, G4double edep)
138{
139 // G4cout << "analisis " << slice << " "<< sector << " "<< edep/MeV << G4endl;
140 voxelLeftBreast -> fill(slice,sector, edep);
141}
142
143void G4HumanPhantomAnalysisManager::voxelRightBreastEnergyDeposit(G4int slice, G4int sector, G4double edep)
144{
145 //G4cout << "analisis " << slice << " "<< sector << " "<< edep/MeV << G4endl;
146 voxelRightBreast -> fill(slice,sector, edep);
147}
148
149void G4HumanPhantomAnalysisManager::finish()
150{
151 theTree -> commit();
152 theTree -> close();
153 G4cout<<"closing the hbk file"<<G4endl;
154}
155#endif
Note: See TracBrowser for help on using the repository browser.