Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GB01BOptrMultiParticleChangeCrossSection.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 //
28 
30 #include "G4ParticleDefinition.hh"
31 #include "G4ParticleTable.hh"
32 
34  : G4VBiasingOperator("TestManyExponentialTransform")
35 {}
36 
38 {
39  const G4ParticleDefinition* particle =
41 
42  if ( particle == 0 )
43  {
45  ed << "Particle `" << particleName << "' not found !" << G4endl;
46  G4Exception("GB01BOptrMultiParticleChangeCrossSection::AddParticle(...)",
47  "exGB01.02",
49  ed);
50  return;
51  }
52 
54  fParticlesToBias.push_back( particle );
55  fBOptrForParticle[ particle ] = optr;
56 }
57 
59 GB01BOptrMultiParticleChangeCrossSection::
60 ProposeOccurenceBiasingOperation(const G4Track* track,
61  const G4BiasingProcessInterface* callingProcess)
62 {
63  // -- examples of limitations imposed to applied the biasing:
64  // -- limit application of biasing to primary particles only:
65  if ( track->GetParentID() != 0 ) return 0;
66  // -- limit to at most 5 biased interactions:
67  if ( fnInteractions > 4 ) return 0;
68  // -- and limit to a weight of at least 0.05:
69  if ( track->GetWeight() < 0.05 ) return 0;
70 
71  if ( fCurrentOperator ) return fCurrentOperator->
72  GetProposedOccurenceBiasingOperation(track, callingProcess);
73  else return 0;
74 }
75 
76 
78 {
79  // -- fetch the underneath biasing operator, if any, for the current particle type:
80  const G4ParticleDefinition* definition = track->GetParticleDefinition();
81  std::map < const G4ParticleDefinition*, GB01BOptrChangeCrossSection* > :: iterator
82  it = fBOptrForParticle.find( definition );
83  fCurrentOperator = 0;
84  if ( it != fBOptrForParticle.end() ) fCurrentOperator = (*it).second;
85 
86  // -- reset count for number of biased interactions:
87  fnInteractions = 0;
88 }
89 
90 void
91 GB01BOptrMultiParticleChangeCrossSection::
92 OperationApplied( const G4BiasingProcessInterface* callingProcess,
93  G4BiasingAppliedCase biasingCase,
94  G4VBiasingOperation* occurenceOperationApplied,
95  G4double weightForOccurenceInteraction,
96  G4VBiasingOperation* finalStateOperationApplied,
97  const G4VParticleChange* particleChangeProduced )
98 {
99  // -- count number of biased interactions:
100  fnInteractions++;
101 
102  // -- inform the underneath biasing operator that a biased interaction occured:
103  if ( fCurrentOperator ) fCurrentOperator->ReportOperationApplied( callingProcess,
104  biasingCase,
105  occurenceOperationApplied,
106  weightForOccurenceInteraction,
107  finalStateOperationApplied,
108  particleChangeProduced );
109 }
G4int GetParentID() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4VBiasingOperation * GetProposedOccurenceBiasingOperation(const G4Track *track, const G4BiasingProcessInterface *callingProcess)
G4BiasingAppliedCase
const G4ParticleDefinition * GetParticleDefinition() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ParticleTable * GetParticleTable()
G4double GetWeight() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void ReportOperationApplied(const G4BiasingProcessInterface *callingProcess, G4BiasingAppliedCase biasingCase, G4VBiasingOperation *operationApplied, const G4VParticleChange *particleChangeProduced)