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 /// \file runAndEvent/RE01/src/RE01DetectorConstruction.cc 27 /// \brief Implementation of the RE01DetectorConstruction class 28 // 29 // 30 31 #include "RE01DetectorConstruction.hh" 32 33 #include "RE01CalorimeterParametrisation.hh" 34 #include "RE01Field.hh" 35 #include "RE01RegionInformation.hh" 36 #include "RE01TrackerParametrisation.hh" 37 #include "RE01TrackerSD.hh" 38 39 #include "G4Box.hh" 40 #include "G4Colour.hh" 41 #include "G4Element.hh" 42 #include "G4ElementTable.hh" 43 #include "G4FieldManager.hh" 44 #include "G4LogicalVolume.hh" 45 #include "G4Material.hh" 46 #include "G4MaterialTable.hh" 47 #include "G4NistManager.hh" 48 #include "G4PVParameterised.hh" 49 #include "G4PVPlacement.hh" 50 #include "G4Region.hh" 51 #include "G4RegionStore.hh" 52 #include "G4RotationMatrix.hh" 53 #include "G4SDManager.hh" 54 #include "G4SystemOfUnits.hh" 55 #include "G4ThreeVector.hh" 56 #include "G4Transform3D.hh" 57 #include "G4TransportationManager.hh" 58 #include "G4Tubs.hh" 59 #include "G4VisAttributes.hh" 60 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 RE01DetectorConstruction::RE01DetectorConstruction() : G4VUserDetectorConstruction() 63 { 64 #include "RE01DetectorParameterDef.icc" 65 } 66 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 RE01DetectorConstruction::~RE01DetectorConstruction() 69 { 70 ; 71 } 72 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 G4VPhysicalVolume* RE01DetectorConstruction::Construct() 75 { 76 //------------------------------------------------------------------------- 77 // Materials 78 //------------------------------------------------------------------------- 79 80 G4double a, iz, density; 81 G4String name, symbol; 82 G4int nel; 83 84 a = 1.01 * g / mole; 85 G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", iz = 1., a); 86 87 a = 12.01 * g / mole; 88 G4Element* elC = new G4Element(name = "Carbon", symbol = "C", iz = 6., a); 89 90 // Material Information imported from NIST database. 91 G4NistManager* NISTman = G4NistManager::Instance(); 92 G4Material* air = NISTman->FindOrBuildMaterial("G4_AIR"); 93 G4Material* lead = NISTman->FindOrBuildMaterial("G4_Pb"); 94 G4Material* arGas = NISTman->FindOrBuildMaterial("G4_Ar"); 95 G4Material* silicon = NISTman->FindOrBuildMaterial("G4_Si"); 96 97 density = 1.032 * g / cm3; 98 G4Material* scinti = new G4Material(name = "Scintillator", density, nel = 2); 99 scinti->AddElement(elC, 9); 100 scinti->AddElement(elH, 10); 101 102 //------------------------------------------------------------------------- 103 // Detector geometry 104 //------------------------------------------------------------------------- 105 //------------------------------ experimental hall 106 G4Box* experimentalHall_box = new G4Box("expHall_b", fExpHall_x, fExpHall_y, fExpHall_z); 107 G4LogicalVolume* experimentalHall_log = 108 new G4LogicalVolume(experimentalHall_box, air, "expHall_L", 0, 0, 0); 109 G4VPhysicalVolume* experimentalHall_phys = 110 new G4PVPlacement(0, G4ThreeVector(), experimentalHall_log, "expHall_P", 0, false, 0); 111 G4VisAttributes* experimentalHallVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); 112 experimentalHallVisAtt->SetForceWireframe(true); 113 experimentalHall_log->SetVisAttributes(experimentalHallVisAtt); 114 G4Region* defaultRegion = (*(G4RegionStore::GetInstance()))[0]; 115 RE01RegionInformation* defaultRInfo = new RE01RegionInformation(); 116 defaultRInfo->SetWorld(); 117 defaultRInfo->Print(); 118 defaultRegion->SetUserInformation(defaultRInfo); 119 120 //------------------------------ tracker 121 G4VSolid* tracker_tubs = new G4Tubs("trkTubs_tubs", fTrkTubs_rmin, fTrkTubs_rmax, fTrkTubs_dz, 122 fTrkTubs_sphi, fTrkTubs_dphi); 123 G4LogicalVolume* tracker_log = new G4LogicalVolume(tracker_tubs, arGas, "trackerT_L", 0, 0, 0); 124 // G4VPhysicalVolume * tracker_phys = 125 new G4PVPlacement(0, G4ThreeVector(), tracker_log, "tracker_phys", experimentalHall_log, false, 126 0); 127 G4VisAttributes* tracker_logVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); 128 tracker_logVisAtt->SetForceWireframe(true); 129 tracker_log->SetVisAttributes(tracker_logVisAtt); 130 G4Region* trackerRegion = new G4Region("TrackerRegion"); 131 RE01RegionInformation* trackerInfo = new RE01RegionInformation(); 132 trackerInfo->SetTracker(); 133 trackerRegion->SetUserInformation(trackerInfo); 134 tracker_log->SetRegion(trackerRegion); 135 trackerRegion->AddRootLogicalVolume(tracker_log); 136 137 //------------------------------ tracker layers 138 // As an example for Parameterised volume 139 // dummy values for G4Tubs -- modified by parameterised volume 140 G4VSolid* trackerLayer_tubs = new G4Tubs("trackerLayer_tubs", fTrkTubs_rmin, fTrkTubs_rmax, 141 fTrkTubs_dz, fTrkTubs_sphi, fTrkTubs_dphi); 142 fTrackerLayer_log = new G4LogicalVolume(trackerLayer_tubs, silicon, "trackerB_L", 0, 0, 0); 143 G4VPVParameterisation* trackerParam = new RE01TrackerParametrisation; 144 // dummy value : kXAxis -- modified by parameterised volume 145 // G4VPhysicalVolume *trackerLayer_phys = 146 new G4PVParameterised("trackerLayer_phys", fTrackerLayer_log, tracker_log, kXAxis, fNotrkLayers, 147 trackerParam); 148 G4VisAttributes* trackerLayer_logVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0)); 149 trackerLayer_logVisAtt->SetForceWireframe(true); 150 fTrackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt); 151 152 //------------------------------ calorimeter 153 G4VSolid* calorimeter_tubs = new G4Tubs("calorimeter_tubs", fCaloTubs_rmin, fCaloTubs_rmax, 154 fCaloTubs_dz, fCaloTubs_sphi, fCaloTubs_dphi); 155 fCalorimeter_log = new G4LogicalVolume(calorimeter_tubs, scinti, "caloT_L", 0, 0, 0); 156 // G4VPhysicalVolume * calorimeter_phys = 157 new G4PVPlacement(0, G4ThreeVector(), fCalorimeter_log, "caloM_P", experimentalHall_log, false, 158 0); 159 G4VisAttributes* calorimeter_logVisATT = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); 160 calorimeter_logVisATT->SetForceWireframe(true); 161 fCalorimeter_log->SetVisAttributes(calorimeter_logVisATT); 162 G4Region* calorimeterRegion = new G4Region("CalorimeterRegion"); 163 RE01RegionInformation* calorimeterInfo = new RE01RegionInformation(); 164 calorimeterInfo->SetCalorimeter(); 165 calorimeterRegion->SetUserInformation(calorimeterInfo); 166 fCalorimeter_log->SetRegion(calorimeterRegion); 167 calorimeterRegion->AddRootLogicalVolume(fCalorimeter_log); 168 169 //------------------------------- Lead layers 170 // As an example for Parameterised volume 171 // dummy values for G4Tubs -- modified by parameterised volume 172 G4VSolid* caloLayer_tubs = new G4Tubs("caloLayer_tubs", fCaloRing_rmin, fCaloRing_rmax, 173 fCaloRing_dz, fCaloRing_sphi, fCaloRing_dphi); 174 G4LogicalVolume* caloLayer_log = new G4LogicalVolume(caloLayer_tubs, lead, "caloR_L", 0, 0, 0); 175 G4VPVParameterisation* calorimeterParam = new RE01CalorimeterParametrisation; 176 // dummy value : kXAxis -- modified by parameterised volume 177 // G4VPhysicalVolume * caloLayer_phys = 178 new G4PVParameterised("caloLayer_phys", caloLayer_log, fCalorimeter_log, kXAxis, fNocaloLayers, 179 calorimeterParam); 180 G4VisAttributes* caloLayer_logVisAtt = new G4VisAttributes(G4Colour(0.7, 1.0, 0.0)); 181 caloLayer_logVisAtt->SetForceWireframe(true); 182 caloLayer_log->SetVisAttributes(caloLayer_logVisAtt); 183 184 return experimentalHall_phys; 185 } 186 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 188 void RE01DetectorConstruction::ConstructSDandField() 189 { 190 //------------------------------------------------------------------ 191 // Sensitive Detector 192 //------------------------------------------------------------------ 193 194 G4String trackerSDname = "/mydet/tracker"; 195 RE01TrackerSD* trackerSD = new RE01TrackerSD(trackerSDname); 196 G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD); 197 SetSensitiveDetector(fTrackerLayer_log, trackerSD); 198 199 // N.B. Calorimeter SD is defined in the parallel world. 200 201 //------------------------------------------------------------------------- 202 // Magnetic field 203 //------------------------------------------------------------------------- 204 205 RE01Field* myField = new RE01Field; 206 G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 207 fieldMgr->SetDetectorField(myField); 208 fieldMgr->CreateChordFinder(myField); 209 } 210