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