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