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