[807] | 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: F01DetectorConstruction.cc,v 1.15 2006/06/29 17:16:25 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | #include "F01DetectorConstruction.hh" |
---|
| 33 | #include "F01DetectorMessenger.hh" |
---|
| 34 | |
---|
| 35 | #include "F01CalorimeterSD.hh" |
---|
| 36 | #include "F01FieldSetup.hh" |
---|
| 37 | |
---|
| 38 | #include "G4Material.hh" |
---|
| 39 | #include "G4Tubs.hh" |
---|
| 40 | #include "G4LogicalVolume.hh" |
---|
| 41 | #include "G4PVPlacement.hh" |
---|
| 42 | #include "G4UniformMagField.hh" |
---|
| 43 | #include "G4FieldManager.hh" |
---|
| 44 | #include "G4TransportationManager.hh" |
---|
| 45 | #include "G4SDManager.hh" |
---|
| 46 | #include "G4RunManager.hh" |
---|
| 47 | |
---|
| 48 | #include "G4GeometryManager.hh" |
---|
| 49 | #include "G4PhysicalVolumeStore.hh" |
---|
| 50 | #include "G4LogicalVolumeStore.hh" |
---|
| 51 | #include "G4SolidStore.hh" |
---|
| 52 | |
---|
| 53 | #include "G4ios.hh" |
---|
| 54 | |
---|
| 55 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 56 | // |
---|
| 57 | // |
---|
| 58 | |
---|
| 59 | F01DetectorConstruction::F01DetectorConstruction() |
---|
| 60 | : solidWorld(0), logicWorld(0), physiWorld(0), |
---|
| 61 | solidAbsorber(0),logicAbsorber(0), physiAbsorber(0), |
---|
| 62 | fEmFieldSetup(0), calorimeterSD(0), |
---|
| 63 | AbsorberMaterial(0), worldchanged(false), WorldMaterial(0) |
---|
| 64 | { |
---|
| 65 | // default parameter values of the calorimeter |
---|
| 66 | |
---|
| 67 | WorldSizeZ = 44000.*mm; |
---|
| 68 | WorldSizeR = 22000.*mm; |
---|
| 69 | |
---|
| 70 | AbsorberThickness = 1.0*mm; |
---|
| 71 | |
---|
| 72 | AbsorberRadius = 20000.*mm; |
---|
| 73 | |
---|
| 74 | zAbsorber = 21990.0*mm ; |
---|
| 75 | |
---|
| 76 | // create commands for interactive definition of the calorimeter |
---|
| 77 | |
---|
| 78 | detectorMessenger = new F01DetectorMessenger(this); |
---|
| 79 | |
---|
| 80 | // create materials |
---|
| 81 | |
---|
| 82 | DefineMaterials(); |
---|
| 83 | |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | ////////////////////////////////////////////////////////////////////////// |
---|
| 87 | // |
---|
| 88 | // |
---|
| 89 | |
---|
| 90 | F01DetectorConstruction::~F01DetectorConstruction() |
---|
| 91 | { |
---|
| 92 | delete detectorMessenger; |
---|
| 93 | if (fEmFieldSetup) delete fEmFieldSetup; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | ////////////////////////////////////////////////////////////////////////// |
---|
| 97 | // |
---|
| 98 | // |
---|
| 99 | |
---|
| 100 | G4VPhysicalVolume* F01DetectorConstruction::Construct() |
---|
| 101 | { |
---|
| 102 | G4VPhysicalVolume* calorWorld= ConstructCalorimeter(); |
---|
| 103 | |
---|
| 104 | // Construct the field creator - this will register the field it creates |
---|
| 105 | fEmFieldSetup= new F01FieldSetup( // G4ThreeVector(0.0, 0.0, 1.0*tesla) ); |
---|
| 106 | G4ThreeVector( 3.3*tesla, 0.0, 0.0 ) ) ; |
---|
| 107 | return calorWorld; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 111 | // |
---|
| 112 | // |
---|
| 113 | |
---|
| 114 | void F01DetectorConstruction::DefineMaterials() |
---|
| 115 | { |
---|
| 116 | //This function illustrates the possible ways to define materials |
---|
| 117 | |
---|
| 118 | G4String name, symbol ; // a=mass of a mole; |
---|
| 119 | G4double a, z, density ; // z=mean number of protons; |
---|
| 120 | G4int nel ; |
---|
| 121 | G4int ncomponents; |
---|
| 122 | G4double fractionmass, pressure, temperature; |
---|
| 123 | |
---|
| 124 | // |
---|
| 125 | // define Elements |
---|
| 126 | // |
---|
| 127 | |
---|
| 128 | a = 1.01*g/mole; |
---|
| 129 | G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); |
---|
| 130 | |
---|
| 131 | a = 12.01*g/mole; |
---|
| 132 | G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); |
---|
| 133 | |
---|
| 134 | a = 14.01*g/mole; |
---|
| 135 | G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); |
---|
| 136 | |
---|
| 137 | a = 16.00*g/mole; |
---|
| 138 | G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); |
---|
| 139 | |
---|
| 140 | a = 39.948*g/mole; |
---|
| 141 | G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a); |
---|
| 142 | |
---|
| 143 | // |
---|
| 144 | // define simple materials |
---|
| 145 | // |
---|
| 146 | |
---|
| 147 | // Mylar |
---|
| 148 | |
---|
| 149 | density = 1.39*g/cm3; |
---|
| 150 | G4Material* Mylar = new G4Material(name="Mylar", density, nel=3); |
---|
| 151 | Mylar->AddElement(elO,2); |
---|
| 152 | Mylar->AddElement(elC,5); |
---|
| 153 | Mylar->AddElement(elH,4); |
---|
| 154 | |
---|
| 155 | // Polypropelene |
---|
| 156 | |
---|
| 157 | G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2); |
---|
| 158 | CH2->AddElement(elH,2); |
---|
| 159 | CH2->AddElement(elC,1); |
---|
| 160 | |
---|
| 161 | // Krypton as detector gas, STP |
---|
| 162 | |
---|
| 163 | density = 3.700*mg/cm3 ; |
---|
| 164 | a = 83.80*g/mole ; |
---|
| 165 | G4Material* Kr = new G4Material(name="Kr",z=36., a, density ); |
---|
| 166 | |
---|
| 167 | // Dry air (average composition) |
---|
| 168 | |
---|
| 169 | density = 1.7836*mg/cm3 ; // STP |
---|
| 170 | G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1); |
---|
| 171 | Argon->AddElement(elAr, 1); |
---|
| 172 | |
---|
| 173 | density = 1.25053*mg/cm3 ; // STP |
---|
| 174 | G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1); |
---|
| 175 | Nitrogen->AddElement(elN, 2); |
---|
| 176 | |
---|
| 177 | density = 1.4289*mg/cm3 ; // STP |
---|
| 178 | G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1); |
---|
| 179 | Oxygen->AddElement(elO, 2); |
---|
| 180 | |
---|
| 181 | density = 1.2928*mg/cm3 ; // STP |
---|
| 182 | density *= 1.0e-8 ; // pumped vacuum |
---|
| 183 | |
---|
| 184 | temperature = STP_Temperature; |
---|
| 185 | pressure = 1.0e-8*STP_Pressure; |
---|
| 186 | |
---|
| 187 | G4Material* Air = new G4Material(name="Air" , density, ncomponents=3, |
---|
| 188 | kStateGas,temperature,pressure); |
---|
| 189 | Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ; |
---|
| 190 | Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ; |
---|
| 191 | Air->AddMaterial( Argon, fractionmass = 0.0128 ) ; |
---|
| 192 | |
---|
| 193 | // Xenon as detector gas, STP |
---|
| 194 | |
---|
| 195 | density = 5.858*mg/cm3 ; |
---|
| 196 | a = 131.29*g/mole ; |
---|
| 197 | G4Material* Xe = new G4Material(name="Xenon",z=54., a, density ); |
---|
| 198 | |
---|
| 199 | // Carbon dioxide, STP |
---|
| 200 | |
---|
| 201 | density = 1.977*mg/cm3; |
---|
| 202 | G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2); |
---|
| 203 | CarbonDioxide->AddElement(elC,1); |
---|
| 204 | CarbonDioxide->AddElement(elO,2); |
---|
| 205 | |
---|
| 206 | // 80% Xe + 20% CO2, STP |
---|
| 207 | |
---|
| 208 | density = 5.0818*mg/cm3 ; |
---|
| 209 | G4Material* Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2); |
---|
| 210 | Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ; |
---|
| 211 | Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ; |
---|
| 212 | |
---|
| 213 | // 80% Kr + 20% CO2, STP |
---|
| 214 | |
---|
| 215 | density = 3.601*mg/cm3 ; |
---|
| 216 | G4Material* Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2); |
---|
| 217 | Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ; |
---|
| 218 | Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ; |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; |
---|
| 222 | |
---|
| 223 | // default materials of the calorimeter |
---|
| 224 | |
---|
| 225 | AbsorberMaterial = Air ; // Kr20CO2 ; // XeCO2CF4 ; |
---|
| 226 | |
---|
| 227 | WorldMaterial = Air ; |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | ///////////////////////////////////////////////////////////////////////// |
---|
| 231 | // |
---|
| 232 | // |
---|
| 233 | |
---|
| 234 | G4VPhysicalVolume* F01DetectorConstruction::ConstructCalorimeter() |
---|
| 235 | { |
---|
| 236 | // complete the Calor parameters definition and Print |
---|
| 237 | |
---|
| 238 | ComputeCalorParameters(); |
---|
| 239 | PrintCalorParameters(); |
---|
| 240 | |
---|
| 241 | // Cleanup old geometry |
---|
| 242 | |
---|
| 243 | if (physiWorld) |
---|
| 244 | { |
---|
| 245 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
| 246 | G4PhysicalVolumeStore::GetInstance()->Clean(); |
---|
| 247 | G4LogicalVolumeStore::GetInstance()->Clean(); |
---|
| 248 | G4SolidStore::GetInstance()->Clean(); |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | // World |
---|
| 252 | |
---|
| 253 | solidWorld = new G4Tubs("World", // its name |
---|
| 254 | 0.,WorldSizeR,WorldSizeZ/2.,0.,twopi); // its size |
---|
| 255 | |
---|
| 256 | logicWorld = new G4LogicalVolume(solidWorld, // its solid |
---|
| 257 | WorldMaterial, // its material |
---|
| 258 | "World"); // its name |
---|
| 259 | |
---|
| 260 | physiWorld = new G4PVPlacement(0, // no rotation |
---|
| 261 | G4ThreeVector(), // at (0,0,0) |
---|
| 262 | "World", // its name |
---|
| 263 | logicWorld, // its logical volume |
---|
| 264 | 0, // its mother volume |
---|
| 265 | false, // no boolean operation |
---|
| 266 | 0); // copy number |
---|
| 267 | // Absorber |
---|
| 268 | |
---|
| 269 | if (AbsorberThickness > 0.) |
---|
| 270 | { |
---|
| 271 | solidAbsorber = new G4Tubs("Absorber", 1.0*mm, |
---|
| 272 | AbsorberRadius, |
---|
| 273 | AbsorberThickness/2., |
---|
| 274 | 0.0,twopi); |
---|
| 275 | |
---|
| 276 | logicAbsorber = new G4LogicalVolume(solidAbsorber, |
---|
| 277 | AbsorberMaterial, |
---|
| 278 | "Absorber"); |
---|
| 279 | |
---|
| 280 | physiAbsorber = new G4PVPlacement(0, |
---|
| 281 | G4ThreeVector(0.,0.,zAbsorber), |
---|
| 282 | "Absorber", |
---|
| 283 | logicAbsorber, |
---|
| 284 | physiWorld, |
---|
| 285 | false, |
---|
| 286 | 0); |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | // Sensitive Detectors: Absorber |
---|
| 290 | |
---|
| 291 | G4SDManager* SDman = G4SDManager::GetSDMpointer(); |
---|
| 292 | |
---|
| 293 | if(!calorimeterSD) |
---|
| 294 | { |
---|
| 295 | calorimeterSD = new F01CalorimeterSD("CalorSD",this); |
---|
| 296 | SDman->AddNewDetector( calorimeterSD ); |
---|
| 297 | } |
---|
| 298 | if (logicAbsorber) logicAbsorber->SetSensitiveDetector(calorimeterSD); |
---|
| 299 | |
---|
| 300 | return physiWorld; |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | //////////////////////////////////////////////////////////////////////////// |
---|
| 304 | // |
---|
| 305 | // |
---|
| 306 | |
---|
| 307 | void F01DetectorConstruction::PrintCalorParameters() |
---|
| 308 | { |
---|
| 309 | G4cout << "\n The WORLD is made of " |
---|
| 310 | << WorldSizeZ/mm << "mm of " << WorldMaterial->GetName() ; |
---|
| 311 | G4cout << ", the transverse size (R) of the world is " << WorldSizeR/mm << " mm. " << G4endl; |
---|
| 312 | G4cout << " The ABSORBER is made of " |
---|
| 313 | << AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName() ; |
---|
| 314 | G4cout << ", the transverse size (R) is " << AbsorberRadius/mm << " mm. " << G4endl; |
---|
| 315 | G4cout << " Z position of the (middle of the) absorber " << zAbsorber/mm << " mm." << G4endl; |
---|
| 316 | G4cout << G4endl; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | /////////////////////////////////////////////////////////////////////////// |
---|
| 320 | // |
---|
| 321 | // |
---|
| 322 | |
---|
| 323 | void F01DetectorConstruction::SetAbsorberMaterial(G4String materialChoice) |
---|
| 324 | { |
---|
| 325 | // get the pointer to the material table |
---|
| 326 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
| 327 | |
---|
| 328 | // search the material by its name |
---|
| 329 | G4Material* pttoMaterial; |
---|
| 330 | for (size_t J=0 ; J<theMaterialTable->size() ; J++) |
---|
| 331 | { pttoMaterial = (*theMaterialTable)[J]; |
---|
| 332 | if(pttoMaterial->GetName() == materialChoice) |
---|
| 333 | { |
---|
| 334 | AbsorberMaterial = pttoMaterial; |
---|
| 335 | logicAbsorber->SetMaterial(pttoMaterial); |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | //////////////////////////////////////////////////////////////////////////// |
---|
| 341 | // |
---|
| 342 | // |
---|
| 343 | |
---|
| 344 | void F01DetectorConstruction::SetWorldMaterial(G4String materialChoice) |
---|
| 345 | { |
---|
| 346 | // get the pointer to the material table |
---|
| 347 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); |
---|
| 348 | |
---|
| 349 | // search the material by its name |
---|
| 350 | G4Material* pttoMaterial; |
---|
| 351 | for (size_t J=0 ; J<theMaterialTable->size() ; J++) |
---|
| 352 | { pttoMaterial = (*theMaterialTable)[J]; |
---|
| 353 | if(pttoMaterial->GetName() == materialChoice) |
---|
| 354 | { |
---|
| 355 | WorldMaterial = pttoMaterial; |
---|
| 356 | logicWorld->SetMaterial(pttoMaterial); |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | /////////////////////////////////////////////////////////////////////////// |
---|
| 362 | // |
---|
| 363 | // |
---|
| 364 | |
---|
| 365 | void F01DetectorConstruction::SetAbsorberThickness(G4double val) |
---|
| 366 | { |
---|
| 367 | // change Absorber thickness and recompute the calorimeter parameters |
---|
| 368 | AbsorberThickness = val; |
---|
| 369 | ComputeCalorParameters(); |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 373 | // |
---|
| 374 | // |
---|
| 375 | |
---|
| 376 | void F01DetectorConstruction::SetAbsorberRadius(G4double val) |
---|
| 377 | { |
---|
| 378 | // change the transverse size and recompute the calorimeter parameters |
---|
| 379 | AbsorberRadius = val; |
---|
| 380 | ComputeCalorParameters(); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | //////////////////////////////////////////////////////////////////////////// |
---|
| 384 | // |
---|
| 385 | // |
---|
| 386 | |
---|
| 387 | void F01DetectorConstruction::SetWorldSizeZ(G4double val) |
---|
| 388 | { |
---|
| 389 | worldchanged=true; |
---|
| 390 | WorldSizeZ = val; |
---|
| 391 | ComputeCalorParameters(); |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | /////////////////////////////////////////////////////////////////////////// |
---|
| 395 | // |
---|
| 396 | // |
---|
| 397 | |
---|
| 398 | void F01DetectorConstruction::SetWorldSizeR(G4double val) |
---|
| 399 | { |
---|
| 400 | worldchanged=true; |
---|
| 401 | WorldSizeR = val; |
---|
| 402 | ComputeCalorParameters(); |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 406 | // |
---|
| 407 | // |
---|
| 408 | |
---|
| 409 | void F01DetectorConstruction::SetAbsorberZpos(G4double val) |
---|
| 410 | { |
---|
| 411 | zAbsorber = val; |
---|
| 412 | ComputeCalorParameters(); |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 417 | // |
---|
| 418 | // |
---|
| 419 | |
---|
| 420 | void F01DetectorConstruction::UpdateGeometry() |
---|
| 421 | { |
---|
| 422 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter()); |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | // |
---|
| 426 | // |
---|
| 427 | //////////////////////////////////////////////////////////////////////////// |
---|