Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 08:29:27

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 exampleB03.cc
0027 /// \brief Main program of the biasing/B03 example
0028 
0029 // --------------------------------------------------------------
0030 //      GEANT 4 - exampleB03
0031 //
0032 // --------------------------------------------------------------
0033 // Comments
0034 //
0035 // This example intends to show how to use both importance sampling and a
0036 // customized scoring making use of the scoring framework
0037 // in a parallel geometry.
0038 //
0039 // A simple geometry consisting of a 180 cm high concrete cylinder
0040 // is constructed in the mass geometry.
0041 // A geometry is constructed in the parallel geometry
0042 // in order to assign importance values to slabs
0043 // of width 10cm and for scoring. The parallel world volume should
0044 // overlap the mass world volume and  the radii of the slabs is larger
0045 // than the radius of the concrete cylinder in the mass geometry.
0046 // Pairs of G4GeometryCell and importance values are stored in
0047 // the importance store.
0048 // The scoring uses the primitive scorers via the Multi Functional Detector
0049 //
0050 //
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 #include "B03ActionInitialization.hh"
0054 #include "B03DetectorConstruction.hh"
0055 #include "B03PhysicsList.hh"
0056 
0057 #include "G4RunManagerFactory.hh"
0058 #include "G4SystemOfUnits.hh"
0059 #include "G4Types.hh"
0060 #include "G4UImanager.hh"
0061 #include "G4VPhysicalVolume.hh"
0062 
0063 #include <iostream>
0064 // #include "B03PrimaryGeneratorAction.hh"
0065 // #include "B03RunAction.hh"
0066 
0067 // construction for the parallel geometry
0068 #include "B03ImportanceDetectorConstruction.hh"
0069 
0070 // Files specific for biasing and scoring
0071 // #include "G4Scorer.hh"
0072 // #include "G4GeometrySampler.hh"
0073 #include "G4IStore.hh"
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 int main(int, char**)
0078 {
0079   G4int numberOfEvents = 100;
0080 
0081   G4long myseed = 345354;
0082 
0083   auto* runManager = G4RunManagerFactory::CreateRunManager();
0084   runManager->SetNumberOfThreads(2);
0085 
0086   G4Random::setTheSeed(myseed);
0087 
0088   // create the detector      ---------------------------
0089   B03DetectorConstruction* detector = new B03DetectorConstruction();
0090   runManager->SetUserInitialization(detector);
0091   //  ---------------------------------------------------
0092 
0093   // create a parallel detector
0094   G4String parallelName("ParallelBiasingWorld");
0095   B03ImportanceDetectorConstruction* pdet = new B03ImportanceDetectorConstruction(parallelName);
0096   detector->RegisterParallelWorld(pdet);
0097 
0098   // G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
0099   // B03PhysicsList* physlist = new B03PhysicsList;
0100   // name of first parallel world:
0101   B03PhysicsList* physlist = new B03PhysicsList(parallelName);
0102   // push parallel world to store in case of multiple worlds:
0103   physlist->AddParallelWorldName(parallelName);
0104   // physlist->AddParallelWorldName(parallelName);
0105   // physlist->AddParallelWorldName(sparallelName);
0106   // physlist->AddBiasing(&pgs,parallelName);
0107 
0108   runManager->SetUserInitialization(physlist);
0109 
0110   // Set user action classes through Worker Initialization
0111   //
0112   B03ActionInitialization* actions = new B03ActionInitialization;
0113   runManager->SetUserInitialization(actions);
0114 
0115   //   runManager->SetUserAction(new B03PrimaryGeneratorAction);
0116   //   //  runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
0117   //   runManager->SetUserAction(new B03RunAction);
0118 
0119   runManager->Initialize();
0120 
0121   G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
0122   G4cout << " ghost world: " << pdet->GetName() << G4endl;
0123 
0124   // create an importance
0125   G4IStore* aIstore = G4IStore::GetInstance(pdet->GetName());
0126 
0127   // create a geometry cell for the world volume replpicanumber is 0!
0128   G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
0129   // set world volume importance to 1
0130   aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
0131 
0132   // set importance values and create scorers
0133   G4int cell(1);
0134   for (cell = 1; cell <= 18; cell++) {
0135     G4GeometryCell gCell = pdet->GetGeometryCell(cell);
0136     G4cout << " adding cell: " << cell << " replica: " << gCell.GetReplicaNumber()
0137            << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
0138     G4double imp = std::pow(2.0, cell - 1);
0139     // x    aIstore.AddImportanceGeometryCell(imp, gCell);
0140     aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
0141   }
0142 
0143   // creating the geometry cell and add both to the store
0144   //  G4GeometryCell gCell = pdet->GetGeometryCell(18);
0145 
0146   // create importance geometry cell pair for the "rest"cell
0147   // with the same importance as the last concrete cell
0148   G4GeometryCell gCell = pdet->GetGeometryCell(19);
0149   //  G4double imp = std::pow(2.0,18);
0150   G4double imp = std::pow(2.0, 17);
0151   aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
0152 
0153   // temporary fix before runManager->BeamOn works...
0154   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0155   G4String command1 = "/control/cout/setCoutFile fileName";
0156   UImanager->ApplyCommand(command1);
0157 
0158   G4String command2 = "/run/beamOn " + G4UIcommand::ConvertToString(numberOfEvents);
0159   ;
0160   UImanager->ApplyCommand(command2);
0161 
0162   //  runManager->BeamOn(numberOfEvents);
0163 
0164   // pgs.ClearSampling();
0165 
0166   delete runManager;
0167 
0168   return 0;
0169 }
0170 
0171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......