source: trunk/examples/advanced/microbeam/src/MicrobeamPhantomConfiguration.cc @ 1341

Last change on this file since 1341 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

  • Property svn:executable set to *
File size: 4.3 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// $Id: MicrobeamPhantomConfiguration.cc,v 1.9 2010/06/25 09:41:03 gunter Exp $
28// -------------------------------------------------------------------
29
30#include "MicrobeamPhantomConfiguration.hh"
31
32G4int MicrobeamPhantomConfiguration::phantomTotalPixels = 0;
33G4int MicrobeamPhantomConfiguration::nucleusTotalPixels = 0;
34G4int MicrobeamPhantomConfiguration::cytoplasmTotalPixels = 0;
35G4float MicrobeamPhantomConfiguration::dx = 0;
36G4float MicrobeamPhantomConfiguration::dy = 0;
37G4float MicrobeamPhantomConfiguration::dz = 0;
38G4float MicrobeamPhantomConfiguration::nucleusMass = 0;
39G4float MicrobeamPhantomConfiguration::cytoplasmMass = 0;
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42
43MicrobeamPhantomConfiguration::MicrobeamPhantomConfiguration() {
44Initialize();
45}
46
47MicrobeamPhantomConfiguration::~MicrobeamPhantomConfiguration()
48{
49  delete[] voxelThreeVector;
50}
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53
54G4int MicrobeamPhantomConfiguration::Initialize() {
55
56  G4int ncols;
57  G4float vx, vy, vz, tmp, density;
58  G4int den, mat;
59  G4float denCyto1, denCyto2, denCyto3, denNucl1, denNucl2, denNucl3;
60  FILE* fMap;
61 
62  phantomTotalPixels=0;
63  nucleusTotalPixels=0;
64  cytoplasmTotalPixels=0;
65  dx=0;
66  dy=0;
67  dz=0;
68  nucleusMass=0;
69  cytoplasmMass=0;
70  density=0;
71
72  // READ PHANTOM PARAMETERS
73  fMap = fopen("phantom.dat","r");
74
75  ncols = fscanf(fMap,"%i %i %i",&phantomTotalPixels, &nucleusTotalPixels, &cytoplasmTotalPixels);
76  ncols = fscanf(fMap,"%f %f %f",&dx, &dy, &dz);
77  ncols = fscanf(fMap,"%f %f %f",&tmp, &tmp, &tmp);
78  ncols = fscanf(fMap,"%f %f %f",&denCyto1, &denCyto2, &denCyto3);
79  ncols = fscanf(fMap,"%f %f %f",&denNucl1, &denNucl2, &denNucl3);
80  dx = dx * micrometer;
81  dy = dy * micrometer;
82  dz = dz * micrometer;
83  voxelThreeVector = new G4ThreeVector [phantomTotalPixels];
84
85  for (G4int i=0; i<phantomTotalPixels; i++) 
86  { 
87    ncols = fscanf(fMap,"%f %f %f %i %i %f",&vx, &vy, &vz, &mat, &den, &tmp);
88
89    if (std::abs(mat-2)<1.e-30) // NUCLEUS
90        {
91          if (std::abs(den-1)<1.e-30) density = denNucl1*(g/cm3);
92          if (std::abs(den-2)<1.e-30) density = denNucl2*(g/cm3);
93          if (std::abs(den-3)<1.e-30) density = denNucl3*(g/cm3);
94          nucleusMass   = nucleusMass   + density * dx * dy * dz ;
95        }
96
97    if (std::abs(mat-1)<1.e-30) // CYTOPLASM
98        { 
99          if (std::abs(den-1)<1e-30) density = denCyto1*(g/cm3);
100          if (std::abs(den-2)<1e-30) density = denCyto2*(g/cm3);
101          if (std::abs(den-3)<1e-30) density = denCyto3*(g/cm3);
102          cytoplasmMass = cytoplasmMass + density * dx * dy * dz ;
103        }
104   
105    G4ThreeVector v(vx,vy,vz);
106    voxelThreeVector[i] = v;
107  }
108
109  fclose(fMap);
110
111  return 0;
112}
113
114
Note: See TracBrowser for help on using the repository browser.