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