Geant4  10.02.p01
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 
33 #include "G4SystemOfUnits.hh"
34 
36  : G4VBiasingOperator("TestManyExponentialTransform")
37 {}
38 
40 {
41  const G4ParticleDefinition* particle =
43 
44  if ( particle == 0 )
45  {
47  ed << "Particle `" << particleName << "' not found !" << G4endl;
48  G4Exception("GB01BOptrMultiParticleChangeCrossSection::AddParticle(...)",
49  "exGB01.02",
51  ed);
52  return;
53  }
54 
56  fParticlesToBias.push_back( particle );
57  fBOptrForParticle[ particle ] = optr;
58 }
59 
63  const G4BiasingProcessInterface* callingProcess)
64 {
65  // -- examples of limitations imposed to apply the biasing:
66  // -- limit application of biasing to primary particles only:
67  if ( track->GetParentID() != 0 ) return 0;
68  // -- limit to at most 5 biased interactions:
69  if ( fnInteractions > 4 ) return 0;
70  // -- and limit to a weight of at least 0.05:
71  if ( track->GetWeight() < 0.05 ) return 0;
72 
73  if ( fCurrentOperator ) return fCurrentOperator->
74  GetProposedOccurenceBiasingOperation(track, callingProcess);
75  else return 0;
76 }
77 
78 
80 {
81  // -- fetch the underneath biasing operator, if any, for the current particle type:
82  const G4ParticleDefinition* definition = track->GetParticleDefinition();
83  std::map < const G4ParticleDefinition*, GB01BOptrChangeCrossSection* > :: iterator
84  it = fBOptrForParticle.find( definition );
85  fCurrentOperator = 0;
86  if ( it != fBOptrForParticle.end() ) fCurrentOperator = (*it).second;
87 
88  // -- reset count for number of biased interactions:
89  fnInteractions = 0;
90 }
91 
92 void
95  G4BiasingAppliedCase biasingCase,
96  G4VBiasingOperation* occurenceOperationApplied,
97  G4double weightForOccurenceInteraction,
98  G4VBiasingOperation* finalStateOperationApplied,
99  const G4VParticleChange* particleChangeProduced )
100 {
101  // -- count number of biased interactions:
102  fnInteractions++;
103 
104  // -- inform the underneath biasing operator that a biased interaction occured:
106  biasingCase,
107  occurenceOperationApplied,
108  weightForOccurenceInteraction,
109  finalStateOperationApplied,
110  particleChangeProduced );
111 }
G4int GetParentID() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
virtual void OperationApplied(const G4BiasingProcessInterface *callingProcess, G4BiasingAppliedCase biasingCase, G4VBiasingOperation *occurenceOperationApplied, G4double weightForOccurenceInteraction, G4VBiasingOperation *finalStateOperationApplied, const G4VParticleChange *particleChangeProduced)
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
std::vector< const G4ParticleDefinition * > fParticlesToBias
double G4double
Definition: G4Types.hh:76
void ReportOperationApplied(const G4BiasingProcessInterface *callingProcess, G4BiasingAppliedCase biasingCase, G4VBiasingOperation *operationApplied, const G4VParticleChange *particleChangeProduced)
std::map< const G4ParticleDefinition *, GB01BOptrChangeCrossSection * > fBOptrForParticle
virtual G4VBiasingOperation * ProposeOccurenceBiasingOperation(const G4Track *track, const G4BiasingProcessInterface *callingProcess)