139const G4int G4CascadeInterface::maximumTries = 20;
149 balance->
setLimits(5*perCent, 10*MeV/GeV);
159 delete collider; collider=0;
160 delete balance; balance=0;
161 delete output; output=0;
166 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
167 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
168 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
169 <<
"Final state hadrons are produced by a classical cascade\n"
170 <<
"consisting of individual hadron-nucleon scatterings which use\n"
171 <<
"free-space partial cross sections, corrected for various\n"
172 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
173 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
174 <<
"travel in straight lines until they are reflected from or\n"
175 <<
"transmitted through shell boundaries.\n";
233 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
236 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
241#ifdef G4CASCADE_DEBUG_INTERFACE
242 static G4int counter(0);
244 G4cerr <<
"Reaction number "<< counter <<
" "
249 if (!randomFile.empty()) {
251 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
281 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
284 collider->
collide(bullet, target, *output);
285 balance->
collide(bullet, target, *output);
291 if (numberOfTries >= maximumTries) {
293 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
298 if (!balance->
okay()) {
305 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
327#ifdef G4CASCADE_DEBUG_INTERFACE
331 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
332 for (
size_t i=0; i<theSecondaries->size(); i++) {
341 if (!randomFile.empty()) {
343 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
365 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
368 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
369 balance->
collide(bullet, target, *output);
376 if (numberOfTries >= maximumTries && !balance->
okay()) {
382 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
401 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
418 G4int bulletType = 0;
419 G4int bulletA = 0, bulletZ = 0;
428 if (0 == bulletType && 0 == bulletA*bulletZ) {
431 <<
" not usable as bullet." <<
G4endl;
442 bulletInLabFrame.
rotateZ(-projectileMomentum.
phi());
444 bulletInLabFrame.
invert();
447 projectileMomentum.
e());
449 if (bulletType > 0) {
450 hadronBullet.
fill(momentumBullet, bulletType);
451 bullet = &hadronBullet;
453 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
454 bullet = &nucleusBullet;
475 nucleusTarget.
fill(A, Z);
476 target = &nucleusTarget;
479 target = &hadronTarget;
495 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
496 << outgoingType <<
G4endl;
531 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
540 if (!particles.empty()) {
542 for (; ipart != particles.end(); ipart++) {
548 if (!outgoingNuclei.empty()) {
550 for (; ifrag != outgoingNuclei.end(); ifrag++) {
558 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
569 if (!particles.empty()) {
571 for (; ipart != particles.end(); ipart++) {
575 propResult->push_back(rp);
581 if (!fragments.empty()) {
583 for (; ifrag != fragments.end(); ifrag++) {
587 propResult->push_back(rp);
599 balance->
collide(bullet, target, *output);
603 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
608 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
612 if (std::abs(balance->
deltaKE()) > 0.01 ) {
613 G4cerr <<
"Kinetic energy conservation violated by "
620 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
621 <<
"\nTotal energy conservation at level "
624 if (balance->
deltaKE() > 5.0e-5 ) {
625 G4cerr <<
"FATAL ERROR: kinetic energy created "
637 const G4double coulumbBarrier = 8.7 * MeV/GeV;
639 const std::vector<G4InuclElementaryParticle>& p =
643 if (ipart->type() ==
proton) {
644 violated |= (ipart->getKineticEnergy() < coulumbBarrier);
654 const std::vector<G4InuclElementaryParticle>& out =
657#ifdef G4CASCADE_DEBUG_INTERFACE
659 G4cout <<
" retryInelasticProton: number of Tries "
660 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
661 <<
"\n retryInelasticProton: AND collision type ";
664 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
665 <<
"\n retryInelasticProton: AND Leading particles bullet "
666 << (out.size() >= 2 &&
669 ?
"YES (t)" :
"NO (f)")
674 return ( (numberOfTries < maximumTries) &&
693#ifdef G4CASCADE_DEBUG_INTERFACE
695 G4cout <<
" retryInelasticNucleus: numberOfTries "
696 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
697 <<
"\n retryInelasticNucleus: AND outputParticles "
698 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
699#ifdef G4CASCADE_COULOMB_DEV
700 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
702 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
703 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
705 <<
"\n retryInelasticNucleus: AND collsion type "
706 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
707 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
708 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
710 <<
"\n retryInelasticNucleus: OR conservation "
711 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
715 return ( ((numberOfTries < maximumTries) &&
717#ifdef G4CASCADE_COULOMB_DEV
720 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
723#ifndef G4CASCADE_SKIP_ECONS
724 || (!balance->
okay())
736 std::ostream& errInfo =
G4cerr;
738 errInfo <<
" >>> G4CascadeInterface has non-conserving"
739 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
741 G4String throwMsg =
"G4CascadeInterface - ";
743 throwMsg +=
"Energy";
744 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
749 throwMsg +=
"Momentum";
750 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
755 throwMsg +=
"Baryon number";
756 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
760 throwMsg +=
"Charge";
761 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
765 errInfo <<
" Final event output, for debugging:\n"
766 <<
" Bullet: \n" << *bullet <<
G4endl
767 <<
" Target: \n" << *target <<
G4endl;
770 throwMsg +=
" non-conservation. More info in output.";
std::vector< G4InuclElementaryParticle >::iterator particleIterator
std::vector< G4InuclElementaryParticle >::const_iterator particleIterator
std::vector< G4InuclNuclei >::const_iterator nucleiIterator
std::vector< G4ReactionProduct * > G4ReactionProductVector
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
static DLL_API const HepLorentzRotation IDENTITY
HepLorentzRotation & rotateY(double delta)
HepLorentzRotation & rotateZ(double delta)
HepLorentzRotation & invert()
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()
static const G4String & randomFile()
G4int numberOfOutgoingParticles() const
const std::vector< G4InuclNuclei > & getOutgoingNuclei() const
void rotateEvent(const G4LorentzRotation &rotate)
void printCollisionOutput(std::ostream &os=G4cout) const
const std::vector< G4InuclElementaryParticle > & getOutgoingParticles() const
void setVerboseLevel(G4int verbose)
G4int numberOfOutgoingNuclei() const
void SetStatusChange(G4HadFinalStateStatus aS)
void AddSecondary(G4DynamicParticle *aP)
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)
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
G4ParticleDefinition * GetDefinition() const
const G4LorentzVector & Get4Momentum() const
G4int GetAtomicNumber() const
G4int GetAtomicMass() const
const G4String & GetParticleName() const
virtual G4int GetCharge()=0
virtual G4int GetMassNumber()=0
virtual void setVerboseLevel(G4int verbose=0)
const G4HadProjectile * GetPrimaryProjectile() const