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 runAndEvent/RE01/src/RE01DetectorCon 26 /// \file runAndEvent/RE01/src/RE01DetectorConstruction.cc 27 /// \brief Implementation of the RE01DetectorC 27 /// \brief Implementation of the RE01DetectorConstruction class 28 // 28 // >> 29 // $Id: RE01DetectorConstruction.cc 75598 2013-11-04 13:00:59Z gcosmo $ 29 // 30 // 30 31 31 #include "RE01DetectorConstruction.hh" 32 #include "RE01DetectorConstruction.hh" 32 << 33 #include "RE01TrackerSD.hh" >> 34 #include "RE01CalorimeterSD.hh" >> 35 #include "RE01CalorimeterROGeometry.hh" >> 36 #include "RE01TrackerParametrisation.hh" 33 #include "RE01CalorimeterParametrisation.hh" 37 #include "RE01CalorimeterParametrisation.hh" 34 #include "RE01Field.hh" 38 #include "RE01Field.hh" 35 #include "RE01RegionInformation.hh" 39 #include "RE01RegionInformation.hh" 36 #include "RE01TrackerParametrisation.hh" << 37 #include "RE01TrackerSD.hh" << 38 40 39 #include "G4Box.hh" << 41 #include "G4NistManager.hh" 40 #include "G4Colour.hh" << 42 #include "G4Material.hh" >> 43 #include "G4MaterialTable.hh" 41 #include "G4Element.hh" 44 #include "G4Element.hh" 42 #include "G4ElementTable.hh" 45 #include "G4ElementTable.hh" 43 #include "G4FieldManager.hh" << 46 #include "G4Box.hh" >> 47 #include "G4Tubs.hh" 44 #include "G4LogicalVolume.hh" 48 #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" 49 #include "G4ThreeVector.hh" >> 50 #include "G4PVPlacement.hh" >> 51 #include "G4PVParameterised.hh" 56 #include "G4Transform3D.hh" 52 #include "G4Transform3D.hh" >> 53 #include "G4RotationMatrix.hh" >> 54 #include "G4FieldManager.hh" 57 #include "G4TransportationManager.hh" 55 #include "G4TransportationManager.hh" 58 #include "G4Tubs.hh" << 56 #include "G4SDManager.hh" 59 #include "G4VisAttributes.hh" 57 #include "G4VisAttributes.hh" >> 58 #include "G4Colour.hh" >> 59 #include "G4Region.hh" >> 60 #include "G4RegionStore.hh" >> 61 #include "G4SystemOfUnits.hh" 60 62 61 //....oooOO0OOooo........oooOO0OOooo........oo << 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 RE01DetectorConstruction::RE01DetectorConstruc << 64 RE01DetectorConstruction::RE01DetectorConstruction() >> 65 : G4VUserDetectorConstruction() 63 { 66 { 64 #include "RE01DetectorParameterDef.icc" 67 #include "RE01DetectorParameterDef.icc" 65 } 68 } 66 69 67 //....oooOO0OOooo........oooOO0OOooo........oo << 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 RE01DetectorConstruction::~RE01DetectorConstru 71 RE01DetectorConstruction::~RE01DetectorConstruction() 69 { << 72 {;} 70 ; << 71 } << 72 73 73 //....oooOO0OOooo........oooOO0OOooo........oo << 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 G4VPhysicalVolume* RE01DetectorConstruction::C 75 G4VPhysicalVolume* RE01DetectorConstruction::Construct() 75 { 76 { 76 //------------------------------------------ 77 //------------------------------------------------------------------------- >> 78 // Magnetic field >> 79 //------------------------------------------------------------------------- >> 80 /****************************************************************** >> 81 static G4bool fieldIsInitialized = false; >> 82 if(!fieldIsInitialized) >> 83 { >> 84 RE01Field* myField = new RE01Field; >> 85 G4FieldManager* fieldMgr >> 86 = G4TransportationManager::GetTransportationManager() >> 87 ->GetFieldManager(); >> 88 fieldMgr->SetDetectorField(myField); >> 89 fieldMgr->CreateChordFinder(myField); >> 90 fieldIsInitialized = true; >> 91 } >> 92 *******************************************************************/ >> 93 //------------------------------------------------------------------------- 77 // Materials 94 // Materials 78 //------------------------------------------ 95 //------------------------------------------------------------------------- 79 96 80 G4double a, iz, density; 97 G4double a, iz, density; 81 G4String name, symbol; 98 G4String name, symbol; 82 G4int nel; 99 G4int nel; 83 100 84 a = 1.01 * g / mole; << 101 a = 1.01*g/mole; 85 G4Element* elH = new G4Element(name = "Hydro << 102 G4Element* elH = new G4Element(name="Hydrogen", symbol="H", iz=1., a); 86 103 87 a = 12.01 * g / mole; << 104 a = 12.01*g/mole; 88 G4Element* elC = new G4Element(name = "Carbo << 105 G4Element* elC = new G4Element(name="Carbon", symbol="C", iz=6., a); 89 106 90 // Material Information imported from NIST 107 // Material Information imported from NIST database. 91 G4NistManager* NISTman = G4NistManager::Inst 108 G4NistManager* NISTman = G4NistManager::Instance(); 92 G4Material* air = NISTman->FindOrBuildMateri << 109 G4Material* air = NISTman->FindOrBuildMaterial("G4_AIR"); 93 G4Material* lead = NISTman->FindOrBuildMater << 110 G4Material* lead = NISTman->FindOrBuildMaterial("G4_Pb"); 94 G4Material* arGas = NISTman->FindOrBuildMate << 111 G4Material* arGas = NISTman->FindOrBuildMaterial("G4_Ar"); 95 G4Material* silicon = NISTman->FindOrBuildMa 112 G4Material* silicon = NISTman->FindOrBuildMaterial("G4_Si"); 96 113 97 density = 1.032 * g / cm3; << 114 density = 1.032*g/cm3; 98 G4Material* scinti = new G4Material(name = " << 115 G4Material* scinti = new G4Material(name="Scintillator", density, nel=2); 99 scinti->AddElement(elC, 9); 116 scinti->AddElement(elC, 9); 100 scinti->AddElement(elH, 10); 117 scinti->AddElement(elH, 10); 101 118 102 //------------------------------------------ 119 //------------------------------------------------------------------------- 103 // Detector geometry 120 // Detector geometry 104 //------------------------------------------ 121 //------------------------------------------------------------------------- 105 //------------------------------ experimenta 122 //------------------------------ experimental hall 106 G4Box* experimentalHall_box = new G4Box("exp << 123 G4Box * experimentalHall_box 107 G4LogicalVolume* experimentalHall_log = << 124 = new G4Box("expHall_b",fExpHall_x,fExpHall_y,fExpHall_z); 108 new G4LogicalVolume(experimentalHall_box, << 125 G4LogicalVolume * experimentalHall_log 109 G4VPhysicalVolume* experimentalHall_phys = << 126 = new G4LogicalVolume(experimentalHall_box,air,"expHall_L",0,0,0); 110 new G4PVPlacement(0, G4ThreeVector(), expe << 127 G4VPhysicalVolume * experimentalHall_phys 111 G4VisAttributes* experimentalHallVisAtt = ne << 128 = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P", >> 129 0,false,0); >> 130 G4VisAttributes* experimentalHallVisAtt >> 131 = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 112 experimentalHallVisAtt->SetForceWireframe(tr 132 experimentalHallVisAtt->SetForceWireframe(true); 113 experimentalHall_log->SetVisAttributes(exper 133 experimentalHall_log->SetVisAttributes(experimentalHallVisAtt); 114 G4Region* defaultRegion = (*(G4RegionStore:: 134 G4Region* defaultRegion = (*(G4RegionStore::GetInstance()))[0]; 115 RE01RegionInformation* defaultRInfo = new RE 135 RE01RegionInformation* defaultRInfo = new RE01RegionInformation(); 116 defaultRInfo->SetWorld(); 136 defaultRInfo->SetWorld(); 117 defaultRInfo->Print(); 137 defaultRInfo->Print(); 118 defaultRegion->SetUserInformation(defaultRIn 138 defaultRegion->SetUserInformation(defaultRInfo); 119 139 120 //------------------------------ tracker 140 //------------------------------ tracker 121 G4VSolid* tracker_tubs = new G4Tubs("trkTubs << 141 G4VSolid * tracker_tubs 122 fTrkTubs << 142 = new G4Tubs("trkTubs_tubs",fTrkTubs_rmin,fTrkTubs_rmax,fTrkTubs_dz, 123 G4LogicalVolume* tracker_log = new G4Logical << 143 fTrkTubs_sphi,fTrkTubs_dphi); >> 144 G4LogicalVolume * tracker_log >> 145 = new G4LogicalVolume(tracker_tubs,arGas,"trackerT_L",0,0,0); 124 // G4VPhysicalVolume * tracker_phys = 146 // G4VPhysicalVolume * tracker_phys = 125 new G4PVPlacement(0, G4ThreeVector(), tracke << 147 new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys", 126 0); << 148 experimentalHall_log,false,0); 127 G4VisAttributes* tracker_logVisAtt = new G4V << 149 G4VisAttributes* tracker_logVisAtt >> 150 = new G4VisAttributes(G4Colour(1.0,0.0,1.0)); 128 tracker_logVisAtt->SetForceWireframe(true); 151 tracker_logVisAtt->SetForceWireframe(true); 129 tracker_log->SetVisAttributes(tracker_logVis 152 tracker_log->SetVisAttributes(tracker_logVisAtt); 130 G4Region* trackerRegion = new G4Region("Trac 153 G4Region* trackerRegion = new G4Region("TrackerRegion"); 131 RE01RegionInformation* trackerInfo = new RE0 154 RE01RegionInformation* trackerInfo = new RE01RegionInformation(); 132 trackerInfo->SetTracker(); 155 trackerInfo->SetTracker(); 133 trackerRegion->SetUserInformation(trackerInf 156 trackerRegion->SetUserInformation(trackerInfo); 134 tracker_log->SetRegion(trackerRegion); 157 tracker_log->SetRegion(trackerRegion); 135 trackerRegion->AddRootLogicalVolume(tracker_ 158 trackerRegion->AddRootLogicalVolume(tracker_log); 136 159 137 //------------------------------ tracker lay 160 //------------------------------ tracker layers 138 // As an example for Parameterised volume << 161 // As an example for Parameterised volume 139 // dummy values for G4Tubs -- modified by pa 162 // dummy values for G4Tubs -- modified by parameterised volume 140 G4VSolid* trackerLayer_tubs = new G4Tubs("tr << 163 G4VSolid * trackerLayer_tubs 141 fTr << 164 = new G4Tubs("trackerLayer_tubs",fTrkTubs_rmin,fTrkTubs_rmax,fTrkTubs_dz, 142 fTrackerLayer_log = new G4LogicalVolume(trac << 165 fTrkTubs_sphi,fTrkTubs_dphi); 143 G4VPVParameterisation* trackerParam = new RE << 166 fTrackerLayer_log >> 167 = new G4LogicalVolume(trackerLayer_tubs,silicon,"trackerB_L",0,0,0); >> 168 G4VPVParameterisation * trackerParam >> 169 = new RE01TrackerParametrisation; 144 // dummy value : kXAxis -- modified by param 170 // dummy value : kXAxis -- modified by parameterised volume 145 // G4VPhysicalVolume *trackerLayer_phys = 171 // G4VPhysicalVolume *trackerLayer_phys = 146 new G4PVParameterised("trackerLayer_phys", f << 172 new G4PVParameterised("trackerLayer_phys",fTrackerLayer_log,tracker_log, 147 trackerParam); << 173 kXAxis, fNotrkLayers, trackerParam); 148 G4VisAttributes* trackerLayer_logVisAtt = ne << 174 G4VisAttributes* trackerLayer_logVisAtt >> 175 = new G4VisAttributes(G4Colour(0.5,0.0,1.0)); 149 trackerLayer_logVisAtt->SetForceWireframe(tr 176 trackerLayer_logVisAtt->SetForceWireframe(true); 150 fTrackerLayer_log->SetVisAttributes(trackerL 177 fTrackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt); 151 178 152 //------------------------------ calorimeter 179 //------------------------------ calorimeter 153 G4VSolid* calorimeter_tubs = new G4Tubs("cal << 180 G4VSolid * calorimeter_tubs 154 fCal << 181 = new G4Tubs("calorimeter_tubs",fCaloTubs_rmin,fCaloTubs_rmax, 155 fCalorimeter_log = new G4LogicalVolume(calor << 182 fCaloTubs_dz,fCaloTubs_sphi,fCaloTubs_dphi); >> 183 fCalorimeter_log >> 184 = new G4LogicalVolume(calorimeter_tubs,scinti,"caloT_L",0,0,0); 156 // G4VPhysicalVolume * calorimeter_phys = 185 // G4VPhysicalVolume * calorimeter_phys = 157 new G4PVPlacement(0, G4ThreeVector(), fCalor << 186 new G4PVPlacement(0,G4ThreeVector(),fCalorimeter_log,"caloM_P", 158 0); << 187 experimentalHall_log,false,0); 159 G4VisAttributes* calorimeter_logVisATT = new << 188 G4VisAttributes* calorimeter_logVisATT >> 189 = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 160 calorimeter_logVisATT->SetForceWireframe(tru 190 calorimeter_logVisATT->SetForceWireframe(true); 161 fCalorimeter_log->SetVisAttributes(calorimet 191 fCalorimeter_log->SetVisAttributes(calorimeter_logVisATT); 162 G4Region* calorimeterRegion = new G4Region(" 192 G4Region* calorimeterRegion = new G4Region("CalorimeterRegion"); 163 RE01RegionInformation* calorimeterInfo = new 193 RE01RegionInformation* calorimeterInfo = new RE01RegionInformation(); 164 calorimeterInfo->SetCalorimeter(); 194 calorimeterInfo->SetCalorimeter(); 165 calorimeterRegion->SetUserInformation(calori 195 calorimeterRegion->SetUserInformation(calorimeterInfo); 166 fCalorimeter_log->SetRegion(calorimeterRegio 196 fCalorimeter_log->SetRegion(calorimeterRegion); 167 calorimeterRegion->AddRootLogicalVolume(fCal 197 calorimeterRegion->AddRootLogicalVolume(fCalorimeter_log); 168 198 >> 199 G4String ROgeometryName = "CalorimeterROGeom"; >> 200 fCalorimeterRO = new RE01CalorimeterROGeometry(ROgeometryName); >> 201 fCalorimeterRO->BuildROGeometry(); >> 202 169 //------------------------------- Lead layer 203 //------------------------------- Lead layers 170 // As an example for Parameterised volume << 204 // As an example for Parameterised volume 171 // dummy values for G4Tubs -- modified by pa 205 // dummy values for G4Tubs -- modified by parameterised volume 172 G4VSolid* caloLayer_tubs = new G4Tubs("caloL << 206 G4VSolid * caloLayer_tubs 173 fCaloR << 207 = new G4Tubs("caloLayer_tubs",fCaloRing_rmin,fCaloRing_rmax, 174 G4LogicalVolume* caloLayer_log = new G4Logic << 208 fCaloRing_dz,fCaloRing_sphi,fCaloRing_dphi); 175 G4VPVParameterisation* calorimeterParam = ne << 209 G4LogicalVolume * caloLayer_log >> 210 = new G4LogicalVolume(caloLayer_tubs,lead,"caloR_L",0,0,0); >> 211 G4VPVParameterisation * calorimeterParam >> 212 = new RE01CalorimeterParametrisation; 176 // dummy value : kXAxis -- modified by param 213 // dummy value : kXAxis -- modified by parameterised volume 177 // G4VPhysicalVolume * caloLayer_phys = 214 // G4VPhysicalVolume * caloLayer_phys = 178 new G4PVParameterised("caloLayer_phys", calo << 215 new G4PVParameterised("caloLayer_phys",caloLayer_log,fCalorimeter_log, 179 calorimeterParam); << 216 kXAxis, fNocaloLayers, calorimeterParam); 180 G4VisAttributes* caloLayer_logVisAtt = new G << 217 G4VisAttributes* caloLayer_logVisAtt >> 218 = new G4VisAttributes(G4Colour(0.7,1.0,0.0)); 181 caloLayer_logVisAtt->SetForceWireframe(true) 219 caloLayer_logVisAtt->SetForceWireframe(true); 182 caloLayer_log->SetVisAttributes(caloLayer_lo 220 caloLayer_log->SetVisAttributes(caloLayer_logVisAtt); 183 221 >> 222 184 return experimentalHall_phys; 223 return experimentalHall_phys; 185 } 224 } 186 225 187 //....oooOO0OOooo........oooOO0OOooo........oo 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 188 void RE01DetectorConstruction::ConstructSDandF << 227 void RE01DetectorConstruction::ConstructSDandField() { 189 { << 228 190 //------------------------------------------ 229 //------------------------------------------------------------------ 191 // Sensitive Detector 230 // Sensitive Detector 192 //------------------------------------------ 231 //------------------------------------------------------------------ 193 << 232 //G4SDManager* SDman = G4SDManager::GetSDMpointer(); >> 233 194 G4String trackerSDname = "/mydet/tracker"; 234 G4String trackerSDname = "/mydet/tracker"; 195 RE01TrackerSD* trackerSD = new RE01TrackerSD << 235 RE01TrackerSD * trackerSD = new RE01TrackerSD(trackerSDname); 196 G4SDManager::GetSDMpointer()->AddNewDetector << 236 //SDman->AddNewDetector(trackerSD); 197 SetSensitiveDetector(fTrackerLayer_log, trac 237 SetSensitiveDetector(fTrackerLayer_log, trackerSD); >> 238 >> 239 G4String calorimeterSDname = "/mydet/calorimeter"; >> 240 RE01CalorimeterSD * calorimeterSD = new RE01CalorimeterSD(calorimeterSDname); >> 241 calorimeterSD->SetROgeometry(fCalorimeterRO); >> 242 //SDman->AddNewDetector(calorimeterSD); >> 243 SetSensitiveDetector(fCalorimeter_log, calorimeterSD); 198 244 199 // N.B. Calorimeter SD is defined in the par << 200 << 201 //------------------------------------------ << 202 // Magnetic field << 203 //------------------------------------------ << 204 << 205 RE01Field* myField = new RE01Field; << 206 G4FieldManager* fieldMgr = G4TransportationM << 207 fieldMgr->SetDetectorField(myField); << 208 fieldMgr->CreateChordFinder(myField); << 209 } 245 } >> 246 210 247