Geant4_10
G4ILawCommonTruncatedExp.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 //
27 #include "G4Track.hh"
28 
31 
32 //#include "G4Exception.hh"
33 
36  fExpInteractionLaw("expLawFor"+name)
37  //fIsSingular(false)
38 {}
39 
41 {}
42 
43 
45 {
46  return fExpInteractionLaw.ComputeEffectiveCrossSectionAt( distance ) * fOperation->GetTriggeredProcessXSfraction();
47 }
48 
50 {
51  G4double niProba = fExpInteractionLaw.ComputeNonInteractionProbabilityAt( distance );
52 
53  if ( niProba > 0.0 )
54  {
55  return std::exp( std::log(niProba) / fNumberOfSharing );
56  }
57  else
58  {
60  ed << " Negative probability for `" << GetName() << "' p = " << niProba << " distance = " << distance << " !!! " << G4endl;
61  G4Exception(" G4ILawCommonTruncatedExp::ComputeNonInteractionProbabilityAt(...)",
62  "BIAS.GEN.08",
64  ed);
65  return niProba;
66  }
67 }
68 
69 G4double G4ILawCommonTruncatedExp::SampleInteractionLength()
70 {
71  if ( fFirstSamplingCall ) fInteractionDistance = fExpInteractionLaw.SampleInteractionLength();
72  fFirstSamplingCall = false;
73  return DBL_MAX;
74 }
75 
76 G4double G4ILawCommonTruncatedExp::UpdateInteractionLengthForStep(G4double truePathLength)
77 {
78  if ( fFirstUpdateCall )
79  fInteractionDistance = fExpInteractionLaw.UpdateInteractionLengthForStep(truePathLength);
80  fFirstUpdateCall = false;
81  return DBL_MAX;
82 }
83 
85 {
86  fFirstSamplingCall = true;
87  fFirstUpdateCall = true;
88 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
const XML_Char * name
Definition: expat.h:151
G4ILawCommonTruncatedExp(G4String name="expSharedForceInteractionLaw")
virtual G4double SampleInteractionLength()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength)
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const