|
|
|||
File indexing completed on 2026-06-05 07:54:20
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file exampleB01.cc 0027 /// \brief Main program of the biasing/B01 example 0028 0029 // -------------------------------------------------------------- 0030 // GEANT 4 - exampleB01 0031 // 0032 // -------------------------------------------------------------- 0033 // Comments 0034 // 0035 // This example intends to show how to use importance sampling and scoring 0036 // in the mass (tracking) geometry. 0037 // A simple geometry consisting of a 180 cm high concrete cylinder 0038 // divided into 18 slabs of 10cm each is created. 0039 // Importance values are assigned to the 18 concrete slabs in the 0040 // detector construction class for simplicity. 0041 // Pairs of G4GeometryCell and importance values are stored in 0042 // the importance store. 0043 // Scoring is carried out by the multifunctional detector (MFD) and 0044 // sensitive detectors 0045 // 0046 // Alex Howard (alexander.howard@cern.ch): 0047 // 22/11/13: Migrated to the new MT compliant design which moves the 0048 // biasing process to the physicslist constructor - here 0049 // via the modular physicslists 0050 // 0051 0052 // -------------------------------------------------------------- 0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0054 0055 #include "G4GeometryManager.hh" 0056 #include "G4RunManagerFactory.hh" 0057 #include "G4Types.hh" 0058 #include "G4UImanager.hh" 0059 #include "G4VPhysicalVolume.hh" 0060 0061 #include <iostream> 0062 #include <stdlib.h> 0063 0064 // user classes 0065 #include "B01ActionInitialization.hh" 0066 #include "B01DetectorConstruction.hh" 0067 #include "FTFP_BERT.hh" 0068 0069 #include "G4ImportanceBiasing.hh" 0070 #include "G4WeightWindowBiasing.hh" 0071 // #include "B01PrimaryGeneratorAction.hh" 0072 // #include "B01RunAction.hh" 0073 0074 // Files specific for biasing and scoring 0075 #include "G4GeometrySampler.hh" 0076 #include "G4IStore.hh" 0077 #include "G4VWeightWindowStore.hh" 0078 #include "G4WeightWindowAlgorithm.hh" 0079 0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0081 0082 int main(int argc, char** argv) 0083 { 0084 G4int mode = 0; 0085 if (argc > 1) mode = atoi(argv[1]); 0086 0087 G4int numberOfEvents = 100; 0088 G4long myseed = 345354; 0089 0090 auto* runManager = G4RunManagerFactory::CreateRunManager(); 0091 runManager->SetNumberOfThreads(2); 0092 0093 G4Random::setTheSeed(myseed); 0094 0095 G4VWeightWindowAlgorithm* wwAlg = 0; // pointer for WeightWindow (mode>0) 0096 0097 // create the detector --------------------------- 0098 B01DetectorConstruction* detector = new B01DetectorConstruction(); 0099 runManager->SetUserInitialization(detector); 0100 G4GeometrySampler mgs(detector->GetWorldVolume(), "neutron"); 0101 0102 G4VModularPhysicsList* physicsList = new FTFP_BERT; 0103 if (mode == 0) { 0104 physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs)); 0105 } 0106 else { 0107 wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor 0108 1, // survival factor 0109 100); // max. number of splitting 0110 0111 physicsList->RegisterPhysics(new G4WeightWindowBiasing(&mgs, wwAlg, onBoundary)); 0112 // place of action 0113 } 0114 runManager->SetUserInitialization(physicsList); 0115 0116 // Set user action classes through Worker Initialization 0117 // 0118 B01ActionInitialization* actions = new B01ActionInitialization; 0119 runManager->SetUserInitialization(actions); 0120 0121 runManager->Initialize(); 0122 0123 if (mode == 0) { 0124 detector->CreateImportanceStore(); 0125 } 0126 else { 0127 detector->CreateWeightWindowStore(); 0128 } 0129 0130 // runManager->BeamOn(numberOfEvents); 0131 0132 // temporary fix before runManager->BeamOn works... 0133 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0134 G4String command1 = "/control/cout/setCoutFile threadOut"; 0135 UImanager->ApplyCommand(command1); 0136 G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents); 0137 ; 0138 UImanager->ApplyCommand(command2); 0139 0140 // open geometry for clean biasing stores clean-up 0141 // 0142 G4GeometryManager::GetInstance()->OpenGeometry(); 0143 0144 if (wwAlg) { 0145 delete wwAlg; 0146 } 0147 0148 // mgs.ClearSampling(); 0149 0150 delete runManager; 0151 0152 return 0; 0153 } 0154 0155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|