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 // $Id: RE05DetectorConstruction.cc 69920 2013-05-17 13:36:37Z gcosmo $ 26 // 27 // 27 /// \file RE05/src/RE05DetectorConstruction.cc 28 /// \file RE05/src/RE05DetectorConstruction.cc 28 /// \brief Implementation of the RE05DetectorC 29 /// \brief Implementation of the RE05DetectorConstruction class 29 // 30 // 30 31 31 #include "RE05DetectorConstruction.hh" 32 #include "RE05DetectorConstruction.hh" 32 << 33 #include "RE05TrackerSD.hh" 33 #include "RE05CalorimeterParametrisation.hh" << 34 #include "RE05CalorimeterSD.hh" 34 #include "RE05CalorimeterSD.hh" 35 #include "RE05Field.hh" << 36 #include "RE05MuonSD.hh" 35 #include "RE05MuonSD.hh" 37 #include "RE05TrackerParametrisation.hh" 36 #include "RE05TrackerParametrisation.hh" 38 #include "RE05TrackerSD.hh" << 37 #include "RE05CalorimeterParametrisation.hh" >> 38 #include "RE05Field.hh" 39 39 40 #include "G4Box.hh" << 40 #include "G4Material.hh" 41 #include "G4Colour.hh" << 41 #include "G4MaterialTable.hh" 42 #include "G4Element.hh" 42 #include "G4Element.hh" 43 #include "G4ElementTable.hh" 43 #include "G4ElementTable.hh" 44 #include "G4FieldManager.hh" << 44 #include "G4Box.hh" >> 45 #include "G4Tubs.hh" 45 #include "G4LogicalVolume.hh" 46 #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" 47 #include "G4ThreeVector.hh" >> 48 #include "G4PVPlacement.hh" >> 49 #include "G4PVParameterised.hh" 54 #include "G4Transform3D.hh" 50 #include "G4Transform3D.hh" >> 51 #include "G4RotationMatrix.hh" >> 52 #include "G4FieldManager.hh" 55 #include "G4TransportationManager.hh" 53 #include "G4TransportationManager.hh" 56 #include "G4Tubs.hh" << 54 #include "G4SDManager.hh" 57 #include "G4VisAttributes.hh" 55 #include "G4VisAttributes.hh" >> 56 #include "G4Colour.hh" >> 57 #include "G4SystemOfUnits.hh" 58 58 59 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 60 60 61 RE05DetectorConstruction::RE05DetectorConstruc << 61 RE05DetectorConstruction::RE05DetectorConstruction() 62 { 62 { >> 63 63 #include "RE05DetectorParameterDef.icc" 64 #include "RE05DetectorParameterDef.icc" >> 65 64 } 66 } 65 67 66 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 69 68 RE05DetectorConstruction::~RE05DetectorConstru << 70 RE05DetectorConstruction::~RE05DetectorConstruction() >> 71 { >> 72 delete Scinti; >> 73 delete Silicon; >> 74 delete Ar; >> 75 delete Lead; >> 76 delete Air; >> 77 >> 78 delete O; >> 79 delete N; >> 80 delete C; >> 81 delete H; >> 82 } 69 83 70 //....oooOO0OOooo........oooOO0OOooo........oo 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 85 72 void RE05DetectorConstruction::DefineMaterials 86 void RE05DetectorConstruction::DefineMaterials() 73 { 87 { 74 //------------------------------------------ 88 //------------------------------------------------------------------------- 75 // Materials 89 // Materials 76 //------------------------------------------ 90 //------------------------------------------------------------------------- 77 91 78 G4double a, z, density; 92 G4double a, z, density; 79 G4int nel; 93 G4int nel; 80 94 81 G4Element* H = new G4Element("Hydrogen", "H" << 95 H = new G4Element("Hydrogen", "H", z=1., a= 1.01*g/mole); 82 G4Element* C = new G4Element("Carbon", "C", << 96 C = new G4Element("Carbon", "C", z=6., a= 12.01*g/mole); 83 G4Element* N = new G4Element("Nitrogen", "N" << 97 N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole); 84 G4Element* O = new G4Element("Oxygen", "O", << 98 O = new G4Element("Oxygen", "O", z=8., a= 16.00*g/mole); 85 << 99 86 fAir = new G4Material("Air", density = 1.29 << 100 Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2); 87 fAir->AddElement(N, 70. * perCent); << 101 Air->AddElement(N, 70.*perCent); 88 fAir->AddElement(O, 30. * perCent); << 102 Air->AddElement(O, 30.*perCent); 89 << 103 90 fLead = new G4Material("Lead", z = 82., a = << 104 Lead = 91 << 105 new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3); 92 fAr = new G4Material("ArgonGas", z = 18., a << 106 93 << 107 Ar = 94 fSilicon = new G4Material("Silicon", z = 14. << 108 new G4Material("ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3); 95 << 109 96 fScinti = new G4Material("Scintillator", den << 110 Silicon = 97 fScinti->AddElement(C, 9); << 111 new G4Material("Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3); 98 fScinti->AddElement(H, 10); << 112 >> 113 Scinti = new G4Material("Scintillator", density= 1.032*g/cm3, nel=2); >> 114 Scinti->AddElement(C, 9); >> 115 Scinti->AddElement(H, 10); 99 } 116 } 100 117 101 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 119 103 G4VPhysicalVolume* RE05DetectorConstruction::C 120 G4VPhysicalVolume* RE05DetectorConstruction::Construct() 104 { 121 { 105 DefineMaterials(); 122 DefineMaterials(); 106 123 107 //------------------------------------------ 124 //------------------------------------------------------------------------- 108 // Detector geometry 125 // Detector geometry 109 //------------------------------------------ 126 //------------------------------------------------------------------------- 110 127 111 //------------------------------ experimenta 128 //------------------------------ experimental hall 112 G4Box* experimentalHall_box = new G4Box("exp << 129 G4Box * experimentalHall_box 113 G4LogicalVolume* experimentalHall_log = << 130 = new G4Box("expHall_b",expHall_x,expHall_y,expHall_z); 114 new G4LogicalVolume(experimentalHall_box, << 131 G4LogicalVolume * experimentalHall_log 115 G4VPhysicalVolume* experimentalHall_phys = << 132 = new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0); 116 new G4PVPlacement(0, G4ThreeVector(), expe << 133 G4VPhysicalVolume * experimentalHall_phys >> 134 = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P", >> 135 0,false,0); 117 experimentalHall_log->SetVisAttributes(G4Vis 136 experimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); 118 137 119 //------------------------------ tracker 138 //------------------------------ tracker 120 G4VSolid* fTracker_tubs = new G4Tubs("trkTub << 139 G4VSolid * tracker_tubs 121 fTrkTub << 140 = new G4Tubs("trkTubs_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz, 122 G4LogicalVolume* fTracker_log = new G4Logica << 141 trkTubs_sphi,trkTubs_dphi); 123 // G4VPhysicalVolume * fTracker_phys = << 142 G4LogicalVolume * tracker_log 124 new G4PVPlacement(0, G4ThreeVector(), fTrack << 143 = new G4LogicalVolume(tracker_tubs,Ar,"trackerT_L",0,0,0); 125 0); << 144 // G4VPhysicalVolume * tracker_phys = 126 G4VisAttributes* fTracker_logVisAtt = new G4 << 145 new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys", 127 fTracker_log->SetVisAttributes(fTracker_logV << 146 experimentalHall_log,false,0); >> 147 G4VisAttributes* tracker_logVisAtt >> 148 = new G4VisAttributes(G4Colour(1.0,0.0,1.0)); >> 149 tracker_log->SetVisAttributes(tracker_logVisAtt); 128 150 129 //------------------------------ tracker lay 151 //------------------------------ tracker layers 130 // As an example for Parameterised volume << 152 // As an example for Parameterised volume 131 // dummy values for G4Tubs -- modified by pa 153 // dummy values for G4Tubs -- modified by parameterised volume 132 G4VSolid* trackerLayer_tubs = new G4Tubs("tr << 154 G4VSolid * trackerLayer_tubs 133 fTr << 155 = new G4Tubs("trackerLayer_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz, 134 G4LogicalVolume* trackerLayer_log = << 156 trkTubs_sphi,trkTubs_dphi); 135 new G4LogicalVolume(trackerLayer_tubs, fSi << 157 G4LogicalVolume * trackerLayer_log 136 G4VPVParameterisation* trackerParam = new RE << 158 = new G4LogicalVolume(trackerLayer_tubs,Silicon,"trackerB_L",0,0,0); >> 159 G4VPVParameterisation * trackerParam >> 160 = new RE05TrackerParametrisation; 137 // dummy value : kXAxis -- modified by param 161 // dummy value : kXAxis -- modified by parameterised volume 138 // G4VPhysicalVolume *trackerLayer_phys = 162 // G4VPhysicalVolume *trackerLayer_phys = 139 new G4PVParameterised("trackerLayer_phys", t << 163 new G4PVParameterised("trackerLayer_phys",trackerLayer_log,tracker_log, 140 trackerParam); << 164 kXAxis, notrkLayers, trackerParam); 141 G4VisAttributes* trackerLayer_logVisAtt = ne << 165 G4VisAttributes* trackerLayer_logVisAtt >> 166 = new G4VisAttributes(G4Colour(0.5,0.0,1.0)); 142 trackerLayer_logVisAtt->SetForceWireframe(tr 167 trackerLayer_logVisAtt->SetForceWireframe(true); 143 trackerLayer_log->SetVisAttributes(trackerLa 168 trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt); 144 169 145 //------------------------------ calorimeter 170 //------------------------------ calorimeter 146 G4VSolid* calorimeter_tubs = new G4Tubs("cal << 171 G4VSolid * calorimeter_tubs 147 fCal << 172 = new G4Tubs("calorimeter_tubs",caloTubs_rmin,caloTubs_rmax, 148 G4LogicalVolume* calorimeter_log = << 173 caloTubs_dz,caloTubs_sphi,caloTubs_dphi); 149 new G4LogicalVolume(calorimeter_tubs, fSci << 174 G4LogicalVolume * calorimeter_log >> 175 = new G4LogicalVolume(calorimeter_tubs,Scinti,"caloT_L",0,0,0); 150 // G4VPhysicalVolume * calorimeter_phys = 176 // G4VPhysicalVolume * calorimeter_phys = 151 new G4PVPlacement(0, G4ThreeVector(), calori << 177 new G4PVPlacement(0,G4ThreeVector(),calorimeter_log,"caloM_P", 152 G4VisAttributes* calorimeter_logVisATT = new << 178 experimentalHall_log,false,0); >> 179 G4VisAttributes* calorimeter_logVisATT >> 180 = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 153 calorimeter_logVisATT->SetForceWireframe(tru 181 calorimeter_logVisATT->SetForceWireframe(true); 154 calorimeter_log->SetVisAttributes(calorimete 182 calorimeter_log->SetVisAttributes(calorimeter_logVisATT); 155 183 156 //------------------------------- Lead layer 184 //------------------------------- Lead layers 157 // As an example for Parameterised volume << 185 // As an example for Parameterised volume 158 // dummy values for G4Tubs -- modified by pa 186 // dummy values for G4Tubs -- modified by parameterised volume 159 G4VSolid* caloLayer_tubs = new G4Tubs("caloL << 187 G4VSolid * caloLayer_tubs 160 fCaloR << 188 = new G4Tubs("caloLayer_tubs",caloRing_rmin,caloRing_rmax, 161 G4LogicalVolume* caloLayer_log = new G4Logic << 189 caloRing_dz,caloRing_sphi,caloRing_dphi); 162 G4VPVParameterisation* calorimeterParam = ne << 190 G4LogicalVolume * caloLayer_log >> 191 = new G4LogicalVolume(caloLayer_tubs,Lead,"caloR_L",0,0,0); >> 192 G4VPVParameterisation * calorimeterParam >> 193 = new RE05CalorimeterParametrisation; 163 // dummy value : kXAxis -- modified by param 194 // dummy value : kXAxis -- modified by parameterised volume 164 // G4VPhysicalVolume * caloLayer_phys = 195 // G4VPhysicalVolume * caloLayer_phys = 165 new G4PVParameterised("caloLayer_phys", calo << 196 new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log, 166 calorimeterParam); << 197 kXAxis, nocaloLayers, calorimeterParam); 167 G4VisAttributes* caloLayer_logVisAtt = new G << 198 G4VisAttributes* caloLayer_logVisAtt >> 199 = new G4VisAttributes(G4Colour(0.7,1.0,0.0)); 168 caloLayer_log->SetVisAttributes(caloLayer_lo 200 caloLayer_log->SetVisAttributes(caloLayer_logVisAtt); 169 201 170 //------------------------------ muon counte 202 //------------------------------ muon counters 171 // As an example of CSG volumes with rotatio 203 // As an example of CSG volumes with rotation 172 G4VSolid* muoncounter_box = << 204 G4VSolid * muoncounter_box 173 new G4Box("muoncounter_box", fMuBox_width, << 205 = new G4Box("muoncounter_box",muBox_width,muBox_thick, 174 G4LogicalVolume* muoncounter_log = << 206 muBox_length); 175 new G4LogicalVolume(muoncounter_box, fScin << 207 G4LogicalVolume * muoncounter_log 176 for (int i = 0; i < fNomucounter; i++) { << 208 = new G4LogicalVolume(muoncounter_box,Scinti,"mucounter_L",0,0,0); >> 209 for(int i=0; i<nomucounter ; i++) >> 210 { 177 G4double phi, x, y, z; 211 G4double phi, x, y, z; 178 phi = 360. * deg / fNomucounter * i; << 212 phi = 360.*deg/nomucounter*i; 179 x = fMuBox_radius * std::sin(phi); << 213 x = muBox_radius*std::sin(phi); 180 y = fMuBox_radius * std::cos(phi); << 214 y = muBox_radius*std::cos(phi); 181 z = 0. * cm; << 215 z = 0.*cm; 182 G4RotationMatrix rm; 216 G4RotationMatrix rm; 183 rm.rotateZ(phi); 217 rm.rotateZ(phi); 184 new G4PVPlacement(G4Transform3D(rm, G4Thre << 218 new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(x,y,z)), 185 experimentalHall_log, fa << 219 muoncounter_log, "muoncounter_P", >> 220 experimentalHall_log,false,i); 186 } 221 } 187 G4VisAttributes* muoncounter_logVisAtt = new << 222 G4VisAttributes* muoncounter_logVisAtt >> 223 = new G4VisAttributes(G4Colour(0.0,1.0,1.0)); 188 muoncounter_logVisAtt->SetForceWireframe(tru 224 muoncounter_logVisAtt->SetForceWireframe(true); 189 muoncounter_log->SetVisAttributes(muoncounte 225 muoncounter_log->SetVisAttributes(muoncounter_logVisAtt); 190 226 191 return experimentalHall_phys; 227 return experimentalHall_phys; 192 } 228 } 193 229 194 //....oooOO0OOooo........oooOO0OOooo........oo 230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 195 231 196 void RE05DetectorConstruction::ConstructSDandF 232 void RE05DetectorConstruction::ConstructSDandField() 197 { 233 { 198 //------------------------------------------ 234 //------------------------------------------------------------------------- 199 // Magnetic field 235 // Magnetic field 200 //------------------------------------------ 236 //------------------------------------------------------------------------- 201 RE05Field* myField = new RE05Field; 237 RE05Field* myField = new RE05Field; 202 G4FieldManager* fieldMgr = G4TransportationM << 238 G4FieldManager* fieldMgr >> 239 = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 203 fieldMgr->SetDetectorField(myField); 240 fieldMgr->SetDetectorField(myField); 204 fieldMgr->CreateChordFinder(myField); 241 fieldMgr->CreateChordFinder(myField); 205 242 206 //------------------------------------------ 243 //------------------------------------------------------------------ 207 // Sensitive Detectors 244 // Sensitive Detectors 208 //------------------------------------------ 245 //------------------------------------------------------------------ 209 G4String trackerSDname = "/mydet/tracker"; 246 G4String trackerSDname = "/mydet/tracker"; 210 RE05TrackerSD* trackerSD = new RE05TrackerSD << 247 RE05TrackerSD * trackerSD = new RE05TrackerSD(trackerSDname); 211 G4SDManager::GetSDMpointer()->AddNewDetector << 248 SetSensitiveDetector("trackerB_L",trackerSD); 212 SetSensitiveDetector("trackerB_L", trackerSD << 213 249 214 G4String muonSDname = "/mydet/muon"; 250 G4String muonSDname = "/mydet/muon"; 215 RE05MuonSD* muonSD = new RE05MuonSD(muonSDna << 251 RE05MuonSD * muonSD = new RE05MuonSD(muonSDname); 216 G4SDManager::GetSDMpointer()->AddNewDetector << 252 SetSensitiveDetector("mucounter_L",muonSD); 217 SetSensitiveDetector("mucounter_L", muonSD); << 218 } 253 } 219 254 220 //....oooOO0OOooo........oooOO0OOooo........oo << 221 255