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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/microbeam/src/CellParameterisation.cc (Version 11.3.0) and /examples/advanced/microbeam/src/CellParameterisation.cc (Version 9.0.p2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // This example is provided by the Geant4-DNA     
 27 // Any report or published results obtained us    
 28 // shall cite the following Geant4-DNA collabo    
 29 // Med. Phys. 37 (2010) 4692-4708                 
 30 // The Geant4-DNA web site is available at htt    
 31 //                                                
 32 // If you use this example, please cite the fo    
 33 // Rad. Prot. Dos. 133 (2009) 2-11                
 34                                                   
 35 #include "CellParameterisation.hh"                
 36 #include "G4LogicalVolume.hh"                     
 37 #include "G4SystemOfUnits.hh"                     
 38                                                   
 39 // SINGLETON                                      
 40 CellParameterisation * CellParameterisation::g    
 41                                                   
 42 CellParameterisation::CellParameterisation        
 43 (G4Material * nucleus1,  G4Material * cytoplas    
 44  G4Material * nucleus2,  G4Material * cytoplas    
 45  G4Material * nucleus3,  G4Material * cytoplas    
 46  )                                                
 47 {                                                 
 48    fNucleusMaterial1   = nucleus1;                
 49    fCytoplasmMaterial1 = cytoplasm1;              
 50    fNucleusMaterial2   = nucleus2;                
 51    fCytoplasmMaterial2 = cytoplasm2;              
 52    fNucleusMaterial3   = nucleus3;                
 53    fCytoplasmMaterial3 = cytoplasm3;              
 54                                                   
 55    G4int ncols,nlines;                            
 56    G4int shiftX, shiftY, shiftZ;                  
 57    G4double x,y,z,mat,den,tmp,density;            
 58    G4double denCyto1, denCyto2, denCyto3, denN    
 59                                                   
 60    ncols = nlines = shiftX = shiftY = shiftZ =    
 61    x = y = z = mat = den = tmp = density =        
 62      denCyto1 = denCyto2 = denCyto3 = denNucl1    
 63                                                   
 64    // READ PHANTOM                                
 65    fNucleusMass = 0;                              
 66    fCytoplasmMass = 0;                            
 67                                                   
 68    fDimCellBoxX = fDimCellBoxY = fDimCellBoxZ     
 69                                                   
 70    FILE *fMap;                                    
 71    fMap = fopen("phantom.dat","r");               
 72                                                   
 73    while (1)                                      
 74    {                                              
 75       if (nlines == 0)                            
 76       {                                           
 77         ncols = fscanf(fMap,"%i %i %i",&fPhant    
 78   fMapCell    = new G4ThreeVector[fPhantomTota    
 79         fMaterial   = new G4double[fPhantomTot    
 80         fMass       = new G4double[fPhantomTot    
 81         fTissueType = new G4int[fPhantomTotalP    
 82       }                                           
 83                                                   
 84       if (nlines == 1)                            
 85       {                                           
 86         ncols = fscanf(fMap,"%lf %lf %lf",&fDi    
 87   fDimCellBoxX=fDimCellBoxX*micrometer;           
 88         fDimCellBoxY=fDimCellBoxY*micrometer;     
 89         fDimCellBoxZ=fDimCellBoxZ*micrometer;     
 90       }                                           
 91                                                   
 92       // VOXEL SHIFT IN Z ASSUMED TO BE NEGATI    
 93       if (nlines == 2) ncols = fscanf(fMap,"%i    
 94                                                   
 95       if (nlines == 3) ncols = fscanf(fMap,"%l    
 96                                                   
 97       if (nlines == 4) ncols = fscanf(fMap,"%l    
 98                                                   
 99       if (nlines >  4) ncols = fscanf(fMap,"%l    
100                                                   
101       if (ncols  <  0) break;                     
102                                                   
103       // VOXEL SHIFT IN ORDER TO CENTER PHANTO    
104       G4ThreeVector v(x+shiftX,y+shiftY,z-1500    
105       if (nlines>4)                               
106       {                                           
107                                                   
108     fMapCell[nlines-5]=v;                         
109     fMaterial[nlines-5]=mat;                      
110     fMass[nlines-5]=den;                          
111                                                   
112     // fTissueType: 1 is Cytoplasm - 2 is Nucl    
113                                                   
114           if( fMaterial[nlines-5] == 2 ) // fM    
115           {                                       
116       if( fMass[nlines-5] == 1 )                  
117     {                                             
118       fTissueType[nlines-5]=2;                    
119     }                                             
120       if( fMass[nlines-5] == 2 )                  
121     {                                             
122       fTissueType[nlines-5]=2;                    
123     }                                             
124       if( fMass[nlines-5] == 3 )                  
125     {                                             
126       fTissueType[nlines-5]=2;                    
127     }                                             
128     }                                             
129                                                   
130           else if( fMaterial[nlines-5] == 1 )     
131     {                                             
132       if( fMass[nlines-5] == 1 )                  
133     {                                             
134       fTissueType[nlines-5]=1;                    
135     }                                             
136       if( fMass[nlines-5] == 2 )                  
137     {                                             
138       fTissueType[nlines-5]=2;                    
139     }                                             
140       if( fMass[nlines-5] == 3 )                  
141     {                                             
142       fTissueType[nlines-5]=1;                    
143     }                                             
144     }                                             
145                                                   
146     //                                            
147                                                   
148     if (std::abs(mat-2)<1.e-30) // NUCLEUS        
149         {                                         
150       if (std::abs(den-1)<1.e-30) density = de    
151       if (std::abs(den-2)<1.e-30) density = de    
152       if (std::abs(den-3)<1.e-30) density = de    
153       fNucleusMass   = fNucleusMass   + densit    
154         }                                         
155                                                   
156           if (std::abs(mat-1)<1.e-30) // CYTOP    
157         {                                         
158       if (std::abs(den-1)<1e-30) density = den    
159       if (std::abs(den-2)<1e-30) density = den    
160       if (std::abs(den-3)<1e-30) density = den    
161       fCytoplasmMass = fCytoplasmMass + densit    
162     }                                             
163                                                   
164       }                                           
165                                                   
166       nlines++;                                   
167    }                                              
168    fclose(fMap);                                  
169                                                   
170   // NUCLEUS IN GREEN                             
171                                                   
172   fNucleusAttributes1 = new G4VisAttributes;      
173   fNucleusAttributes1->SetColour(G4Colour(0,.8    
174   fNucleusAttributes1->SetForceSolid(false);      
175                                                   
176   fNucleusAttributes2 = new G4VisAttributes;      
177   fNucleusAttributes2->SetColour(G4Colour(0,.9    
178   fNucleusAttributes2->SetForceSolid(false);      
179                                                   
180   fNucleusAttributes3 = new G4VisAttributes;      
181   fNucleusAttributes3->SetColour(G4Colour(0,1,    
182   fNucleusAttributes3->SetForceSolid(false);      
183                                                   
184   // CYTOPLASM IN RED                             
185                                                   
186   fCytoplasmAttributes1 = new G4VisAttributes;    
187   fCytoplasmAttributes1->SetColour(G4Colour(1,    
188   fCytoplasmAttributes1->SetForceSolid(false);    
189                                                   
190   fCytoplasmAttributes2 = new G4VisAttributes;    
191   fCytoplasmAttributes2->SetColour(G4Colour(1.    
192   fCytoplasmAttributes2->SetForceSolid(false);    
193                                                   
194   fCytoplasmAttributes3 = new G4VisAttributes;    
195   fCytoplasmAttributes3->SetColour(G4Colour(1,    
196   fCytoplasmAttributes3->SetForceSolid(false);    
197                                                   
198   //                                              
199   gInstance = this;                               
200  }                                                
201                                                   
202 CellParameterisation::~CellParameterisation()     
203 {                                                 
204   delete[] fMapCell;                              
205   delete[] fMaterial;                             
206   delete[] fMass;                                 
207   delete[] fTissueType;                           
208 }                                                 
209                                                   
210 void CellParameterisation::ComputeTransformati    
211 (const G4int copyNo, G4VPhysicalVolume* physVo    
212 {                                                 
213   G4ThreeVector origin                            
214   (                                               
215       fMapCell[copyNo].x()*fDimCellBoxX,          
216       fMapCell[copyNo].y()*fDimCellBoxY,          
217       fMapCell[copyNo].z()*fDimCellBoxZ           
218   );                                              
219                                                   
220   physVol->SetTranslation(origin);                
221 }                                                 
222                                                   
223 void CellParameterisation::ComputeDimensions      
224 (G4Box&, const G4int, const G4VPhysicalVolume*    
225 {}                                                
226                                                   
227 G4Material*                                       
228 CellParameterisation::ComputeMaterial(const G4    
229                                       G4VPhysi    
230                                       const G4    
231 {                                                 
232     if( fMaterial[copyNo] == 2 ) // fMaterial     
233         {                                         
234    if( fMass[copyNo] == 1 )                       
235     {                                             
236       physVol->GetLogicalVolume()->SetVisAttri    
237       return fNucleusMaterial1;                   
238     }                                             
239    if( fMass[copyNo] == 2 )                       
240     {                                             
241       physVol->GetLogicalVolume()->SetVisAttri    
242       return fNucleusMaterial2;                   
243     }                                             
244    if( fMass[copyNo] == 3 )                       
245     {                                             
246       physVol->GetLogicalVolume()->SetVisAttri    
247       return fNucleusMaterial3;                   
248     }                                             
249   }                                               
250                                                   
251     else if( fMaterial[copyNo] == 1 ) // fMate    
252   {                                               
253    if( fMass[copyNo] == 1 )                       
254     {                                             
255       physVol->GetLogicalVolume()->SetVisAttri    
256       return fCytoplasmMaterial1;                 
257     }                                             
258    if( fMass[copyNo] == 2 )                       
259     {                                             
260       // nucleoli so taken as nucleus !           
261       physVol->GetLogicalVolume()->SetVisAttri    
262       return fCytoplasmMaterial2;                 
263     }                                             
264    if( fMass[copyNo] == 3 )                       
265     {                                             
266       physVol->GetLogicalVolume()->SetVisAttri    
267       return fCytoplasmMaterial3;                 
268     }                                             
269   }                                               
270                                                   
271     return physVol->GetLogicalVolume()->GetMat    
272 }                                                 
273