![]() |
|
|||
File indexing completed on 2025-02-23 09:20:44
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 biasing/B03/exampleB03.cc 0027 /// \brief Main program of the biasing/B03 example 0028 // 0029 // 0030 // 0031 // 0032 // -------------------------------------------------------------- 0033 // GEANT 4 - exampleB03 0034 // 0035 // -------------------------------------------------------------- 0036 // Comments 0037 // 0038 // This example intends to show how to use both importance sampling and a 0039 // customized scoring making use of the scoring framework 0040 // in a parallel geometry. 0041 // 0042 // A simple geometry consisting of a 180 cm high concrete cylinder 0043 // is constructed in the mass geometry. 0044 // A geometry is constructed in the parallel geometry 0045 // in order to assign importance values to slabs 0046 // of width 10cm and for scoring. The parallel world volume should 0047 // overlap the mass world volume and the radii of the slabs is larger 0048 // than the radius of the concrete cylinder in the mass geometry. 0049 // Pairs of G4GeometryCell and importance values are stored in 0050 // the importance store. 0051 // The scoring uses the primitive scorers via the Multi Functional Detector 0052 // 0053 // 0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0055 0056 #include "B03ActionInitialization.hh" 0057 #include "B03DetectorConstruction.hh" 0058 #include "B03PhysicsList.hh" 0059 0060 #include "G4RunManagerFactory.hh" 0061 #include "G4SystemOfUnits.hh" 0062 #include "G4Types.hh" 0063 #include "G4UImanager.hh" 0064 #include "G4VPhysicalVolume.hh" 0065 0066 #include <iostream> 0067 // #include "B03PrimaryGeneratorAction.hh" 0068 // #include "B03RunAction.hh" 0069 0070 // construction for the parallel geometry 0071 #include "B03ImportanceDetectorConstruction.hh" 0072 0073 // Files specific for biasing and scoring 0074 // #include "G4Scorer.hh" 0075 // #include "G4GeometrySampler.hh" 0076 #include "G4IStore.hh" 0077 0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0079 0080 int main(int, char**) 0081 { 0082 G4int numberOfEvents = 100; 0083 0084 G4long myseed = 345354; 0085 0086 auto* runManager = G4RunManagerFactory::CreateRunManager(); 0087 runManager->SetNumberOfThreads(2); 0088 0089 G4Random::setTheSeed(myseed); 0090 0091 // create the detector --------------------------- 0092 B03DetectorConstruction* detector = new B03DetectorConstruction(); 0093 runManager->SetUserInitialization(detector); 0094 // --------------------------------------------------- 0095 0096 // create a parallel detector 0097 G4String parallelName("ParallelBiasingWorld"); 0098 B03ImportanceDetectorConstruction* pdet = new B03ImportanceDetectorConstruction(parallelName); 0099 detector->RegisterParallelWorld(pdet); 0100 0101 // G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron"); 0102 // B03PhysicsList* physlist = new B03PhysicsList; 0103 // name of first parallel world: 0104 B03PhysicsList* physlist = new B03PhysicsList(parallelName); 0105 // push parallel world to store in case of multiple worlds: 0106 physlist->AddParallelWorldName(parallelName); 0107 // physlist->AddParallelWorldName(parallelName); 0108 // physlist->AddParallelWorldName(sparallelName); 0109 // physlist->AddBiasing(&pgs,parallelName); 0110 0111 runManager->SetUserInitialization(physlist); 0112 0113 // Set user action classes through Worker Initialization 0114 // 0115 B03ActionInitialization* actions = new B03ActionInitialization; 0116 runManager->SetUserInitialization(actions); 0117 0118 // runManager->SetUserAction(new B03PrimaryGeneratorAction); 0119 // // runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron)); 0120 // runManager->SetUserAction(new B03RunAction); 0121 0122 runManager->Initialize(); 0123 0124 G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress(); 0125 G4cout << " ghost world: " << pdet->GetName() << G4endl; 0126 0127 // create an importance 0128 G4IStore* aIstore = G4IStore::GetInstance(pdet->GetName()); 0129 0130 // create a geometry cell for the world volume replpicanumber is 0! 0131 G4GeometryCell gWorldVolumeCell(aghostWorld, 0); 0132 // set world volume importance to 1 0133 aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell); 0134 0135 // set importance values and create scorers 0136 G4int cell(1); 0137 for (cell = 1; cell <= 18; cell++) { 0138 G4GeometryCell gCell = pdet->GetGeometryCell(cell); 0139 G4cout << " adding cell: " << cell << " replica: " << gCell.GetReplicaNumber() 0140 << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl; 0141 G4double imp = std::pow(2.0, cell - 1); 0142 // x aIstore.AddImportanceGeometryCell(imp, gCell); 0143 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell); 0144 } 0145 0146 // creating the geometry cell and add both to the store 0147 // G4GeometryCell gCell = pdet->GetGeometryCell(18); 0148 0149 // create importance geometry cell pair for the "rest"cell 0150 // with the same importance as the last concrete cell 0151 G4GeometryCell gCell = pdet->GetGeometryCell(19); 0152 // G4double imp = std::pow(2.0,18); 0153 G4double imp = std::pow(2.0, 17); 0154 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19); 0155 0156 // temporary fix before runManager->BeamOn works... 0157 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0158 G4String command1 = "/control/cout/setCoutFile fileName"; 0159 UImanager->ApplyCommand(command1); 0160 0161 G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents); 0162 ; 0163 UImanager->ApplyCommand(command2); 0164 0165 // runManager->BeamOn(numberOfEvents); 0166 0167 // pgs.ClearSampling(); 0168 0169 delete runManager; 0170 0171 return 0; 0172 } 0173 0174 //....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 |
![]() ![]() |