132 using namespace G4InuclParticleNames;
144 const G4int G4CascadeInterface::maximumTries = 20;
163 delete collider; collider=0;
164 delete balance; balance=0;
165 delete output; output=0;
170 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
171 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
172 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
173 <<
"Final state hadrons are produced by a classical cascade\n"
174 <<
"consisting of individual hadron-nucleon scatterings which use\n"
175 <<
"free-space partial cross sections, corrected for various\n"
176 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
177 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
178 <<
"travel in straight lines until they are reflected from or\n"
179 <<
"transmitted through shell boundaries.\n";
199 if (!ch || !pn || !nn || !pp)
return;
247 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
250 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
255 #ifdef G4CASCADE_DEBUG_INTERFACE
256 static G4int counter(0);
258 G4cerr <<
"Reaction number "<< counter <<
" "
263 if (!randomFile.empty()) {
265 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
295 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
305 if (numberOfTries >= maximumTries) {
307 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
312 if (!balance->
okay()) {
319 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
351 #ifdef G4CASCADE_DEBUG_INTERFACE
355 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
356 for (
size_t i=0; i<theSecondaries->size(); i++) {
365 if (!randomFile.empty()) {
367 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
389 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
392 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
400 if (numberOfTries >= maximumTries && !balance->
okay()) {
406 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
425 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
441 G4int bulletType = 0;
442 G4int bulletA = 0, bulletZ = 0;
451 if (0 == bulletType && 0 == bulletA*bulletZ) {
454 <<
" not usable as bullet." <<
G4endl;
465 bulletInLabFrame.
rotateZ(-projectileMomentum.
phi());
467 bulletInLabFrame.
invert();
470 projectileMomentum.
e());
473 hadronBullet.
fill(momentumBullet, bulletType);
474 bullet = &hadronBullet;
476 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
477 bullet = &nucleusBullet;
498 nucleusTarget.
fill(A, Z);
518 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
519 << outgoingType <<
G4endl;
554 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
563 if (!particles.empty()) {
565 for (; ipart != particles.end(); ipart++) {
571 if (!outgoingNuclei.empty()) {
573 for (; ifrag != outgoingNuclei.end(); ifrag++) {
581 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
592 if (!particles.empty()) {
594 for (; ipart != particles.end(); ipart++) {
598 propResult->push_back(rp);
604 if (!fragments.empty()) {
606 for (; ifrag != fragments.end(); ifrag++) {
610 propResult->push_back(rp);
626 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
631 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
635 if (std::abs(balance->
deltaKE()) > 0.01 ) {
636 G4cerr <<
"Kinetic energy conservation violated by "
643 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
644 <<
"\nTotal energy conservation at level "
647 if (balance->
deltaKE() > 5.0e-5 ) {
648 G4cerr <<
"FATAL ERROR: kinetic energy created "
662 const std::vector<G4InuclElementaryParticle>&
p =
667 violated |= (
ipart->getKineticEnergy() < coulumbBarrier);
677 const std::vector<G4InuclElementaryParticle>& out =
680 #ifdef G4CASCADE_DEBUG_INTERFACE
682 G4cout <<
" retryInelasticProton: number of Tries "
683 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
684 <<
"\n retryInelasticProton: AND collision type ";
687 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
688 <<
"\n retryInelasticProton: AND Leading particles bullet "
689 << (out.size() >= 2 &&
692 ?
"YES (t)" :
"NO (f)")
697 return ( (numberOfTries < maximumTries) &&
716 #ifdef G4CASCADE_DEBUG_INTERFACE
718 G4cout <<
" retryInelasticNucleus: numberOfTries "
719 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
720 <<
"\n retryInelasticNucleus: AND outputParticles "
721 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
722 #ifdef G4CASCADE_COULOMB_DEV
723 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
725 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
726 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
728 <<
"\n retryInelasticNucleus: AND collsion type "
729 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
730 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
731 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
733 <<
"\n retryInelasticNucleus: OR conservation "
734 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
738 return ( ((numberOfTries < maximumTries) &&
740 #ifdef G4CASCADE_COULOMB_DEV
743 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
746 #ifndef G4CASCADE_SKIP_ECONS
747 || (!balance->
okay())
759 std::ostream& errInfo =
G4cerr;
761 errInfo <<
" >>> G4CascadeInterface has non-conserving"
762 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
764 G4String throwMsg =
"G4CascadeInterface - ";
766 throwMsg +=
"Energy";
767 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
772 throwMsg +=
"Momentum";
773 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
778 throwMsg +=
"Baryon number";
779 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
783 throwMsg +=
"Charge";
784 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
788 errInfo <<
" Final event output, for debugging:\n"
789 <<
" Bullet: \n" << *bullet << G4endl
793 throwMsg +=
" non-conservation. More info in output.";
void useCascadeDeexcitation()
void fill(G4int a, G4int z, G4double exc=0., Model model=DefaultModel)
G4bool retryInelasticNucleus() const
void rescatter(G4InuclParticle *bullet, G4KineticTrackVector *theSecondaries, G4V3DNucleus *theNucleus, G4CollisionOutput &globalOutput)
void setVerboseLevel(G4int verbose)
G4CascadeInterface(const G4String &name="BertiniCascade")
static const G4CascadeChannel * GetTable(G4int initialState)
G4bool coulombBarrierViolation() const
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
virtual G4int GetCharge()=0
const G4DynamicParticle & getDynamicParticle() const
G4LorentzVector getMomentum() const
const G4HadProjectile * GetPrimaryProjectile() const
const G4ThreeVector & GetPosition() const
G4bool baryonOkay() const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
void printCollisionOutput(std::ostream &os=G4cout) const
virtual G4int GetMassNumber()=0
G4double getEnergy() const
void setLimits(G4double relative, G4double absolute)
static G4Diproton * Definition()
const G4String & GetParticleName() const
HepLorentzRotation & rotateY(double delta)
virtual void setVerboseLevel(G4int verbose=0)
G4int GetAtomicNumber() const
G4double getKineticEnergy() const
void SetStatusChange(G4HadFinalStateStatus aS)
std::vector< G4ReactionProduct * > G4ReactionProductVector
static const G4String & randomFile()
void useCascadeDeexcitation()
G4ParticleDefinition * GetDefinition() const
void copyOutputToHadronicResult()
virtual void DumpConfiguration(std::ostream &outFile) const
G4GLOB_DLL std::ostream G4cout
ParticleList decay(Cluster *const c)
Carries out a cluster decay.
const G4ParticleDefinition * GetDefinition() const
G4double GetFormationTime() const
G4ReactionProductVector * Propagate(G4KineticTrackVector *theSecondaries, G4V3DNucleus *theNucleus)
void setVerboseLevel(G4int verbose=0)
G4bool energyOkay() const
G4double GetKineticEnergy() const
G4bool createTarget(G4Nucleus &theNucleus)
G4int numberOfOutgoingParticles() const
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &globalOutput)
G4ReactionProductVector * copyOutputToReactionProducts()
G4double relativeE() const
G4DynamicParticle * makeDynamicParticle(const G4InuclElementaryParticle &iep) const
void rotateEvent(const G4LorentzRotation &rotate)
static G4KaonZeroLong * Definition()
const G4LorentzVector & Get4Momentum() const
G4int GetAtomicMass() const
HepLorentzRotation & rotateZ(double delta)
HepLorentzRotation & invert()
static G4Dineutron * Definition()
G4int numberOfOutgoingNuclei() const
void SetEnergyChange(G4double anEnergy)
void usePreCompoundDeexcitation()
G4bool chargeOkay() const
static void saveEngineStatus(const char filename[]="Config.conf")
const std::vector< G4InuclNuclei > & getOutgoingNuclei() const
static G4KaonZeroShort * Definition()
const std::vector< G4InuclElementaryParticle > & getOutgoingParticles() const
virtual void SetVerboseLevel(G4int value)
void fill(G4int ityp, Model model=DefaultModel)
std::vector< G4InuclNuclei >::const_iterator nucleiIterator
G4HadFinalState theParticleChange
std::vector< G4InuclElementaryParticle >::iterator particleIterator
G4bool momentumOkay() const
void throwNonConservationFailure()
virtual void ModelDescription(std::ostream &outFile) const
G4bool quasi_deutron() const
static DLL_API const HepLorentzRotation IDENTITY
G4double relativeP() const
G4bool createBullet(const G4HadProjectile &aTrack)
void SetVerboseLevel(G4int verbose)
G4bool retryInelasticProton() const
const G4LorentzVector & Get4Momentum() const
void SetEnergyMomentumCheckLevels(G4double relativeLevel, G4double absoluteLevel)
G4ParticleDefinition * getDefinition() const
void usePreCompoundDeexcitation()
void AddSecondary(G4DynamicParticle *aP)
static void DumpConfiguration(std::ostream &os)
static G4UnboundPN * Definition()
G4GLOB_DLL std::ostream G4cerr
G4bool IsApplicable(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
virtual ~G4CascadeInterface()
G4HadFinalState * NoInteraction(const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
static G4bool usePreCompound()