Geant4  10.00.p03
G4CascadeColliderBase.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: G4CascadeColliderBase.cc 71942 2013-06-28 19:08:11Z mkelsey $
27 //
28 // 20100714 M. Kelsey -- Move functionality from G4VCascadeCollider, and
29 // provide conservation-checking here, with wrapper function
30 // and control flag.
31 // 20100721 M. Kelsey -- Use G4CASCADE_CHECK_ECONS to set default control
32 // flag for validations.
33 // 20100923 M. Kelsey -- Migrate to integer A and Z
34 // 20100925 M. Kelsey -- Add explosion() interfaces for G4Fragment and for
35 // (A,Z,E). Move implementation to latter. Add Z==0 condition.
36 // 20110225 M. Kelsey -- Add setVerboseLevel(), calls through to members
37 // 20130621 Move doConservationChecks to G4CascadeParameters, check there
38 // before instantiating CheckBalance; change explosion() to
39 // use reference, add validateOutput() w/G4Fragment
40 // 20130622 Move fragment-handling functions to G4CascadeDeexciteBase
41 
42 #include "G4CascadeColliderBase.hh"
43 #include "G4CascadeCheckBalance.hh"
44 #include "G4CascadeParameters.hh"
45 #include "G4CollisionOutput.hh"
46 #include "G4InteractionCase.hh"
48 #include "G4InuclNuclei.hh"
50 #include <vector>
51 
52 using namespace G4InuclSpecialFunctions;
53 
54 
55 // Constructor and destructor
56 
58  : G4VCascadeCollider(name, verbose), balance(0) {
60  balance = new G4CascadeCheckBalance(name);
61 }
62 
64  delete balance;
65 }
66 
69  if (balance) balance->setVerboseLevel(verbose);
70 }
71 
72 
73 // Both bullet and target must be hadrons or photons for this to work
74 
76  G4InuclParticle* target) const {
77  return (dynamic_cast<G4InuclElementaryParticle*>(bullet) &&
78  dynamic_cast<G4InuclElementaryParticle*>(target));
79 }
80 
81 
82 // Decide whether bullet-target interaction is candidate for cascade
83 
84 G4bool
86  G4InuclParticle* target,
87  G4double ekin) const {
88  if (verboseLevel) {
89  G4cout << " >>> " << theName << "::inelasticInteractionPossible" << G4endl;
90  }
91 
92  // If hadron-hadron collision, defer to ElementaryParticleCollider
93  if (useEPCollider(bullet, target)) return true;
94 
95  // See which one of the two (or both) is a nucleus, get properties
96  // FIXME: Should set a = baryon() for both, but that's not in base
97  G4InuclNuclei* nuclei_bullet = dynamic_cast<G4InuclNuclei*>(bullet);
98  G4double ab = nuclei_bullet ? nuclei_bullet->getA() : 1; // FIXME
99  G4double zb = nuclei_bullet ? nuclei_bullet->getZ() : bullet->getCharge();
100 
101  G4InuclNuclei* nuclei_target = dynamic_cast<G4InuclNuclei*>(target);
102  G4double at = nuclei_target ? nuclei_target->getA() : 1; // FIXME
103  G4double zt = nuclei_target ? nuclei_target->getZ() : target->getCharge();
104 
105  // VCOL (Coulomb barrier) used for testing if elastic collision necessary
106  const G4double coeff = 0.001 * 1.2;
107 
108  G4double VCOL = coeff * zt * zb / (G4cbrt(at) + G4cbrt(ab));
109 
110  G4bool possible = true; // Force inelastic; should be (ekin >= VCOL)
111 
112  if (verboseLevel > 3) {
113  G4cout << " VCOL: " << VCOL << " ekin: " << ekin << " inelastic possible: "
114  << possible << G4endl;
115  }
116 
117  return possible;
118 }
119 
120 
121 // Validate output for energy, momentum conservation, etc.
122 
124  G4InuclParticle* target,
125  G4CollisionOutput& output) {
126  if (!balance) return true; // Skip checks unless requested
127 
128  if (verboseLevel > 1)
129  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
130 
131  // Show final state particles
132  if (verboseLevel > 2) output.printCollisionOutput();
133 
135  balance->collide(bullet, target, output);
136  return balance->okay(); // Returns false if violations
137 }
138 
140  G4CollisionOutput& output) {
141  if (!balance) return true; // Skip checks unless requested
142 
143  if (verboseLevel > 1)
144  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
145 
147  balance->collide(fragment, output);
148  return balance->okay(); // Returns false if violations
149 }
150 
152  G4InuclParticle* target,
153  const std::vector<G4InuclElementaryParticle>& particles) {
154  if (!balance) return true; // Skip checks unless requested
155 
156  if (verboseLevel > 1)
157  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
158 
160  balance->collide(bullet, target, particles);
161  return balance->okay(); // Returns false if violations
162 }
G4int getZ() const
virtual G4bool useEPCollider(G4InuclParticle *bullet, G4InuclParticle *target) const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4CascadeCheckBalance * balance
G4String name
Definition: TRTMaterials.hh:40
void printCollisionOutput(std::ostream &os=G4cout) const
virtual G4bool inelasticInteractionPossible(G4InuclParticle *bullet, G4InuclParticle *target, G4double ekin) const
static G4bool checkConservation()
int G4int
Definition: G4Types.hh:78
virtual void setVerboseLevel(G4int verbose=0)
G4GLOB_DLL std::ostream G4cout
G4int getA() const
bool G4bool
Definition: G4Types.hh:79
static const G4double ab
virtual G4bool validateOutput(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4double getCharge() const
#define G4endl
Definition: G4ios.hh:61
virtual void setVerboseLevel(G4int verbose=0)
double G4double
Definition: G4Types.hh:76
G4CascadeColliderBase(const char *name, G4int verbose=0)