Geant4 Cross Reference |
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 /// \file exoticphysics/monopole/src/DetectorC 26 /// \file exoticphysics/monopole/src/DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 28 // 28 // 29 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "DetectorConstruction.hh" 33 #include "DetectorConstruction.hh" 34 << 35 #include "DetectorMessenger.hh" 34 #include "DetectorMessenger.hh" 36 35 >> 36 #include "G4Material.hh" 37 #include "G4Box.hh" 37 #include "G4Box.hh" 38 #include "G4GeometryManager.hh" << 39 #include "G4LogicalVolume.hh" 38 #include "G4LogicalVolume.hh" 40 #include "G4LogicalVolumeStore.hh" << 41 #include "G4Material.hh" << 42 #include "G4MonopoleFieldSetup.hh" << 43 #include "G4NistManager.hh" << 44 #include "G4PVPlacement.hh" 39 #include "G4PVPlacement.hh" >> 40 #include "G4UniformMagField.hh" >> 41 >> 42 #include "G4GeometryManager.hh" >> 43 #include "G4UserLimits.hh" 45 #include "G4PhysicalVolumeStore.hh" 44 #include "G4PhysicalVolumeStore.hh" >> 45 #include "G4LogicalVolumeStore.hh" 46 #include "G4SolidStore.hh" 46 #include "G4SolidStore.hh" 47 #include "G4StateManager.hh" 47 #include "G4StateManager.hh" 48 #include "G4UniformMagField.hh" << 48 49 #include "G4UnitsTable.hh" 49 #include "G4UnitsTable.hh" 50 #include "G4UserLimits.hh" << 50 #include "G4NistManager.hh" 51 // #include "G4FieldManager.hh" << 51 52 // #include "G4TransportationManager.hh" << 52 #include "G4MonopoleFieldSetup.hh" 53 #include "G4AutoDelete.hh" << 53 //#include "G4FieldManager.hh" 54 #include "G4GlobalMagFieldMessenger.hh" << 54 //#include "G4TransportationManager.hh" 55 #include "G4RunManager.hh" << 56 #include "G4SystemOfUnits.hh" << 57 #include "G4ThreeVector.hh" 55 #include "G4ThreeVector.hh" >> 56 #include "G4RunManager.hh" >> 57 #include "G4SystemOfUnits.hh" >> 58 >> 59 #include "G4GlobalMagFieldMessenger.hh" >> 60 #include "G4AutoDelete.hh" 58 61 59 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 60 63 61 DetectorConstruction::DetectorConstruction() 64 DetectorConstruction::DetectorConstruction() 62 : G4VUserDetectorConstruction(), << 65 : G4VUserDetectorConstruction(), 63 fWorldMaterial(0), << 66 fWorldMaterial(0), 64 fAbsorMaterial(0), << 67 fAbsorMaterial(0), 65 fLogAbsor(0), << 68 fLogAbsor(0), 66 fMonFieldSetup(), << 69 fMonFieldSetup(), 67 fDetectorMessenger(0) << 70 fDetectorMessenger(0) 68 { 71 { 69 // default parameter values 72 // default parameter values 70 fAbsorSizeX = fAbsorSizeYZ = 10 * cm; 73 fAbsorSizeX = fAbsorSizeYZ = 10 * cm; 71 fWorldSizeX = fWorldSizeYZ = 1.2 * fAbsorSiz 74 fWorldSizeX = fWorldSizeYZ = 1.2 * fAbsorSizeX; 72 fMaxStepSize = 5 * mm; 75 fMaxStepSize = 5 * mm; 73 76 74 SetMaterial("G4_Al"); 77 SetMaterial("G4_Al"); 75 fWorldMaterial = G4NistManager::Instance()-> << 78 fWorldMaterial = >> 79 G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"); 76 80 77 // create commands for interactive definitio 81 // create commands for interactive definition of the detector 78 fDetectorMessenger = new DetectorMessenger(t 82 fDetectorMessenger = new DetectorMessenger(this); 79 } 83 } 80 84 81 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 86 83 DetectorConstruction::~DetectorConstruction() 87 DetectorConstruction::~DetectorConstruction() 84 { 88 { 85 delete fDetectorMessenger; 89 delete fDetectorMessenger; 86 // delete fMonFieldSetup; 90 // delete fMonFieldSetup; 87 } 91 } 88 92 89 //....oooOO0OOooo........oooOO0OOooo........oo 93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 90 94 91 G4VPhysicalVolume* DetectorConstruction::Const 95 G4VPhysicalVolume* DetectorConstruction::Construct() 92 { << 96 { 93 G4GeometryManager::GetInstance()->OpenGeomet 97 G4GeometryManager::GetInstance()->OpenGeometry(); 94 G4PhysicalVolumeStore::GetInstance()->Clean( 98 G4PhysicalVolumeStore::GetInstance()->Clean(); 95 G4LogicalVolumeStore::GetInstance()->Clean() 99 G4LogicalVolumeStore::GetInstance()->Clean(); 96 G4SolidStore::GetInstance()->Clean(); 100 G4SolidStore::GetInstance()->Clean(); 97 101 98 /**************************** World *** 102 /**************************** World *****************************/ 99 G4Box* sWorld = new G4Box("world", fWorldSiz << 103 G4Box * sWorld = new G4Box("world", >> 104 fWorldSizeX / 2, fWorldSizeYZ / 2, fWorldSizeYZ / 2); 100 105 101 G4LogicalVolume* lWorld = new G4LogicalVolum << 106 G4LogicalVolume * lWorld = new G4LogicalVolume(sWorld, >> 107 fWorldMaterial, >> 108 "world"); >> 109 >> 110 G4VPhysicalVolume * pWorld = new G4PVPlacement(0, //no rotation >> 111 G4ThreeVector(), //at (0,0,0) >> 112 lWorld, //logical volume >> 113 "world", //name >> 114 0, //mother volume >> 115 false, //no boolean operation >> 116 0); //copy number 102 117 103 G4VPhysicalVolume* pWorld = new G4PVPlacemen << 104 << 105 << 106 << 107 << 108 << 109 << 110 118 111 /************************** Absorber * 119 /************************** Absorber ***************************/ 112 G4Box* sAbsor = new G4Box("Absorber", fAbsor << 120 G4Box * sAbsor = new G4Box("Absorber", >> 121 fAbsorSizeX / 2, fAbsorSizeYZ / 2, fAbsorSizeYZ / 2); 113 122 114 fLogAbsor = new G4LogicalVolume(sAbsor, fAbs << 123 fLogAbsor = new G4LogicalVolume(sAbsor, 115 << 124 fAbsorMaterial, 116 new G4PVPlacement(0, // no rotation << 125 "Absorber"); 117 G4ThreeVector(), // at (0 << 126 118 fLogAbsor, // logical vol << 127 new G4PVPlacement(0, //no rotation 119 "Absorber", // name << 128 G4ThreeVector(), //at (0,0,0) 120 lWorld, // mother volume << 129 fLogAbsor, //logical volume 121 false, // no boolean oper << 130 "Absorber", //name 122 0); // copy number << 131 lWorld, //mother volume >> 132 false, //no boolean operation >> 133 0); //copy number 123 fLogAbsor->SetUserLimits(new G4UserLimits(fM 134 fLogAbsor->SetUserLimits(new G4UserLimits(fMaxStepSize)); 124 135 125 PrintParameters(); 136 PrintParameters(); 126 137 127 /************ always return the World vo 138 /************ always return the World volume *****************/ 128 return pWorld; 139 return pWorld; 129 } 140 } 130 141 131 //....oooOO0OOooo........oooOO0OOooo........oo 142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 132 143 133 void DetectorConstruction::PrintParameters() 144 void DetectorConstruction::PrintParameters() 134 { 145 { 135 G4cout << "\n------------------------------- 146 G4cout << "\n---------------------------------------------------------\n"; 136 G4cout << "---> The Absorber is " << G4BestU << 147 G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeX, "Length") 137 << fAbsorMaterial->GetName() << G4end << 148 << " of " << fAbsorMaterial->GetName() << G4endl; 138 G4cout << "\n------------------------------- 149 G4cout << "\n---------------------------------------------------------\n"; >> 150 139 } 151 } 140 152 141 //....oooOO0OOooo........oooOO0OOooo........oo 153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 142 154 143 void DetectorConstruction::SetSizeX(G4double v 155 void DetectorConstruction::SetSizeX(G4double value) 144 { 156 { 145 if (value > 0.0) { << 157 if(value > 0.0) { 146 fAbsorSizeX = value; << 158 fAbsorSizeX = value; 147 fWorldSizeX = 1.2 * fAbsorSizeX; 159 fWorldSizeX = 1.2 * fAbsorSizeX; 148 if (G4StateManager::GetStateManager()->Get << 160 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) { 149 G4RunManager::GetRunManager()->Reinitial 161 G4RunManager::GetRunManager()->ReinitializeGeometry(); 150 } 162 } 151 } 163 } 152 } 164 } 153 << 165 154 //....oooOO0OOooo........oooOO0OOooo........oo 166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 155 167 156 void DetectorConstruction::SetSizeYZ(G4double 168 void DetectorConstruction::SetSizeYZ(G4double value) 157 { 169 { 158 if (value > 0.0) { << 170 if(value > 0.0) { 159 fAbsorSizeYZ = value; << 171 fAbsorSizeYZ = value; 160 fWorldSizeYZ = 1.2 * fAbsorSizeYZ; 172 fWorldSizeYZ = 1.2 * fAbsorSizeYZ; 161 if (G4StateManager::GetStateManager()->Get << 173 if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) { 162 G4RunManager::GetRunManager()->Reinitial 174 G4RunManager::GetRunManager()->ReinitializeGeometry(); 163 } 175 } 164 } 176 } 165 } << 177 } 166 178 167 //....oooOO0OOooo........oooOO0OOooo........oo 179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 168 180 169 void DetectorConstruction::SetMaterial(const G 181 void DetectorConstruction::SetMaterial(const G4String& namemat) 170 { 182 { 171 // search the material by its name << 183 // search the material by its name 172 G4Material* mat = G4NistManager::Instance()- 184 G4Material* mat = G4NistManager::Instance()->FindOrBuildMaterial(namemat); 173 if (!mat) { << 185 if(!mat) { 174 G4cout << "!!! DetectorConstruction::SetMa << 186 G4cout << "!!! DetectorConstruction::SetMaterial: WARNING Material <" 175 << "> does not exist in DB" << G4en << 187 << namemat << "> does not exist in DB" << G4endl; 176 return; 188 return; 177 } 189 } 178 // new material is found out 190 // new material is found out 179 if (mat != fAbsorMaterial) { 191 if (mat != fAbsorMaterial) { 180 fAbsorMaterial = mat; 192 fAbsorMaterial = mat; 181 if (fLogAbsor) { << 193 if(fLogAbsor) { fLogAbsor->SetMaterial(mat); } 182 fLogAbsor->SetMaterial(mat); << 183 } << 184 G4RunManager::GetRunManager()->PhysicsHasB 194 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 185 } 195 } 186 } 196 } 187 197 188 //....oooOO0OOooo........oooOO0OOooo........oo 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 189 199 190 void DetectorConstruction::ConstructSDandField 200 void DetectorConstruction::ConstructSDandField() 191 { 201 { 192 // Define magnetic field 202 // Define magnetic field 193 if (!fMonFieldSetup.Get()) { << 203 if ( ! fMonFieldSetup.Get() ) { 194 G4MonopoleFieldSetup* fieldSetup = new G4M << 204 G4MonopoleFieldSetup* fieldSetup 195 G4AutoDelete::Register(fieldSetup); // Ke << 205 = new G4MonopoleFieldSetup(); >> 206 G4AutoDelete::Register(fieldSetup); // Kernel will delete the F01FieldSetup 196 fMonFieldSetup.Put(fieldSetup); 207 fMonFieldSetup.Put(fieldSetup); 197 } 208 } 198 fMonFieldSetup.Get()->ConstructMagField(); << 209 fMonFieldSetup.Get()->ConstructMagField(); // add field value 199 } 210 } 200 211 201 //....oooOO0OOooo........oooOO0OOooo........oo 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 202 213 203 void DetectorConstruction::SetMaxStepSize(G4do 214 void DetectorConstruction::SetMaxStepSize(G4double step) 204 { 215 { 205 fMaxStepSize = step; 216 fMaxStepSize = step; 206 if (fLogAbsor) { << 217 if(fLogAbsor) { fLogAbsor->SetUserLimits(new G4UserLimits(fMaxStepSize)); } 207 fLogAbsor->SetUserLimits(new G4UserLimits( << 208 } << 209 } 218 } 210 219 211 //....oooOO0OOooo........oooOO0OOooo........oo 220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 212 221