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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/biasing/B03/exampleB03.cc (Version 11.3.0) and /examples/extended/biasing/B03/exampleB03.cc (Version 10.4)


  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/B03/exampleB03.cc                26 /// \file biasing/B03/exampleB03.cc
 27 /// \brief Main program of the biasing/B03 exa     27 /// \brief Main program of the biasing/B03 example
 28 //                                                 28 //
 29 //                                                 29 //
                                                   >>  30 // $Id: exampleB03.cc 70528 2013-05-31 16:50:36Z gcosmo $
 30 //                                                 31 //
 31 //                                             <<  32 // 
 32 // -------------------------------------------     33 // --------------------------------------------------------------
 33 //      GEANT 4 - exampleB03                       34 //      GEANT 4 - exampleB03
 34 //                                                 35 //
 35 // -------------------------------------------     36 // --------------------------------------------------------------
 36 // Comments                                        37 // Comments
 37 //                                                 38 //
 38 // This example intends to show how to use bot     39 // This example intends to show how to use both importance sampling and a
 39 // customized scoring making use of the scorin     40 // customized scoring making use of the scoring framework
 40 // in a parallel geometry.                         41 // in a parallel geometry.
 41 //                                             <<  42 // 
 42 // A simple geometry consisting of a 180 cm hi     43 // A simple geometry consisting of a 180 cm high concrete cylinder
 43 // is constructed in the mass geometry.            44 // is constructed in the mass geometry.
 44 // A geometry is constructed in the parallel g     45 // A geometry is constructed in the parallel geometry
 45 // in order to assign importance values to sla     46 // in order to assign importance values to slabs
 46 // of width 10cm and for scoring. The parallel <<  47 // of width 10cm and for scoring. The parallel world volume should 
 47 // overlap the mass world volume and  the radi <<  48 // overlap the mass world volume and  the radii of the slabs is larger 
 48 // than the radius of the concrete cylinder in     49 // than the radius of the concrete cylinder in the mass geometry.
 49 // Pairs of G4GeometryCell and importance valu     50 // Pairs of G4GeometryCell and importance values are stored in
 50 // the importance store.                           51 // the importance store.
 51 // The scoring uses the primitive scorers via      52 // The scoring uses the primitive scorers via the Multi Functional Detector
 52 //                                             <<  53 // 
 53 //                                             <<  54 // 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    56 
 56 #include "B03ActionInitialization.hh"          <<  57 #include <iostream>
 57 #include "B03DetectorConstruction.hh"          <<  58 
 58 #include "B03PhysicsList.hh"                   <<  59 #ifdef G4MULTITHREADED
                                                   >>  60 #include "G4MTRunManager.hh"
                                                   >>  61 #else
                                                   >>  62 #include "G4RunManager.hh"
                                                   >>  63 #endif
 59                                                    64 
 60 #include "G4RunManagerFactory.hh"              << 
 61 #include "G4SystemOfUnits.hh"                  << 
 62 #include "G4Types.hh"                          << 
 63 #include "G4UImanager.hh"                      << 
 64 #include "G4VPhysicalVolume.hh"                    65 #include "G4VPhysicalVolume.hh"
                                                   >>  66 #include "G4UImanager.hh"
                                                   >>  67 #include "G4SystemOfUnits.hh"
 65                                                    68 
 66 #include <iostream>                            <<  69 #include "B03DetectorConstruction.hh"
                                                   >>  70 #include "B03PhysicsList.hh"
                                                   >>  71 
                                                   >>  72 #include "B03ActionInitialization.hh"
 67 // #include "B03PrimaryGeneratorAction.hh"         73 // #include "B03PrimaryGeneratorAction.hh"
 68 // #include "B03RunAction.hh"                      74 // #include "B03RunAction.hh"
 69                                                    75 
 70 // construction for the parallel geometry          76 // construction for the parallel geometry
 71 #include "B03ImportanceDetectorConstruction.hh     77 #include "B03ImportanceDetectorConstruction.hh"
 72                                                    78 
 73 // Files specific for biasing and scoring          79 // Files specific for biasing and scoring
 74 // #include "G4Scorer.hh"                      <<  80 //#include "G4Scorer.hh"
 75 // #include "G4GeometrySampler.hh"             <<  81 #include "G4GeometrySampler.hh"
 76 #include "G4IStore.hh"                             82 #include "G4IStore.hh"
 77                                                    83 
 78 //....oooOO0OOooo........oooOO0OOooo........oo     84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 79                                                    85 
 80 int main(int, char**)                          <<  86 int main(int , char **)
 81 {                                              <<  87 {  
 82   G4int numberOfEvents = 100;                      88   G4int numberOfEvents = 100;
 83                                                    89 
 84   G4long myseed = 345354;                          90   G4long myseed = 345354;
 85                                                    91 
 86   auto* runManager = G4RunManagerFactory::Crea <<  92 #ifdef G4MULTITHREADED
                                                   >>  93   G4MTRunManager * runManager = new G4MTRunManager;
                                                   >>  94   G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
                                                   >>  95   G4cout << " but using only two! " << G4endl;
 87   runManager->SetNumberOfThreads(2);               96   runManager->SetNumberOfThreads(2);
                                                   >>  97   //  runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
                                                   >>  98 #else
                                                   >>  99   G4RunManager * runManager = new G4RunManager;
                                                   >> 100 #endif
 88                                                   101 
 89   G4Random::setTheSeed(myseed);                   102   G4Random::setTheSeed(myseed);
 90                                                   103 
 91   // create the detector      ----------------    104   // create the detector      ---------------------------
 92   B03DetectorConstruction* detector = new B03D << 105   B03DetectorConstruction *detector = new B03DetectorConstruction();
 93   runManager->SetUserInitialization(detector);    106   runManager->SetUserInitialization(detector);
 94   //  ----------------------------------------    107   //  ---------------------------------------------------
 95                                                   108 
 96   // create a parallel detector                   109   // create a parallel detector
 97   G4String parallelName("ParallelBiasingWorld"    110   G4String parallelName("ParallelBiasingWorld");
 98   B03ImportanceDetectorConstruction* pdet = ne << 111   B03ImportanceDetectorConstruction *pdet = 
                                                   >> 112     new B03ImportanceDetectorConstruction(parallelName);
 99   detector->RegisterParallelWorld(pdet);          113   detector->RegisterParallelWorld(pdet);
100                                                   114 
101   // G4GeometrySampler pgs(pdet->GetWorldVolum << 115   G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
102   // B03PhysicsList* physlist = new B03Physics << 116   B03PhysicsList* physlist = new B03PhysicsList;
103   // name of first parallel world:             << 117   physlist->AddParallelWorldName(parallelName); 
104   B03PhysicsList* physlist = new B03PhysicsLis << 118   //physlist->AddParallelWorldName(sparallelName);
105   // push parallel world to store in case of m << 119   physlist->AddBiasing(&pgs,parallelName);
106   physlist->AddParallelWorldName(parallelName) << 120   
107   // physlist->AddParallelWorldName(parallelNa << 
108   // physlist->AddParallelWorldName(sparallelN << 
109   // physlist->AddBiasing(&pgs,parallelName);  << 
110                                                << 
111   runManager->SetUserInitialization(physlist);    121   runManager->SetUserInitialization(physlist);
112                                                   122 
113   // Set user action classes through Worker In << 123  // Set user action classes through Worker Initialization
114   //                                           << 124  //
115   B03ActionInitialization* actions = new B03Ac    125   B03ActionInitialization* actions = new B03ActionInitialization;
116   runManager->SetUserInitialization(actions);     126   runManager->SetUserInitialization(actions);
117                                                   127 
118   //   runManager->SetUserAction(new B03Primar << 128 //   runManager->SetUserAction(new B03PrimaryGeneratorAction);
119   //   //  runManager->SetUserAction(new B03Pr << 129 //   //  runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
120   //   runManager->SetUserAction(new B03RunAct << 130 //   runManager->SetUserAction(new B03RunAction);
121                                                   131 
122   runManager->Initialize();                       132   runManager->Initialize();
123                                                   133 
124   G4VPhysicalVolume& aghostWorld = pdet->GetWo    134   G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
125   G4cout << " ghost world: " << pdet->GetName(    135   G4cout << " ghost world: " << pdet->GetName() << G4endl;
126                                                   136 
127   // create an importance                      << 137   // create an importance 
128   G4IStore* aIstore = G4IStore::GetInstance(pd << 138   G4IStore *aIstore = G4IStore::GetInstance(pdet->GetName());
129                                                   139 
130   // create a geometry cell for the world volu    140   // create a geometry cell for the world volume replpicanumber is 0!
131   G4GeometryCell gWorldVolumeCell(aghostWorld,    141   G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
132   // set world volume importance to 1             142   // set world volume importance to 1
133   aIstore->AddImportanceGeometryCell(1, gWorld    143   aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
134                                                   144 
135   // set importance values and create scorers  << 145   // set importance values and create scorers 
136   G4int cell(1);                                  146   G4int cell(1);
137   for (cell = 1; cell <= 18; cell++) {         << 147   for (cell=1; cell<=18; cell++) {
138     G4GeometryCell gCell = pdet->GetGeometryCe    148     G4GeometryCell gCell = pdet->GetGeometryCell(cell);
139     G4cout << " adding cell: " << cell << " re << 149     G4cout << " adding cell: " << cell 
                                                   >> 150            << " replica: " << gCell.GetReplicaNumber() 
140            << " name: " << gCell.GetPhysicalVo    151            << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
141     G4double imp = std::pow(2.0, cell - 1);    << 152     G4double imp = std::pow(2.0,cell-1);
142     // x    aIstore.AddImportanceGeometryCell( << 153     //x    aIstore.AddImportanceGeometryCell(imp, gCell);
143     aIstore->AddImportanceGeometryCell(imp, gC    154     aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
144   }                                               155   }
145                                                   156 
146   // creating the geometry cell and add both t    157   // creating the geometry cell and add both to the store
147   //  G4GeometryCell gCell = pdet->GetGeometry    158   //  G4GeometryCell gCell = pdet->GetGeometryCell(18);
148                                                   159 
149   // create importance geometry cell pair for     160   // create importance geometry cell pair for the "rest"cell
150   // with the same importance as the last conc << 161   // with the same importance as the last concrete cell 
151   G4GeometryCell gCell = pdet->GetGeometryCell    162   G4GeometryCell gCell = pdet->GetGeometryCell(19);
152   //  G4double imp = std::pow(2.0,18);         << 163   //  G4double imp = std::pow(2.0,18); 
153   G4double imp = std::pow(2.0, 17);            << 164   G4double imp = std::pow(2.0,17); 
154   aIstore->AddImportanceGeometryCell(imp, gCel    165   aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
155                                                << 166   
156   // temporary fix before runManager->BeamOn w << 167   //temporary fix before runManager->BeamOn works...
157   G4UImanager* UImanager = G4UImanager::GetUIp << 168   G4UImanager* UImanager = G4UImanager::GetUIpointer();  
158   G4String command1 = "/control/cout/setCoutFi    169   G4String command1 = "/control/cout/setCoutFile fileName";
159   UImanager->ApplyCommand(command1);              170   UImanager->ApplyCommand(command1);
160                                                   171 
161   G4String command2 = "/run/beamOn " + G4UIcom << 172   G4String command2 = "/run/beamOn " 
162   ;                                            << 173                     + G4UIcommand::ConvertToString(numberOfEvents);;
163   UImanager->ApplyCommand(command2);              174   UImanager->ApplyCommand(command2);
164                                                   175 
165   //  runManager->BeamOn(numberOfEvents);         176   //  runManager->BeamOn(numberOfEvents);
166                                                   177 
167   // pgs.ClearSampling();                         178   // pgs.ClearSampling();
168                                                   179 
169   delete runManager;                              180   delete runManager;
170                                                << 181  
171   return 0;                                       182   return 0;
172 }                                                 183 }
173                                                   184 
174 //....oooOO0OOooo........oooOO0OOooo........oo    185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175                                                   186