ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleB01.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file exampleB01.cc
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 //
28 //
29 //
30 //
31 //
32 // --------------------------------------------------------------
33 // GEANT 4 - exampleB01
34 //
35 // --------------------------------------------------------------
36 // Comments
37 //
38 // This example intends to show how to use importance sampling and scoring
39 // in the mass (tracking) geometry.
40 // A simple geometry consisting of a 180 cm high concrete cylinder
41 // divided into 18 slabs of 10cm each is created.
42 // Importance values are assigned to the 18 concrete slabs in the
43 // detector construction class for simplicity.
44 // Pairs of G4GeometryCell and importance values are stored in
45 // the importance store.
46 // Scoring is carried out by the multifunctional detector (MFD) and
47 // sensitive detectors
48 //
49 // Alex Howard (alexander.howard@cern.ch):
50 // 22/11/13: Migrated to the new MT compliant design which moves the
51 // biasing process to the physicslist constructor - here
52 // via the modular physicslists
53 //
54 
55 // --------------------------------------------------------------
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
58 #include <iostream>
59 
60 #include <stdlib.h>
61 
62 #include "G4Types.hh"
63 
64 #ifdef G4MULTITHREADED
65 #include "G4MTRunManager.hh"
66 #else
67 #include "G4RunManager.hh"
68 #endif
69 
70 #include "G4VPhysicalVolume.hh"
71 #include "G4UImanager.hh"
72 #include "G4GeometryManager.hh"
73 
74 // user classes
76 #include "FTFP_BERT.hh"
77 #include "G4ImportanceBiasing.hh"
78 #include "G4WeightWindowBiasing.hh"
79 
81 // #include "B01PrimaryGeneratorAction.hh"
82 // #include "B01RunAction.hh"
83 
84 // Files specific for biasing and scoring
85 #include "G4GeometrySampler.hh"
86 #include "G4IStore.hh"
87 #include "G4VWeightWindowStore.hh"
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
92 int main(int argc, char **argv)
93 {
94  G4int mode = 0;
95  if (argc>1) mode = atoi(argv[1]);
96 
97  G4int numberOfEvents = 100;
98  G4long myseed = 345354;
99 
100 #ifdef G4MULTITHREADED
101  G4MTRunManager * runManager = new G4MTRunManager;
102  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
103  G4cout << " and using 2 of them! " << G4endl;
104  runManager->SetNumberOfThreads(2);
105  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
106 #else
107  G4RunManager * runManager = new G4RunManager;
108 #endif
109 
110  G4Random::setTheSeed(myseed);
111 
112  G4VWeightWindowAlgorithm *wwAlg = 0; // pointer for WeightWindow (mode>0)
113 
114  // create the detector ---------------------------
116  runManager->SetUserInitialization(detector);
117  G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
118 
119  G4VModularPhysicsList* physicsList = new FTFP_BERT;
120  if(mode == 0)
121  {
122  physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs));
123  }
124  else
125  {
126  wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor
127  1, // survival factor
128  100); // max. number of splitting
129 
130  physicsList->RegisterPhysics(new G4WeightWindowBiasing
131  (&mgs, wwAlg, onBoundary));
132  // place of action
133  }
134  runManager->SetUserInitialization(physicsList);
135 
136  // Set user action classes through Worker Initialization
137  //
139  runManager->SetUserInitialization(actions);
140 
141  runManager->Initialize();
142 
143  if (mode == 0)
144  {
145  detector->CreateImportanceStore();
146  }
147  else
148  {
149  detector->CreateWeightWindowStore();
150  }
151 
152  // runManager->BeamOn(numberOfEvents);
153 
154  //temporary fix before runManager->BeamOn works...
155  G4UImanager* UImanager = G4UImanager::GetUIpointer();
156  G4String command1 = "/control/cout/setCoutFile threadOut";
157  UImanager->ApplyCommand(command1);
158  G4String command2 = "/run/beamOn " +
159  G4UIcommand::ConvertToString(numberOfEvents);;
160  UImanager->ApplyCommand(command2);
161 
162  // open geometry for clean biasing stores clean-up
163  //
165 
166  if (wwAlg) {
167  delete wwAlg;
168  }
169 
170  // mgs.ClearSampling();
171 
172  delete runManager;
173 
174  return 0;
175 }
176 
177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......