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.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 ]

  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 /// \file exoticphysics/ucn/src/ExUCNDetectorConstruction.cc
 28 /// \brief Implementation of the ExUCNDetectorConstruction class
 29 //
 30 
 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33 
 34 #include "ExUCNDetectorConstruction.hh"
 35 
 36 #include "G4Box.hh"
 37 #include "G4Colour.hh"
 38 #include "G4FieldManager.hh"
 39 #include "G4GeometryManager.hh"
 40 #include "G4LogicalVolume.hh"
 41 #include "G4LogicalVolumeStore.hh"
 42 #include "G4Material.hh"
 43 #include "G4NistManager.hh"
 44 #include "G4PVPlacement.hh"
 45 #include "G4PhysicalConstants.hh"
 46 #include "G4PhysicalVolumeStore.hh"
 47 #include "G4RepleteEofM.hh"
 48 #include "G4SolidStore.hh"
 49 #include "G4SystemOfUnits.hh"
 50 #include "G4TransportationManager.hh"
 51 #include "G4Tubs.hh"
 52 #include "G4UCNMaterialPropertiesTable.hh"
 53 #include "G4UniformGravityField.hh"
 54 #include "G4UserLimits.hh"
 55 #include "G4VPhysicalVolume.hh"
 56 #include "G4VisAttributes.hh"
 57 // #include "G4EqGravityField.hh"
 58 
 59 #include "G4ChordFinder.hh"
 60 #include "G4ClassicalRK4.hh"
 61 #include "G4MagIntegratorStepper.hh"
 62 #include "G4PropagatorInField.hh"
 63 
 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65 
 66 ExUCNDetectorConstruction::ExUCNDetectorConstruction() : fVacuum(0), fGuideMaterial(0)
 67 {
 68   // materials
 69   DefineMaterials();
 70 }
 71 
 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 73 
 74 ExUCNDetectorConstruction::~ExUCNDetectorConstruction()
 75 {
 76   if (fField) delete fField;
 77 }
 78 
 79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 80 
 81 void ExUCNDetectorConstruction::DefineMaterials()
 82 {
 83   G4NistManager* nistMan = G4NistManager::Instance();
 84 
 85   fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
 86   fGuideMaterial = nistMan->FindOrBuildMaterial("G4_Ni");
 87 
 88   // --- Ni diffuse 10%
 89 
 90   G4UCNMaterialPropertiesTable* MPT = new G4UCNMaterialPropertiesTable();
 91 
 92   //  MPT->AddConstProperty("REFLECTIVITY",1.);
 93   //  Commented out above line as REFLECTIVITY=1 by default in
 94   //  G4OpBoundaryProcess.  Also use AddProperty to set REFLECTIVITY if needed
 95   MPT->AddConstProperty("DIFFUSION", 0.1);
 96   MPT->AddConstProperty("FERMIPOT", 252.0);  // Gollub, Table 2.1 in neV
 97   MPT->AddConstProperty("SPINFLIP", 0.);
 98   MPT->AddConstProperty("LOSS", 12.5e-5);  //  Gollub, Table 2.1
 99   MPT->AddConstProperty("LOSSCS", 0.);
100   MPT->AddConstProperty("ABSCS", 4.49);  // 1/v loss cross-section  at room temp.
101   MPT->AddConstProperty("SCATCS", 18.5);  // (incoherent) "elastic" scattering cs
102 
103   G4double neV = 1.e-9 * eV;
104 
105   MPT->SetMicroRoughnessParameters(30 * nm, 1 * nm, 180, 1000, 0 * degree, 90 * degree, 1 * neV,
106                                    1000 * neV, 15, 15, 0.01 * degree);
107 
108   fGuideMaterial->SetMaterialPropertiesTable(MPT);
109 
110   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
115 G4VPhysicalVolume* ExUCNDetectorConstruction::Construct()
116 {
117   //
118   // World
119   //
120 
121   G4double worldSizeX = 1. * m;
122   G4double worldSizeY = 1. * m;
123   G4double worldSizeZ = 100. * m;
124 
125   G4Box* solidWorld = new G4Box("World", worldSizeX / 2., worldSizeY / 2., worldSizeZ / 2.);
126 
127   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fVacuum, "World");
128 
129   G4VPhysicalVolume* physiWorld =
130     new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
131 
132   // --------------------------------- Guide -------------------------------------
133 
134   G4double GuideR = 35. * mm;
135   G4double GuideW = 2. * mm;
136   G4double GuideL = 6. * m;
137 
138   G4Tubs* solidGuide = new G4Tubs("SolidGuide", GuideR, GuideR + GuideW, GuideL / 2., 0., twopi);
139 
140   G4LogicalVolume* logicGuide = new G4LogicalVolume(solidGuide, fGuideMaterial, "Guide");
141 
142   new G4PVPlacement(0, G4ThreeVector(), "Guide", logicGuide, physiWorld, false, 0);
143 
144   // ------------------------------ End Plate  -----------------------------------
145 
146   G4Tubs* solidEndPlate = new G4Tubs("EndPlate", 0., GuideR, GuideW / 2., 0., twopi);
147 
148   G4LogicalVolume* logicEndPlate = new G4LogicalVolume(solidEndPlate, fVacuum, "EndPlate");
149 
150   G4ThreeVector endPlatePos = G4ThreeVector(0., 0., GuideL / 2. + GuideW / 2.);
151 
152   new G4PVPlacement(0, endPlatePos, "EndPlate", logicEndPlate, physiWorld, false, 0);
153 
154   G4double maxStep = 1.0 * mm;
155   G4double maxTime = 100. * s;
156 
157   G4UserLimits* stepLimit = new G4UserLimits(maxStep, DBL_MAX, maxTime);
158 
159   logicWorld->SetUserLimits(stepLimit);
160 
161   //
162   // Visualization attributes
163   //
164 
165   G4VisAttributes* guideColor = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
166   guideColor->SetVisibility(true);
167   guideColor->SetForceWireframe(true);
168 
169   G4VisAttributes* endPlateColor = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
170   endPlateColor->SetVisibility(true);
171   endPlateColor->SetForceSolid(true);
172 
173   logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
174   logicGuide->SetVisAttributes(guideColor);
175   logicEndPlate->SetVisAttributes(endPlateColor);
176 
177   //
178   // always return the physical World
179   //
180   return physiWorld;
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184 
185 G4ThreadLocal G4UniformGravityField* ExUCNDetectorConstruction::fField = 0;
186 
187 void ExUCNDetectorConstruction::ConstructSDandField()
188 {
189   if (!fField) {
190     fField = new G4UniformGravityField();
191 
192     G4RepleteEofM* equation = new G4RepleteEofM(fField);
193     //     G4RepleteEofM* equation = new G4RepleteEofM(fField,12);
194     //     G4EqGravityField* equation = new G4EqGravityField(fField);
195 
196     G4FieldManager* fieldManager =
197       G4TransportationManager::GetTransportationManager()->GetFieldManager();
198     fieldManager->SetDetectorField(fField);
199 
200     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 8);
201     //     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation,12);
202 
203     G4double minStep = 0.01 * mm;
204 
205     G4ChordFinder* chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
206 
207     // Set accuracy parameters
208     G4double deltaChord = 3.0 * mm;
209     chordFinder->SetDeltaChord(deltaChord);
210 
211     G4double deltaOneStep = 0.01 * mm;
212     fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
213 
214     G4double deltaIntersection = 0.1 * mm;
215     fieldManager->SetDeltaIntersection(deltaIntersection);
216 
217     G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
218 
219     G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
220 
221     // Dimensionless limits for relative accuracy of integration
222     G4double epsMin = 2.5e-7;
223     G4double epsMax = 0.001;  // Will soon be maximum without warning.
224     // The relative accuracy used for a step of length 'l'
225     //                    a.)  epsMin              if deltaOneStep / l < epsMin
226     //    epsilon_step =  b.)  epsMax              if deltaOneStep / l > epsMax
227     //                    c.)  deltaOneStep / l    otherwise
228 
229     fieldPropagator->SetMinimumEpsilonStep(epsMin);
230     fieldPropagator->SetMaximumEpsilonStep(epsMax);
231 
232     fieldManager->SetChordFinder(chordFinder);
233   }
234 }
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
237