Geant4 Cross Reference |
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 errProp/src/ExErrorDetectorConstruction.cc 28 /// \brief Implementation of the ExErrorDetectorConstruction class 29 // 30 31 #include "ExErrorDetectorConstruction.hh" 32 33 #include "ExErrorDetectorMessenger.hh" 34 #include "ExErrorMagneticField.hh" 35 36 #include "G4Box.hh" 37 #include "G4Colour.hh" 38 #include "G4LogicalVolume.hh" 39 #include "G4NistManager.hh" 40 #include "G4PVPlacement.hh" 41 #include "G4PVReplica.hh" 42 #include "G4SystemOfUnits.hh" 43 #include "G4UserLimits.hh" 44 #include "G4VisAttributes.hh" 45 #include "G4ios.hh" 46 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 ExErrorDetectorConstruction::ExErrorDetectorConstruction() 49 : G4VUserDetectorConstruction(), 50 fXBEAM(5. * cm), 51 fXCDET(20. * cm), 52 fXECAL(40. * cm), 53 fXSOLN(10. * cm), 54 fXHCAL(100. * cm), 55 fXMUON(50. * cm), 56 fNdivECAL(40. / 10.), 57 fNdivHCAL(100. / 10.), 58 fYZLength(50. * cm), 59 fXHalfWorldLength(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON), 60 fUserLimits(0), 61 fMagField(0), 62 fDetectorMessenger(0) 63 { 64 // create UserLimits 65 fUserLimits = new G4UserLimits(); 66 67 fMagField = 68 new ExErrorMagneticField(G4ThreeVector(0. * kilogauss, 0. * kilogauss, -1. * kilogauss)); 69 fDetectorMessenger = new ExErrorDetectorMessenger(this); 70 } 71 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 ExErrorDetectorConstruction::~ExErrorDetectorConstruction() 74 { 75 delete fMagField; 76 delete fDetectorMessenger; 77 } 78 79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 80 G4VPhysicalVolume* ExErrorDetectorConstruction::Construct() 81 { 82 //--------- Material definition --------- 83 84 // Vacuum 85 /* a = 1.*g/mole; 86 density = 1.E-9*g/cm3; 87 G4Material* Vacuum = new G4Material(name="Vacuum", z=1., a, density); 88 */ 89 90 G4NistManager* nistMgr = G4NistManager::Instance(); 91 G4Material* air = nistMgr->FindOrBuildMaterial("G4_AIR"); 92 // Al 93 G4Material* al = nistMgr->FindOrBuildMaterial("G4_Al"); 94 // Fe 95 G4Material* fe = nistMgr->FindOrBuildMaterial("G4_Fe"); 96 // Cu 97 G4Material* cu = nistMgr->FindOrBuildMaterial("G4_Cu"); 98 99 // Print all the materials defined. 100 // 101 G4cout << G4endl << "The materials defined are : " << G4endl << G4endl; 102 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 103 104 //--- Sizes of the principal geometrical components (solids) --- (half lengths) 105 // double fXBEAM = 5.*2.*cm; 106 // double fXCDET = 90.*cm; 107 // double fXECAL = 40.*cm; 108 // double fXSOLN = 10.*cm; 109 // double fXHCAL = 100.*cm; 110 // double fXMUON = 50.*cm; 111 // double fNdivECAL = 10; 112 // double fNdivHCAL = 10; 113 // double fYZLength = 100.*cm; 114 115 // double fXWorldLength= fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON; 116 117 //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- 118 119 //------------------------------ 120 // World 121 //------------------------------ 122 //- G4double HalfWorldLength = fXWorldLength; 123 G4cout << " HalfWorldLength " << fXHalfWorldLength << G4endl; 124 125 G4Box* solidWorld = new G4Box("world", fXHalfWorldLength, fYZLength, fYZLength); 126 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, air, "World", 0, 0, 0); 127 // Must place the World Physical volume unrotated at (0,0,0). 128 // 129 G4VPhysicalVolume* physiWorld = new G4PVPlacement(0, // no rotation 130 G4ThreeVector(), // at (0,0,0) 131 "World", // its name 132 logicWorld, // its logical volume 133 0, // its mother volume 134 false, // no boolean operations 135 0); // no field specific to volum 136 137 //------------------------------ 138 // BEAM 139 //------------------------------ 140 G4Box* solidBEAM = new G4Box("BEAM", fXBEAM, fYZLength, fYZLength); 141 G4LogicalVolume* logicBEAM = new G4LogicalVolume(solidBEAM, air, "BEAM", 0, 0, 0); 142 G4ThreeVector positionBEAM = G4ThreeVector(0., 0., 0.); 143 // G4VPhysicalVolume* physiBEAM = 144 new G4PVPlacement(0, // no rotation 145 positionBEAM, // at (x,y,z) 146 "BEAM", // its name 147 logicBEAM, // its logical volume 148 physiWorld, // its mother volume 149 false, // no boolean operations 150 0); // no particular field 151 152 //------------------------------ 153 // CDET (Central DETector) 154 //------------------------------ 155 G4ThreeVector positionCdet = G4ThreeVector(fXBEAM + fXCDET / 2., 0., 0.); 156 G4Box* solidCDET = new G4Box("CDET", fXCDET / 2., fYZLength, fYZLength); 157 G4LogicalVolume* logicCDET = new G4LogicalVolume(solidCDET, air, "Cdet", 0, 0, 0); 158 // G4VPhysicalVolume* physiCDET = 159 new G4PVPlacement(0, // no rotation 160 positionCdet, // at (x,y,z) 161 "CDET", // its name 162 logicCDET, // its logical volume 163 physiWorld, // its mother volume 164 false, // no boolean operations 165 0); // no particular field 166 167 //------------------------------ 168 // ECAL 169 //------------------------------ 170 G4ThreeVector positionECAL = G4ThreeVector(fXBEAM + fXCDET + fXECAL / 2., 0., 0.); 171 G4Box* solidECAL = new G4Box("ECAL", fXECAL / 2., fYZLength, fYZLength); 172 G4LogicalVolume* logicECAL = new G4LogicalVolume(solidECAL, cu, "ECAL", 0, 0, 0); 173 G4VPhysicalVolume* physiECAL = new G4PVPlacement(0, // no rotation 174 positionECAL, // at (x,y,z) 175 "ECAL", // its name 176 logicECAL, // its logical volume 177 physiWorld, // its mother volume 178 false, // no boolean operations 179 0); // no particular field 180 //--------- Divide it 181 G4Box* solidECALdiv = new G4Box("ECAL", fXECAL / 2. / fNdivECAL, fYZLength, fYZLength); 182 G4LogicalVolume* logicECALdiv = new G4LogicalVolume(solidECALdiv, cu, "ECALdiv", 0, 0, 0); 183 new G4PVReplica("DVEC", logicECALdiv, physiECAL, kXAxis, G4int(fNdivECAL), fXECAL / fNdivECAL); 184 185 //------------------------------ 186 // SOLN 187 //------------------------------ 188 G4ThreeVector positionSOLN = G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN / 2., 0., 0.); 189 G4Box* solidSOLN = new G4Box("SOLN", fXSOLN / 2., fYZLength, fYZLength); 190 G4LogicalVolume* logicSOLN = new G4LogicalVolume(solidSOLN, al, "SOLN", 0, 0, 0); 191 new G4PVPlacement(0, // no rotation 192 positionSOLN, // at (x,y,z) 193 "SOLN", // its name 194 logicSOLN, // its logical volume 195 physiWorld, // its mother volume 196 false, // no boolean operations 197 0); // no particular field 198 199 //------------------------------ 200 // HCAL 201 //------------------------------ 202 G4ThreeVector positionHCAL = 203 G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL / 2., 0., 0.); 204 G4Box* solidHCAL = new G4Box("HCAL", fXHCAL / 2., fYZLength, fYZLength); 205 G4LogicalVolume* logicHCAL = new G4LogicalVolume(solidHCAL, fe, "HCAL", 0, 0, 0); 206 G4VPhysicalVolume* physiHCAL = new G4PVPlacement(0, // no rotation 207 positionHCAL, // at (x,y,z) 208 "HCAL", // its name 209 logicHCAL, // its logical volume 210 physiWorld, // its mother volume 211 false, // no boolean operations 212 0); // no particular field 213 //--------- Divide it 214 G4Box* solidHCALdiv = new G4Box("HCAL", fXHCAL / 2. / fNdivHCAL, fYZLength, fYZLength); 215 G4LogicalVolume* logicHCALdiv = new G4LogicalVolume(solidHCALdiv, fe, "HCALdiv", 0, 0, 0); 216 new G4PVReplica("DVEH", logicHCALdiv, physiHCAL, kXAxis, G4int(fNdivHCAL), fXHCAL / fNdivHCAL); 217 218 //------------------------------ 219 // MUON 220 //------------------------------ 221 G4ThreeVector positionMUON = 222 G4ThreeVector(fXBEAM + fXCDET + fXECAL + fXSOLN + fXHCAL + fXMUON / 2., 0., 0.); 223 G4Box* solidMUON = new G4Box("MUON", fXMUON / 2., fYZLength, fYZLength); 224 G4LogicalVolume* logicMUON = new G4LogicalVolume(solidMUON, air, "MUON", 0, 0, 0); 225 new G4PVPlacement(0, // no rotation 226 positionMUON, // at (x,y,z) 227 "MUON", // its name 228 logicMUON, // its logical volume 229 physiWorld, // its mother volume 230 false, // no boolean operations 231 0); // no particular field 232 233 G4VisAttributes* worldVisAtt = new G4VisAttributes(0); 234 logicWorld->SetVisAttributes(worldVisAtt); 235 return physiWorld; 236 } 237 238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 239 void ExErrorDetectorConstruction::SetMagField(G4double fieldValue) 240 { 241 fMagField->SetFieldValue(fieldValue); 242 } 243