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 // 26 // 27 /// \file ExGflash2DetectorConstruction.cc 27 /// \file ExGflash2DetectorConstruction.cc 28 /// \brief Implementation of the ExGflash2Dete 28 /// \brief Implementation of the ExGflash2DetectorConstruction class 29 // 29 // 30 // Created by Joanna Weng 26.11.2004 30 // Created by Joanna Weng 26.11.2004 31 31 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 34 34 35 // User Classes 35 // User Classes 36 #include "ExGflash2DetectorConstruction.hh" 36 #include "ExGflash2DetectorConstruction.hh" 37 << 38 #include "ExGflash2SensitiveDetector.hh" 37 #include "ExGflash2SensitiveDetector.hh" 39 38 40 // G4 Classes 39 // G4 Classes 41 #include "G4AutoDelete.hh" << 42 #include "G4Box.hh" << 43 #include "G4Colour.hh" << 44 #include "G4LogicalVolume.hh" << 45 #include "G4Material.hh" << 46 #include "G4NistManager.hh" 40 #include "G4NistManager.hh" 47 #include "G4PVPlacement.hh" << 41 #include "G4Material.hh" 48 #include "G4SDManager.hh" << 49 #include "G4SystemOfUnits.hh" << 50 #include "G4ThreeVector.hh" 42 #include "G4ThreeVector.hh" >> 43 #include "G4PVPlacement.hh" 51 #include "G4VPhysicalVolume.hh" 44 #include "G4VPhysicalVolume.hh" >> 45 #include "G4LogicalVolume.hh" >> 46 #include "G4Box.hh" >> 47 #include "G4SDManager.hh" 52 #include "G4VisAttributes.hh" 48 #include "G4VisAttributes.hh" >> 49 #include "G4Colour.hh" >> 50 #include "G4SystemOfUnits.hh" >> 51 #include "G4AutoDelete.hh" 53 #include "globals.hh" 52 #include "globals.hh" 54 53 >> 54 >> 55 55 //....oooOO0OOooo........oooOO0OOooo........oo 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 56 57 57 ExGflash2DetectorConstruction::ExGflash2Detect 58 ExGflash2DetectorConstruction::ExGflash2DetectorConstruction() >> 59 :G4VUserDetectorConstruction(), fCrystalLog(nullptr), fCrystalPhys{} 58 { 60 { 59 G4cout << "ExGflash2DetectorConstruction::De << 61 G4cout<<"ExGflash2DetectorConstruction::Detector constructor"<<G4endl; 60 } 62 } 61 63 62 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 65 64 ExGflash2DetectorConstruction::~ExGflash2Detec << 66 ExGflash2DetectorConstruction::~ExGflash2DetectorConstruction() {} 65 67 66 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 69 68 G4VPhysicalVolume* ExGflash2DetectorConstructi 70 G4VPhysicalVolume* ExGflash2DetectorConstruction::Construct() 69 { 71 { 70 //--------- Definitions of Solids, Logical V 72 //--------- Definitions of Solids, Logical Volumes, Physical Volumes --------- 71 G4cout << "Defining the materials" << G4endl 73 G4cout << "Defining the materials" << G4endl; 72 // Get nist material manager 74 // Get nist material manager 73 G4NistManager* nistManager = G4NistManager:: 75 G4NistManager* nistManager = G4NistManager::Instance(); 74 // Build materials 76 // Build materials 75 G4Material* air = nistManager->FindOrBuildMa << 77 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR"); 76 G4Material* pbWO4 = nistManager->FindOrBuild 78 G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4"); 77 << 79 78 /******************************* 80 /******************************* 79 * The Experimental Hall * 81 * The Experimental Hall * 80 *******************************/ 82 *******************************/ 81 G4double experimentalHall_x = 1000. * cm; << 83 G4double experimentalHall_x=1000.*cm; 82 G4double experimentalHall_y = 1000. * cm; << 84 G4double experimentalHall_y=1000.*cm; 83 G4double experimentalHall_z = 1000. * cm; << 85 G4double experimentalHall_z=1000.*cm; 84 << 86 85 G4VSolid* experimentalHall_box = new G4Box(" << 87 G4VSolid* experimentalHall_box 86 e << 88 = new G4Box("expHall_box", // World Volume 87 e << 89 experimentalHall_x, // x size 88 e << 90 experimentalHall_y, // y size 89 << 91 experimentalHall_z); // z size 90 auto experimentalHallLog = new G4LogicalVolu << 92 91 << 93 G4LogicalVolume* experimentalHallLog 92 << 94 = new G4LogicalVolume(experimentalHall_box, 93 << 95 air, 94 G4VPhysicalVolume* experimentalHallPhys = << 96 "expHallLog", 95 new G4PVPlacement(nullptr, << 97 0, //opt: fieldManager 96 G4ThreeVector(), // at << 98 0, //opt: SensitiveDetector 97 "expHall", experimentalH << 99 0); //opt: UserLimits 98 << 100 G4VPhysicalVolume* experimentalHallPhys 99 //------------------------------ << 101 = new G4PVPlacement(0, >> 102 G4ThreeVector(), //at (0,0,0) >> 103 "expHall", >> 104 experimentalHallLog, >> 105 0, >> 106 false, >> 107 0); >> 108 >> 109 >> 110 //------------------------------ 100 // Calorimeter segments 111 // Calorimeter segments 101 //------------------------------ 112 //------------------------------ 102 // Simplified `CMS-like` PbWO4 crystal calor << 113 // Simplified `CMS-like` PbWO4 crystal calorimeter 103 << 114 104 G4int nbOfCrystals = 10; // this are the cr << 115 G4int nbOfCrystals = 10; // this are the crystals PER ROW in this example 105 // cube of 10 x 10 << 116 // cube of 10 x 10 crystals 106 // don't change it << 117 // don't change it @the moment, since 107 // the readout in << 118 // the readout in event action assumes this 108 // dimensions and << 119 // dimensions and is not automatically adapted 109 // in this version << 120 // in this version of the example :-( 110 // Simplified `CMS-like` PbWO4 crystal calor << 121 // Simplified `CMS-like` PbWO4 crystal calorimeter 111 G4double calo_xside = 31 * cm; << 122 G4double calo_xside = 31*cm; 112 G4double calo_yside = 31 * cm; << 123 G4double calo_yside = 31*cm; 113 G4double calo_zside = 24 * cm; << 124 G4double calo_zside = 24*cm; 114 125 115 G4double crystalWidth = 3 * cm; << 126 G4double crystalWidth = 3*cm; 116 G4double crystalLength = 24 * cm; << 127 G4double crystalLength = 24*cm; 117 128 118 calo_xside = (crystalWidth * nbOfCrystals) + << 129 calo_xside = (crystalWidth*nbOfCrystals)+1*cm; 119 calo_yside = (crystalWidth * nbOfCrystals) + << 130 calo_yside = (crystalWidth*nbOfCrystals)+1*cm; 120 calo_zside = crystalLength; 131 calo_zside = crystalLength; 121 << 132 122 auto calo_box = new G4Box("CMS calorimeter", << 133 G4Box* calo_box= new G4Box("CMS calorimeter", // its name 123 calo_xside / 2., << 134 calo_xside/2., // size 124 calo_yside / 2., c << 135 calo_yside/2., 125 auto caloLog = new G4LogicalVolume(calo_box, << 136 calo_zside/2.); 126 air, // << 137 G4LogicalVolume* caloLog 127 "calo log << 138 = new G4LogicalVolume(calo_box, // its solid 128 nullptr, << 139 air, // its material 129 nullptr, << 140 "calo log", // its name 130 nullptr); << 141 0, // opt: fieldManager 131 << 142 0, // opt: SensitiveDetector >> 143 0); // opt: UserLimit >> 144 132 G4double xpos = 0.0; 145 G4double xpos = 0.0; 133 G4double ypos = 0.0; 146 G4double ypos = 0.0; 134 G4double zpos = 100.0 * cm; << 147 G4double zpos = 100.0*cm; 135 new G4PVPlacement(nullptr, G4ThreeVector(xpo << 148 new G4PVPlacement(0, 136 experimentalHallLog, false << 149 G4ThreeVector(xpos, ypos, zpos), 137 << 150 caloLog, >> 151 "calorimeter", >> 152 experimentalHallLog, >> 153 false, >> 154 1); >> 155 138 // Crystals 156 // Crystals 139 G4VSolid* crystal_box = new G4Box("Crystal", << 157 G4VSolid* crystal_box 140 crystalWid << 158 = new G4Box("Crystal", // its name 141 // size << 159 crystalWidth/2, 142 fCrystalLog = new G4LogicalVolume(crystal_bo << 160 crystalWidth/2, 143 pbWO4, // << 161 crystalLength/2); 144 "CrystalLo << 162 // size 145 << 163 fCrystalLog 146 for (G4int i = 0; i < nbOfCrystals; i++) { << 164 = new G4LogicalVolume(crystal_box, // its solid 147 for (G4int j = 0; j < nbOfCrystals; j++) { << 165 pbWO4, // its material 148 G4int n = i * 10 + j; << 166 "CrystalLog"); // its name 149 G4ThreeVector crystalPos((i * crystalWid << 167 150 fCrystalPhys[n] = new G4PVPlacement(null << 168 for (G4int i=0; i<nbOfCrystals; i++) 151 crys << 169 { 152 fCry << 170 153 "cry << 171 for (G4int j=0; j<nbOfCrystals; j++) 154 calo << 172 { 155 } << 173 G4int n = i*10+j; 156 } << 174 G4ThreeVector crystalPos((i*crystalWidth)-135, 157 G4cout << "There are " << nbOfCrystals << " << 175 (j*crystalWidth)-135,0 ); 158 << nbOfCrystals * nbOfCrystals << " c << 176 fCrystalPhys[n] 159 G4cout << "They have width of " << crystalW << 177 = new G4PVPlacement(0, // no rotation 160 << crystalLength / cm << " cm. The Ma << 178 crystalPos, // translation 161 << 179 fCrystalLog, >> 180 "crystal", // its name >> 181 caloLog, >> 182 false, >> 183 i); >> 184 } >> 185 } >> 186 G4cout << "There are " << nbOfCrystals << >> 187 " crystals per row in the calorimeter, so in total "<< >> 188 nbOfCrystals*nbOfCrystals << " crystals" << G4endl; >> 189 G4cout << "They have width of " << crystalWidth /cm << >> 190 " cm and a length of " << crystalLength /cm >> 191 <<" cm. The Material is "<< pbWO4 << G4endl; >> 192 >> 193 162 experimentalHallLog->SetVisAttributes(G4VisA 194 experimentalHallLog->SetVisAttributes(G4VisAttributes::GetInvisible()); 163 auto caloVisAtt = new G4VisAttributes(G4Colo << 195 G4VisAttributes* caloVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 164 auto crystalVisAtt = new G4VisAttributes(G4C << 196 G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 165 caloLog->SetVisAttributes(caloVisAtt); 197 caloLog->SetVisAttributes(caloVisAtt); 166 fCrystalLog->SetVisAttributes(crystalVisAtt) 198 fCrystalLog->SetVisAttributes(crystalVisAtt); 167 199 168 // Parametrisation region defined in ExGflas << 169 200 >> 201 // Parametrisation region defined in ExGflash2ParallelWorld >> 202 170 return experimentalHallPhys; 203 return experimentalHallPhys; 171 } 204 } 172 205 173 //....oooOO0OOooo........oooOO0OOooo........oo 206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 174 207 175 void ExGflash2DetectorConstruction::ConstructS 208 void ExGflash2DetectorConstruction::ConstructSDandField() 176 { 209 { 177 // -- sensitive detectors: 210 // -- sensitive detectors: 178 G4SDManager* SDman = G4SDManager::GetSDMpoin 211 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 179 auto CaloSD = new ExGflash2SensitiveDetector << 212 ExGflash2SensitiveDetector* CaloSD >> 213 = new ExGflash2SensitiveDetector("Calorimeter",this); 180 SDman->AddNewDetector(CaloSD); 214 SDman->AddNewDetector(CaloSD); 181 fCrystalLog->SetSensitiveDetector(CaloSD); 215 fCrystalLog->SetSensitiveDetector(CaloSD); 182 << 216 183 // Fast simulation implemented in ExGflash2P 217 // Fast simulation implemented in ExGflash2ParallelWorld 184 } 218 } 185 219 186 //....oooOO0OOooo........oooOO0OOooo........oo 220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 187 221