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/dmparticle/src/Detecto 26 /// \file exoticphysics/dmparticle/src/DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 28 // 28 // >> 29 // $Id: DetectorConstruction.cc 68036 2013-03-13 14:13:45Z gcosmo $ 29 // 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 33 33 #include "DetectorConstruction.hh" 34 #include "DetectorConstruction.hh" 34 << 35 #include "DetectorMessenger.hh" 35 #include "DetectorMessenger.hh" 36 #include "TargetSD.hh" << 37 36 >> 37 #include "G4Material.hh" 38 #include "G4Box.hh" 38 #include "G4Box.hh" 39 #include "G4FieldManager.hh" << 40 #include "G4GeometryManager.hh" << 41 #include "G4LogicalVolume.hh" 39 #include "G4LogicalVolume.hh" 42 #include "G4Material.hh" << 43 #include "G4NistManager.hh" << 44 #include "G4PVPlacement.hh" 40 #include "G4PVPlacement.hh" 45 #include "G4RunManager.hh" << 41 #include "TargetSD.hh" 46 #include "G4SDManager.hh" 42 #include "G4SDManager.hh" 47 #include "G4SystemOfUnits.hh" << 43 48 #include "G4ThreeVector.hh" << 44 #include "G4GeometryManager.hh" >> 45 49 #include "G4UnitsTable.hh" 46 #include "G4UnitsTable.hh" >> 47 #include "G4NistManager.hh" >> 48 >> 49 #include "G4FieldManager.hh" >> 50 #include "G4ThreeVector.hh" >> 51 #include "G4RunManager.hh" >> 52 #include "G4SystemOfUnits.hh" 50 53 51 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 55 53 DetectorConstruction::DetectorConstruction() 56 DetectorConstruction::DetectorConstruction() 54 : G4VUserDetectorConstruction(), fAbsorMater << 57 : G4VUserDetectorConstruction(), >> 58 fAbsorMaterial(nullptr), >> 59 fLogAbsor(nullptr), >> 60 fWorld(nullptr) 55 { 61 { 56 // default parameter values 62 // default parameter values 57 fAbsorSizeZ = fAbsorSizeXY = 10 * cm; 63 fAbsorSizeZ = fAbsorSizeXY = 10 * cm; 58 fWorldSizeZ = fWorldSizeXY = 1.2 * fAbsorSiz 64 fWorldSizeZ = fWorldSizeXY = 1.2 * fAbsorSizeZ; 59 65 60 SetMaterial("G4_Al"); 66 SetMaterial("G4_Al"); 61 fWorldMaterial = G4NistManager::Instance()-> << 67 fWorldMaterial = >> 68 G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"); 62 69 63 // create commands for interactive definitio 70 // create commands for interactive definition of the detector 64 fDetectorMessenger = new DetectorMessenger(t 71 fDetectorMessenger = new DetectorMessenger(this); 65 } 72 } 66 73 67 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 75 69 DetectorConstruction::~DetectorConstruction() 76 DetectorConstruction::~DetectorConstruction() 70 { 77 { 71 delete fDetectorMessenger; 78 delete fDetectorMessenger; 72 } 79 } 73 80 74 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 75 82 76 G4VPhysicalVolume* DetectorConstruction::Const 83 G4VPhysicalVolume* DetectorConstruction::Construct() 77 { << 84 { 78 if (fWorld) { << 85 if(fWorld) { return fWorld; } 79 return fWorld; << 80 } << 81 86 82 /**************************** World *** 87 /**************************** World *****************************/ 83 G4Box* sWorld = new G4Box("world", fWorldSiz << 88 G4Box * sWorld = new G4Box("world", >> 89 fWorldSizeXY / 2, fWorldSizeXY / 2, fWorldSizeZ / 2); 84 90 85 G4LogicalVolume* lWorld = new G4LogicalVolum << 91 G4LogicalVolume * lWorld = new G4LogicalVolume(sWorld, >> 92 fWorldMaterial, >> 93 "world"); >> 94 >> 95 fWorld = new G4PVPlacement(0, //no rotation >> 96 G4ThreeVector(), //at (0,0,0) >> 97 lWorld, //logical volume >> 98 "world", //name >> 99 0, //mother volume >> 100 false, //no boolean operation >> 101 0); //copy number 86 102 87 fWorld = new G4PVPlacement(0, // no rotatio << 88 G4ThreeVector(), << 89 lWorld, // logic << 90 "world", // name << 91 0, // mother vo << 92 false, // no boo << 93 0); // copy numb << 94 103 95 /************************** Absorber * 104 /************************** Absorber ***************************/ 96 105 97 G4Box* sAbsor = new G4Box("Absorber", fAbsor << 106 G4Box * sAbsor = new G4Box("Absorber", 98 << 107 fAbsorSizeXY / 2, fAbsorSizeXY / 2, fAbsorSizeZ / 2); 99 fLogAbsor = new G4LogicalVolume(sAbsor, fAbs << 100 108 101 new G4PVPlacement(0, // no rotation << 109 fLogAbsor = new G4LogicalVolume(sAbsor, 102 G4ThreeVector(), // at (0 << 110 fAbsorMaterial, 103 fLogAbsor, // logical vol << 111 "Absorber"); 104 "Absorber", // name << 112 105 lWorld, // mother volume << 113 new G4PVPlacement(0, //no rotation 106 false, // no boolean oper << 114 G4ThreeVector(), //at (0,0,0) 107 0); // copy number << 115 fLogAbsor, //logical volume >> 116 "Absorber", //name >> 117 lWorld, //mother volume >> 118 false, //no boolean operation >> 119 0); //copy number 108 120 109 PrintParameters(); 121 PrintParameters(); 110 122 111 /************ always return the World vo 123 /************ always return the World volume *****************/ 112 return fWorld; 124 return fWorld; 113 } 125 } 114 126 115 //....oooOO0OOooo........oooOO0OOooo........oo 127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 128 117 void DetectorConstruction::PrintParameters() 129 void DetectorConstruction::PrintParameters() 118 { 130 { 119 G4cout << "\n------------------------------- 131 G4cout << "\n---------------------------------------------------------\n"; 120 G4cout << "---> The Absorber is " << G4BestU << 132 G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeZ, "Length") 121 << fAbsorMaterial->GetName() << G4end << 133 << " of " << fAbsorMaterial->GetName() << G4endl; 122 G4cout << "\n------------------------------- 134 G4cout << "\n---------------------------------------------------------\n"; >> 135 123 } 136 } 124 137 125 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 126 139 127 void DetectorConstruction::SetSizeZ(G4double v 140 void DetectorConstruction::SetSizeZ(G4double value) 128 { 141 { 129 if (value > 0.0) { << 142 if(value > 0.0) { 130 fAbsorSizeZ = value; << 143 fAbsorSizeZ = value; 131 fWorldSizeZ = 1.2 * fAbsorSizeZ; 144 fWorldSizeZ = 1.2 * fAbsorSizeZ; 132 } 145 } 133 } 146 } 134 << 147 135 //....oooOO0OOooo........oooOO0OOooo........oo 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 136 149 137 void DetectorConstruction::SetSizeXY(G4double 150 void DetectorConstruction::SetSizeXY(G4double value) 138 { 151 { 139 if (value > 0.0) { << 152 if(value > 0.0) 140 fAbsorSizeXY = value; << 153 { >> 154 fAbsorSizeXY = value; 141 fWorldSizeXY = 1.2 * fAbsorSizeXY; 155 fWorldSizeXY = 1.2 * fAbsorSizeXY; 142 } 156 } 143 } << 157 } 144 158 145 //....oooOO0OOooo........oooOO0OOooo........oo 159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 146 160 147 void DetectorConstruction::SetMaterial(const G 161 void DetectorConstruction::SetMaterial(const G4String& namemat) 148 { 162 { 149 // search the material by its name << 163 // search the material by its name 150 164 151 G4Material* mat = G4NistManager::Instance()- 165 G4Material* mat = G4NistManager::Instance()->FindOrBuildMaterial(namemat); 152 if (!mat) { << 166 if(!mat) { 153 G4cout << "!!! DetectorConstruction::SetMa << 167 G4cout << "!!! DetectorConstruction::SetMaterial: WARNING Material <" 154 << "> does not exist in DB" << G4en << 168 << namemat << "> does not exist in DB" << G4endl; 155 return; 169 return; 156 } 170 } 157 // new material is found out 171 // new material is found out 158 if (mat != fAbsorMaterial) { 172 if (mat != fAbsorMaterial) { 159 fAbsorMaterial = mat; 173 fAbsorMaterial = mat; 160 if (fLogAbsor) { << 174 if(fLogAbsor) { fLogAbsor->SetMaterial(mat); } 161 fLogAbsor->SetMaterial(mat); << 162 } << 163 G4RunManager::GetRunManager()->PhysicsHasB 175 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 164 } 176 } 165 } 177 } 166 178 167 //....oooOO0OOooo........oooOO0OOooo........oo 179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 168 180 169 void DetectorConstruction::ConstructSDandField 181 void DetectorConstruction::ConstructSDandField() 170 { 182 { 171 auto sd = new TargetSD("Target"); 183 auto sd = new TargetSD("Target"); 172 G4SDManager::GetSDMpointer()->AddNewDetector 184 G4SDManager::GetSDMpointer()->AddNewDetector(sd); 173 SetSensitiveDetector(fLogAbsor, sd); << 185 SetSensitiveDetector(fLogAbsor, sd); 174 } 186 } 175 187 176 //....oooOO0OOooo........oooOO0OOooo........oo 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 177 189