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.23 2006/06/29 16:34:07 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-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> << 66 52 67 // user classes << 53 #include "G4VPhysicalVolume.hh" 68 #include "B01ActionInitialization.hh" << 54 #include "G4RunManager.hh" 69 #include "B01DetectorConstruction.hh" << 55 #include "G4UImanager.hh" 70 #include "FTFP_BERT.hh" << 56 #include "G4GeometryManager.hh" 71 57 72 #include "G4ImportanceBiasing.hh" << 58 #include "B01DetectorConstruction.hh" 73 #include "G4WeightWindowBiasing.hh" << 59 #include "B01PhysicsList.hh" 74 // #include "B01PrimaryGeneratorAction.hh" << 60 #include "B01PrimaryGeneratorAction.hh" 75 // #include "B01RunAction.hh" << 76 61 77 // Files specific for biasing and scoring 62 // Files specific for biasing and scoring 78 #include "G4GeometrySampler.hh" << 63 #include "G4Scorer.hh" >> 64 #include "G4MassGeometrySampler.hh" 79 #include "G4IStore.hh" 65 #include "G4IStore.hh" 80 #include "G4VWeightWindowStore.hh" 66 #include "G4VWeightWindowStore.hh" 81 #include "G4WeightWindowAlgorithm.hh" 67 #include "G4WeightWindowAlgorithm.hh" 82 68 83 //....oooOO0OOooo........oooOO0OOooo........oo << 69 // a score table >> 70 #include "G4ScoreTable.hh" >> 71 84 72 85 int main(int argc, char** argv) << 73 int main(int argc, char **argv) 86 { 74 { 87 G4int mode = 0; 75 G4int mode = 0; 88 if (argc > 1) mode = atoi(argv[1]); << 76 if (argc>1) mode = atoi(argv[1]); 89 77 90 G4int numberOfEvents = 100; << 78 std::ostream *myout = &G4cout; >> 79 G4int numberOfEvent = 100; 91 G4long myseed = 345354; 80 G4long myseed = 345354; >> 81 CLHEP::HepRandom::setTheSeed(myseed); 92 82 93 auto* runManager = G4RunManagerFactory::Crea << 83 G4RunManager *runManager = new G4RunManager; 94 runManager->SetNumberOfThreads(2); << 84 95 << 96 G4Random::setTheSeed(myseed); << 97 << 98 G4VWeightWindowAlgorithm* wwAlg = 0; // poi << 99 << 100 // create the detector ---------------- 85 // create the detector --------------------------- 101 B01DetectorConstruction* detector = new B01D << 86 B01DetectorConstruction *detector = new B01DetectorConstruction(); 102 runManager->SetUserInitialization(detector); 87 runManager->SetUserInitialization(detector); 103 G4GeometrySampler mgs(detector->GetWorldVolu << 88 // --------------------------------------------------- 104 << 89 runManager->SetUserInitialization(new B01PhysicsList); 105 G4VModularPhysicsList* physicsList = new FTF << 90 runManager->SetUserAction(new B01PrimaryGeneratorAction); 106 if (mode == 0) { << 91 runManager->Initialize(); 107 physicsList->RegisterPhysics(new G4Importa << 108 } << 109 else { << 110 wwAlg = new G4WeightWindowAlgorithm(1, // << 111 1, // << 112 100); << 113 92 114 physicsList->RegisterPhysics(new G4WeightW << 93 // pointers for importance store, weight-window store 115 // place of action << 94 // and weight-window algorithm 116 } << 95 // 117 runManager->SetUserInitialization(physicsLis << 96 G4VIStore *aIstore = 0; >> 97 G4VWeightWindowStore *aWWstore = 0; >> 98 G4VWeightWindowAlgorithm *wwAlg = 0; 118 99 119 // Set user action classes through Worker In << 100 // use a scorer 120 // 101 // 121 B01ActionInitialization* actions = new B01Ac << 102 G4Scorer scorer; 122 runManager->SetUserInitialization(actions); << 123 103 124 runManager->Initialize(); << 104 // create sampler for biasing and scoring in the mass geometry >> 105 // >> 106 G4MassGeometrySampler mgs("neutron"); >> 107 mgs.PrepareScoring(&scorer); 125 108 126 if (mode == 0) { << 109 if (mode == 0) 127 detector->CreateImportanceStore(); << 110 { >> 111 // prepare for importance sampling >> 112 // >> 113 aIstore = detector->CreateImportanceStore(); >> 114 mgs.PrepareImportanceSampling(aIstore, 0); 128 } 115 } 129 else { << 116 else 130 detector->CreateWeightWindowStore(); << 117 { >> 118 // prepare for weight window technique >> 119 // in this case the algoritm is initialized such that >> 120 // the weight window tehcnique does exactly the same as >> 121 // the importance sampling technique, therefore >> 122 // the place of action ( the locations where >> 123 // splitting and Russian roulette are to be applied) >> 124 // is chosen to be on the boundary between cells. >> 125 // >> 126 aWWstore = detector->CreateWeightWindowStore(); >> 127 >> 128 wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor >> 129 1, // survival factor >> 130 100); // max. number of splitting >> 131 >> 132 mgs.PrepareWeightWindow(aWWstore, wwAlg, onBoundary); // place of action 131 } 133 } >> 134 mgs.Configure(); 132 135 133 // runManager->BeamOn(numberOfEvents); << 136 runManager->BeamOn(numberOfEvent); 134 137 135 // temporary fix before runManager->BeamOn w << 138 // print a table of the scores 136 G4UImanager* UImanager = G4UImanager::GetUIp << 139 // 137 G4String command1 = "/control/cout/setCoutFi << 140 G4ScoreTable sp(aIstore); 138 UImanager->ApplyCommand(command1); << 141 sp.Print(scorer.GetMapGeometryCellCellScorer(), myout); 139 G4String command2 = "/run/beamOn " + G4UIcom << 140 ; << 141 UImanager->ApplyCommand(command2); << 142 142 143 // open geometry for clean biasing stores cl 143 // open geometry for clean biasing stores clean-up 144 // 144 // 145 G4GeometryManager::GetInstance()->OpenGeomet 145 G4GeometryManager::GetInstance()->OpenGeometry(); 146 146 >> 147 if (aIstore) { >> 148 delete aIstore; >> 149 } >> 150 if (aWWstore) { >> 151 delete aWWstore; >> 152 } 147 if (wwAlg) { 153 if (wwAlg) { 148 delete wwAlg; 154 delete wwAlg; 149 } 155 } 150 156 151 // mgs.ClearSampling(); << 157 mgs.ClearSampling(); 152 158 153 delete runManager; 159 delete runManager; 154 160 155 return 0; 161 return 0; 156 } 162 } 157 << 158 //....oooOO0OOooo........oooOO0OOooo........oo << 159 163