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 RE05/src/RE05DetectorConstruction.cc 28 /// \brief Implementation of the RE05DetectorConstruction class 29 // 30 31 #include "RE05DetectorConstruction.hh" 32 33 #include "RE05CalorimeterParametrisation.hh" 34 #include "RE05CalorimeterSD.hh" 35 #include "RE05Field.hh" 36 #include "RE05MuonSD.hh" 37 #include "RE05TrackerParametrisation.hh" 38 #include "RE05TrackerSD.hh" 39 40 #include "G4Box.hh" 41 #include "G4Colour.hh" 42 #include "G4Element.hh" 43 #include "G4ElementTable.hh" 44 #include "G4FieldManager.hh" 45 #include "G4LogicalVolume.hh" 46 #include "G4Material.hh" 47 #include "G4MaterialTable.hh" 48 #include "G4PVParameterised.hh" 49 #include "G4PVPlacement.hh" 50 #include "G4RotationMatrix.hh" 51 #include "G4SDManager.hh" 52 #include "G4SystemOfUnits.hh" 53 #include "G4ThreeVector.hh" 54 #include "G4Transform3D.hh" 55 #include "G4TransportationManager.hh" 56 #include "G4Tubs.hh" 57 #include "G4VisAttributes.hh" 58 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 60 61 RE05DetectorConstruction::RE05DetectorConstruction() : G4VUserDetectorConstruction() 62 { 63 #include "RE05DetectorParameterDef.icc" 64 } 65 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 68 RE05DetectorConstruction::~RE05DetectorConstruction() {} 69 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 72 void RE05DetectorConstruction::DefineMaterials() 73 { 74 //------------------------------------------------------------------------- 75 // Materials 76 //------------------------------------------------------------------------- 77 78 G4double a, z, density; 79 G4int nel; 80 81 G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole); 82 G4Element* C = new G4Element("Carbon", "C", z = 6., a = 12.01 * g / mole); 83 G4Element* N = new G4Element("Nitrogen", "N", z = 7., a = 14.01 * g / mole); 84 G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole); 85 86 fAir = new G4Material("Air", density = 1.29 * mg / cm3, nel = 2); 87 fAir->AddElement(N, 70. * perCent); 88 fAir->AddElement(O, 30. * perCent); 89 90 fLead = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3); 91 92 fAr = new G4Material("ArgonGas", z = 18., a = 39.95 * g / mole, density = 1.782 * mg / cm3); 93 94 fSilicon = new G4Material("Silicon", z = 14., a = 28.09 * g / mole, density = 2.33 * g / cm3); 95 96 fScinti = new G4Material("Scintillator", density = 1.032 * g / cm3, nel = 2); 97 fScinti->AddElement(C, 9); 98 fScinti->AddElement(H, 10); 99 } 100 101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 103 G4VPhysicalVolume* RE05DetectorConstruction::Construct() 104 { 105 DefineMaterials(); 106 107 //------------------------------------------------------------------------- 108 // Detector geometry 109 //------------------------------------------------------------------------- 110 111 //------------------------------ experimental hall 112 G4Box* experimentalHall_box = new G4Box("expHall_b", fExpHall_x, fExpHall_y, fExpHall_z); 113 G4LogicalVolume* experimentalHall_log = 114 new G4LogicalVolume(experimentalHall_box, fAir, "expHall_L", 0, 0, 0); 115 G4VPhysicalVolume* experimentalHall_phys = 116 new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log, "expHall_P", 0, false, 0); 117 experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); 118 119 //------------------------------ tracker 120 G4VSolid* fTracker_tubs = new G4Tubs("trkTubs_tubs", fTrkTubs_rmin, fTrkTubs_rmax, fTrkTubs_dz, 121 fTrkTubs_sphi, fTrkTubs_dphi); 122 G4LogicalVolume* fTracker_log = new G4LogicalVolume(fTracker_tubs, fAr, "trackerT_L", 0, 0, 0); 123 // G4VPhysicalVolume * fTracker_phys = 124 new G4PVPlacement(0, G4ThreeVector(), fTracker_log, "tracker_phys", experimentalHall_log, false, 125 0); 126 G4VisAttributes* fTracker_logVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); 127 fTracker_log->SetVisAttributes(fTracker_logVisAtt); 128 129 //------------------------------ tracker layers 130 // As an example for Parameterised volume 131 // dummy values for G4Tubs -- modified by parameterised volume 132 G4VSolid* trackerLayer_tubs = new G4Tubs("trackerLayer_tubs", fTrkTubs_rmin, fTrkTubs_rmax, 133 fTrkTubs_dz, fTrkTubs_sphi, fTrkTubs_dphi); 134 G4LogicalVolume* trackerLayer_log = 135 new G4LogicalVolume(trackerLayer_tubs, fSilicon, "trackerB_L", 0, 0, 0); 136 G4VPVParameterisation* trackerParam = new RE05TrackerParametrisation; 137 // dummy value : kXAxis -- modified by parameterised volume 138 // G4VPhysicalVolume *trackerLayer_phys = 139 new G4PVParameterised("trackerLayer_phys", trackerLayer_log, fTracker_log, kXAxis, fNotrkLayers, 140 trackerParam); 141 G4VisAttributes* trackerLayer_logVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0)); 142 trackerLayer_logVisAtt->SetForceWireframe(true); 143 trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt); 144 145 //------------------------------ calorimeter 146 G4VSolid* calorimeter_tubs = new G4Tubs("calorimeter_tubs", fCaloTubs_rmin, fCaloTubs_rmax, 147 fCaloTubs_dz, fCaloTubs_sphi, fCaloTubs_dphi); 148 G4LogicalVolume* calorimeter_log = 149 new G4LogicalVolume(calorimeter_tubs, fScinti, "caloT_L", 0, 0, 0); 150 // G4VPhysicalVolume * calorimeter_phys = 151 new G4PVPlacement(0, G4ThreeVector(), calorimeter_log, "caloM_P", experimentalHall_log, false, 0); 152 G4VisAttributes* calorimeter_logVisATT = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); 153 calorimeter_logVisATT->SetForceWireframe(true); 154 calorimeter_log->SetVisAttributes(calorimeter_logVisATT); 155 156 //------------------------------- Lead layers 157 // As an example for Parameterised volume 158 // dummy values for G4Tubs -- modified by parameterised volume 159 G4VSolid* caloLayer_tubs = new G4Tubs("caloLayer_tubs", fCaloRing_rmin, fCaloRing_rmax, 160 fCaloRing_dz, fCaloRing_sphi, fCaloRing_dphi); 161 G4LogicalVolume* caloLayer_log = new G4LogicalVolume(caloLayer_tubs, fLead, "caloR_L", 0, 0, 0); 162 G4VPVParameterisation* calorimeterParam = new RE05CalorimeterParametrisation; 163 // dummy value : kXAxis -- modified by parameterised volume 164 // G4VPhysicalVolume * caloLayer_phys = 165 new G4PVParameterised("caloLayer_phys", caloLayer_log, calorimeter_log, kXAxis, fNocaloLayers, 166 calorimeterParam); 167 G4VisAttributes* caloLayer_logVisAtt = new G4VisAttributes(G4Colour(0.7, 1.0, 0.0)); 168 caloLayer_log->SetVisAttributes(caloLayer_logVisAtt); 169 170 //------------------------------ muon counters 171 // As an example of CSG volumes with rotation 172 G4VSolid* muoncounter_box = 173 new G4Box("muoncounter_box", fMuBox_width, fMuBox_thick, fMuBox_length); 174 G4LogicalVolume* muoncounter_log = 175 new G4LogicalVolume(muoncounter_box, fScinti, "mucounter_L", 0, 0, 0); 176 for (int i = 0; i < fNomucounter; i++) { 177 G4double phi, x, y, z; 178 phi = 360. * deg / fNomucounter * i; 179 x = fMuBox_radius * std::sin(phi); 180 y = fMuBox_radius * std::cos(phi); 181 z = 0. * cm; 182 G4RotationMatrix rm; 183 rm.rotateZ(phi); 184 new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(x, y, z)), muoncounter_log, "muoncounter_P", 185 experimentalHall_log, false, i); 186 } 187 G4VisAttributes* muoncounter_logVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); 188 muoncounter_logVisAtt->SetForceWireframe(true); 189 muoncounter_log->SetVisAttributes(muoncounter_logVisAtt); 190 191 return experimentalHall_phys; 192 } 193 194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 195 196 void RE05DetectorConstruction::ConstructSDandField() 197 { 198 //------------------------------------------------------------------------- 199 // Magnetic field 200 //------------------------------------------------------------------------- 201 RE05Field* myField = new RE05Field; 202 G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 203 fieldMgr->SetDetectorField(myField); 204 fieldMgr->CreateChordFinder(myField); 205 206 //------------------------------------------------------------------ 207 // Sensitive Detectors 208 //------------------------------------------------------------------ 209 G4String trackerSDname = "/mydet/tracker"; 210 RE05TrackerSD* trackerSD = new RE05TrackerSD(trackerSDname); 211 G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD); 212 SetSensitiveDetector("trackerB_L", trackerSD); 213 214 G4String muonSDname = "/mydet/muon"; 215 RE05MuonSD* muonSD = new RE05MuonSD(muonSDname); 216 G4SDManager::GetSDMpointer()->AddNewDetector(muonSD); 217 SetSensitiveDetector("mucounter_L", muonSD); 218 } 219 220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 221