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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 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 /// \file biasing/B03/exampleB03.cc
 27 /// \brief Main program of the biasing/B03 example
 28 //
 29 //
 30 //
 31 //
 32 // --------------------------------------------------------------
 33 //      GEANT 4 - exampleB03
 34 //
 35 // --------------------------------------------------------------
 36 // Comments
 37 //
 38 // This example intends to show how to use both importance sampling and a
 39 // customized scoring making use of the scoring framework
 40 // in a parallel geometry.
 41 //
 42 // A simple geometry consisting of a 180 cm high concrete cylinder
 43 // is constructed in the mass geometry.
 44 // A geometry is constructed in the parallel geometry
 45 // in order to assign importance values to slabs
 46 // of width 10cm and for scoring. The parallel world volume should
 47 // overlap the mass world volume and  the radii of the slabs is larger
 48 // than the radius of the concrete cylinder in the mass geometry.
 49 // Pairs of G4GeometryCell and importance values are stored in
 50 // the importance store.
 51 // The scoring uses the primitive scorers via the Multi Functional Detector
 52 //
 53 //
 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55 
 56 #include "B03ActionInitialization.hh"
 57 #include "B03DetectorConstruction.hh"
 58 #include "B03PhysicsList.hh"
 59 
 60 #include "G4RunManagerFactory.hh"
 61 #include "G4SystemOfUnits.hh"
 62 #include "G4Types.hh"
 63 #include "G4UImanager.hh"
 64 #include "G4VPhysicalVolume.hh"
 65 
 66 #include <iostream>
 67 // #include "B03PrimaryGeneratorAction.hh"
 68 // #include "B03RunAction.hh"
 69 
 70 // construction for the parallel geometry
 71 #include "B03ImportanceDetectorConstruction.hh"
 72 
 73 // Files specific for biasing and scoring
 74 // #include "G4Scorer.hh"
 75 // #include "G4GeometrySampler.hh"
 76 #include "G4IStore.hh"
 77 
 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 79 
 80 int main(int, char**)
 81 {
 82   G4int numberOfEvents = 100;
 83 
 84   G4long myseed = 345354;
 85 
 86   auto* runManager = G4RunManagerFactory::CreateRunManager();
 87   runManager->SetNumberOfThreads(2);
 88 
 89   G4Random::setTheSeed(myseed);
 90 
 91   // create the detector      ---------------------------
 92   B03DetectorConstruction* detector = new B03DetectorConstruction();
 93   runManager->SetUserInitialization(detector);
 94   //  ---------------------------------------------------
 95 
 96   // create a parallel detector
 97   G4String parallelName("ParallelBiasingWorld");
 98   B03ImportanceDetectorConstruction* pdet = new B03ImportanceDetectorConstruction(parallelName);
 99   detector->RegisterParallelWorld(pdet);
100 
101   // G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
102   // B03PhysicsList* physlist = new B03PhysicsList;
103   // name of first parallel world:
104   B03PhysicsList* physlist = new B03PhysicsList(parallelName);
105   // push parallel world to store in case of multiple worlds:
106   physlist->AddParallelWorldName(parallelName);
107   // physlist->AddParallelWorldName(parallelName);
108   // physlist->AddParallelWorldName(sparallelName);
109   // physlist->AddBiasing(&pgs,parallelName);
110 
111   runManager->SetUserInitialization(physlist);
112 
113   // Set user action classes through Worker Initialization
114   //
115   B03ActionInitialization* actions = new B03ActionInitialization;
116   runManager->SetUserInitialization(actions);
117 
118   //   runManager->SetUserAction(new B03PrimaryGeneratorAction);
119   //   //  runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
120   //   runManager->SetUserAction(new B03RunAction);
121 
122   runManager->Initialize();
123 
124   G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
125   G4cout << " ghost world: " << pdet->GetName() << G4endl;
126 
127   // create an importance
128   G4IStore* aIstore = G4IStore::GetInstance(pdet->GetName());
129 
130   // create a geometry cell for the world volume replpicanumber is 0!
131   G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
132   // set world volume importance to 1
133   aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
134 
135   // set importance values and create scorers
136   G4int cell(1);
137   for (cell = 1; cell <= 18; cell++) {
138     G4GeometryCell gCell = pdet->GetGeometryCell(cell);
139     G4cout << " adding cell: " << cell << " replica: " << gCell.GetReplicaNumber()
140            << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
141     G4double imp = std::pow(2.0, cell - 1);
142     // x    aIstore.AddImportanceGeometryCell(imp, gCell);
143     aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
144   }
145 
146   // creating the geometry cell and add both to the store
147   //  G4GeometryCell gCell = pdet->GetGeometryCell(18);
148 
149   // create importance geometry cell pair for the "rest"cell
150   // with the same importance as the last concrete cell
151   G4GeometryCell gCell = pdet->GetGeometryCell(19);
152   //  G4double imp = std::pow(2.0,18);
153   G4double imp = std::pow(2.0, 17);
154   aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
155 
156   // temporary fix before runManager->BeamOn works...
157   G4UImanager* UImanager = G4UImanager::GetUIpointer();
158   G4String command1 = "/control/cout/setCoutFile fileName";
159   UImanager->ApplyCommand(command1);
160 
161   G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents);
162   ;
163   UImanager->ApplyCommand(command2);
164 
165   //  runManager->BeamOn(numberOfEvents);
166 
167   // pgs.ClearSampling();
168 
169   delete runManager;
170 
171   return 0;
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175