Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 #include "DetectorConstruction.hh" 27 28 #include "HGCalTBMaterials.hh" 29 #include "SiPMSD.hh" 30 #include "SiliconPixelSD.hh" 31 #include "DetectorConstruction0.hh" 32 #include "DetectorConstruction1.hh" 33 #include "DetectorConstruction2.hh" 34 35 #include "G4Box.hh" 36 #include "G4PVPlacement.hh" 37 #include "G4GenericMessenger.hh" 38 #include "G4LogicalVolume.hh" 39 #include "G4ProductionCuts.hh" 40 #include "G4RunManager.hh" 41 #include "G4SDManager.hh" 42 #include "G4UImanager.hh" 43 #include "G4UserLimits.hh" 44 #include "G4String.hh" 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 47 48 DetectorConstruction::DetectorConstruction() 49 : G4VUserDetectorConstruction(), fConfigur 50 DefineCommands(); 51 } 52 53 //....oooOO0OOooo........oooOO0OOooo........oo 54 55 DetectorConstruction::~DetectorConstruction() 56 57 //....oooOO0OOooo........oooOO0OOooo........oo 58 59 G4VPhysicalVolume *DetectorConstruction::Const 60 // definition of the fMaterials 61 fMaterials = new HGCalTBMaterials(); 62 fMaterials->SetEventDisplayColorScheme(); 63 64 /***** Definition of the world = beam line * 65 66 // World = Beam line 67 G4Box *solidWorld = new G4Box("World", 0.5 * 68 0.5 * fMateria 69 0.5 * fMateria 70 71 G4Material *world_mat = fMaterials->GetAir() 72 fLogicWorld = new G4LogicalVolume(solidWorld 73 74 G4VPhysicalVolume *physWorld = new G4PVPlace 75 0, G4ThreeVector(0., 0., 0.), fLogicWorl 76 77 return physWorld; 78 } 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 81 82 void DetectorConstruction::ConstructHGCal() { 83 84 G4double z0 = -fMaterials->GetBeamLineLength 85 86 std::cout << "Constructing configuration " < 87 88 /***** START GENERIC PLACEMENT ALGORITHM 89 for (size_t item_index = 0; item_index < fEl 90 std::string item_type = fElementsMap[item_ 91 G4double dz = fElementsMap[item_index].sec 92 z0 += dz; 93 94 // places the item at inside the world at 95 // item's thickness 96 fMaterials->PlaceItemInLogicalVolume(item_ 97 } 98 99 G4RunManager::GetRunManager()->GeometryHasBe 100 G4UImanager *UImanager = G4UImanager::GetUIp 101 UImanager->ApplyCommand("/vis/drawVolume"); 102 UImanager->ApplyCommand("/vis/viewer/set/tar 103 std::to_string(fVisV 104 UImanager->ApplyCommand("/vis/scene/add/traj 105 UImanager->ApplyCommand("/vis/scene/add/hits 106 } 107 108 //....oooOO0OOooo........oooOO0OOooo........oo 109 110 void DetectorConstruction::ConstructSDandField 111 G4SDManager *sdman = G4SDManager::GetSDMpoin 112 113 SiliconPixelSD *sensitiveSilicon = new Silic 114 (fMaterials->GetSiPixelLogical()->GetNam 115 sdman->AddNewDetector(sensitiveSilicon); 116 fMaterials->GetSiPixelLogical()->SetSensitiv 117 118 SiPMSD *sensitiveSiPM = new SiPMSD( 119 (fMaterials->GetAHCALSiPMlogical()->GetN 120 sdman->AddNewDetector(sensitiveSiPM); 121 fMaterials->GetAHCALSiPMlogical()->SetSensit 122 } 123 124 //....oooOO0OOooo........oooOO0OOooo........oo 125 126 void DetectorConstruction::SelectConfiguration 127 128 if (fConfiguration != -1) { 129 G4ExceptionDescription msg; 130 msg << "Configuration " << fConfiguration 131 << "Configuration can be set only once 132 << "edit your macro if necessary).\n"; 133 G4Exception("DetectorConstruction::SelectC 134 JustWarning, msg); 135 return; 136 } 137 138 fVisViewpoint = 0; 139 if (val == 0) 140 DetectorConstruction0(fElementsMap, fVisVi 141 else if (val == 1) 142 DetectorConstruction1(fElementsMap, fVisVi 143 else if (val == 2) 144 DetectorConstruction2(fElementsMap, fVisVi 145 else { 146 G4ExceptionDescription msg; 147 msg << "Configuration " << val << " is not 148 << "Choose between configuration 0, 1, 149 G4Exception("DetectorConstruction::SelectC 150 JustWarning, msg); 151 return; 152 } 153 fConfiguration = val; 154 155 ConstructHGCal(); 156 } 157 158 //....oooOO0OOooo........oooOO0OOooo........oo 159 160 void DetectorConstruction::SetStepSizeSilicon( 161 // setting the step size in silicon: 162 G4double maxTrackLength = val * 0.001 * CLHE 163 fMaterials->GetSiPixelLogical()->SetUserLimi 164 new G4UserLimits(0, maxTrackLength)); 165 166 G4Region *reg = fMaterials->GetSiPixelLogica 167 G4ProductionCuts *cuts = new G4ProductionCut 168 cuts->SetProductionCut(maxTrackLength); 169 reg->SetProductionCuts(cuts); 170 } 171 172 //....oooOO0OOooo........oooOO0OOooo........oo 173 174 void DetectorConstruction::DefineCommands() { 175 // define command directory using generic me 176 fMessenger = new G4GenericMessenger(this, "/ 177 "Configu 178 179 // configuration command 180 auto &configCmd = fMessenger->DeclareMethod( 181 "configuration", &DetectorConstruction:: 182 "Select the configuration (0 for HGCal t 183 " with beamline (upstream material), or 184 configCmd.SetParameterName("index", true); 185 configCmd.SetDefaultValue("0"); 186 187 auto &SiStepSizeCmd = fMessenger->DeclareMet 188 "stepSilicon", &DetectorConstruction::Se 189 "Maximum step size in silicon pixels, un 190 SiStepSizeCmd.SetParameterName("size", true) 191 SiStepSizeCmd.SetDefaultValue("30."); 192 } 193 194 //....oooOO0OOooo........oooOO0OOooo........oo 195