Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/purging_magnet/src/PurgMagDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.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/purging_magnet/src/PurgMagDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/purging_magnet/src/PurgMagDetectorConstruction.cc (Version 9.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Code developed by:                              26 // Code developed by:
 27 //  S.Larsson                                      27 //  S.Larsson
 28 //                                                 28 //
 29 //    ****************************************     29 //    *****************************************
 30 //    *                                            30 //    *                                       *
 31 //    *    PurgMagDetectorConstruction.cc          31 //    *    PurgMagDetectorConstruction.cc     *
 32 //    *                                            32 //    *                                       *
 33 //    ****************************************     33 //    *****************************************
 34 //                                                 34 //
                                                   >>  35 // $Id: PurgMagDetectorConstruction.cc,v 1.4 2006/06/29 16:06:11 gunter Exp $
                                                   >>  36 // GEANT4 tag $Name: geant4-09-00 $
 35 //                                                 37 //
 36 #include "PurgMagDetectorConstruction.hh"          38 #include "PurgMagDetectorConstruction.hh"
 37 #include "PurgMagTabulatedField3D.hh"              39 #include "PurgMagTabulatedField3D.hh"
 38 #include "globals.hh"                          << 
 39 #include "G4PhysicalConstants.hh"              << 
 40 #include "G4SystemOfUnits.hh"                  << 
 41 #include "G4ThreeVector.hh"                        40 #include "G4ThreeVector.hh"
                                                   >>  41 #include "globals.hh"
 42 #include "G4Material.hh"                           42 #include "G4Material.hh"
 43 #include "G4Box.hh"                                43 #include "G4Box.hh"
 44 #include "G4Trd.hh"                                44 #include "G4Trd.hh"
 45 #include "G4Tubs.hh"                               45 #include "G4Tubs.hh"
 46 #include "G4LogicalVolume.hh"                      46 #include "G4LogicalVolume.hh"
 47 #include "G4PVPlacement.hh"                        47 #include "G4PVPlacement.hh"
 48 #include "G4PVReplica.hh"                          48 #include "G4PVReplica.hh"
 49 #include "G4PVParameterised.hh"                    49 #include "G4PVParameterised.hh"
 50 #include "G4Mag_UsualEqRhs.hh"                     50 #include "G4Mag_UsualEqRhs.hh"
 51 #include "G4FieldManager.hh"                       51 #include "G4FieldManager.hh"
 52 #include "G4TransportationManager.hh"              52 #include "G4TransportationManager.hh"
 53 #include "G4EqMagElectricField.hh"                 53 #include "G4EqMagElectricField.hh"
 54                                                    54 
 55 #include "G4ChordFinder.hh"                        55 #include "G4ChordFinder.hh"
 56 #include "G4UniformMagField.hh"                    56 #include "G4UniformMagField.hh"
 57 #include "G4ExplicitEuler.hh"                      57 #include "G4ExplicitEuler.hh"
 58 #include "G4ImplicitEuler.hh"                      58 #include "G4ImplicitEuler.hh"
 59 #include "G4SimpleRunge.hh"                        59 #include "G4SimpleRunge.hh"
 60 #include "G4SimpleHeum.hh"                         60 #include "G4SimpleHeum.hh"
 61 #include "G4ClassicalRK4.hh"                       61 #include "G4ClassicalRK4.hh"
 62 #include "G4HelixExplicitEuler.hh"                 62 #include "G4HelixExplicitEuler.hh"
 63 #include "G4HelixImplicitEuler.hh"                 63 #include "G4HelixImplicitEuler.hh"
 64 #include "G4HelixSimpleRunge.hh"                   64 #include "G4HelixSimpleRunge.hh"
 65 #include "G4CashKarpRKF45.hh"                      65 #include "G4CashKarpRKF45.hh"
 66 #include "G4RKG3_Stepper.hh"                       66 #include "G4RKG3_Stepper.hh"
 67                                                    67 
 68 #include "G4VisAttributes.hh"                      68 #include "G4VisAttributes.hh"
 69 #include "G4Colour.hh"                             69 #include "G4Colour.hh"
 70 #include "G4UnitsTable.hh"                         70 #include "G4UnitsTable.hh"
 71 #include "G4ios.hh"                                71 #include "G4ios.hh"
 72                                                    72 
 73 //....oooOO0OOooo........oooOO0OOooo........oo     73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 74 // Possibility to turn off (0) magnetic field      74 // Possibility to turn off (0) magnetic field and measurement volume. 
 75 #define GAP 1          // Magnet geometric vol     75 #define GAP 1          // Magnet geometric volume
 76 #define MAG 1          // Magnetic field grid      76 #define MAG 1          // Magnetic field grid
 77 #define MEASUREVOL 1   // Volume for measureme     77 #define MEASUREVOL 1   // Volume for measurement
 78                                                    78 
 79 //....oooOO0OOooo........oooOO0OOooo........oo     79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 80                                                    80 
 81 PurgMagDetectorConstruction::PurgMagDetectorCo     81 PurgMagDetectorConstruction::PurgMagDetectorConstruction()
 82                                                    82 
 83   :physiWorld(NULL), logicWorld(NULL), solidWo     83   :physiWorld(NULL), logicWorld(NULL), solidWorld(NULL),
 84    physiGap1(NULL), logicGap1(NULL), solidGap1     84    physiGap1(NULL), logicGap1(NULL), solidGap1(NULL),
 85    physiGap2(NULL), logicGap2(NULL), solidGap2     85    physiGap2(NULL), logicGap2(NULL), solidGap2(NULL),
 86    physiMeasureVolume(NULL), logicMeasureVolum <<  86    physiMeasureVolume(NULL), logicMeasureVolume(NULL), solidMeasureVolume(NULL),
 87    solidMeasureVolume(NULL),                   << 
 88    WorldMaterial(NULL),                            87    WorldMaterial(NULL), 
 89    GapMaterial(NULL)                               88    GapMaterial(NULL)
 90                                                    89     
 91 {                                                  90 {
 92   fField.Put(0);                               << 
 93   WorldSizeXY=WorldSizeZ=0;                        91   WorldSizeXY=WorldSizeZ=0;
 94   GapSizeX1=GapSizeX2=GapSizeY1=GapSizeY2=GapS     92   GapSizeX1=GapSizeX2=GapSizeY1=GapSizeY2=GapSizeZ=0;
 95   MeasureVolumeSizeXY=MeasureVolumeSizeZ=0;        93   MeasureVolumeSizeXY=MeasureVolumeSizeZ=0;
 96 }                                                  94 }  
 97                                                    95 
 98 //....oooOO0OOooo........oooOO0OOooo........oo     96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 99                                                    97 
100 PurgMagDetectorConstruction::~PurgMagDetectorC     98 PurgMagDetectorConstruction::~PurgMagDetectorConstruction()
101 {}                                                 99 {}
102                                                   100 
103 //....oooOO0OOooo........oooOO0OOooo........oo    101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
104                                                   102 
105 G4VPhysicalVolume* PurgMagDetectorConstruction    103 G4VPhysicalVolume* PurgMagDetectorConstruction::Construct()
106                                                   104 
107 {                                                 105 {
108   DefineMaterials();                              106   DefineMaterials();
109   return ConstructCalorimeter();                  107   return ConstructCalorimeter();
110 }                                                 108 }
111                                                   109 
112 //....oooOO0OOooo........oooOO0OOooo........oo    110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113                                                   111 
114 void PurgMagDetectorConstruction::DefineMateri    112 void PurgMagDetectorConstruction::DefineMaterials()
115 {                                                 113 { 
116   //This function illustrates the possible way    114   //This function illustrates the possible ways to define materials.
117   //Density and mass per mole taken from Physi    115   //Density and mass per mole taken from Physics Handbook for Science
118   //and engineering, sixth edition. This is a     116   //and engineering, sixth edition. This is a general material list
119   //with extra materials for other examples.      117   //with extra materials for other examples.
120                                                   118   
121   G4String name, symbol;                          119   G4String name, symbol;             
122   G4double density;                               120   G4double density;            
123                                                   121   
124   G4int ncomponents, natoms;                      122   G4int ncomponents, natoms;
125   G4double fractionmass;                          123   G4double fractionmass;
126   G4double temperature, pressure;                 124   G4double temperature, pressure;
127                                                   125   
128   // Define Elements                              126   // Define Elements  
129   // Example: G4Element* Notation  = new G4Ele    127   // Example: G4Element* Notation  = new G4Element ("Element", "Notation", z, a);
130   G4Element*   H  = new G4Element ("Hydrogen",    128   G4Element*   H  = new G4Element ("Hydrogen", "H", 1. ,  1.01*g/mole);
131   G4Element*   N  = new G4Element ("Nitrogen",    129   G4Element*   N  = new G4Element ("Nitrogen", "N", 7., 14.01*g/mole);
132   G4Element*   O  = new G4Element ("Oxygen"  ,    130   G4Element*   O  = new G4Element ("Oxygen"  , "O", 8. , 16.00*g/mole);
133   G4Element*   Ar = new G4Element ("Argon" , "    131   G4Element*   Ar = new G4Element ("Argon" , "Ar", 18., 39.948*g/mole );
134                                                   132   
135                                                   133   
136   // Define Material                              134   // Define Material
137   // Example: G4Material* Notation = new G4Mat    135   // Example: G4Material* Notation = new G4Material("Material", z, a, density);
138   /* Not used in this setup, will be used in f    136   /* Not used in this setup, will be used in further development.
139   G4Material* He = new G4Material("Helium", 2.    137   G4Material* He = new G4Material("Helium", 2., 4.00*g/mole, 0.178*mg/cm3);
140   G4Material* Be = new G4Material("Beryllium",    138   G4Material* Be = new G4Material("Beryllium", 4., 9.01*g/mole, 1.848*g/cm3);
141   G4Material* W  = new G4Material("Tungsten",     139   G4Material* W  = new G4Material("Tungsten", 74., 183.85*g/mole, 19.30*g/cm3);
142   G4Material* Cu = new G4Material("Copper", 29    140   G4Material* Cu = new G4Material("Copper", 29., 63.55*g/mole, 8.96*g/cm3);
143   */                                              141   */
144   G4Material* Fe = new G4Material("Iron", 26.,    142   G4Material* Fe = new G4Material("Iron", 26., 55.84*g/mole, 7.87*g/cm3);  
145                                                   143 
146   // Define materials from elements.              144   // Define materials from elements.
147                                                   145   
148   // Case 1: chemical molecule                    146   // Case 1: chemical molecule  
149   // Water                                        147   // Water 
150   density = 1.000*g/cm3;                          148   density = 1.000*g/cm3;
151   G4Material* H2O = new G4Material(name="H2O"     149   G4Material* H2O = new G4Material(name="H2O"  , density, ncomponents=2);
152   H2O->AddElement(H, natoms=2);                   150   H2O->AddElement(H, natoms=2);
153   H2O->AddElement(O, natoms=1);                   151   H2O->AddElement(O, natoms=1);
154                                                   152   
155   // Case 2: mixture by fractional mass.          153   // Case 2: mixture by fractional mass.
156   // Air                                          154   // Air
157   density = 1.290*mg/cm3;                         155   density = 1.290*mg/cm3;
158   G4Material* Air = new G4Material(name="Air"     156   G4Material* Air = new G4Material(name="Air"  , density, ncomponents=2);
159   Air->AddElement(N, fractionmass=0.7);           157   Air->AddElement(N, fractionmass=0.7);
160   Air->AddElement(O, fractionmass=0.3);           158   Air->AddElement(O, fractionmass=0.3);
161                                                   159 
162   // Vacuum                                       160   // Vacuum
163   density     = 1.e-5*g/cm3;                      161   density     = 1.e-5*g/cm3;
164   pressure    = 2.e-2*bar;                        162   pressure    = 2.e-2*bar;
165   temperature = STP_Temperature;         //fro    163   temperature = STP_Temperature;         //from PhysicalConstants.h
166   G4Material* vacuum = new G4Material(name="va    164   G4Material* vacuum = new G4Material(name="vacuum", density, ncomponents=1,
167                                       kStateGa    165                                       kStateGas,temperature,pressure);
168   vacuum->AddMaterial(Air, fractionmass=1.);      166   vacuum->AddMaterial(Air, fractionmass=1.);
169                                                   167 
170                                                   168 
171   // Laboratory vacuum: Dry air (average compo    169   // Laboratory vacuum: Dry air (average composition)
172   density = 1.7836*mg/cm3 ;       // STP          170   density = 1.7836*mg/cm3 ;       // STP
173   G4Material* Argon = new G4Material(name="Arg    171   G4Material* Argon = new G4Material(name="Argon", density, ncomponents=1);
174   Argon->AddElement(Ar, 1);                       172   Argon->AddElement(Ar, 1);
175                                                   173   
176   density = 1.25053*mg/cm3 ;       // STP         174   density = 1.25053*mg/cm3 ;       // STP
177   G4Material* Nitrogen = new G4Material(name="    175   G4Material* Nitrogen = new G4Material(name="N2", density, ncomponents=1);
178   Nitrogen->AddElement(N, 2);                     176   Nitrogen->AddElement(N, 2);
179                                                   177   
180   density = 1.4289*mg/cm3 ;       // STP          178   density = 1.4289*mg/cm3 ;       // STP
181   G4Material* Oxygen = new G4Material(name="O2    179   G4Material* Oxygen = new G4Material(name="O2", density, ncomponents=1);
182   Oxygen->AddElement(O, 2);                       180   Oxygen->AddElement(O, 2);
183                                                   181   
184                                                   182   
185   density  = 1.2928*mg/cm3 ;       // STP         183   density  = 1.2928*mg/cm3 ;       // STP
186   density *= 1.0e-8 ;              // pumped v    184   density *= 1.0e-8 ;              // pumped vacuum
187                                                   185   
188   temperature = STP_Temperature;                  186   temperature = STP_Temperature;
189   pressure = 1.0e-8*STP_Pressure;                 187   pressure = 1.0e-8*STP_Pressure;
190                                                   188 
191   G4Material* LaboratoryVacuum = new G4Materia    189   G4Material* LaboratoryVacuum = new G4Material(name="LaboratoryVacuum",
192             density,ncomponents=3,                190             density,ncomponents=3,
193             kStateGas,temperature,pressure);      191             kStateGas,temperature,pressure);
194   LaboratoryVacuum->AddMaterial( Nitrogen, fra    192   LaboratoryVacuum->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ;
195   LaboratoryVacuum->AddMaterial( Oxygen,   fra    193   LaboratoryVacuum->AddMaterial( Oxygen,   fractionmass = 0.2315 ) ;
196   LaboratoryVacuum->AddMaterial( Argon,    fra    194   LaboratoryVacuum->AddMaterial( Argon,    fractionmass = 0.0128 ) ;
197                                                   195   
198                                                   196 
199   G4cout << G4endl << *(G4Material::GetMateria    197   G4cout << G4endl << *(G4Material::GetMaterialTable()) << G4endl;
200                                                   198 
201                                                   199 
202   // Default materials in setup.                  200   // Default materials in setup.
203   WorldMaterial = LaboratoryVacuum;               201   WorldMaterial = LaboratoryVacuum;
204   GapMaterial = Fe;                               202   GapMaterial = Fe;
205                                                   203 
206                                                   204 
207   G4cout << "end material"<< G4endl;           << 205   G4cout << "end material"<< endl;  
208 }                                                 206 }
209                                                   207 
210 //....oooOO0OOooo........oooOO0OOooo........oo    208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
211 G4VPhysicalVolume* PurgMagDetectorConstruction    209 G4VPhysicalVolume* PurgMagDetectorConstruction::ConstructCalorimeter()
212 {                                                 210 {
213   // Complete the parameters definition           211   // Complete the parameters definition
214                                                   212   
215   //The World                                     213   //The World
216   WorldSizeXY  = 300.*cm;  // Cube                214   WorldSizeXY  = 300.*cm;  // Cube
217   WorldSizeZ   = 300.*cm;                         215   WorldSizeZ   = 300.*cm;
218                                                   216   
219   //Measurement volume                            217   //Measurement volume
220   MeasureVolumeSizeXY = 280.*cm;  // Cubic sli    218   MeasureVolumeSizeXY = 280.*cm;  // Cubic slice
221   MeasureVolumeSizeZ  = 1.*cm;                    219   MeasureVolumeSizeZ  = 1.*cm; 
222                                                   220 
223   // Position of measurement volume.              221   // Position of measurement volume. 
224   // SSD is Source to Surface Distance. Source    222   // SSD is Source to Surface Distance. Source in origo and measurements 50 cm 
225   // below in the z-direction (symbolizin a pa    223   // below in the z-direction (symbolizin a patient at SSD = 50 cm)
226                                                   224  
227   SSD = 50.*cm;                                   225   SSD = 50.*cm;
228   MeasureVolumePosition = -(SSD + MeasureVolum    226   MeasureVolumePosition = -(SSD + MeasureVolumeSizeZ/2); 
229                                                   227   
230                                                   228 
231   // Geometric definition of the gap of the pu    229   // Geometric definition of the gap of the purging magnet. Approximation of
232   // the shape of the pole gap.                   230   // the shape of the pole gap.    
233                                                   231 
234   GapSizeY1 = 10.*cm;    // length along x at     232   GapSizeY1 = 10.*cm;    // length along x at the surface positioned at -dz
235   GapSizeY2 = 10.*cm;    // length along x at     233   GapSizeY2 = 10.*cm;    // length along x at the surface positioned at +dz
236   GapSizeX1 = 10.*cm;    // length along y at     234   GapSizeX1 = 10.*cm;    // length along y at the surface positioned at -dz
237   GapSizeX2 = 18.37*cm;  // length along y at     235   GapSizeX2 = 18.37*cm;  // length along y at the surface positioned at +dz
238   GapSizeZ  = 11.5*cm;   // length along z axi    236   GapSizeZ  = 11.5*cm;   // length along z axis
239                                                   237 
240   Gap1PosY = 0.*cm;                               238   Gap1PosY = 0.*cm;
241   Gap1PosX = -9.55*cm;                            239   Gap1PosX = -9.55*cm;
242   Gap1PosZ = -6.89*cm;                            240   Gap1PosZ = -6.89*cm;
243                                                   241 
244   Gap2PosY = 0.*cm;                               242   Gap2PosY = 0.*cm;
245   Gap2PosX = 9.55*cm;                             243   Gap2PosX = 9.55*cm;
246   Gap2PosZ = -6.89*cm;                            244   Gap2PosZ = -6.89*cm;
247                                                   245 
248                                                   246 
249   // Coordinate correction for field grif.        247   // Coordinate correction for field grif. 
250   // Gap opening at z = -11.4 mm.                 248   // Gap opening at z = -11.4 mm.
251   // In field grid coordonates gap at z = -0.0    249   // In field grid coordonates gap at z = -0.007m in field from z = 0.0m to 
252   // z = 0.087m.                                  250   // z = 0.087m.
253   // -> zOffset = -11.4-(-7) = 4.4 mm             251   // -> zOffset = -11.4-(-7) = 4.4 mm
254                                                   252 
255   zOffset = 4.4*mm;                               253   zOffset = 4.4*mm;  
256                                                   254 
257 //....oooOO0OOooo........oooOO0OOooo........oo    255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
258 //                                                256 // 
                                                   >> 257 //  Magnetic Field - Purging magnet
                                                   >> 258 //
                                                   >> 259 #if MAG
                                                   >> 260 
                                                   >> 261   static G4bool fieldIsInitialized = false;
                                                   >> 262   if(!fieldIsInitialized)
                                                   >> 263     {
                                                   >> 264       G4FieldManager   *pFieldMgr;
                                                   >> 265       // G4MagIntegratorStepper *pStepper;
                                                   >> 266       
                                                   >> 267       //Field grid in A9.TABLE. File must be in accessible from run urn directory. 
                                                   >> 268       G4MagneticField* PurgMagField= new PurgMagTabulatedField3D("PurgMag3D.TABLE", zOffset);
                                                   >> 269       
                                                   >> 270       pFieldMgr=G4TransportationManager::GetTransportationManager()->GetFieldManager();
                                                   >> 271       
                                                   >> 272       G4cout<< "DeltaStep "<<pFieldMgr->GetDeltaOneStep()/mm <<"mm" <<endl;
                                                   >> 273       
                                                   >> 274       G4ChordFinder *pChordFinder = new G4ChordFinder(PurgMagField);
                                                   >> 275       pFieldMgr->SetChordFinder( pChordFinder );
                                                   >> 276       
                                                   >> 277       pFieldMgr->SetDetectorField(PurgMagField);
                                                   >> 278       
                                                   >> 279       fieldIsInitialized = true;
                                                   >> 280     }
                                                   >> 281 #endif
                                                   >> 282 
259 //....oooOO0OOooo........oooOO0OOooo........oo    283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
260                                                   284 
261 // Some out prints of the setup.                  285 // Some out prints of the setup. 
262                                                   286   
263   G4cout << "\n-------------------------------    287   G4cout << "\n-----------------------------------------------------------"
264    << "\n      Geometry and materials"            288    << "\n      Geometry and materials"
265    << "\n-------------------------------------    289    << "\n-----------------------------------------------------------"
266    << "\n ---> World:"                            290    << "\n ---> World:" 
267    << "\n ---> " << WorldMaterial->GetName() <    291    << "\n ---> " << WorldMaterial->GetName() << " in World"
268    << "\n ---> " << "WorldSizeXY: " << G4BestU    292    << "\n ---> " << "WorldSizeXY: " << G4BestUnit(WorldSizeXY,"Length")
269    << "\n ---> " << "WorldSizeZ: " << G4BestUn    293    << "\n ---> " << "WorldSizeZ: " << G4BestUnit(WorldSizeZ,"Length");
270                                                   294   
271 #if GAP                                           295 #if GAP
272   G4cout << "\n-------------------------------    296   G4cout << "\n-----------------------------------------------------------"
273    << "\n ---> Purging Magnet:"                   297    << "\n ---> Purging Magnet:" 
274    << "\n ---> " << "Gap made of "<< GapMateri    298    << "\n ---> " << "Gap made of "<< GapMaterial->GetName() 
275    << "\n ---> " << "GapSizeY1: " << G4BestUni    299    << "\n ---> " << "GapSizeY1: " << G4BestUnit(GapSizeY1,"Length") 
276    << "\n ---> " << "GapSizeY2: " << G4BestUni    300    << "\n ---> " << "GapSizeY2: " << G4BestUnit(GapSizeY2,"Length") 
277    << "\n ---> " << "GapSizeX1: " << G4BestUni    301    << "\n ---> " << "GapSizeX1: " << G4BestUnit(GapSizeX1,"Length") 
278    << "\n ---> " << "GapSizeX2: " << G4BestUni    302    << "\n ---> " << "GapSizeX2: " << G4BestUnit(GapSizeX2,"Length");
279 #endif                                            303 #endif
280                                                   304   
281 #if MEASUREVOL                                    305 #if MEASUREVOL
282   G4cout << "\n-------------------------------    306   G4cout << "\n-----------------------------------------------------------"
283    << "\n ---> Measurement Volume:"               307    << "\n ---> Measurement Volume:" 
284    << "\n ---> " << WorldMaterial->GetName() <    308    << "\n ---> " << WorldMaterial->GetName() << " in Measurement volume"
285    << "\n ---> " << "MeasureVolumeXY: " << G4B    309    << "\n ---> " << "MeasureVolumeXY: " << G4BestUnit(MeasureVolumeSizeXY,"Length") 
286    << "\n ---> " << "MeasureVolumeZ: " << G4Be    310    << "\n ---> " << "MeasureVolumeZ: " << G4BestUnit(MeasureVolumeSizeZ,"Length")
287    << "\n ---> " << "At SSD =  " << G4BestUnit    311    << "\n ---> " << "At SSD =  " << G4BestUnit(MeasureVolumePosition,"Length");
288 #endif                                            312 #endif
289                                                   313   
290   G4cout << "\n-------------------------------    314   G4cout << "\n-----------------------------------------------------------\n";
291                                                   315   
292                                                   316     
293 //....oooOO0OOooo........oooOO0OOooo........oo    317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
294   //                                              318   //     
295   // World                                        319   // World
296   //                                              320   //
297                                                   321   
298                                                   322 
299   solidWorld = new G4Box("World",                 323   solidWorld = new G4Box("World",              //its name
300          WorldSizeXY/2,WorldSizeXY/2,WorldSize    324          WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2);  //its size
301                                                   325   
302                                                   326 
303   logicWorld = new G4LogicalVolume(solidWorld,    327   logicWorld = new G4LogicalVolume(solidWorld,          //its solid
304            WorldMaterial, //its material          328            WorldMaterial, //its material
305            "World");    //its name                329            "World");    //its name
306                                                   330   
307   physiWorld = new G4PVPlacement(0,     //no r    331   physiWorld = new G4PVPlacement(0,     //no rotation
308            G4ThreeVector(), //at (0,0,0)          332            G4ThreeVector(), //at (0,0,0)
309                                  "World",   //    333                                  "World",   //its name
310                                  logicWorld,      334                                  logicWorld,    //its logical volume
311                                  NULL,      //    335                                  NULL,      //its mother  volume
312                                  false,     //    336                                  false,     //no boolean operation
313                                  0);      //co    337                                  0);      //copy number
314                                                   338 
315   // Visualization attributes                     339   // Visualization attributes
316   G4VisAttributes* simpleWorldVisAtt= new G4Vi    340   G4VisAttributes* simpleWorldVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); //White
317   simpleWorldVisAtt->SetVisibility(true);         341   simpleWorldVisAtt->SetVisibility(true);
318   logicWorld->SetVisAttributes(simpleWorldVisA    342   logicWorld->SetVisAttributes(simpleWorldVisAtt);
319                                                   343  
320                                                   344 
321 //....oooOO0OOooo........oooOO0OOooo........oo    345 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
322   //                                              346   //     
323   // Measurement Volume                           347   // Measurement Volume
324   //                                              348   //
325                                                   349   
326 #if MEASUREVOL                                    350 #if MEASUREVOL
327                                                   351 
328   solidMeasureVolume = new G4Box("MeasureVolum    352   solidMeasureVolume = new G4Box("MeasureVolume",              //its name
329                    MeasureVolumeSizeXY/2,Measu    353                    MeasureVolumeSizeXY/2,MeasureVolumeSizeXY/2,MeasureVolumeSizeZ/2);  //its size
330                                                   354 
331   logicMeasureVolume = new G4LogicalVolume(sol    355   logicMeasureVolume = new G4LogicalVolume(solidMeasureVolume,  //its solid
332                                    WorldMateri    356                                    WorldMaterial,         //its material
333                                    "MeasureVol    357                                    "MeasureVolume");    //its name
334                                                   358                                    
335   physiMeasureVolume = new G4PVPlacement(0,       359   physiMeasureVolume = new G4PVPlacement(0,                  //no rotation
336            G4ThreeVector(0.,0.,MeasureVolumePo    360            G4ThreeVector(0.,0.,MeasureVolumePosition), //at (0,0,0)
337                                  "MeasureVolum    361                                  "MeasureVolume",                //its name
338                                  logicMeasureV    362                                  logicMeasureVolume,                 //its logical volume
339                                  physiWorld,      363                                  physiWorld,                   //its mother  volume
340                                  false,           364                                  false,                          //no boolean operation
341                                  0);              365                                  0);                           //copy number
342                                                   366 
343   // Visualization attributes                     367   // Visualization attributes
344   G4VisAttributes* simpleMeasureVolumeVisAtt=     368   G4VisAttributes* simpleMeasureVolumeVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); //White
345   simpleMeasureVolumeVisAtt->SetVisibility(tru    369   simpleMeasureVolumeVisAtt->SetVisibility(true);
346   simpleMeasureVolumeVisAtt->SetForceSolid(tru    370   simpleMeasureVolumeVisAtt->SetForceSolid(true);
347   logicMeasureVolume->SetVisAttributes(simpleM    371   logicMeasureVolume->SetVisAttributes(simpleMeasureVolumeVisAtt);
348                                                   372 
349 #endif                                            373 #endif
350                                                   374 
351 //....oooOO0OOooo........oooOO0OOooo........oo    375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
352   //                                              376   //                              
353   //Gap cone. Opening 20 deg. Two separate tra    377   //Gap cone. Opening 20 deg. Two separate trapezoids. Iron.
354   //                                              378   // 
355                                                   379 
356 #if GAP                                           380 #if GAP
357                                                   381 
358   //Gap part 1, placed in negative x-direction    382   //Gap part 1, placed in negative x-direction.
359                                                   383 
360   solidGap1 = new G4Trd("Gap1",                   384   solidGap1 = new G4Trd("Gap1",
361       GapSizeX1/2,  // Half-length along x at     385       GapSizeX1/2,  // Half-length along x at the surface positioned at -dz
362       GapSizeX2/2,  // Half-length along x at     386       GapSizeX2/2,  // Half-length along x at the surface positioned at +dz
363       GapSizeY1/2,  // Half-length along y at     387       GapSizeY1/2,  // Half-length along y at the surface positioned at -dz
364       GapSizeY2/2,  // Half-length along y at     388       GapSizeY2/2,  // Half-length along y at the surface positioned at +dz
365       GapSizeZ/2 ); // Half-length along z axi    389       GapSizeZ/2 ); // Half-length along z axis
366                                                   390   
367   logicGap1 = new G4LogicalVolume(solidGap1,      391   logicGap1 = new G4LogicalVolume(solidGap1,            //its solid
368           GapMaterial,          //its material    392           GapMaterial,          //its material
369           "Gap1");              //its name        393           "Gap1");              //its name
370                                                   394   
371   physiGap1 = new G4PVPlacement(0,                395   physiGap1 = new G4PVPlacement(0,                          //90 deg rotation
372         G4ThreeVector(Gap1PosX,Gap1PosY,Gap1Po    396         G4ThreeVector(Gap1PosX,Gap1PosY,Gap1PosZ),  //position
373         "Gap1",                       //its na    397         "Gap1",                       //its name
374         logicGap1,                        //it    398         logicGap1,                        //its logical volume
375         physiWorld,                       //it    399         physiWorld,                       //its mother  volume
376         false,                          //no b    400         false,                          //no boolean operation
377         0);                         //copy num    401         0);                         //copy number
378                                                   402   
379   //Gap part 2, placed in positive x-direction    403   //Gap part 2, placed in positive x-direction.
380                                                   404 
381   solidGap2 = new G4Trd("Gap2",                   405   solidGap2 = new G4Trd("Gap2",
382                   GapSizeX1/2,  // Half-length    406                   GapSizeX1/2,  // Half-length along x at the surface positioned at -dz
383             GapSizeX2/2,  // Half-length along    407             GapSizeX2/2,  // Half-length along x at the surface positioned at +dz
384                   GapSizeY1/2,  // Half-length    408                   GapSizeY1/2,  // Half-length along y at the surface positioned at -dz
385       GapSizeY2/2,  // Half-length along y at     409       GapSizeY2/2,  // Half-length along y at the surface positioned at +dz
386                   GapSizeZ/2 ); // Half-length    410                   GapSizeZ/2 ); // Half-length along z axis
387                                                   411   
388   logicGap2 = new G4LogicalVolume(solidGap2,      412   logicGap2 = new G4LogicalVolume(solidGap2,          //its solid
389           GapMaterial,          //its material    413           GapMaterial,          //its material
390           "Gap2");              //its name        414           "Gap2");              //its name
391                                                   415   
392   physiGap2 = new G4PVPlacement(0,                416   physiGap2 = new G4PVPlacement(0,                          //no rotation
393         G4ThreeVector(Gap2PosX,Gap2PosY,Gap2Po    417         G4ThreeVector(Gap2PosX,Gap2PosY,Gap2PosZ),  //position
394         "Gap2",                         //its     418         "Gap2",                         //its name
395         logicGap2,                      //its     419         logicGap2,                      //its logical volume
396         physiWorld,                     //its     420         physiWorld,                     //its mother  volume
397         false,                        //no boo    421         false,                        //no boolean operation
398         0);                       //copy numbe    422         0);                       //copy number
399                                                   423 
400   // Visualization attributes                     424   // Visualization attributes
401   G4VisAttributes* simpleGap1VisAtt= new G4Vis    425   G4VisAttributes* simpleGap1VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //yellow
402   simpleGap1VisAtt->SetVisibility(true);          426   simpleGap1VisAtt->SetVisibility(true);
403   simpleGap1VisAtt->SetForceSolid(true);          427   simpleGap1VisAtt->SetForceSolid(true);
404   logicGap1->SetVisAttributes(simpleGap1VisAtt    428   logicGap1->SetVisAttributes(simpleGap1VisAtt);
405                                                   429   
406   G4VisAttributes* simpleGap2VisAtt= new G4Vis    430   G4VisAttributes* simpleGap2VisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0)); //yellow
407   simpleGap2VisAtt->SetVisibility(true);          431   simpleGap2VisAtt->SetVisibility(true);
408   simpleGap2VisAtt->SetForceSolid(true);          432   simpleGap2VisAtt->SetForceSolid(true);  
409   logicGap2->SetVisAttributes(simpleGap2VisAtt    433   logicGap2->SetVisAttributes(simpleGap2VisAtt);
410                                                   434 
411 #endif                                            435 #endif
412                                                   436 
413 //....oooOO0OOooo........oooOO0OOooo........oo    437 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
414                                                   438 
415   return physiWorld;                              439   return physiWorld;
416 }                                                 440 }
417 //....oooOO0OOooo........oooOO0OOooo........oo    441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
418                                                   442 
419 void PurgMagDetectorConstruction::ConstructSDa << 
420 {                                              << 
421 //  Magnetic Field - Purging magnet            << 
422 //                                             << 
423 #if MAG                                        << 
424                                                << 
425   if (fField.Get() == 0)                       << 
426     {                                          << 
427       //Field grid in A9.TABLE. File must be i << 
428       G4MagneticField* PurgMagField= new PurgM << 
429       fField.Put(PurgMagField);                << 
430                                                << 
431       //This is thread-local                   << 
432       G4FieldManager* pFieldMgr =              << 
433   G4TransportationManager::GetTransportationMa << 
434                                                << 
435       G4cout<< "DeltaStep "<<pFieldMgr->GetDel << 
436       //G4ChordFinder *pChordFinder = new G4Ch << 
437                                                   443 
438       pFieldMgr->SetDetectorField(fField.Get() << 
439       pFieldMgr->CreateChordFinder(fField.Get( << 
440                                                << 
441     }                                          << 
442 #endif                                         << 
443 }                                              << 
444                                                   444