150 maximumTries(20), numberOfTries(0),
159 balance->
setLimits(5*perCent, 10*MeV/GeV);
175 delete collider; collider=0;
176 delete ltcollider; ltcollider = 0;
177 delete balance; balance=0;
178 delete output; output=0;
183 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
184 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
185 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
186 <<
"Final state hadrons are produced by a classical cascade\n"
187 <<
"consisting of individual hadron-nucleon scatterings which use\n"
188 <<
"free-space partial cross sections, corrected for various\n"
189 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
190 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
191 <<
"travel in straight lines until they are reflected from or\n"
192 <<
"transmitted through shell boundaries.\n";
212 if (!ch || !
pn || !
nn || !
pp)
return;
264 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
267 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
272#ifdef G4CASCADE_DEBUG_INTERFACE
273 static G4int counter(0);
275 G4cerr <<
"Reaction number "<< counter <<
" "
280 if (!randomFile.empty()) {
282 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
309 ltcollider->
collide(bullet, target, *output);
330 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
333 collider->
collide(bullet, target, *output);
334 balance->
collide(bullet, target, *output);
341 if (numberOfTries >= maximumTries) {
343 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
348 if (!balance->
okay()) {
355 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
386#ifdef G4CASCADE_DEBUG_INTERFACE
390 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
391 for (
size_t i=0; i<theSecondaries->size(); i++) {
400 if (!randomFile.empty()) {
402 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
424 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
427 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
428 balance->
collide(bullet, target, *output);
435 if (numberOfTries >= maximumTries && !balance->
okay()) {
441 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
460 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
476 G4int bulletType = 0;
477 G4int bulletA = 0, bulletZ = 0;
486 if (0 == bulletType && 0 == bulletA*bulletZ) {
489 <<
" not usable as bullet." <<
G4endl;
507 projectileMomentum.
e());
510 hadronBullet.
fill(momentumBullet, bulletType);
511 bullet = &hadronBullet;
513 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
514 bullet = &nucleusBullet;
535 nucleusTarget.
fill(
A, Z);
536 target = &nucleusTarget;
539 target = &hadronTarget;
555 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
556 << outgoingType <<
G4endl;
591 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
600 if (!particles.empty()) {
602 for (; ipart != particles.end(); ipart++) {
608 if (!outgoingNuclei.empty()) {
610 for (; ifrag != outgoingNuclei.end(); ifrag++) {
618 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
629 if (!particles.empty()) {
631 for (; ipart != particles.end(); ipart++) {
636 propResult->push_back(rp);
642 if (!fragments.empty()) {
644 for (; ifrag != fragments.end(); ifrag++) {
649 propResult->push_back(rp);
661 balance->
collide(bullet, target, *output);
665 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
670 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
674 if (std::abs(balance->
deltaKE()) > 0.01 ) {
675 G4cerr <<
"Kinetic energy conservation violated by "
682 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
683 <<
"\nTotal energy conservation at level "
686 if (balance->
deltaKE() > 5.0e-5 ) {
687 G4cerr <<
"FATAL ERROR: kinetic energy created "
699 const G4double coulumbBarrier = 8.7 * MeV/GeV;
701 const std::vector<G4InuclElementaryParticle>& p =
705 if (ipart->type() ==
proton) {
706 violated |= (ipart->getKineticEnergy() < coulumbBarrier);
716 const std::vector<G4InuclElementaryParticle>& out =
719#ifdef G4CASCADE_DEBUG_INTERFACE
721 G4cout <<
" retryInelasticProton: number of Tries "
722 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
723 <<
"\n retryInelasticProton: AND collision type ";
726 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
727 <<
"\n retryInelasticProton: AND Leading particles bullet "
728 << (out.size() >= 2 &&
731 ?
"YES (t)" :
"NO (f)")
736 return ( (numberOfTries < maximumTries) &&
755#ifdef G4CASCADE_DEBUG_INTERFACE
757 G4cout <<
" retryInelasticNucleus: numberOfTries "
758 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
759 <<
"\n retryInelasticNucleus: AND outputParticles "
760 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
761#ifdef G4CASCADE_COULOMB_DEV
762 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
764 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
765 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
767 <<
"\n retryInelasticNucleus: AND collision type "
768 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
769 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
770 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
772 <<
"\n retryInelasticNucleus: OR conservation "
773 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
777 return ( (numberOfTries < maximumTries) &&
779#ifdef G4CASCADE_COULOMB_DEV
782 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
785#ifndef G4CASCADE_SKIP_ECONS
786 || (!balance->
okay())
799 std::ostream& errInfo =
G4cerr;
801 errInfo <<
" >>> G4CascadeInterface has non-conserving"
802 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
804 G4String throwMsg =
"G4CascadeInterface - ";
806 throwMsg +=
"Energy";
807 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
812 throwMsg +=
"Momentum";
813 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
818 throwMsg +=
"Baryon number";
819 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
823 throwMsg +=
"Charge";
824 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
828 errInfo <<
" Final event output, for debugging:\n"
829 <<
" Bullet: \n" << *bullet <<
G4endl
830 <<
" Target: \n" << *target <<
G4endl;
833 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
void useAblaDeexcitation()
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 useAblaDeexcitation()
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)