138 using namespace G4InuclParticleNames;
149 maximumTries(20), numberOfTries(0),
167 delete collider; collider=0;
168 delete balance; balance=0;
169 delete output; output=0;
174 outFile <<
"The Bertini-style cascade implements the inelastic scattering\n"
175 <<
"of hadrons by nuclei. Nucleons, pions, kaons and hyperons\n"
176 <<
"from 0 to 15 GeV may be used as projectiles in this model.\n"
177 <<
"Final state hadrons are produced by a classical cascade\n"
178 <<
"consisting of individual hadron-nucleon scatterings which use\n"
179 <<
"free-space partial cross sections, corrected for various\n"
180 <<
"nuclear medium effects. The target nucleus is modeled as a\n"
181 <<
"set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
182 <<
"travel in straight lines until they are reflected from or\n"
183 <<
"transmitted through shell boundaries.\n";
203 if (!ch || !pn || !nn || !pp)
return;
251 G4cout <<
" >>> G4CascadeInterface::ApplyYourself" <<
G4endl;
254 G4cerr <<
" >>> G4CascadeInterface got negative-energy track: "
259 #ifdef G4CASCADE_DEBUG_INTERFACE
260 static G4int counter(0);
262 G4cerr <<
"Reaction number "<< counter <<
" "
267 if (!randomFile.empty()) {
269 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
299 G4cout <<
" Generating cascade attempt " << numberOfTries <<
G4endl;
310 if (numberOfTries >= maximumTries) {
312 G4cout <<
" Cascade aborted after trials " << numberOfTries <<
G4endl;
317 if (!balance->
okay()) {
324 G4cout <<
" Cascade output after trials " << numberOfTries <<
G4endl;
356 #ifdef G4CASCADE_DEBUG_INTERFACE
360 <<
"\n " << theSecondaries->size() <<
" secondaries:" <<
G4endl;
361 for (
size_t i=0; i<theSecondaries->size(); i++) {
370 if (!randomFile.empty()) {
372 G4cout <<
" Saving random engine state to " << randomFile <<
G4endl;
394 G4cout <<
" Generating rescatter attempt " << numberOfTries <<
G4endl;
397 collider->
rescatter(bullet, theSecondaries, theNucleus, *output);
405 if (numberOfTries >= maximumTries && !balance->
okay()) {
411 G4cout <<
" Cascade rescatter after trials " << numberOfTries <<
G4endl;
430 G4cout <<
" >>> G4CascadeInterface::NoInteraction" <<
G4endl;
446 G4int bulletType = 0;
447 G4int bulletA = 0, bulletZ = 0;
456 if (0 == bulletType && 0 == bulletA*bulletZ) {
459 <<
" not usable as bullet." <<
G4endl;
470 bulletInLabFrame.
rotateZ(-projectileMomentum.
phi());
472 bulletInLabFrame.
invert();
475 projectileMomentum.
e());
478 hadronBullet.
fill(momentumBullet, bulletType);
479 bullet = &hadronBullet;
481 nucleusBullet.
fill(momentumBullet, bulletA, bulletZ);
482 bullet = &nucleusBullet;
503 nucleusTarget.
fill(A, Z);
523 G4cerr <<
" ERROR: G4CascadeInterface incompatible particle type "
524 << outgoingType <<
G4endl;
559 G4cout <<
" >>> G4CascadeInterface::copyOutputToHadronicResult" <<
G4endl;
568 if (!particles.empty()) {
570 for (; ipart != particles.end(); ipart++) {
576 if (!outgoingNuclei.empty()) {
578 for (; ifrag != outgoingNuclei.end(); ifrag++) {
586 G4cout <<
" >>> G4CascadeInterface::copyOutputToReactionProducts" <<
G4endl;
597 if (!particles.empty()) {
599 for (; ipart != particles.end(); ipart++) {
603 propResult->push_back(rp);
609 if (!fragments.empty()) {
611 for (; ifrag != fragments.end(); ifrag++) {
615 propResult->push_back(rp);
631 G4cerr <<
"ERROR: no baryon number conservation, sum of baryons = "
636 G4cerr <<
"ERROR: no charge conservation, sum of charges = "
640 if (std::abs(balance->
deltaKE()) > 0.01 ) {
641 G4cerr <<
"Kinetic energy conservation violated by "
648 G4cout <<
"Initial energy " << eInit <<
" final energy " << eFinal
649 <<
"\nTotal energy conservation at level "
652 if (balance->
deltaKE() > 5.0e-5 ) {
653 G4cerr <<
"FATAL ERROR: kinetic energy created "
667 const std::vector<G4InuclElementaryParticle>&
p =
671 if (ipart->type() ==
proton) {
672 violated |= (ipart->getKineticEnergy() < coulumbBarrier);
682 const std::vector<G4InuclElementaryParticle>& out =
685 #ifdef G4CASCADE_DEBUG_INTERFACE
687 G4cout <<
" retryInelasticProton: number of Tries "
688 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
689 <<
"\n retryInelasticProton: AND collision type ";
692 G4cout << (out.size() == 2 ?
"ELASTIC (t)" :
"INELASTIC (f)")
693 <<
"\n retryInelasticProton: AND Leading particles bullet "
694 << (out.size() >= 2 &&
697 ?
"YES (t)" :
"NO (f)")
702 return ( (numberOfTries < maximumTries) &&
721 #ifdef G4CASCADE_DEBUG_INTERFACE
723 G4cout <<
" retryInelasticNucleus: numberOfTries "
724 << ((numberOfTries < maximumTries) ?
"RETRY (t)" :
"EXIT (f)")
725 <<
"\n retryInelasticNucleus: AND outputParticles "
726 << ((npart != 0) ?
"NON-ZERO (t)" :
"EMPTY (f)")
727 #ifdef G4CASCADE_COULOMB_DEV
728 <<
"\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
730 <<
"\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
731 << ((npart+nfrag > 2) ?
"INELASTIC (t)" :
"ELASTIC (f)")
733 <<
"\n retryInelasticNucleus: AND collsion type "
734 << ((npart+nfrag < 3) ?
"ELASTIC (t)" :
"INELASTIC (f)")
735 <<
"\n retryInelasticNucleus: AND Leading particle bullet "
736 << ((firstOut == bullet->
getDefinition()) ?
"YES (t)" :
"NO (f)")
738 <<
"\n retryInelasticNucleus: OR conservation "
739 << (!balance->
okay() ?
"FAILED (t)" :
"PASSED (f)")
743 return ( (numberOfTries < maximumTries) &&
745 #ifdef G4CASCADE_COULOMB_DEV
748 (npart+nfrag < 3 && firstOut == bullet->getDefinition())
751 #ifndef G4CASCADE_SKIP_ECONS
752 || (!balance->
okay())
765 std::ostream& errInfo =
G4cerr;
767 errInfo <<
" >>> G4CascadeInterface has non-conserving"
768 <<
" cascade after " << numberOfTries <<
" attempts." <<
G4endl;
770 G4String throwMsg =
"G4CascadeInterface - ";
772 throwMsg +=
"Energy";
773 errInfo <<
" Energy conservation violated by " << balance->
deltaE()
778 throwMsg +=
"Momentum";
779 errInfo <<
" Momentum conservation violated by " << balance->
deltaP()
784 throwMsg +=
"Baryon number";
785 errInfo <<
" Baryon number violated by " << balance->
deltaB() <<
G4endl;
789 throwMsg +=
"Charge";
790 errInfo <<
" Charge conservation violated by " << balance->
deltaQ()
794 errInfo <<
" Final event output, for debugging:\n"
795 <<
" Bullet: \n" << *bullet << G4endl
799 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)
static constexpr double perCent
void printCollisionOutput(std::ostream &os=G4cout) const
virtual G4int GetMassNumber()=0
const G4ParticleDefinition * getDefinition() const
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
void useCascadeDeexcitation()
void copyOutputToHadronicResult()
virtual void DumpConfiguration(std::ostream &outFile) const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
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
static constexpr double GeV
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()
static constexpr double MeV
virtual void ModelDescription(std::ostream &outFile) const
G4bool quasi_deutron() const
static DLL_API const HepLorentzRotation IDENTITY
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
G4double relativeP() const
G4bool createBullet(const G4HadProjectile &aTrack)
void SetVerboseLevel(G4int verbose)
G4bool retryInelasticProton() const
const G4LorentzVector & Get4Momentum() const
void SetVerboseLevel(G4int value)
void SetEnergyMomentumCheckLevels(G4double relativeLevel, G4double absoluteLevel)
const G4ParticleDefinition * GetDefinition() const
void usePreCompoundDeexcitation()
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()