Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file B2bDetectorConstruction.cc 28 /// \brief Implementation of the B2bDetectorCo 29 30 #include "B2bDetectorConstruction.hh" 31 32 #include "B2TrackerSD.hh" 33 #include "B2bChamberParameterisation.hh" 34 #include "B2bDetectorMessenger.hh" 35 36 #include "G4Box.hh" 37 #include "G4Colour.hh" 38 #include "G4GeometryManager.hh" 39 #include "G4GeometryTolerance.hh" 40 #include "G4GlobalMagFieldMessenger.hh" 41 #include "G4LogicalVolume.hh" 42 #include "G4Material.hh" 43 #include "G4NistManager.hh" 44 #include "G4PVParameterised.hh" 45 #include "G4PVPlacement.hh" 46 #include "G4SDManager.hh" 47 #include "G4SystemOfUnits.hh" 48 #include "G4Tubs.hh" 49 #include "G4UserLimits.hh" 50 #include "G4VisAttributes.hh" 51 52 // #include "G4ios.hh" 53 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 56 G4ThreadLocal G4GlobalMagFieldMessenger* B2bDe 57 58 B2bDetectorConstruction::B2bDetectorConstructi 59 : G4VUserDetectorConstruction(), 60 fLogicTarget(NULL), 61 fLogicChamber(NULL), 62 fTargetMaterial(NULL), 63 fChamberMaterial(NULL), 64 fStepLimit(NULL), 65 fCheckOverlaps(true) 66 { 67 fMessenger = new B2bDetectorMessenger(this); 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 B2bDetectorConstruction::~B2bDetectorConstruct 73 { 74 delete fStepLimit; 75 delete fMessenger; 76 delete fMagFieldMessenger; 77 fMagFieldMessenger = 0; 78 } 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 81 82 G4VPhysicalVolume* B2bDetectorConstruction::Co 83 { 84 // Define materials 85 DefineMaterials(); 86 87 // Define volumes 88 return DefineVolumes(); 89 } 90 91 //....oooOO0OOooo........oooOO0OOooo........oo 92 93 void B2bDetectorConstruction::DefineMaterials( 94 { 95 // Material definition 96 97 G4NistManager* nistManager = G4NistManager:: 98 99 // Air defined using NIST Manager 100 nistManager->FindOrBuildMaterial("G4_AIR"); 101 102 // Lead defined using NIST Manager 103 fTargetMaterial = nistManager->FindOrBuildMa 104 105 // Xenon gas defined using NIST Manager 106 fChamberMaterial = nistManager->FindOrBuildM 107 108 // Print materials 109 G4cout << *(G4Material::GetMaterialTable()) 110 } 111 112 //....oooOO0OOooo........oooOO0OOooo........oo 113 114 G4VPhysicalVolume* B2bDetectorConstruction::De 115 { 116 G4Material* air = G4Material::GetMaterial("G 117 118 // Sizes of the principal geometrical compon 119 120 G4int NbOfChambers = 5; 121 G4double chamberSpacing = 80 * cm; // from 122 123 G4double chamberWidth = 20.0 * cm; // width 124 G4double targetLength = 5.0 * cm; // full l 125 126 G4double trackerLength = (NbOfChambers + 1) 127 128 G4double worldLength = 1.2 * (2 * targetLeng 129 130 G4double targetRadius = 0.5 * targetLength; 131 targetLength = 0.5 * targetLength; // Half 132 G4double trackerSize = 0.5 * trackerLength; 133 134 // Definitions of Solids, Logical Volumes, P 135 136 // World 137 138 G4GeometryManager::GetInstance()->SetWorldMa 139 140 G4cout << "Computed tolerance = " 141 << G4GeometryTolerance::GetInstance() 142 143 G4Box* worldS = new G4Box("world", // its n 144 worldLength / 2, w 145 G4LogicalVolume* worldLV = new G4LogicalVolu 146 147 148 149 // Must place the World Physical volume unr 150 // 151 G4VPhysicalVolume* worldPV = new G4PVPlaceme 152 153 154 155 156 157 158 159 160 // Target 161 162 G4ThreeVector positionTarget = G4ThreeVector 163 164 G4Tubs* targetS = new G4Tubs("target", 0., t 165 fLogicTarget = new G4LogicalVolume(targetS, 166 new G4PVPlacement(0, // no rotation 167 positionTarget, // at (x, 168 fLogicTarget, // its logi 169 "Target", // its name 170 worldLV, // its mother vo 171 false, // no boolean oper 172 0, // copy number 173 fCheckOverlaps); // check 174 175 G4cout << "Target is " << 2 * targetLength / 176 << G4endl; 177 178 // Tracker 179 180 G4ThreeVector positionTracker = G4ThreeVecto 181 182 G4Tubs* trackerS = new G4Tubs("tracker", 0, 183 G4LogicalVolume* trackerLV = new G4LogicalVo 184 new G4PVPlacement(0, // no rotation 185 positionTracker, // at (x 186 trackerLV, // its logical 187 "Tracker", // its name 188 worldLV, // its mother v 189 false, // no boolean oper 190 0, // copy number 191 fCheckOverlaps); // check 192 193 // Tracker segments 194 195 // An example of Parameterised volumes 196 // Dummy values for G4Tubs -- modified by pa 197 198 G4Tubs* chamberS = new G4Tubs("tracker", 0, 199 fLogicChamber = new G4LogicalVolume(chamberS 200 201 G4double firstPosition = -trackerSize + cham 202 G4double firstLength = trackerLength / 10; 203 G4double lastLength = trackerLength; 204 205 G4VPVParameterisation* chamberParam = 206 new B2bChamberParameterisation(NbOfChamber 207 firstPositi 208 chamberSpac 209 chamberWidt 210 firstLength 211 lastLength) 212 213 // dummy value : kZAxis -- modified by param 214 215 new G4PVParameterised("Chamber", // their n 216 fLogicChamber, // the 217 trackerLV, // Mother 218 kZAxis, // Are placed 219 NbOfChambers, // Numb 220 chamberParam, // The 221 fCheckOverlaps); // c 222 223 G4cout << "There are " << NbOfChambers << " 224 << "\nThe chambers are " << chamberWi 225 << "\nThe distance between chamber is 226 227 // Visualization attributes 228 229 G4VisAttributes* boxVisAtt = new G4VisAttrib 230 worldLV->SetVisAttributes(boxVisAtt); 231 fLogicTarget->SetVisAttributes(boxVisAtt); 232 trackerLV->SetVisAttributes(boxVisAtt); 233 234 G4VisAttributes* chamberVisAtt = new G4VisAt 235 fLogicChamber->SetVisAttributes(chamberVisAt 236 237 // Example of User Limits 238 // 239 // Below is an example of how to set trackin 240 // logical volume 241 // 242 // Sets a max step length in the tracker reg 243 244 G4double maxStep = 0.5 * chamberWidth; 245 fStepLimit = new G4UserLimits(maxStep); 246 trackerLV->SetUserLimits(fStepLimit); 247 248 /// Set additional contraints on the track, 249 /// 250 /// G4double maxLength = 2*trackerLength, ma 251 /// trackerLV->SetUserLimits(new G4UserLimit 252 /// 253 /// 254 /// 255 256 // Always return the physical world 257 258 return worldPV; 259 } 260 261 //....oooOO0OOooo........oooOO0OOooo........oo 262 263 void B2bDetectorConstruction::ConstructSDandFi 264 { 265 // Sensitive detectors 266 267 G4String trackerChamberSDname = "B2/TrackerC 268 B2TrackerSD* aTrackerSD = new B2TrackerSD(tr 269 G4SDManager::GetSDMpointer()->AddNewDetector 270 SetSensitiveDetector(fLogicChamber, aTracker 271 272 // Create global magnetic field messenger. 273 // Uniform magnetic field is then created au 274 // the field value is not zero. 275 G4ThreeVector fieldValue = G4ThreeVector(); 276 fMagFieldMessenger = new G4GlobalMagFieldMes 277 fMagFieldMessenger->SetVerboseLevel(1); 278 } 279 280 //....oooOO0OOooo........oooOO0OOooo........oo 281 282 void B2bDetectorConstruction::SetTargetMateria 283 { 284 G4NistManager* nistManager = G4NistManager:: 285 286 G4Material* pttoMaterial = nistManager->Find 287 288 if (fTargetMaterial != pttoMaterial) { 289 if (pttoMaterial) { 290 fTargetMaterial = pttoMaterial; 291 if (fLogicTarget) fLogicTarget->SetMater 292 G4cout << "\n----> The target is made of 293 } 294 else { 295 G4cout << "\n--> WARNING from SetTarget 296 << G4endl; 297 } 298 } 299 } 300 301 //....oooOO0OOooo........oooOO0OOooo........oo 302 303 void B2bDetectorConstruction::SetChamberMateri 304 { 305 G4NistManager* nistManager = G4NistManager:: 306 307 G4Material* pttoMaterial = nistManager->Find 308 309 if (fChamberMaterial != pttoMaterial) { 310 if (pttoMaterial) { 311 fChamberMaterial = pttoMaterial; 312 if (fLogicChamber) fLogicChamber->SetMat 313 G4cout << "\n----> The chambers are made 314 } 315 else { 316 G4cout << "\n--> WARNING from SetChambe 317 << G4endl; 318 } 319 } 320 } 321 322 //....oooOO0OOooo........oooOO0OOooo........oo 323 324 void B2bDetectorConstruction::SetMaxStep(G4dou 325 { 326 if ((fStepLimit) && (maxStep > 0.)) fStepLim 327 } 328 329 //....oooOO0OOooo........oooOO0OOooo........oo 330