Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:43

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/B01/exampleB01.cc
0027 /// \brief Main program of the biasing/B01 example
0028 //
0029 //
0030 //
0031 //
0032 // --------------------------------------------------------------
0033 //      GEANT 4 - exampleB01
0034 //
0035 // --------------------------------------------------------------
0036 // Comments
0037 //
0038 // This example intends to show how to use importance sampling and scoring
0039 // in the mass (tracking) geometry.
0040 // A simple geometry consisting of a 180 cm high concrete cylinder
0041 // divided into 18 slabs of 10cm each is created.
0042 // Importance values are assigned to the 18 concrete slabs in the
0043 // detector construction class for simplicity.
0044 // Pairs of G4GeometryCell and importance values are stored in
0045 // the importance store.
0046 // Scoring is carried out by the multifunctional detector (MFD) and
0047 // sensitive detectors
0048 //
0049 // Alex Howard (alexander.howard@cern.ch):
0050 // 22/11/13: Migrated to the new MT compliant design which moves the
0051 //           biasing process to the physicslist constructor - here
0052 //           via the modular physicslists
0053 //
0054 
0055 // --------------------------------------------------------------
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 #include "G4GeometryManager.hh"
0059 #include "G4RunManagerFactory.hh"
0060 #include "G4Types.hh"
0061 #include "G4UImanager.hh"
0062 #include "G4VPhysicalVolume.hh"
0063 
0064 #include <iostream>
0065 #include <stdlib.h>
0066 
0067 // user classes
0068 #include "B01ActionInitialization.hh"
0069 #include "B01DetectorConstruction.hh"
0070 #include "FTFP_BERT.hh"
0071 
0072 #include "G4ImportanceBiasing.hh"
0073 #include "G4WeightWindowBiasing.hh"
0074 // #include "B01PrimaryGeneratorAction.hh"
0075 // #include "B01RunAction.hh"
0076 
0077 // Files specific for biasing and scoring
0078 #include "G4GeometrySampler.hh"
0079 #include "G4IStore.hh"
0080 #include "G4VWeightWindowStore.hh"
0081 #include "G4WeightWindowAlgorithm.hh"
0082 
0083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0084 
0085 int main(int argc, char** argv)
0086 {
0087   G4int mode = 0;
0088   if (argc > 1) mode = atoi(argv[1]);
0089 
0090   G4int numberOfEvents = 100;
0091   G4long myseed = 345354;
0092 
0093   auto* runManager = G4RunManagerFactory::CreateRunManager();
0094   runManager->SetNumberOfThreads(2);
0095 
0096   G4Random::setTheSeed(myseed);
0097 
0098   G4VWeightWindowAlgorithm* wwAlg = 0;  // pointer for WeightWindow (mode>0)
0099 
0100   // create the detector      ---------------------------
0101   B01DetectorConstruction* detector = new B01DetectorConstruction();
0102   runManager->SetUserInitialization(detector);
0103   G4GeometrySampler mgs(detector->GetWorldVolume(), "neutron");
0104 
0105   G4VModularPhysicsList* physicsList = new FTFP_BERT;
0106   if (mode == 0) {
0107     physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs));
0108   }
0109   else {
0110     wwAlg = new G4WeightWindowAlgorithm(1,  // upper limit factor
0111                                         1,  // survival factor
0112                                         100);  // max. number of splitting
0113 
0114     physicsList->RegisterPhysics(new G4WeightWindowBiasing(&mgs, wwAlg, onBoundary));
0115     // place of action
0116   }
0117   runManager->SetUserInitialization(physicsList);
0118 
0119   // Set user action classes through Worker Initialization
0120   //
0121   B01ActionInitialization* actions = new B01ActionInitialization;
0122   runManager->SetUserInitialization(actions);
0123 
0124   runManager->Initialize();
0125 
0126   if (mode == 0) {
0127     detector->CreateImportanceStore();
0128   }
0129   else {
0130     detector->CreateWeightWindowStore();
0131   }
0132 
0133   //  runManager->BeamOn(numberOfEvents);
0134 
0135   // temporary fix before runManager->BeamOn works...
0136   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0137   G4String command1 = "/control/cout/setCoutFile threadOut";
0138   UImanager->ApplyCommand(command1);
0139   G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents);
0140   ;
0141   UImanager->ApplyCommand(command2);
0142 
0143   // open geometry for clean biasing stores clean-up
0144   //
0145   G4GeometryManager::GetInstance()->OpenGeometry();
0146 
0147   if (wwAlg) {
0148     delete wwAlg;
0149   }
0150 
0151   // mgs.ClearSampling();
0152 
0153   delete runManager;
0154 
0155   return 0;
0156 }
0157 
0158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......