149 maximumTries(20), numberOfTries(0),
158 balance->
setLimits(5*perCent, 10*MeV/GeV);
169 delete collider; collider=0;
170 delete ltcollider; ltcollider = 0;
171 delete balance; balance=0;
172 delete output; output=0;
177 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
178 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
179 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
180 <<
"Final state hadrons are produced by a classical cascade\n"
181 <<
"consisting of individual hadron-nucleon scatterings which use\n"
182 <<
"free-space partial cross sections, corrected for various\n"
183 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
184 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
185 <<
"travel in straight lines until they are reflected from or\n"
186 <<
"transmitted through shell boundaries.\n";
206 if (!ch || !
pn || !
nn || !
pp)
return;
254 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
257 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
262#ifdef G4CASCADE_DEBUG_INTERFACE
263 static G4int counter(0);
265 G4cerr <<
"Reaction number "<< counter <<
" "
270 if (!randomFile.empty()) {
272 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
299 ltcollider->
collide(bullet, target, *output);
320 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
323 collider->
collide(bullet, target, *output);
324 balance->
collide(bullet, target, *output);
331 if (numberOfTries >= maximumTries) {
333 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
338 if (!balance->
okay()) {
345 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
376#ifdef G4CASCADE_DEBUG_INTERFACE
380 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
381 for (
size_t i=0; i<theSecondaries->size(); i++) {
390 if (!randomFile.empty()) {
392 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
414 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
417 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
418 balance->
collide(bullet, target, *output);
425 if (numberOfTries >= maximumTries && !balance->
okay()) {
431 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
450 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
466 G4int bulletType = 0;
467 G4int bulletA = 0, bulletZ = 0;
476 if (0 == bulletType && 0 == bulletA*bulletZ) {
479 <<
" not usable as bullet." <<
G4endl;
497 projectileMomentum.
e());
500 hadronBullet.
fill(momentumBullet, bulletType);
501 bullet = &hadronBullet;
503 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
504 bullet = &nucleusBullet;
525 nucleusTarget.
fill(
A, Z);
526 target = &nucleusTarget;
529 target = &hadronTarget;
545 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
546 << outgoingType <<
G4endl;
581 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
590 if (!particles.empty()) {
592 for (; ipart != particles.end(); ipart++) {
598 if (!outgoingNuclei.empty()) {
600 for (; ifrag != outgoingNuclei.end(); ifrag++) {
608 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
619 if (!particles.empty()) {
621 for (; ipart != particles.end(); ipart++) {
625 propResult->push_back(rp);
631 if (!fragments.empty()) {
633 for (; ifrag != fragments.end(); ifrag++) {
637 propResult->push_back(rp);
649 balance->
collide(bullet, target, *output);
653 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
658 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
662 if (std::abs(balance->
deltaKE()) > 0.01 ) {
663 G4cerr <<
"Kinetic energy conservation violated by "
670 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
671 <<
"\nTotal energy conservation at level "
674 if (balance->
deltaKE() > 5.0e-5 ) {
675 G4cerr <<
"FATAL ERROR: kinetic energy created "
687 const G4double coulumbBarrier = 8.7 * MeV/GeV;
689 const std::vector<G4InuclElementaryParticle>& p =
693 if (ipart->type() ==
proton) {
694 violated |= (ipart->getKineticEnergy() < coulumbBarrier);
704 const std::vector<G4InuclElementaryParticle>& out =
707#ifdef G4CASCADE_DEBUG_INTERFACE
709 G4cout <<
" retryInelasticProton: number of Tries "
710 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
711 <<
"\n retryInelasticProton: AND collision type ";
714 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
715 <<
"\n retryInelasticProton: AND Leading particles bullet "
716 << (out.size() >= 2 &&
719 ?
"YES (t)" :
"NO (f)")
724 return ( (numberOfTries < maximumTries) &&
743#ifdef G4CASCADE_DEBUG_INTERFACE
745 G4cout <<
" retryInelasticNucleus: numberOfTries "
746 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
747 <<
"\n retryInelasticNucleus: AND outputParticles "
748 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
749#ifdef G4CASCADE_COULOMB_DEV
750 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
752 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
753 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
755 <<
"\n retryInelasticNucleus: AND collision type "
756 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
757 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
758 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
760 <<
"\n retryInelasticNucleus: OR conservation "
761 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
765 return ( (numberOfTries < maximumTries) &&
767#ifdef G4CASCADE_COULOMB_DEV
770 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
773#ifndef G4CASCADE_SKIP_ECONS
774 || (!balance->
okay())
787 std::ostream& errInfo =
G4cerr;
789 errInfo <<
" >>> G4CascadeInterface has non-conserving"
790 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
792 G4String throwMsg =
"G4CascadeInterface - ";
794 throwMsg +=
"Energy";
795 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
800 throwMsg +=
"Momentum";
801 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
806 throwMsg +=
"Baryon number";
807 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
811 throwMsg +=
"Charge";
812 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
816 errInfo <<
" Final event output, for debugging:\n"
817 <<
" Bullet: \n" << *bullet <<
G4endl
818 <<
" Target: \n" << *target <<
G4endl;
821 throwMsg +=
" non-conservation. More info in output.";
std::vector< G4InuclElementaryParticle >::iterator particleIterator
std::vector< G4InuclElementaryParticle >::const_iterator particleIterator
std::vector< G4InuclNuclei >::const_iterator nucleiIterator
double A(double temperature)
std::vector< G4ReactionProduct * > G4ReactionProductVector
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static void saveEngineStatus(const char filename[]="Config.conf")
static const G4CascadeChannel * GetTable(G4int initialState)
void setLimits(G4double relative, G4double absolute)
G4bool baryonOkay() const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4bool momentumOkay() const
G4double relativeP() const
G4bool chargeOkay() const
G4double relativeE() const
G4bool energyOkay() const
virtual void ModelDescription(std::ostream &outFile) const
G4bool coulombBarrierViolation() const
void usePreCompoundDeexcitation()
G4bool retryInelasticNucleus() const
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
G4bool IsApplicable(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
G4HadFinalState * NoInteraction(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
G4bool createBullet(const G4HadProjectile &aTrack)
G4bool createTarget(G4Nucleus &theNucleus)
G4ReactionProductVector * copyOutputToReactionProducts()
virtual void DumpConfiguration(std::ostream &outFile) const
void copyOutputToHadronicResult()
void SetVerboseLevel(G4int verbose)
void throwNonConservationFailure()
G4ReactionProductVector * Propagate(G4KineticTrackVector *theSecondaries, G4V3DNucleus *theNucleus)
virtual ~G4CascadeInterface()
G4bool retryInelasticProton() const
G4DynamicParticle * makeDynamicParticle(const G4InuclElementaryParticle &iep) const
G4CascadeInterface(const G4String &name="BertiniCascade")
void useCascadeDeexcitation()
static void DumpConfiguration(std::ostream &os)
static G4bool usePreCompound()
G4int numberOfOutgoingParticles() const
const std::vector< G4InuclNuclei > & getOutgoingNuclei() const
void printCollisionOutput(std::ostream &os=G4cout) const
const std::vector< G4InuclElementaryParticle > & getOutgoingParticles() const
void setVerboseLevel(G4int verbose)
G4int numberOfOutgoingNuclei() const
static G4Dineutron * Definition()
static G4Diproton * Definition()
void SetStatusChange(G4HadFinalStateStatus aS)
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
void SetEnergyChange(G4double anEnergy)
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4HadFinalState theParticleChange
void SetVerboseLevel(G4int value)
void SetEnergyMomentumCheckLevels(G4double relativeLevel, G4double absoluteLevel)
void useCascadeDeexcitation()
void usePreCompoundDeexcitation()
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &globalOutput)
void rescatter(G4InuclParticle *bullet, G4KineticTrackVector *theSecondaries, G4V3DNucleus *theNucleus, G4CollisionOutput &globalOutput)
void setVerboseLevel(G4int verbose=0)
G4bool quasi_deutron() const
void fill(G4int ityp, Model model=DefaultModel)
void fill(G4int a, G4int z, G4double exc=0., Model model=DefaultModel)
const G4ParticleDefinition * getDefinition() const
G4double getKineticEnergy() const
G4LorentzVector getMomentum() const
G4double getEnergy() const
const G4DynamicParticle & getDynamicParticle() const
static G4KaonZeroLong * Definition()
static G4KaonZeroShort * Definition()
G4double GetFormationTime() const
const G4ThreeVector & GetPosition() const
const G4ParticleDefinition * GetDefinition() const
const G4LorentzVector & Get4Momentum() const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &globalOutput)
G4int GetAtomicNumber() const
G4int GetAtomicMass() const
const G4String & GetParticleName() const
static G4UnboundPN * Definition()
virtual G4int GetCharge()=0
virtual G4int GetMassNumber()=0
virtual void setVerboseLevel(G4int verbose=0)
const G4HadProjectile * GetPrimaryProjectile() const
const char * name(G4int ptype)