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/B02/exampleB02.cc << 27 /// \brief Main program of the biasing/B02 exa << 28 // << 29 // << 30 // 26 // >> 27 // $Id: exampleB02.cc,v 1.20 2006/06/29 16:34:23 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 31 // 29 // >> 30 // 32 // ------------------------------------------- 31 // -------------------------------------------------------------- 33 // GEANT 4 - exampleB02 32 // GEANT 4 - exampleB02 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 both importance sampling and a 39 // in the mass (tracking) geometry. << 38 // customized scoring making use of the scoring framework >> 39 // in a parallel geometry. >> 40 // 40 // A simple geometry consisting of a 180 cm hi 41 // A simple geometry consisting of a 180 cm high concrete cylinder 41 // divided into 18 slabs of 10cm each is creat << 42 // is constructed in the mass geometry. 42 // Importance values are assigned to the 18 co << 43 // A geometry is constructed in the parallel geometry 43 // detector construction class for simplicity. << 44 // in order to assign importance values to slabs >> 45 // of width 10cm and for scoring. The parallel world volume should >> 46 // overlap the mass world volume and the radii of the slabs is larger >> 47 // than the radius of the concrete cylinder in the mass geometry. 44 // Pairs of G4GeometryCell and importance valu 48 // Pairs of G4GeometryCell and importance values are stored in 45 // the importance store. 49 // the importance store. 46 // << 50 // The scoring uses the G4CellSCorer and one customized scorer for >> 51 // the last slab. >> 52 // >> 53 // 47 54 48 // ------------------------------------------- 55 // -------------------------------------------------------------- 49 56 50 #include "G4GeometryManager.hh" << 51 #include "G4RunManagerFactory.hh" << 52 #include "G4Types.hh" << 53 #include "G4UImanager.hh" << 54 #include "G4VPhysicalVolume.hh" << 55 << 56 #include <iostream> 57 #include <iostream> 57 #include <stdlib.h> << 58 58 59 // user classes << 59 #include "G4VPhysicalVolume.hh" 60 #include "B02ActionInitialization.hh" << 60 #include "G4RunManager.hh" >> 61 #include "G4UImanager.hh" >> 62 61 #include "B02DetectorConstruction.hh" 63 #include "B02DetectorConstruction.hh" 62 #include "B02ImportanceDetectorConstruction.hh << 64 #include "B02PhysicsList.hh" 63 #include "FTFP_BERT.hh" << 65 #include "B02PrimaryGeneratorAction.hh" 64 66 65 #include "G4ImportanceBiasing.hh" << 67 // construction for the parallel geometry 66 #include "G4ParallelWorldPhysics.hh" << 68 #include "B02ImportanceDetectorConstruction.hh" 67 // #include "B02PrimaryGeneratorAction.hh" << 68 // #include "B02RunAction.hh" << 69 69 70 // Files specific for biasing and scoring 70 // Files specific for biasing and scoring 71 #include "G4GeometrySampler.hh" << 71 #include "G4Scorer.hh" >> 72 #include "G4ParallelGeometrySampler.hh" 72 #include "G4IStore.hh" 73 #include "G4IStore.hh" 73 #include "G4VWeightWindowStore.hh" << 74 #include "G4WeightWindowAlgorithm.hh" << 75 74 76 //....oooOO0OOooo........oooOO0OOooo........oo << 75 // customized scorer and store >> 76 #include "B02CellScorer.hh" >> 77 #include "B02CellScorerStore.hh" 77 78 78 int main(int argc, char** argv) << 79 // a score table 79 { << 80 #include "G4ScoreTable.hh" 80 G4int mode = 0; << 81 if (argc > 1) mode = atoi(argv[1]); << 82 if (mode != 0) { << 83 G4cout << " mode not used yet, refer to B0 << 84 } << 85 81 86 G4int numberOfEvents = 100; << 82 // AIDA stuff 87 G4long myseed = 345354; << 88 83 89 auto* runManager = G4RunManagerFactory::Crea << 84 #include "AIDA/IAnalysisFactory.h" 90 runManager->SetNumberOfThreads(2); << 85 #include "AIDA/ITree.h" >> 86 #include "AIDA/ITreeFactory.h" >> 87 #include "AIDA/IHistogram1D.h" >> 88 #include "AIDA/IHistogramFactory.h" 91 89 92 G4Random::setTheSeed(myseed); << 93 90 >> 91 >> 92 int main(int , char **) >> 93 { >> 94 std::ostream *myout = &G4cout; >> 95 G4int numberOfEvent = 100; >> 96 >> 97 G4long myseed = 345354; >> 98 >> 99 CLHEP::HepRandom::setTheSeed(myseed); >> 100 >> 101 G4RunManager *runManager = new G4RunManager; >> 102 94 // create the detector ---------------- 103 // create the detector --------------------------- 95 B02DetectorConstruction* detector = new B02D << 104 B02DetectorConstruction *detector = new B02DetectorConstruction(); 96 runManager->SetUserInitialization(detector); 105 runManager->SetUserInitialization(detector); >> 106 // --------------------------------------------------- >> 107 runManager->SetUserInitialization(new B02PhysicsList); >> 108 runManager->SetUserAction(new B02PrimaryGeneratorAction); >> 109 // runManager->Initialize(); 97 110 98 G4String parallelName("ParallelBiasingWorld" << 99 B02ImportanceDetectorConstruction* pdet = ne << 100 detector->RegisterParallelWorld(pdet); << 101 << 102 G4GeometrySampler pgs(pdet->GetWorldVolume() << 103 111 104 pgs.SetParallel(true); << 112 // create a parallel detector >> 113 B02ImportanceDetectorConstruction *pdet = >> 114 new B02ImportanceDetectorConstruction; >> 115 runManager->Initialize(); 105 116 106 G4VModularPhysicsList* physicsList = new FTF << 107 physicsList->RegisterPhysics(new G4Importanc << 108 physicsList->RegisterPhysics(new G4ParallelW << 109 117 110 runManager->SetUserInitialization(physicsLis << 118 // create an importance >> 119 G4IStore aIstore(pdet->GetWorldVolume()); >> 120 // create a geometry cell for the world volume replpicanumber is 0! >> 121 G4GeometryCell gWorldVolumeCell(pdet->GetWorldVolume(), 0); >> 122 // set world volume importance to 1 >> 123 aIstore.AddImportanceGeometryCell(1, gWorldVolumeCell); >> 124 >> 125 // create a customized cell scorer store >> 126 B02CellScorerStore b02store; >> 127 >> 128 // set importance values and create scorers >> 129 G4int cell(1); >> 130 for (cell=1; cell<=18; cell++) { >> 131 G4GeometryCell gCell = pdet->GetGeometryCell(cell); >> 132 G4double imp = std::pow(2.0,cell-1); >> 133 aIstore.AddImportanceGeometryCell(imp, gCell); >> 134 // adding the standard G4CellScorer for 17 concrete cells >> 135 if (cell<18) { >> 136 b02store.AddG4CellScorer(gCell); >> 137 } >> 138 } 111 139 112 // Set user action classes through Worker In << 140 // create a histogram for a special scorer for the last cell 113 // << 141 AIDA::IAnalysisFactory *af = AIDA_createAnalysisFactory(); 114 B02ActionInitialization* actions = new B02Ac << 142 AIDA::ITreeFactory *tf = af->createTreeFactory(); 115 runManager->SetUserInitialization(actions); << 143 AIDA::ITree *tree = tf->create("b02.hbook", "hbook",false,true); >> 144 AIDA::IHistogramFactory *hf = af->createHistogramFactory( *tree ); >> 145 AIDA::IHistogram1D *h = >> 146 hf->createHistogram1D("10","w*sl vs. e", 30, 0., 20*MeV); >> 147 // create a special scorer for the last cell >> 148 B02CellScorer b02scorer(h); >> 149 116 150 117 runManager->Initialize(); << 118 151 119 pdet->CreateImportanceStore(); << 120 152 121 // temporary fix before runManager->BeamOn w << 153 // creating the geometry cell and add both to the store 122 G4UImanager* UImanager = G4UImanager::GetUIp << 154 G4GeometryCell gCell = pdet->GetGeometryCell(18); 123 G4String command1 = "/control/cout/setCoutFi << 155 b02store.AddB02CellScorer(&b02scorer, gCell); 124 UImanager->ApplyCommand(command1); << 156 125 G4String command2 = "/run/beamOn " + G4UIcom << 157 // create importance geometry cell pair for the "rest"cell 126 UImanager->ApplyCommand(command2); << 158 // with the same importance as the last concrete cell 127 << 159 gCell = pdet->GetGeometryCell(19); 128 // open geometry for clean biasing stores cl << 160 G4double imp = std::pow(2.0,18); 129 // << 161 aIstore.AddImportanceGeometryCell(imp, gCell); 130 G4GeometryManager::GetInstance()->OpenGeomet << 162 >> 163 >> 164 // create the importance and scoring sampler for biasing and scoring >> 165 // in the parallel world >> 166 >> 167 G4CellStoreScorer scorer(b02store); >> 168 >> 169 G4ParallelGeometrySampler pgs(pdet->GetWorldVolume(), >> 170 "neutron"); >> 171 pgs.PrepareScoring(&scorer); >> 172 pgs.PrepareImportanceSampling(&aIstore, 0); >> 173 pgs.Configure(); >> 174 >> 175 runManager->BeamOn(numberOfEvent); >> 176 >> 177 // print a table of the scores >> 178 G4ScoreTable sp(&aIstore); >> 179 sp.Print(b02store.GetMapGeometryCellCellScorer(), myout); >> 180 >> 181 >> 182 tree->commit(); >> 183 tree->close(); >> 184 >> 185 delete af; >> 186 delete tf; >> 187 delete tree; 131 188 132 // pgs.ClearSampling(); << 189 pgs.ClearSampling(); 133 190 134 delete runManager; 191 delete runManager; 135 << 192 136 return 0; 193 return 0; 137 } 194 } 138 195 139 //....oooOO0OOooo........oooOO0OOooo........oo << 196 >> 197 140 198