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/B01/exampleB01.cc 26 /// \file biasing/B01/exampleB01.cc 27 /// \brief Main program of the biasing/B01 exa 27 /// \brief Main program of the biasing/B01 example 28 // 28 // 29 // 29 // >> 30 // $Id: exampleB01.cc 105209 2017-07-14 12:45:43Z gcosmo $ 30 // 31 // 31 // << 32 // 32 // ------------------------------------------- 33 // -------------------------------------------------------------- 33 // GEANT 4 - exampleB01 34 // GEANT 4 - exampleB01 34 // 35 // 35 // ------------------------------------------- 36 // -------------------------------------------------------------- 36 // Comments 37 // Comments 37 // 38 // 38 // This example intends to show how to use imp 39 // This example intends to show how to use importance sampling and scoring 39 // in the mass (tracking) geometry. 40 // in the mass (tracking) geometry. 40 // A simple geometry consisting of a 180 cm hi 41 // A simple geometry consisting of a 180 cm high concrete cylinder 41 // divided into 18 slabs of 10cm each is creat << 42 // divided into 18 slabs of 10cm each is created. 42 // Importance values are assigned to the 18 co 43 // Importance values are assigned to the 18 concrete slabs in the 43 // detector construction class for simplicity. 44 // detector construction class for simplicity. 44 // Pairs of G4GeometryCell and importance valu 45 // Pairs of G4GeometryCell and importance values are stored in 45 // the importance store. 46 // the importance store. 46 // Scoring is carried out by the multifunction 47 // Scoring is carried out by the multifunctional detector (MFD) and 47 // sensitive detectors 48 // sensitive detectors 48 // 49 // 49 // Alex Howard (alexander.howard@cern.ch): 50 // Alex Howard (alexander.howard@cern.ch): 50 // 22/11/13: Migrated to the new MT compliant 51 // 22/11/13: Migrated to the new MT compliant design which moves the 51 // biasing process to the physicslis << 52 // biasing process to the physicslist constructor - here 52 // via the modular physicslists 53 // via the modular physicslists 53 // << 54 // 54 55 55 // ------------------------------------------- 56 // -------------------------------------------------------------- 56 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 58 58 #include "G4GeometryManager.hh" << 59 #include "G4RunManagerFactory.hh" << 60 #include "G4Types.hh" << 61 #include "G4UImanager.hh" << 62 #include "G4VPhysicalVolume.hh" << 63 << 64 #include <iostream> 59 #include <iostream> >> 60 65 #include <stdlib.h> 61 #include <stdlib.h> 66 62 >> 63 #ifdef G4MULTITHREADED >> 64 #include "G4MTRunManager.hh" >> 65 #else >> 66 #include "G4RunManager.hh" >> 67 #endif >> 68 >> 69 #include "G4VPhysicalVolume.hh" >> 70 #include "G4UImanager.hh" >> 71 #include "G4GeometryManager.hh" >> 72 67 // user classes 73 // user classes 68 #include "B01ActionInitialization.hh" << 69 #include "B01DetectorConstruction.hh" 74 #include "B01DetectorConstruction.hh" 70 #include "FTFP_BERT.hh" 75 #include "FTFP_BERT.hh" 71 << 72 #include "G4ImportanceBiasing.hh" 76 #include "G4ImportanceBiasing.hh" 73 #include "G4WeightWindowBiasing.hh" 77 #include "G4WeightWindowBiasing.hh" >> 78 >> 79 #include "B01ActionInitialization.hh" 74 // #include "B01PrimaryGeneratorAction.hh" 80 // #include "B01PrimaryGeneratorAction.hh" 75 // #include "B01RunAction.hh" 81 // #include "B01RunAction.hh" 76 82 77 // Files specific for biasing and scoring 83 // Files specific for biasing and scoring 78 #include "G4GeometrySampler.hh" 84 #include "G4GeometrySampler.hh" 79 #include "G4IStore.hh" 85 #include "G4IStore.hh" 80 #include "G4VWeightWindowStore.hh" 86 #include "G4VWeightWindowStore.hh" 81 #include "G4WeightWindowAlgorithm.hh" 87 #include "G4WeightWindowAlgorithm.hh" 82 88 83 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 84 90 85 int main(int argc, char** argv) << 91 int main(int argc, char **argv) 86 { 92 { 87 G4int mode = 0; 93 G4int mode = 0; 88 if (argc > 1) mode = atoi(argv[1]); << 94 if (argc>1) mode = atoi(argv[1]); 89 95 90 G4int numberOfEvents = 100; 96 G4int numberOfEvents = 100; 91 G4long myseed = 345354; 97 G4long myseed = 345354; 92 98 93 auto* runManager = G4RunManagerFactory::Crea << 99 #ifdef G4MULTITHREADED >> 100 G4MTRunManager * runManager = new G4MTRunManager; >> 101 G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl; >> 102 G4cout << " and using 2 of them! " << G4endl; 94 runManager->SetNumberOfThreads(2); 103 runManager->SetNumberOfThreads(2); >> 104 // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores()); >> 105 #else >> 106 G4RunManager * runManager = new G4RunManager; >> 107 #endif 95 108 96 G4Random::setTheSeed(myseed); 109 G4Random::setTheSeed(myseed); 97 110 98 G4VWeightWindowAlgorithm* wwAlg = 0; // poi << 111 G4VWeightWindowAlgorithm *wwAlg = 0; // pointer for WeightWindow (mode>0) 99 112 100 // create the detector ---------------- 113 // create the detector --------------------------- 101 B01DetectorConstruction* detector = new B01D 114 B01DetectorConstruction* detector = new B01DetectorConstruction(); 102 runManager->SetUserInitialization(detector); 115 runManager->SetUserInitialization(detector); 103 G4GeometrySampler mgs(detector->GetWorldVolu << 116 G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron"); 104 117 105 G4VModularPhysicsList* physicsList = new FTF 118 G4VModularPhysicsList* physicsList = new FTFP_BERT; 106 if (mode == 0) { << 119 if(mode == 0) 107 physicsList->RegisterPhysics(new G4Importa << 120 { 108 } << 121 physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs)); 109 else { << 122 } 110 wwAlg = new G4WeightWindowAlgorithm(1, // << 123 else 111 1, // << 124 { 112 100); << 125 wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor 113 << 126 1, // survival factor 114 physicsList->RegisterPhysics(new G4WeightW << 127 100); // max. number of splitting 115 // place of action << 128 116 } << 129 physicsList->RegisterPhysics(new G4WeightWindowBiasing >> 130 (&mgs, wwAlg, onBoundary)); >> 131 // place of action >> 132 } 117 runManager->SetUserInitialization(physicsLis 133 runManager->SetUserInitialization(physicsList); 118 134 119 // Set user action classes through Worker In << 135 // Set user action classes through Worker Initialization 120 // << 136 // 121 B01ActionInitialization* actions = new B01Ac 137 B01ActionInitialization* actions = new B01ActionInitialization; 122 runManager->SetUserInitialization(actions); 138 runManager->SetUserInitialization(actions); 123 139 124 runManager->Initialize(); 140 runManager->Initialize(); 125 141 126 if (mode == 0) { << 142 if (mode == 0) 127 detector->CreateImportanceStore(); << 143 { 128 } << 144 detector->CreateImportanceStore(); 129 else { << 145 } 130 detector->CreateWeightWindowStore(); << 146 else 131 } << 147 { >> 148 detector->CreateWeightWindowStore(); >> 149 } 132 150 133 // runManager->BeamOn(numberOfEvents); 151 // runManager->BeamOn(numberOfEvents); 134 152 135 // temporary fix before runManager->BeamOn w << 153 //temporary fix before runManager->BeamOn works... 136 G4UImanager* UImanager = G4UImanager::GetUIp << 154 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 137 G4String command1 = "/control/cout/setCoutFi 155 G4String command1 = "/control/cout/setCoutFile threadOut"; 138 UImanager->ApplyCommand(command1); 156 UImanager->ApplyCommand(command1); 139 G4String command2 = "/run/beamOn " + G4UIcom << 157 G4String command2 = "/run/beamOn " + 140 ; << 158 G4UIcommand::ConvertToString(numberOfEvents);; 141 UImanager->ApplyCommand(command2); 159 UImanager->ApplyCommand(command2); 142 160 143 // open geometry for clean biasing stores cl 161 // open geometry for clean biasing stores clean-up 144 // 162 // 145 G4GeometryManager::GetInstance()->OpenGeomet 163 G4GeometryManager::GetInstance()->OpenGeometry(); 146 164 147 if (wwAlg) { 165 if (wwAlg) { 148 delete wwAlg; 166 delete wwAlg; 149 } 167 } 150 168 151 // mgs.ClearSampling(); 169 // mgs.ClearSampling(); 152 170 153 delete runManager; 171 delete runManager; 154 172 155 return 0; 173 return 0; 156 } 174 } 157 175 158 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 177