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 << 27 /// \brief Main program of the biasing/B01 exa << 28 // << 29 // << 30 // 26 // >> 27 // $Id: exampleB01.cc,v 1.27 2007/06/22 13:22:09 ahoward Exp $ >> 28 // GEANT4 tag $Name: geant4-09-01-patch-01 $ 31 // 29 // >> 30 // 32 // ------------------------------------------- 31 // -------------------------------------------------------------- 33 // GEANT 4 - exampleB01 32 // GEANT 4 - exampleB01 34 // 33 // 35 // ------------------------------------------- 34 // -------------------------------------------------------------- 36 // Comments 35 // Comments 37 // 36 // 38 // This example intends to show how to use imp 37 // This example intends to show how to use importance sampling and scoring 39 // in the mass (tracking) geometry. 38 // in the mass (tracking) geometry. 40 // A simple geometry consisting of a 180 cm hi 39 // A simple geometry consisting of a 180 cm high concrete cylinder 41 // divided into 18 slabs of 10cm each is creat << 40 // divided into 18 slabs of 10cm each is created. 42 // Importance values are assigned to the 18 co 41 // Importance values are assigned to the 18 concrete slabs in the 43 // detector construction class for simplicity. 42 // detector construction class for simplicity. 44 // Pairs of G4GeometryCell and importance valu 43 // Pairs of G4GeometryCell and importance values are stored in 45 // the importance store. 44 // the importance store. 46 // Scoring is carried out by the multifunction << 45 // The G4Scorer is used for the scoring. This is a top level 47 // sensitive detectors << 46 // class using the frame work provided for scoring. 48 // << 47 // 49 // Alex Howard (alexander.howard@cern.ch): << 50 // 22/11/13: Migrated to the new MT compliant << 51 // biasing process to the physicslis << 52 // via the modular physicslists << 53 // << 54 48 55 // ------------------------------------------- 49 // -------------------------------------------------------------- 56 //....oooOO0OOooo........oooOO0OOooo........oo << 57 << 58 #include "G4GeometryManager.hh" << 59 #include "G4RunManagerFactory.hh" << 60 #include "G4Types.hh" << 61 #include "G4UImanager.hh" << 62 #include "G4VPhysicalVolume.hh" << 63 50 64 #include <iostream> 51 #include <iostream> 65 #include <stdlib.h> << 52 >> 53 #include "G4VPhysicalVolume.hh" >> 54 #include "G4RunManager.hh" >> 55 #include "G4UImanager.hh" >> 56 #include "G4GeometryManager.hh" 66 57 67 // user classes 58 // user classes 68 #include "B01ActionInitialization.hh" << 69 #include "B01DetectorConstruction.hh" 59 #include "B01DetectorConstruction.hh" 70 #include "FTFP_BERT.hh" << 60 #include "B01PhysicsList.hh" 71 << 61 #include "B01PrimaryGeneratorAction.hh" 72 #include "G4ImportanceBiasing.hh" << 62 #include "B01RunAction.hh" 73 #include "G4WeightWindowBiasing.hh" << 63 #include "B01ScoreTable.hh" 74 // #include "B01PrimaryGeneratorAction.hh" << 75 // #include "B01RunAction.hh" << 76 64 77 // Files specific for biasing and scoring 65 // Files specific for biasing and scoring 78 #include "G4GeometrySampler.hh" 66 #include "G4GeometrySampler.hh" 79 #include "G4IStore.hh" 67 #include "G4IStore.hh" 80 #include "G4VWeightWindowStore.hh" 68 #include "G4VWeightWindowStore.hh" 81 #include "G4WeightWindowAlgorithm.hh" 69 #include "G4WeightWindowAlgorithm.hh" 82 70 83 //....oooOO0OOooo........oooOO0OOooo........oo << 84 71 85 int main(int argc, char** argv) << 72 int main(int argc, char **argv) 86 { 73 { 87 G4int mode = 0; 74 G4int mode = 0; 88 if (argc > 1) mode = atoi(argv[1]); << 75 if (argc>1) mode = atoi(argv[1]); 89 76 90 G4int numberOfEvents = 100; 77 G4int numberOfEvents = 100; 91 G4long myseed = 345354; 78 G4long myseed = 345354; >> 79 CLHEP::HepRandom::setTheSeed(myseed); 92 80 93 auto* runManager = G4RunManagerFactory::Crea << 81 G4RunManager *runManager = new G4RunManager; 94 runManager->SetNumberOfThreads(2); << 82 95 << 96 G4Random::setTheSeed(myseed); << 97 << 98 G4VWeightWindowAlgorithm* wwAlg = 0; // poi << 99 << 100 // create the detector ---------------- 83 // create the detector --------------------------- 101 B01DetectorConstruction* detector = new B01D << 84 B01DetectorConstruction *detector = new B01DetectorConstruction(); 102 runManager->SetUserInitialization(detector); 85 runManager->SetUserInitialization(detector); 103 G4GeometrySampler mgs(detector->GetWorldVolu << 86 // --------------------------------------------------- 104 << 87 runManager->SetUserInitialization(new B01PhysicsList); 105 G4VModularPhysicsList* physicsList = new FTF << 88 runManager->SetUserAction(new B01PrimaryGeneratorAction); 106 if (mode == 0) { << 89 runManager->SetUserAction(new B01RunAction); 107 physicsList->RegisterPhysics(new G4Importa << 90 runManager->Initialize(); 108 } << 109 else { << 110 wwAlg = new G4WeightWindowAlgorithm(1, // << 111 1, // << 112 100); << 113 << 114 physicsList->RegisterPhysics(new G4WeightW << 115 // place of action << 116 } << 117 runManager->SetUserInitialization(physicsLis << 118 91 119 // Set user action classes through Worker In << 92 // pointers for importance store, weight-window store >> 93 // and weight-window algorithm 120 // 94 // 121 B01ActionInitialization* actions = new B01Ac << 95 G4VIStore *aIstore = 0; 122 runManager->SetUserInitialization(actions); << 96 G4VWeightWindowStore *aWWstore = 0; >> 97 G4VWeightWindowAlgorithm *wwAlg = 0; 123 98 124 runManager->Initialize(); << 99 // create sampler for biasing and scoring in the mass geometry >> 100 // >> 101 G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron"); >> 102 mgs.SetParallel(false); 125 103 126 if (mode == 0) { << 104 if (mode == 0) 127 detector->CreateImportanceStore(); << 105 { >> 106 // prepare for importance sampling >> 107 // >> 108 aIstore = detector->CreateImportanceStore(); >> 109 mgs.PrepareImportanceSampling(aIstore, 0); 128 } 110 } 129 else { << 111 else 130 detector->CreateWeightWindowStore(); << 112 { >> 113 // prepare for weight window technique >> 114 // in this case the algoritm is initialized such that >> 115 // the weight window tehcnique does exactly the same as >> 116 // the importance sampling technique, therefore >> 117 // the place of action ( the locations where >> 118 // splitting and Russian roulette are to be applied) >> 119 // is chosen to be on the boundary between cells. >> 120 // >> 121 aWWstore = detector->CreateWeightWindowStore(); >> 122 >> 123 wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor >> 124 1, // survival factor >> 125 100); // max. number of splitting >> 126 >> 127 mgs.PrepareWeightWindow(aWWstore, wwAlg, onBoundary); // place of action 131 } 128 } >> 129 mgs.Configure(); 132 130 133 // runManager->BeamOn(numberOfEvents); << 131 runManager->BeamOn(numberOfEvents); 134 132 135 // temporary fix before runManager->BeamOn w << 133 // print a table of the scores 136 G4UImanager* UImanager = G4UImanager::GetUIp << 134 // 137 G4String command1 = "/control/cout/setCoutFi << 135 B01ScoreTable sp(aIstore); //ASO 138 UImanager->ApplyCommand(command1); << 139 G4String command2 = "/run/beamOn " + G4UIcom << 140 ; << 141 UImanager->ApplyCommand(command2); << 142 136 143 // open geometry for clean biasing stores cl 137 // open geometry for clean biasing stores clean-up 144 // 138 // 145 G4GeometryManager::GetInstance()->OpenGeomet 139 G4GeometryManager::GetInstance()->OpenGeometry(); 146 140 >> 141 if (aIstore) { >> 142 delete aIstore; >> 143 } >> 144 if (aWWstore) { >> 145 delete aWWstore; >> 146 } 147 if (wwAlg) { 147 if (wwAlg) { 148 delete wwAlg; 148 delete wwAlg; 149 } 149 } 150 150 151 // mgs.ClearSampling(); << 151 mgs.ClearSampling(); 152 152 153 delete runManager; 153 delete runManager; 154 154 155 return 0; 155 return 0; 156 } 156 } 157 << 158 //....oooOO0OOooo........oooOO0OOooo........oo << 159 157