Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:28:42

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 exampleB02.cc
0027 /// \brief Main program of the biasing/B02 example
0028 
0029 // --------------------------------------------------------------
0030 //      GEANT 4 - exampleB02
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 //
0044 
0045 // --------------------------------------------------------------
0046 
0047 #include "G4GeometryManager.hh"
0048 #include "G4RunManagerFactory.hh"
0049 #include "G4Types.hh"
0050 #include "G4UImanager.hh"
0051 #include "G4VPhysicalVolume.hh"
0052 
0053 #include <iostream>
0054 #include <stdlib.h>
0055 
0056 // user classes
0057 #include "B02ActionInitialization.hh"
0058 #include "B02DetectorConstruction.hh"
0059 #include "B02ImportanceDetectorConstruction.hh"
0060 #include "FTFP_BERT.hh"
0061 
0062 #include "G4ImportanceBiasing.hh"
0063 #include "G4ParallelWorldPhysics.hh"
0064 // #include "B02PrimaryGeneratorAction.hh"
0065 // #include "B02RunAction.hh"
0066 
0067 // Files specific for biasing and scoring
0068 #include "G4GeometrySampler.hh"
0069 #include "G4IStore.hh"
0070 #include "G4VWeightWindowStore.hh"
0071 #include "G4WeightWindowAlgorithm.hh"
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 int main(int argc, char** argv)
0076 {
0077   G4int mode = 0;
0078   if (argc > 1) mode = atoi(argv[1]);
0079   if (mode != 0) {
0080     G4cout << " mode not used yet, refer to B01 to see WeightWindow technique " << mode << G4endl;
0081   }
0082 
0083   G4int numberOfEvents = 100;
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   B02DetectorConstruction* detector = new B02DetectorConstruction();
0093   runManager->SetUserInitialization(detector);
0094 
0095   G4String parallelName("ParallelBiasingWorld");
0096   B02ImportanceDetectorConstruction* pdet = new B02ImportanceDetectorConstruction(parallelName);
0097   detector->RegisterParallelWorld(pdet);
0098 
0099   G4GeometrySampler pgs(pdet->GetWorldVolume(), "neutron");
0100 
0101   pgs.SetParallel(true);
0102 
0103   G4VModularPhysicsList* physicsList = new FTFP_BERT;
0104   physicsList->RegisterPhysics(new G4ImportanceBiasing(&pgs, parallelName));
0105   physicsList->RegisterPhysics(new G4ParallelWorldPhysics(parallelName));
0106 
0107   runManager->SetUserInitialization(physicsList);
0108 
0109   // Set user action classes through Worker Initialization
0110   //
0111   B02ActionInitialization* actions = new B02ActionInitialization;
0112   runManager->SetUserInitialization(actions);
0113 
0114   runManager->Initialize();
0115 
0116   pdet->CreateImportanceStore();
0117 
0118   // temporary fix before runManager->BeamOn works...
0119   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0120   G4String command1 = "/control/cout/setCoutFile threadOut";
0121   UImanager->ApplyCommand(command1);
0122   G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents);
0123   UImanager->ApplyCommand(command2);
0124 
0125   // open geometry for clean biasing stores clean-up
0126   //
0127   G4GeometryManager::GetInstance()->OpenGeometry();
0128 
0129   // pgs.ClearSampling();
0130 
0131   delete runManager;
0132 
0133   return 0;
0134 }
0135 
0136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......