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 biasing/B03/exampleB03.cc 26 /// \file biasing/B03/exampleB03.cc 27 /// \brief Main program of the biasing/B03 exa 27 /// \brief Main program of the biasing/B03 example 28 // 28 // 29 // 29 // >> 30 // $Id: exampleB03.cc 70528 2013-05-31 16:50:36Z gcosmo $ 30 // 31 // 31 // << 32 // 32 // ------------------------------------------- 33 // -------------------------------------------------------------- 33 // GEANT 4 - exampleB03 34 // GEANT 4 - exampleB03 34 // 35 // 35 // ------------------------------------------- 36 // -------------------------------------------------------------- 36 // Comments 37 // Comments 37 // 38 // 38 // This example intends to show how to use bot 39 // This example intends to show how to use both importance sampling and a 39 // customized scoring making use of the scorin 40 // customized scoring making use of the scoring framework 40 // in a parallel geometry. 41 // in a parallel geometry. 41 // << 42 // 42 // A simple geometry consisting of a 180 cm hi 43 // A simple geometry consisting of a 180 cm high concrete cylinder 43 // is constructed in the mass geometry. 44 // is constructed in the mass geometry. 44 // A geometry is constructed in the parallel g 45 // A geometry is constructed in the parallel geometry 45 // in order to assign importance values to sla 46 // in order to assign importance values to slabs 46 // of width 10cm and for scoring. The parallel << 47 // of width 10cm and for scoring. The parallel world volume should 47 // overlap the mass world volume and the radi << 48 // overlap the mass world volume and the radii of the slabs is larger 48 // than the radius of the concrete cylinder in 49 // than the radius of the concrete cylinder in the mass geometry. 49 // Pairs of G4GeometryCell and importance valu 50 // Pairs of G4GeometryCell and importance values are stored in 50 // the importance store. 51 // the importance store. 51 // The scoring uses the primitive scorers via 52 // The scoring uses the primitive scorers via the Multi Functional Detector 52 // << 53 // 53 // << 54 // 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 56 56 #include "B03ActionInitialization.hh" << 57 #include <iostream> 57 #include "B03DetectorConstruction.hh" << 58 58 #include "B03PhysicsList.hh" << 59 #ifdef G4MULTITHREADED >> 60 #include "G4MTRunManager.hh" >> 61 #else >> 62 #include "G4RunManager.hh" >> 63 #endif 59 64 60 #include "G4RunManagerFactory.hh" << 61 #include "G4SystemOfUnits.hh" << 62 #include "G4Types.hh" << 63 #include "G4UImanager.hh" << 64 #include "G4VPhysicalVolume.hh" 65 #include "G4VPhysicalVolume.hh" >> 66 #include "G4UImanager.hh" >> 67 #include "G4SystemOfUnits.hh" 65 68 66 #include <iostream> << 69 #include "B03DetectorConstruction.hh" >> 70 #include "B03PhysicsList.hh" >> 71 >> 72 #include "B03ActionInitialization.hh" 67 // #include "B03PrimaryGeneratorAction.hh" 73 // #include "B03PrimaryGeneratorAction.hh" 68 // #include "B03RunAction.hh" 74 // #include "B03RunAction.hh" 69 75 70 // construction for the parallel geometry 76 // construction for the parallel geometry 71 #include "B03ImportanceDetectorConstruction.hh 77 #include "B03ImportanceDetectorConstruction.hh" 72 78 73 // Files specific for biasing and scoring 79 // Files specific for biasing and scoring 74 // #include "G4Scorer.hh" << 80 //#include "G4Scorer.hh" 75 // #include "G4GeometrySampler.hh" << 81 #include "G4GeometrySampler.hh" 76 #include "G4IStore.hh" 82 #include "G4IStore.hh" 77 83 >> 84 >> 85 78 //....oooOO0OOooo........oooOO0OOooo........oo 86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 79 87 80 int main(int, char**) << 88 int main(int , char **) 81 { << 89 { 82 G4int numberOfEvents = 100; 90 G4int numberOfEvents = 100; 83 91 84 G4long myseed = 345354; 92 G4long myseed = 345354; 85 93 86 auto* runManager = G4RunManagerFactory::Crea << 94 #ifdef G4MULTITHREADED >> 95 G4MTRunManager * runManager = new G4MTRunManager; >> 96 G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl; >> 97 G4cout << " but using only two! " << G4endl; 87 runManager->SetNumberOfThreads(2); 98 runManager->SetNumberOfThreads(2); >> 99 // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores()); >> 100 #else >> 101 G4RunManager * runManager = new G4RunManager; >> 102 #endif 88 103 89 G4Random::setTheSeed(myseed); 104 G4Random::setTheSeed(myseed); 90 105 91 // create the detector ---------------- 106 // create the detector --------------------------- 92 B03DetectorConstruction* detector = new B03D << 107 B03DetectorConstruction *detector = new B03DetectorConstruction(); 93 runManager->SetUserInitialization(detector); 108 runManager->SetUserInitialization(detector); 94 // ---------------------------------------- 109 // --------------------------------------------------- 95 110 96 // create a parallel detector 111 // create a parallel detector 97 G4String parallelName("ParallelBiasingWorld" 112 G4String parallelName("ParallelBiasingWorld"); 98 B03ImportanceDetectorConstruction* pdet = ne << 113 B03ImportanceDetectorConstruction *pdet = >> 114 new B03ImportanceDetectorConstruction(parallelName); 99 detector->RegisterParallelWorld(pdet); 115 detector->RegisterParallelWorld(pdet); 100 116 101 // G4GeometrySampler pgs(pdet->GetWorldVolum << 117 G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron"); 102 // B03PhysicsList* physlist = new B03Physics << 118 B03PhysicsList* physlist = new B03PhysicsList; 103 // name of first parallel world: << 119 physlist->AddParallelWorldName(parallelName); 104 B03PhysicsList* physlist = new B03PhysicsLis << 120 //physlist->AddParallelWorldName(sparallelName); 105 // push parallel world to store in case of m << 121 physlist->AddBiasing(&pgs,parallelName); 106 physlist->AddParallelWorldName(parallelName) << 122 107 // physlist->AddParallelWorldName(parallelNa << 108 // physlist->AddParallelWorldName(sparallelN << 109 // physlist->AddBiasing(&pgs,parallelName); << 110 << 111 runManager->SetUserInitialization(physlist); 123 runManager->SetUserInitialization(physlist); 112 124 113 // Set user action classes through Worker In << 125 // Set user action classes through Worker Initialization 114 // << 126 // 115 B03ActionInitialization* actions = new B03Ac 127 B03ActionInitialization* actions = new B03ActionInitialization; 116 runManager->SetUserInitialization(actions); 128 runManager->SetUserInitialization(actions); 117 129 118 // runManager->SetUserAction(new B03Primar << 130 // runManager->SetUserAction(new B03PrimaryGeneratorAction); 119 // // runManager->SetUserAction(new B03Pr << 131 // // runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron)); 120 // runManager->SetUserAction(new B03RunAct << 132 // runManager->SetUserAction(new B03RunAction); 121 133 122 runManager->Initialize(); 134 runManager->Initialize(); 123 135 124 G4VPhysicalVolume& aghostWorld = pdet->GetWo 136 G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress(); 125 G4cout << " ghost world: " << pdet->GetName( 137 G4cout << " ghost world: " << pdet->GetName() << G4endl; 126 138 127 // create an importance << 139 // create an importance 128 G4IStore* aIstore = G4IStore::GetInstance(pd << 140 G4IStore *aIstore = G4IStore::GetInstance(pdet->GetName()); 129 141 130 // create a geometry cell for the world volu 142 // create a geometry cell for the world volume replpicanumber is 0! 131 G4GeometryCell gWorldVolumeCell(aghostWorld, 143 G4GeometryCell gWorldVolumeCell(aghostWorld, 0); 132 // set world volume importance to 1 144 // set world volume importance to 1 133 aIstore->AddImportanceGeometryCell(1, gWorld 145 aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell); 134 146 135 // set importance values and create scorers << 147 // set importance values and create scorers 136 G4int cell(1); 148 G4int cell(1); 137 for (cell = 1; cell <= 18; cell++) { << 149 for (cell=1; cell<=18; cell++) { 138 G4GeometryCell gCell = pdet->GetGeometryCe 150 G4GeometryCell gCell = pdet->GetGeometryCell(cell); 139 G4cout << " adding cell: " << cell << " re << 151 G4cout << " adding cell: " << cell >> 152 << " replica: " << gCell.GetReplicaNumber() 140 << " name: " << gCell.GetPhysicalVo 153 << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl; 141 G4double imp = std::pow(2.0, cell - 1); << 154 G4double imp = std::pow(2.0,cell-1); 142 // x aIstore.AddImportanceGeometryCell( << 155 //x aIstore.AddImportanceGeometryCell(imp, gCell); 143 aIstore->AddImportanceGeometryCell(imp, gC 156 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell); 144 } 157 } 145 158 146 // creating the geometry cell and add both t 159 // creating the geometry cell and add both to the store 147 // G4GeometryCell gCell = pdet->GetGeometry 160 // G4GeometryCell gCell = pdet->GetGeometryCell(18); 148 161 >> 162 149 // create importance geometry cell pair for 163 // create importance geometry cell pair for the "rest"cell 150 // with the same importance as the last conc << 164 // with the same importance as the last concrete cell 151 G4GeometryCell gCell = pdet->GetGeometryCell 165 G4GeometryCell gCell = pdet->GetGeometryCell(19); 152 // G4double imp = std::pow(2.0,18); << 166 // G4double imp = std::pow(2.0,18); 153 G4double imp = std::pow(2.0, 17); << 167 G4double imp = std::pow(2.0,17); 154 aIstore->AddImportanceGeometryCell(imp, gCel 168 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19); 155 << 169 156 // temporary fix before runManager->BeamOn w << 170 //temporary fix before runManager->BeamOn works... 157 G4UImanager* UImanager = G4UImanager::GetUIp << 171 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 158 G4String command1 = "/control/cout/setCoutFi 172 G4String command1 = "/control/cout/setCoutFile fileName"; 159 UImanager->ApplyCommand(command1); 173 UImanager->ApplyCommand(command1); 160 174 161 G4String command2 = "/run/beamOn " + G4UIcom << 175 G4String command2 = "/run/beamOn " 162 ; << 176 + G4UIcommand::ConvertToString(numberOfEvents);; 163 UImanager->ApplyCommand(command2); 177 UImanager->ApplyCommand(command2); 164 178 165 // runManager->BeamOn(numberOfEvents); 179 // runManager->BeamOn(numberOfEvents); 166 180 167 // pgs.ClearSampling(); << 181 pgs.ClearSampling(); 168 182 169 delete runManager; 183 delete runManager; 170 << 184 171 return 0; 185 return 0; 172 } 186 } 173 187 174 //....oooOO0OOooo........oooOO0OOooo........oo 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 175 189