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 Par01/src/Par01DetectorConstruction. 26 /// \file Par01/src/Par01DetectorConstruction.cc 27 /// \brief Implementation of the Par01Detector 27 /// \brief Implementation of the Par01DetectorConstruction class 28 // 28 // 29 // 29 // >> 30 // $Id: Par01DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $ 30 // 31 // 31 #include "Par01DetectorConstruction.hh" 32 #include "Par01DetectorConstruction.hh" 32 << 33 #include "Par01CalorimeterSD.hh" 33 #include "Par01CalorimeterSD.hh" 34 #include "Par01EMShowerModel.hh" 34 #include "Par01EMShowerModel.hh" 35 #include "Par01PiModel.hh" 35 #include "Par01PiModel.hh" 36 36 37 #include "G4Box.hh" << 37 #include "G4Material.hh" 38 #include "G4Colour.hh" << 38 #include "G4MaterialTable.hh" 39 #include "G4Element.hh" 39 #include "G4Element.hh" >> 40 #include "G4ProductionCuts.hh" 40 #include "G4ElementTable.hh" 41 #include "G4ElementTable.hh" >> 42 #include "G4Box.hh" >> 43 #include "G4Tubs.hh" 41 #include "G4LogicalVolume.hh" 44 #include "G4LogicalVolume.hh" 42 #include "G4Material.hh" << 45 #include "G4ThreeVector.hh" 43 #include "G4MaterialTable.hh" << 44 #include "G4NistManager.hh" << 45 #include "G4PVPlacement.hh" 46 #include "G4PVPlacement.hh" 46 #include "G4ProductionCuts.hh" << 47 #include "G4RegionStore.hh" << 48 #include "G4SDManager.hh" 47 #include "G4SDManager.hh" 49 #include "G4SystemOfUnits.hh" << 50 #include "G4ThreeVector.hh" << 51 #include "G4Tubs.hh" << 52 #include "G4VisAttributes.hh" 48 #include "G4VisAttributes.hh" >> 49 #include "G4Colour.hh" >> 50 #include "G4SystemOfUnits.hh" >> 51 #include "G4NistManager.hh" >> 52 >> 53 #include "G4RegionStore.hh" 53 54 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 56 56 Par01DetectorConstruction::Par01DetectorConstr 57 Par01DetectorConstruction::Par01DetectorConstruction() 57 { << 58 {;} 58 ; << 59 } << 60 59 61 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 61 63 Par01DetectorConstruction::~Par01DetectorConst 62 Par01DetectorConstruction::~Par01DetectorConstruction() 64 { << 63 {;} 65 ; << 66 } << 67 64 68 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 69 66 70 G4VPhysicalVolume* Par01DetectorConstruction:: 67 G4VPhysicalVolume* Par01DetectorConstruction::Construct() 71 { 68 { 72 G4cout << "\nPar01DetectorConstruction....\n 69 G4cout << "\nPar01DetectorConstruction....\n" << G4endl; 73 << 70 74 //--------- Material definition --------- 71 //--------- Material definition --------- 75 // Get nist material manager 72 // Get nist material manager 76 G4NistManager* nistManager = G4NistManager:: 73 G4NistManager* nistManager = G4NistManager::Instance(); 77 74 78 // Build materials 75 // Build materials 79 G4Material* air = nistManager->FindOrBuildMa << 76 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR"); 80 G4Material* csi = nistManager->FindOrBuildMa << 77 G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE"); 81 G4Material* helium = nistManager->FindOrBuil 78 G4Material* helium = nistManager->FindOrBuildMaterial("G4_He"); 82 G4Material* iron = nistManager->FindOrBuildM << 79 G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe"); 83 80 >> 81 84 //--------- G4VSolid, G4LogicalVolume, G4VPh 82 //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume --------- 85 << 83 86 //-------------- 84 //-------------- 87 // World: 85 // World: 88 //-------------- 86 //-------------- 89 G4Box* WorldBox = new G4Box("WorldBox", 400 << 87 G4Box *WorldBox= new G4Box("WorldBox",400*cm, 400*cm, 400*cm); 90 G4LogicalVolume* WorldLog = new G4LogicalVol << 88 G4LogicalVolume *WorldLog=new G4LogicalVolume(WorldBox,air, 91 G4PVPlacement* WorldPhys = << 89 "WorldLogical", 0, 0, 0); 92 new G4PVPlacement(0, G4ThreeVector(), "Wor << 90 G4PVPlacement *WorldPhys=new G4PVPlacement(0,G4ThreeVector(), >> 91 "WorldPhysical", >> 92 WorldLog, >> 93 0,false,0); 93 // Size of detectors: 94 // Size of detectors: 94 G4double detectSize = 125 * cm; << 95 G4double detectSize = 125*cm; 95 << 96 96 //----------------------------- 97 //----------------------------- 97 // "Drift Chamber": 98 // "Drift Chamber": 98 // Not used in parameterisation. 99 // Not used in parameterisation. 99 //----------------------------- 100 //----------------------------- 100 // -- Logical volume: 101 // -- Logical volume: 101 G4Box* driftChamberBox = new G4Box("DriftCha << 102 G4Box *driftChamberBox 102 G4LogicalVolume* driftChamberLog = << 103 = new G4Box("DriftChamberSolid", detectSize, detectSize, 40*cm); 103 new G4LogicalVolume(driftChamberBox, heliu << 104 G4LogicalVolume *driftChamberLog >> 105 = new G4LogicalVolume(driftChamberBox,helium, >> 106 "DriftChamberLogical", 0, 0, 0); 104 // -- Placement: 107 // -- Placement: 105 // G4PVPlacement *driftChamberPhys = 108 // G4PVPlacement *driftChamberPhys = 106 new G4PVPlacement(0, G4ThreeVector(0., 0., 5 << 109 new G4PVPlacement(0,G4ThreeVector(0., 0., 50*cm), 107 WorldPhys, false, 0); << 110 "DriftChamberPhysical", 108 << 111 driftChamberLog, >> 112 WorldPhys,false,0); >> 113 109 //-------------------------- 114 //-------------------------- 110 // "Calorimeter": used in 115 // "Calorimeter": used in 111 // parameterisation below 116 // parameterisation below 112 //-------------------------- 117 //-------------------------- 113 // -- Logical volume: 118 // -- Logical volume: 114 G4Box* calorimeterBox = new G4Box("Calorimet << 119 G4Box *calorimeterBox 115 G4LogicalVolume* calorimeterLog = << 120 = new G4Box("CalorimeterSolid", detectSize, detectSize, 20*cm); 116 new G4LogicalVolume(calorimeterBox, air, " << 121 G4LogicalVolume *calorimeterLog = new G4LogicalVolume(calorimeterBox,air, >> 122 "CalorimeterLogical", 0, 0, 0); 117 // -- Placement: 123 // -- Placement: 118 G4PVPlacement* calorimeterPhys = new G4PVPla << 124 G4PVPlacement *calorimeterPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 120*cm), 119 0, G4ThreeVector(0., 0., 120 * cm), "Calor << 125 "CalorimeterPhysical", 120 << 126 calorimeterLog, >> 127 WorldPhys,false,0); >> 128 121 //-------------------------------------- 129 //-------------------------------------- 122 // The calorimeter is filled with 130 // The calorimeter is filled with 123 // crystals: 131 // crystals: 124 //-------------------------------------- 132 //-------------------------------------- 125 // -- Logical volume: 133 // -- Logical volume: 126 G4double CrystalX = 2.5 * cm; << 134 G4double CrystalX = 2.5*cm; 127 G4double CrystalY = CrystalX; 135 G4double CrystalY = CrystalX; 128 G4double CrystalZ = 20 * cm; << 136 G4double CrystalZ = 20*cm; 129 G4Box* CrystalSolid = new G4Box("CrystalSoli << 137 G4Box *CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ); 130 fCrystalLog = new G4LogicalVolume(CrystalSol << 138 fCrystalLog = new G4LogicalVolume(CrystalSolid,csi, 131 << 139 "CrystalLogical", 0, 0, 0); 132 G4String tName1("Crystal"); // Allow all ta << 140 >> 141 G4String tName1("Crystal"); // Allow all target physicals to share 133 // same name (delayed copy) 142 // same name (delayed copy) 134 << 143 135 // -- and placements inside the calorimeter: 144 // -- and placements inside the calorimeter: 136 G4int copyNo = 0; << 145 G4int copyNo=0; 137 G4double xTlate, yTlate; 146 G4double xTlate, yTlate; 138 fnX = 48; 147 fnX = 48; 139 fnY = 48; 148 fnY = 48; 140 for (G4int j = 0; j < fnY; j++) { << 149 for (G4int j = 0; j < fnY; j++) 141 yTlate = -detectSize + 3 * CrystalY + j * << 150 { 142 for (G4int i = 0; i < fnX; i++) { << 151 yTlate = -detectSize + 3*CrystalY + j*2*CrystalY; 143 xTlate = -detectSize + 3 * CrystalX + i << 152 for (G4int i = 0; i < fnX; i++) 144 new G4PVPlacement(0, G4ThreeVector(xTlat << 153 { 145 calorimeterPhys, false << 154 xTlate = -detectSize + 3*CrystalX + i*2*CrystalX; >> 155 new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), >> 156 tName1, >> 157 fCrystalLog, >> 158 calorimeterPhys,false,copyNo++); >> 159 } 146 } 160 } 147 } << 161 148 162 149 //-------------------------- 163 //-------------------------- 150 // "Hadron Calorimeter": used 164 // "Hadron Calorimeter": used 151 // in parameterisation with 165 // in parameterisation with 152 // a parallel geometry 166 // a parallel geometry 153 //-------------------------- 167 //-------------------------- 154 // -- Logical volume: 168 // -- Logical volume: 155 G4Box* hadCaloBox = new G4Box("HadCaloSolid" << 169 G4Box *hadCaloBox 156 G4LogicalVolume* hadCaloLog = new G4LogicalV << 170 = new G4Box("HadCaloSolid", detectSize, detectSize, 50*cm); >> 171 G4LogicalVolume *hadCaloLog = new G4LogicalVolume(hadCaloBox,air, >> 172 "HadCaloLogical", 0, 0, 0); 157 // -- Placement: 173 // -- Placement: 158 G4PVPlacement* hadCaloPhys = new G4PVPlaceme << 174 G4PVPlacement *hadCaloPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 200*cm), 159 0, G4ThreeVector(0., 0., 200 * cm), "HadCa << 175 "HadCaloPhysical", 160 << 176 hadCaloLog, >> 177 WorldPhys,false,0); >> 178 161 //-------------------------------------- 179 //-------------------------------------- 162 // The calorimeter is filled with 180 // The calorimeter is filled with 163 // towers: 181 // towers: 164 //-------------------------------------- 182 //-------------------------------------- 165 // -- Logical volume: 183 // -- Logical volume: 166 G4double TowerX = 5 * cm; << 184 G4double TowerX = 5*cm; 167 G4double TowerY = TowerX; 185 G4double TowerY = TowerX; 168 G4double TowerZ = 45 * cm; << 186 G4double TowerZ = 45*cm; 169 G4Box* TowerSolid = new G4Box("TowerSolid", << 187 G4Box *TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ); 170 fTowerLog = new G4LogicalVolume(TowerSolid, << 188 fTowerLog = new G4LogicalVolume(TowerSolid,iron, 171 << 189 "TowerLogical", 0, 0, 0); >> 190 172 G4String tName2("Tower"); 191 G4String tName2("Tower"); 173 << 192 174 // -- and placements inside the calorimeter: 193 // -- and placements inside the calorimeter: 175 copyNo = 0; << 194 copyNo=0; 176 fnXhad = 23; 195 fnXhad = 23; 177 fnYhad = 23; 196 fnYhad = 23; 178 for (G4int jj = 0; jj < fnYhad; jj++) { << 197 for (G4int jj = 0; jj < fnYhad; jj++) 179 yTlate = -detectSize + 3 * TowerY + jj * 2 << 198 { 180 for (G4int i = 0; i < fnXhad; i++) { << 199 yTlate = -detectSize + 3*TowerY + jj*2*TowerY; 181 xTlate = -detectSize + 3 * TowerX + i * << 200 for (G4int i = 0; i < fnXhad; i++) 182 new G4PVPlacement(0, G4ThreeVector(xTlat << 201 { 183 false, copyNo++); << 202 xTlate = -detectSize + 3*TowerX + i*2*TowerX; >> 203 new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), >> 204 tName2, >> 205 fTowerLog, >> 206 hadCaloPhys,false,copyNo++); >> 207 } 184 } 208 } 185 } << 209 186 << 210 187 // -- Makes the calorimeterLog volume becomi << 211 188 G4Region* caloRegion = new G4Region("EM_calo << 212 189 caloRegion->AddRootLogicalVolume(calorimeter << 213 // -- Makes the calorimeterLog volume becoming a G4Region: 190 std::vector<double> cuts; << 214 G4Region* caloRegion = new G4Region("EM_calo_region"); 191 cuts.push_back(1.0 * mm); << 215 caloRegion->AddRootLogicalVolume(calorimeterLog); 192 cuts.push_back(1.0 * mm); << 216 std::vector<double> cuts; 193 cuts.push_back(1.0 * mm); << 217 cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm); 194 cuts.push_back(1.0 * mm); << 218 caloRegion->SetProductionCuts(new G4ProductionCuts()); 195 caloRegion->SetProductionCuts(new G4Producti << 219 caloRegion->GetProductionCuts()->SetProductionCuts(cuts); 196 caloRegion->GetProductionCuts()->SetProducti << 220 197 << 221 // Makes had. calo a region to: 198 // Makes had. calo a region to: << 222 G4Region* hadRegion = new G4Region("HAD_calo_region"); 199 G4Region* hadRegion = new G4Region("HAD_calo << 223 hadRegion->AddRootLogicalVolume(hadCaloLog); 200 hadRegion->AddRootLogicalVolume(hadCaloLog); << 224 cuts.clear(); 201 cuts.clear(); << 225 cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm); 202 cuts.push_back(1.0 * cm); << 226 hadRegion->SetProductionCuts(new G4ProductionCuts()); 203 cuts.push_back(1.0 * cm); << 227 hadRegion->GetProductionCuts()->SetProductionCuts(cuts); 204 cuts.push_back(1.0 * cm); << 205 cuts.push_back(1.0 * cm); << 206 hadRegion->SetProductionCuts(new G4Productio << 207 hadRegion->GetProductionCuts()->SetProductio << 208 228 209 //--------- Visualization attributes ------- 229 //--------- Visualization attributes ------------------------------- 210 WorldLog->SetVisAttributes(G4VisAttributes:: 230 WorldLog->SetVisAttributes(G4VisAttributes::GetInvisible()); 211 231 212 auto driftchamberTubeVisAtt = new G4VisAttri << 232 G4VisAttributes * driftchamberTubeVisAtt >> 233 = new G4VisAttributes(G4Colour(0.0,1.0,0.0)); 213 driftchamberTubeVisAtt->SetForceWireframe(tr 234 driftchamberTubeVisAtt->SetForceWireframe(true); 214 driftChamberLog->SetVisAttributes(driftchamb 235 driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt); 215 << 236 216 auto calorimeterBoxVisAtt = new G4VisAttribu << 237 G4VisAttributes * calorimeterBoxVisAtt >> 238 = new G4VisAttributes(G4Colour(0.0,0.0,1.0)); 217 calorimeterBoxVisAtt->SetForceWireframe(true 239 calorimeterBoxVisAtt->SetForceWireframe(true); 218 calorimeterLog->SetVisAttributes(calorimeter 240 calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt); 219 << 241 220 auto crystalVisAtt = new G4VisAttributes(G4C << 242 G4VisAttributes * crystalVisAtt >> 243 = new G4VisAttributes(G4Colour(1.0,0.0,0.0)); 221 crystalVisAtt->SetForceWireframe(true); 244 crystalVisAtt->SetForceWireframe(true); 222 fCrystalLog->SetVisAttributes(crystalVisAtt) 245 fCrystalLog->SetVisAttributes(crystalVisAtt); 223 246 224 auto hadCaloBoxVisAtt = new G4VisAttributes( << 247 G4VisAttributes * hadCaloBoxVisAtt >> 248 = new G4VisAttributes(G4Colour(1.0,0.0,1.0)); 225 hadCaloBoxVisAtt->SetForceWireframe(true); 249 hadCaloBoxVisAtt->SetForceWireframe(true); 226 hadCaloLog->SetVisAttributes(hadCaloBoxVisAt 250 hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt); 227 << 251 228 auto towerVisAtt = new G4VisAttributes(G4Col << 252 G4VisAttributes * towerVisAtt >> 253 = new G4VisAttributes(G4Colour(0.5,0.0,1.0)); 229 towerVisAtt->SetForceWireframe(true); 254 towerVisAtt->SetForceWireframe(true); 230 fTowerLog->SetVisAttributes(towerVisAtt); 255 fTowerLog->SetVisAttributes(towerVisAtt); 231 << 256 232 //------------------------------------------ 257 //------------------------------------------------------------------ 233 << 258 >> 259 234 //----------------------- 260 //----------------------- 235 // Returns the pointer to 261 // Returns the pointer to 236 // the physical world: 262 // the physical world: 237 //----------------------- 263 //----------------------- 238 return WorldPhys; 264 return WorldPhys; 239 } 265 } 240 266 241 //....oooOO0OOooo........oooOO0OOooo........oo 267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 242 268 243 void Par01DetectorConstruction::ConstructSDand 269 void Par01DetectorConstruction::ConstructSDandField() 244 { 270 { 245 //--------- Sensitive detector ------------- 271 //--------- Sensitive detector ------------------------------------- 246 G4SDManager* SDman = G4SDManager::GetSDMpoin 272 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 247 G4String calorimeterSDname = "Par01/Calorime 273 G4String calorimeterSDname = "Par01/Calorimeter"; 248 Par01CalorimeterSD* CalorimeterSD = << 274 Par01CalorimeterSD* CalorimeterSD = new Par01CalorimeterSD( calorimeterSDname, 249 new Par01CalorimeterSD(calorimeterSDname, << 275 fnX*fnY, 250 SDman->AddNewDetector(CalorimeterSD); << 276 "CalCollection" ); 251 fCrystalLog->SetSensitiveDetector(Calorimete << 277 SDman->AddNewDetector( CalorimeterSD ); 252 << 278 fCrystalLog->SetSensitiveDetector(CalorimeterSD); >> 279 253 G4String hadCalorimeterSDname = "Par01/Hadro 280 G4String hadCalorimeterSDname = "Par01/HadronCalorimeter"; 254 Par01CalorimeterSD* HadCalorimeterSD = << 281 Par01CalorimeterSD* HadCalorimeterSD = new Par01CalorimeterSD( hadCalorimeterSDname, 255 new Par01CalorimeterSD(hadCalorimeterSDnam << 282 fnXhad*fnYhad, 256 SDman->AddNewDetector(HadCalorimeterSD); << 283 "HadCollection" ); 257 fTowerLog->SetSensitiveDetector(HadCalorimet << 284 SDman->AddNewDetector( HadCalorimeterSD ); 258 << 285 fTowerLog->SetSensitiveDetector(HadCalorimeterSD); >> 286 259 // --------------- fast simulation --------- 287 // --------------- fast simulation ---------------------------- 260 G4RegionStore* regionStore = G4RegionStore:: 288 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 261 << 289 262 G4Region* caloRegion = regionStore->GetRegio 290 G4Region* caloRegion = regionStore->GetRegion("EM_calo_region"); 263 // builds a model and sets it to the envelop 291 // builds a model and sets it to the envelope of the calorimeter: 264 new Par01EMShowerModel("emShowerModel", calo << 292 new Par01EMShowerModel("emShowerModel",caloRegion); 265 } 293 } 266 294