Geant4_10
G4GenericBiasingPhysics.cc
Go to the documentation of this file.
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 // $Id$
27 //
28 //---------------------------------------------------------------------------
29 //
30 // ClassName: G4GenericBiasingPhysics
31 //
32 // Author: M. Verderi (Sept.10.2013)
33 //
34 // Modified:
35 //
36 //----------------------------------------------------------------------------
37 //
38 //
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43 
44 #include "G4ParticleDefinition.hh"
45 #include "G4ProcessManager.hh"
46 
47 #include "G4BiasingHelper.hh"
48 
49 // factory
51 //
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57  : G4VPhysicsConstructor(name)
58 {;}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {;}
64 
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 {
70  fBiasedParticles.push_back(particleName);
71  std::vector< G4String > dummy;
72  fBiasedProcesses.push_back(dummy);
73  fBiasAllProcesses.push_back(true);
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
78 void G4GenericBiasingPhysics::PhysicsBias(const G4String& particleName, const std::vector< G4String >& processNames)
79 {
80  fBiasedParticles.push_back(particleName);
81  fBiasedProcesses.push_back(processNames);
82  fBiasAllProcesses.push_back(false);
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  fNonPhysBiasedParticles.push_back(particleName);
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
94 void G4GenericBiasingPhysics::Bias(const G4String& particleName)
95 {
96  PhysicsBias(particleName);
97  NonPhysicsBias(particleName);
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
102 void G4GenericBiasingPhysics::Bias(const G4String& particleName, const std::vector< G4String >& processNames)
103 {
104  PhysicsBias(particleName, processNames);
105  NonPhysicsBias(particleName);
106 }
107 
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
112 {;}
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118  aParticleIterator->reset();
119 
120  while( (*aParticleIterator)() )
121  {
122  G4ParticleDefinition* particle = aParticleIterator->value();
123  G4String particleName = particle->GetParticleName();
124 
125  // -- include non physics process interface for biasing:
126  if ( std::find(fNonPhysBiasedParticles.begin(),
127  fNonPhysBiasedParticles.end(),
128  particleName ) != fNonPhysBiasedParticles.end() )
129  {
130  G4ProcessManager* pmanager = particle->GetProcessManager();
132  }
133 
134 
135  if ( std::find(fBiasedParticles.begin(),
136  fBiasedParticles.end(),
137  particleName ) == fBiasedParticles.end() ) continue;
138 
139  G4ProcessManager* pmanager = particle->GetProcessManager();
140  G4ProcessVector* vprocess = pmanager->GetProcessList();
141 
142  G4bool restartLoop(true);
143  while ( restartLoop )
144  {
145  for (G4int ip = 0 ; ip < vprocess->size() ; ip++)
146  {
147  G4VProcess* process = (*vprocess)[ip];
148  G4bool activ = G4BiasingHelper::ActivatePhysicsBiasing(pmanager, process->GetProcessName());
149  restartLoop = activ;
150  if ( restartLoop ) break;
151  }
152  }
153 
154  }
155 }
156 
void PhysicsBias(const G4String &particleName)
const XML_Char * name
Definition: expat.h:151
static void ActivateNonPhysicsBiasing(G4ProcessManager *pmanager, G4String nonPhysicsProcessName="")
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4GenericBiasingPhysics(const G4String &name="BiasingP")
bool G4bool
Definition: G4Types.hh:79
#define aParticleIterator
static G4bool ActivatePhysicsBiasing(G4ProcessManager *pmanager, G4String physicsProcessToBias, G4String wrappedName="")
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4int size() const
void NonPhysicsBias(const G4String &particleName)
G4ProcessVector * GetProcessList() const
#define G4_DECLARE_PHYSCONSTR_FACTORY(physics_constructor)
void Bias(const G4String &particleName)