150 maximumTries(20), numberOfTries(0),
159 balance->
setLimits(5*perCent, 10*MeV/GeV);
172 delete collider; collider=0;
173 delete ltcollider; ltcollider = 0;
174 delete balance; balance=0;
175 delete output; output=0;
180 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
181 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
182 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
183 <<
"Final state hadrons are produced by a classical cascade\n"
184 <<
"consisting of individual hadron-nucleon scatterings which use\n"
185 <<
"free-space partial cross sections, corrected for various\n"
186 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
187 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
188 <<
"travel in straight lines until they are reflected from or\n"
189 <<
"transmitted through shell boundaries.\n";
209 if (!ch || !
pn || !
nn || !
pp)
return;
257 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
260 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
265#ifdef G4CASCADE_DEBUG_INTERFACE
266 static G4int counter(0);
268 G4cerr <<
"Reaction number "<< counter <<
" "
273 if (!randomFile.empty()) {
275 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
302 ltcollider->
collide(bullet, target, *output);
323 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
326 collider->
collide(bullet, target, *output);
327 balance->
collide(bullet, target, *output);
334 if (numberOfTries >= maximumTries) {
336 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
341 if (!balance->
okay()) {
348 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
379#ifdef G4CASCADE_DEBUG_INTERFACE
383 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
384 for (
size_t i=0; i<theSecondaries->size(); i++) {
393 if (!randomFile.empty()) {
395 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
417 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
420 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
421 balance->
collide(bullet, target, *output);
428 if (numberOfTries >= maximumTries && !balance->
okay()) {
434 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
453 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
469 G4int bulletType = 0;
470 G4int bulletA = 0, bulletZ = 0;
479 if (0 == bulletType && 0 == bulletA*bulletZ) {
482 <<
" not usable as bullet." <<
G4endl;
500 projectileMomentum.
e());
503 hadronBullet.
fill(momentumBullet, bulletType);
504 bullet = &hadronBullet;
506 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
507 bullet = &nucleusBullet;
529 target = &nucleusTarget;
532 target = &hadronTarget;
548 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
549 << outgoingType <<
G4endl;
584 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
593 if (!particles.empty()) {
595 for (; ipart != particles.end(); ipart++) {
601 if (!outgoingNuclei.empty()) {
603 for (; ifrag != outgoingNuclei.end(); ifrag++) {
611 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
622 if (!particles.empty()) {
624 for (; ipart != particles.end(); ipart++) {
629 propResult->push_back(rp);
635 if (!fragments.empty()) {
637 for (; ifrag != fragments.end(); ifrag++) {
642 propResult->push_back(rp);
654 balance->
collide(bullet, target, *output);
658 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
663 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
667 if (std::abs(balance->
deltaKE()) > 0.01 ) {
668 G4cerr <<
"Kinetic energy conservation violated by "
675 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
676 <<
"\nTotal energy conservation at level "
679 if (balance->
deltaKE() > 5.0e-5 ) {
680 G4cerr <<
"FATAL ERROR: kinetic energy created "
692 const G4double coulumbBarrier = 8.7 * MeV/GeV;
694 const std::vector<G4InuclElementaryParticle>& p =
698 if (ipart->type() ==
proton) {
699 violated |= (ipart->getKineticEnergy() < coulumbBarrier);
709 const std::vector<G4InuclElementaryParticle>& out =
712#ifdef G4CASCADE_DEBUG_INTERFACE
714 G4cout <<
" retryInelasticProton: number of Tries "
715 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
716 <<
"\n retryInelasticProton: AND collision type ";
719 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
720 <<
"\n retryInelasticProton: AND Leading particles bullet "
721 << (out.size() >= 2 &&
724 ?
"YES (t)" :
"NO (f)")
729 return ( (numberOfTries < maximumTries) &&
748#ifdef G4CASCADE_DEBUG_INTERFACE
750 G4cout <<
" retryInelasticNucleus: numberOfTries "
751 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
752 <<
"\n retryInelasticNucleus: AND outputParticles "
753 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
754#ifdef G4CASCADE_COULOMB_DEV
755 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
757 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
758 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
760 <<
"\n retryInelasticNucleus: AND collision type "
761 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
762 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
763 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
765 <<
"\n retryInelasticNucleus: OR conservation "
766 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
770 return ( (numberOfTries < maximumTries) &&
772#ifdef G4CASCADE_COULOMB_DEV
775 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
778#ifndef G4CASCADE_SKIP_ECONS
779 || (!balance->
okay())
792 std::ostream& errInfo =
G4cerr;
794 errInfo <<
" >>> G4CascadeInterface has non-conserving"
795 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
797 G4String throwMsg =
"G4CascadeInterface - ";
799 throwMsg +=
"Energy";
800 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
805 throwMsg +=
"Momentum";
806 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
811 throwMsg +=
"Baryon number";
812 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
816 throwMsg +=
"Charge";
817 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
821 errInfo <<
" Final event output, for debugging:\n"
822 <<
" Bullet: \n" << *bullet <<
G4endl
823 <<
" Target: \n" << *target <<
G4endl;
826 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
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 G4int GetModelID(const G4int modelIndex)
void SetCreatorModelID(const G4int mod)
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)