Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // 20140930 Change name from "const char*" to "const G4String"
42 
43 #include "G4CascadeColliderBase.hh"
44 #include "G4CascadeCheckBalance.hh"
45 #include "G4CascadeParameters.hh"
46 #include "G4CollisionOutput.hh"
47 #include "G4InteractionCase.hh"
49 #include "G4InuclNuclei.hh"
51 #include <vector>
52 
53 using namespace G4InuclSpecialFunctions;
54 
55 
56 // Constructor and destructor
57 
59  : G4VCascadeCollider(name, verbose), balance(0) {
61  balance = new G4CascadeCheckBalance(name);
62 }
63 
65  delete balance;
66 }
67 
70  if (balance) balance->setVerboseLevel(verbose);
71 }
72 
73 
74 // Both bullet and target must be hadrons or photons for this to work
75 
77  G4InuclParticle* target) const {
78  return (dynamic_cast<G4InuclElementaryParticle*>(bullet) &&
79  dynamic_cast<G4InuclElementaryParticle*>(target));
80 }
81 
82 
83 // Decide whether bullet-target interaction is candidate for cascade
84 
85 G4bool
88  G4double ekin) const {
89  if (verboseLevel) {
90  G4cout << " >>> " << theName << "::inelasticInteractionPossible" << G4endl;
91  }
92 
93  // If hadron-hadron collision, defer to ElementaryParticleCollider
94  if (useEPCollider(bullet, target)) return true;
95 
96  // See which one of the two (or both) is a nucleus, get properties
97  // FIXME: Should set a = baryon() for both, but that's not in base
98  G4InuclNuclei* nuclei_bullet = dynamic_cast<G4InuclNuclei*>(bullet);
99  G4double ab = nuclei_bullet ? nuclei_bullet->getA() : 1; // FIXME
100  G4double zb = nuclei_bullet ? nuclei_bullet->getZ() : bullet->getCharge();
101 
102  G4InuclNuclei* nuclei_target = dynamic_cast<G4InuclNuclei*>(target);
103  G4double at = nuclei_target ? nuclei_target->getA() : 1; // FIXME
104  G4double zt = nuclei_target ? nuclei_target->getZ() : target->getCharge();
105 
106  // VCOL (Coulomb barrier) used for testing if elastic collision necessary
107  const G4double coeff = 0.001 * 1.2;
108 
109  G4double VCOL = coeff * zt * zb / (G4cbrt(at) + G4cbrt(ab));
110 
111  G4bool possible = true; // Force inelastic; should be (ekin >= VCOL)
112 
113  if (verboseLevel > 3) {
114  G4cout << " VCOL: " << VCOL << " ekin: " << ekin << " inelastic possible: "
115  << possible << G4endl;
116  }
117 
118  return possible;
119 }
120 
121 
122 // Validate output for energy, momentum conservation, etc.
123 
126  G4CollisionOutput& output) {
127  if (!balance) return true; // Skip checks unless requested
128 
129  if (verboseLevel > 1)
130  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
131 
132  // Show final state particles
133  if (verboseLevel > 2) output.printCollisionOutput();
134 
136  balance->collide(bullet, target, output);
137  return balance->okay(); // Returns false if violations
138 }
139 
141  G4CollisionOutput& output) {
142  if (!balance) return true; // Skip checks unless requested
143 
144  if (verboseLevel > 1)
145  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
146 
148  balance->collide(fragment, output);
149  return balance->okay(); // Returns false if violations
150 }
151 
154  const std::vector<G4InuclElementaryParticle>& particles) {
155  if (!balance) return true; // Skip checks unless requested
156 
157  if (verboseLevel > 1)
158  G4cout << " >>> " << theName << "::validateOutput" << G4endl;
159 
161  balance->collide(bullet, target, particles);
162  return balance->okay(); // Returns false if violations
163 }
const XML_Char * name
Definition: expat.h:151
G4int getZ() const
const XML_Char * target
Definition: expat.h:268
virtual G4bool useEPCollider(G4InuclParticle *bullet, G4InuclParticle *target) const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4CascadeCheckBalance * balance
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)
G4CascadeColliderBase(const G4String &name, G4int verbose=0)
G4double getCharge() const
#define G4endl
Definition: G4ios.hh:61
virtual void setVerboseLevel(G4int verbose=0)
double G4double
Definition: G4Types.hh:76