G4CascadeInterface Class Reference

#include <G4CascadeInterface.hh>

Inheritance diagram for G4CascadeInterface:

G4VIntraNuclearTransportModel G4HadronicInteraction

Public Member Functions

 G4CascadeInterface (const G4String &name="BertiniCascade")
virtual ~G4CascadeInterface ()
G4ReactionProductVectorPropagate (G4KineticTrackVector *theSecondaries, G4V3DNucleus *theNucleus)
G4HadFinalStateApplyYourself (const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
void SetVerboseLevel (G4int verbose)
G4bool IsApplicable (const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
G4bool IsApplicable (const G4ParticleDefinition *aPD) const
void useCascadeDeexcitation ()
void usePreCompoundDeexcitation ()
virtual void ModelDescription (std::ostream &outFile) const
virtual void DumpConfiguration (std::ostream &outFile) const

Protected Member Functions

void clear ()
G4bool createBullet (const G4HadProjectile &aTrack)
G4bool createTarget (G4Nucleus &theNucleus)
G4bool createTarget (G4V3DNucleus *theNucleus)
G4bool createTarget (G4int A, G4int Z)
G4bool coulombBarrierViolation () const
G4bool retryInelasticProton () const
G4bool retryInelasticNucleus () const
void copyOutputToHadronicResult ()
G4ReactionProductVectorcopyOutputToReactionProducts ()
G4HadFinalStateNoInteraction (const G4HadProjectile &aTrack, G4Nucleus &theNucleus)
void checkFinalResult ()
void throwNonConservationFailure ()
G4DynamicParticlemakeDynamicParticle (const G4InuclElementaryParticle &iep) const
G4DynamicParticlemakeDynamicParticle (const G4InuclNuclei &inuc) const

Detailed Description

Definition at line 84 of file G4CascadeInterface.hh.


Constructor & Destructor Documentation

G4CascadeInterface::G4CascadeInterface ( const G4String name = "BertiniCascade"  ) 

Definition at line 144 of file G4CascadeInterface.cc.

References G4HadronicInteraction::SetEnergyMomentumCheckLevels(), G4CascadeCheckBalance::setLimits(), SetVerboseLevel(), G4CascadeParameters::usePreCompound(), usePreCompoundDeexcitation(), and G4CascadeParameters::verbose().

00145   : G4VIntraNuclearTransportModel(name), numberOfTries(0),
00146     collider(new G4InuclCollider), balance(new G4CascadeCheckBalance(name)),
00147     bullet(0), target(0), output(new G4CollisionOutput) {
00148   SetEnergyMomentumCheckLevels(5*perCent, 10*MeV);
00149   balance->setLimits(5*perCent, 10*MeV/GeV);    // Bertini internal units
00150   // Description();                                // Model description
00151 
00152   this->SetVerboseLevel(G4CascadeParameters::verbose());
00153   if (G4CascadeParameters::usePreCompound()) usePreCompoundDeexcitation();
00154 }

G4CascadeInterface::~G4CascadeInterface (  )  [virtual]

Definition at line 157 of file G4CascadeInterface.cc.

References clear().

00157                                         {
00158   clear();
00159   delete collider; collider=0;
00160   delete balance; balance=0;
00161   delete output; output=0;
00162 }


Member Function Documentation

G4HadFinalState * G4CascadeInterface::ApplyYourself ( const G4HadProjectile aTrack,
G4Nucleus theNucleus 
) [virtual]

Implements G4HadronicInteraction.

Definition at line 230 of file G4CascadeInterface.cc.

References checkFinalResult(), clear(), G4HadFinalState::Clear(), G4CascadeCheckBalance::collide(), G4InuclCollider::collide(), copyOutputToHadronicResult(), createBullet(), createTarget(), G4cerr, G4cout, G4endl, G4Nucleus::GetA_asInt(), G4HadProjectile::GetDefinition(), G4HadProjectile::GetKineticEnergy(), G4ParticleDefinition::GetParticleName(), IsApplicable(), NoInteraction(), G4CascadeCheckBalance::okay(), G4CollisionOutput::printCollisionOutput(), G4CollisionOutput::reset(), retryInelasticNucleus(), retryInelasticProton(), G4CollisionOutput::rotateEvent(), G4HadronicInteraction::theParticleChange, throwNonConservationFailure(), and G4HadronicInteraction::verboseLevel.

00231                                                          {
00232   if (verboseLevel)
00233     G4cout << " >>> G4CascadeInterface::ApplyYourself" << G4endl;
00234 
00235   if (aTrack.GetKineticEnergy() < 0.) {
00236     G4cerr << " >>> G4CascadeInterface got negative-energy track: "
00237            << aTrack.GetDefinition()->GetParticleName() << " Ekin = "
00238            << aTrack.GetKineticEnergy() << G4endl;
00239   }
00240 
00241 #ifdef G4CASCADE_DEBUG_INTERFACE
00242   static G4int counter(0);
00243   counter++;
00244   G4cerr << "Reaction number "<< counter << " "
00245          << aTrack.GetDefinition()->GetParticleName() << " "
00246          << aTrack.GetKineticEnergy() << " MeV" << G4endl;
00247 #endif
00248 
00249   if (!randomFile.empty()) {            // User requested random-seed capture
00250     if (verboseLevel>1) 
00251       G4cout << " Saving random engine state to " << randomFile << G4endl;
00252     CLHEP::HepRandom::saveEngineStatus(randomFile);
00253   }
00254 
00255   theParticleChange.Clear();
00256   clear();
00257 
00258   // Abort processing if no interaction is possible
00259   if (!IsApplicable(aTrack, theNucleus)) {
00260     if (verboseLevel) G4cerr << " No interaction possible " << G4endl;
00261     return NoInteraction(aTrack, theNucleus);
00262   }
00263 
00264   // Make conversion between native Geant4 and Bertini cascade classes.
00265   if (!createBullet(aTrack)) {
00266     if (verboseLevel) G4cerr << " Unable to create usable bullet" << G4endl;
00267     return NoInteraction(aTrack, theNucleus);
00268   }
00269 
00270   if (!createTarget(theNucleus)) {
00271     if (verboseLevel) G4cerr << " Unable to create usable target" << G4endl;
00272     return NoInteraction(aTrack, theNucleus);
00273   }
00274 
00275   // Different retry conditions for proton target vs. nucleus
00276   const G4bool isHydrogen = (theNucleus.GetA_asInt() == 1);
00277 
00278   numberOfTries = 0;
00279   do {                          // we try to create inelastic interaction
00280     if (verboseLevel > 1)
00281       G4cout << " Generating cascade attempt " << numberOfTries << G4endl;
00282     
00283     output->reset();
00284     collider->collide(bullet, target, *output);
00285     balance->collide(bullet, target, *output);
00286     
00287     numberOfTries++;
00288   } while ( isHydrogen ? retryInelasticProton() : retryInelasticNucleus() );
00289 
00290   // Null event if unsuccessful
00291   if (numberOfTries >= maximumTries) {
00292     if (verboseLevel) 
00293       G4cout << " Cascade aborted after trials " << numberOfTries << G4endl;
00294     return NoInteraction(aTrack, theNucleus);
00295   }
00296 
00297   // Abort job if energy or momentum are not conserved
00298   if (!balance->okay()) {
00299     throwNonConservationFailure();
00300     return NoInteraction(aTrack, theNucleus);
00301   }
00302 
00303   // Successful cascade -- clean up and return
00304   if (verboseLevel) {
00305     G4cout << " Cascade output after trials " << numberOfTries << G4endl;
00306     if (verboseLevel > 1) output->printCollisionOutput();
00307   }
00308 
00309   // Rotate event to put Z axis along original projectile direction
00310   output->rotateEvent(bulletInLabFrame);
00311 
00312   copyOutputToHadronicResult();
00313 
00314   // Report violations of conservation laws in original frame
00315   checkFinalResult();
00316 
00317   // Clean up and return final result;
00318   clear();
00319   return &theParticleChange;
00320 }

void G4CascadeInterface::checkFinalResult (  )  [protected]

Definition at line 598 of file G4CascadeInterface.cc.

References G4CascadeCheckBalance::baryonOkay(), G4CascadeCheckBalance::chargeOkay(), G4CascadeCheckBalance::collide(), G4CascadeCheckBalance::deltaB(), G4CascadeCheckBalance::deltaE(), G4CascadeCheckBalance::deltaKE(), G4CascadeCheckBalance::deltaQ(), G4cerr, G4cout, G4endl, G4InuclParticle::getEnergy(), and G4HadronicInteraction::verboseLevel.

Referenced by ApplyYourself().

00598                                           {
00599   balance->collide(bullet, target, *output);
00600 
00601   if (verboseLevel > 2) {
00602     if (!balance->baryonOkay()) {
00603       G4cerr << "ERROR: no baryon number conservation, sum of baryons = "
00604              << balance->deltaB() << G4endl;
00605     }
00606 
00607     if (!balance->chargeOkay()) {
00608       G4cerr << "ERROR: no charge conservation, sum of charges = "
00609              << balance->deltaQ() << G4endl;
00610     }
00611 
00612     if (std::abs(balance->deltaKE()) > 0.01 ) { // GeV
00613       G4cerr << "Kinetic energy conservation violated by "
00614              << balance->deltaKE() << " GeV" << G4endl;
00615     }
00616 
00617     G4double eInit = bullet->getEnergy() + target->getEnergy();
00618     G4double eFinal = eInit + balance->deltaE();
00619 
00620     G4cout << "Initial energy " << eInit << " final energy " << eFinal
00621            << "\nTotal energy conservation at level "
00622            << balance->deltaE() * GeV << " MeV" << G4endl;
00623     
00624     if (balance->deltaKE() > 5.0e-5 ) {         // 0.05 MeV
00625       G4cerr << "FATAL ERROR: kinetic energy created  "
00626              << balance->deltaKE() * GeV << " MeV" << G4endl;
00627     }
00628   }
00629 }

void G4CascadeInterface::clear (  )  [protected]

Definition at line 183 of file G4CascadeInterface.cc.

Referenced by ApplyYourself(), Propagate(), and ~G4CascadeInterface().

00183                                {
00184   bullet=0;
00185   target=0;
00186 }

void G4CascadeInterface::copyOutputToHadronicResult (  )  [protected]

Definition at line 529 of file G4CascadeInterface.cc.

References G4HadFinalState::AddSecondary(), G4cout, G4endl, G4CollisionOutput::getOutgoingNuclei(), G4CollisionOutput::getOutgoingParticles(), makeDynamicParticle(), G4HadFinalState::SetEnergyChange(), G4HadFinalState::SetStatusChange(), stopAndKill, G4HadronicInteraction::theParticleChange, and G4HadronicInteraction::verboseLevel.

Referenced by ApplyYourself().

00529                                                     {
00530   if (verboseLevel > 1)
00531     G4cout << " >>> G4CascadeInterface::copyOutputToHadronicResult" << G4endl;
00532 
00533   const std::vector<G4InuclNuclei>& outgoingNuclei = output->getOutgoingNuclei();
00534   const std::vector<G4InuclElementaryParticle>& particles = output->getOutgoingParticles();
00535 
00536   theParticleChange.SetStatusChange(stopAndKill);
00537   theParticleChange.SetEnergyChange(0.);
00538 
00539   // Get outcoming particles
00540   if (!particles.empty()) { 
00541     particleIterator ipart = particles.begin();
00542     for (; ipart != particles.end(); ipart++) {
00543       theParticleChange.AddSecondary(makeDynamicParticle(*ipart));
00544     }
00545   }
00546 
00547   // get nuclei fragments
00548   if (!outgoingNuclei.empty()) { 
00549     nucleiIterator ifrag = outgoingNuclei.begin();
00550     for (; ifrag != outgoingNuclei.end(); ifrag++) {
00551       theParticleChange.AddSecondary(makeDynamicParticle(*ifrag)); 
00552     }
00553   }
00554 }

G4ReactionProductVector * G4CascadeInterface::copyOutputToReactionProducts (  )  [protected]

Definition at line 556 of file G4CascadeInterface.cc.

References G4cout, G4endl, G4CollisionOutput::getOutgoingNuclei(), G4CollisionOutput::getOutgoingParticles(), makeDynamicParticle(), and G4HadronicInteraction::verboseLevel.

Referenced by Propagate().

00556                                                                           {
00557   if (verboseLevel > 1)
00558     G4cout << " >>> G4CascadeInterface::copyOutputToReactionProducts" << G4endl;
00559 
00560   const std::vector<G4InuclElementaryParticle>& particles = output->getOutgoingParticles();
00561   const std::vector<G4InuclNuclei>& fragments = output->getOutgoingNuclei();
00562 
00563   G4ReactionProductVector* propResult = new G4ReactionProductVector;
00564 
00565   G4ReactionProduct* rp = 0;    // Buffers to create outgoing tracks
00566   G4DynamicParticle* dp = 0;
00567 
00568   // Get outcoming particles
00569   if (!particles.empty()) { 
00570     particleIterator ipart = particles.begin();
00571     for (; ipart != particles.end(); ipart++) {
00572       rp = new G4ReactionProduct;
00573       dp = makeDynamicParticle(*ipart);
00574       (*rp) = (*dp);            // This does all the necessary copying
00575       propResult->push_back(rp);
00576       delete dp;
00577     }
00578   }
00579 
00580   // get nuclei fragments
00581   if (!fragments.empty()) { 
00582     nucleiIterator ifrag = fragments.begin();
00583     for (; ifrag != fragments.end(); ifrag++) {
00584       rp = new G4ReactionProduct;
00585       dp = makeDynamicParticle(*ifrag);
00586       (*rp) = (*dp);            // This does all the necessary copying
00587       propResult->push_back(rp);
00588       delete dp;
00589     }
00590   }
00591 
00592   return propResult;
00593 }

G4bool G4CascadeInterface::coulombBarrierViolation (  )  const [protected]

Definition at line 634 of file G4CascadeInterface.cc.

References G4CollisionOutput::getOutgoingParticles(), and G4InuclParticleNames::proton.

Referenced by retryInelasticNucleus().

00634                                                          {
00635   G4bool violated = false;              // by default coulomb analysis is OK
00636 
00637   const G4double coulumbBarrier = 8.7 * MeV/GeV;        // Bertini uses GeV
00638 
00639   const std::vector<G4InuclElementaryParticle>& p =
00640     output->getOutgoingParticles();
00641 
00642   for (particleIterator ipart=p.begin(); ipart != p.end(); ipart++) {
00643     if (ipart->type() == proton) {
00644       violated |= (ipart->getKineticEnergy() < coulumbBarrier);
00645     }
00646   }
00647 
00648   return violated;
00649 }

G4bool G4CascadeInterface::createBullet ( const G4HadProjectile aTrack  )  [protected]

Definition at line 415 of file G4CascadeInterface.cc.

References G4InuclNuclei::fill(), G4InuclElementaryParticle::fill(), G4cerr, G4cout, G4endl, G4HadProjectile::Get4Momentum(), G4ParticleDefinition::GetAtomicMass(), G4ParticleDefinition::GetAtomicNumber(), G4HadProjectile::GetDefinition(), G4ParticleDefinition::GetParticleName(), G4InuclElementaryParticle::type(), and G4HadronicInteraction::verboseLevel.

Referenced by ApplyYourself(), and Propagate().

00415                                                                      {
00416   const G4ParticleDefinition* trkDef = aTrack.GetDefinition();
00417 
00418   G4int bulletType = 0;                 // For elementary particles
00419   G4int bulletA = 0, bulletZ = 0;       // For nucleus projectile
00420 
00421   if (trkDef->GetAtomicMass() <= 1) {
00422     bulletType = G4InuclElementaryParticle::type(trkDef);
00423   } else {
00424     bulletA = trkDef->GetAtomicMass();
00425     bulletZ = trkDef->GetAtomicNumber();
00426   }
00427 
00428   if (0 == bulletType && 0 == bulletA*bulletZ) {
00429     if (verboseLevel) {
00430       G4cerr << " G4CascadeInterface: " << trkDef->GetParticleName()
00431              << " not usable as bullet." << G4endl;
00432     }
00433     bullet = 0;
00434     return false;
00435   }
00436 
00437   // Code momentum and energy -- Bertini wants z-axis and GeV units
00438   G4LorentzVector projectileMomentum = aTrack.Get4Momentum()/GeV;
00439   
00440   // Rotation/boost to get from z-axis back to original frame
00441   bulletInLabFrame = G4LorentzRotation::IDENTITY;       // Initialize
00442   bulletInLabFrame.rotateZ(-projectileMomentum.phi());
00443   bulletInLabFrame.rotateY(-projectileMomentum.theta());
00444   bulletInLabFrame.invert();
00445   
00446   G4LorentzVector momentumBullet(0., 0., projectileMomentum.rho(),
00447                                  projectileMomentum.e());
00448 
00449   if (bulletType > 0) {
00450     hadronBullet.fill(momentumBullet, bulletType);
00451     bullet = &hadronBullet;
00452   } else {
00453     nucleusBullet.fill(momentumBullet, bulletA, bulletZ);
00454     bullet = &nucleusBullet;
00455   }
00456 
00457   if (verboseLevel > 2) G4cout << "Bullet:  \n" << *bullet << G4endl;  
00458 
00459   return true;
00460 }

G4bool G4CascadeInterface::createTarget ( G4int  A,
G4int  Z 
) [protected]

Definition at line 473 of file G4CascadeInterface.cc.

References G4InuclElementaryParticle::fill(), G4InuclNuclei::fill(), G4cout, G4endl, neutron, G4InuclParticleNames::proton, and G4HadronicInteraction::verboseLevel.

00473                                                         {
00474   if (A > 1) {
00475     nucleusTarget.fill(A, Z);
00476     target = &nucleusTarget;
00477   } else {
00478     hadronTarget.fill(0., (Z=1?proton:neutron));
00479     target = &hadronTarget;
00480   }
00481 
00482   if (verboseLevel > 2) G4cout << "Target:  \n" << *target << G4endl;
00483 
00484   return true;          // Right now, target never fails
00485 }

G4bool G4CascadeInterface::createTarget ( G4V3DNucleus theNucleus  )  [protected]

Definition at line 469 of file G4CascadeInterface.cc.

References createTarget(), G4V3DNucleus::GetCharge(), and G4V3DNucleus::GetMassNumber().

00469                                                                 {
00470   return createTarget(theNucleus->GetMassNumber(), theNucleus->GetCharge());
00471 }

G4bool G4CascadeInterface::createTarget ( G4Nucleus theNucleus  )  [protected]

Definition at line 465 of file G4CascadeInterface.cc.

References G4Nucleus::GetA_asInt(), and G4Nucleus::GetZ_asInt().

Referenced by ApplyYourself(), createTarget(), and Propagate().

00465                                                              {
00466   return createTarget(theNucleus.GetA_asInt(), theNucleus.GetZ_asInt());
00467 }

void G4CascadeInterface::DumpConfiguration ( std::ostream &  outFile  )  const [virtual]

Definition at line 178 of file G4CascadeInterface.cc.

References G4CascadeParameters::DumpConfiguration().

00178                                                                     {
00179   G4CascadeParameters::DumpConfiguration(outFile);
00180 }

G4bool G4CascadeInterface::IsApplicable ( const G4ParticleDefinition aPD  )  const

Definition at line 218 of file G4CascadeInterface.cc.

References G4ParticleDefinition::GetAtomicMass(), G4CascadeChannelTables::GetTable(), and G4InuclElementaryParticle::type().

00218                                                                              {
00219   if (aPD->GetAtomicMass() > 1) return true;            // Nuclei are okay
00220 
00221   // Valid particle and have interactions available
00222   G4int type = G4InuclElementaryParticle::type(aPD);
00223   return (type>0 && G4CascadeChannelTables::GetTable(type));
00224 }

G4bool G4CascadeInterface::IsApplicable ( const G4HadProjectile aTrack,
G4Nucleus theNucleus 
) [virtual]

Reimplemented from G4HadronicInteraction.

Definition at line 213 of file G4CascadeInterface.cc.

References G4HadProjectile::GetDefinition().

Referenced by ApplyYourself(), and G4HadronicAbsorptionBertini::IsApplicable().

00214                                                                      {
00215   return IsApplicable(aTrack.GetDefinition());  
00216 }

G4DynamicParticle * G4CascadeInterface::makeDynamicParticle ( const G4InuclNuclei inuc  )  const [protected]

Definition at line 517 of file G4CascadeInterface.cc.

References G4cout, G4endl, G4InuclParticle::getDynamicParticle(), and G4HadronicInteraction::verboseLevel.

00517                                                                        {
00518   if (verboseLevel > 2) {
00519     G4cout << " Nuclei fragment: \n" << inuc << G4endl;
00520   }
00521   
00522   // Copy local G4DynPart to public output 
00523   return new G4DynamicParticle(inuc.getDynamicParticle());
00524 }

G4DynamicParticle * G4CascadeInterface::makeDynamicParticle ( const G4InuclElementaryParticle iep  )  const [protected]

Definition at line 491 of file G4CascadeInterface.cc.

References G4KaonZeroLong::Definition(), G4KaonZeroShort::Definition(), G4cerr, G4endl, G4UniformRand, G4InuclParticle::getDynamicParticle(), G4InuclParticle::getKineticEnergy(), G4InuclParticle::getMomentum(), G4InuclParticleNames::kaonZero, G4InuclParticleNames::kaonZeroBar, G4InuclElementaryParticle::quasi_deutron(), and G4InuclElementaryParticle::type().

Referenced by copyOutputToHadronicResult(), and copyOutputToReactionProducts().

00491                                                                 {
00492   G4int outgoingType = iep.type();
00493   
00494   if (iep.quasi_deutron()) {
00495     G4cerr << " ERROR: G4CascadeInterface incompatible particle type "
00496            << outgoingType << G4endl;
00497     return 0;
00498   }
00499   
00500   // Copy local G4DynPart to public output (handle kaon mixing specially)
00501   if (outgoingType == kaonZero || outgoingType == kaonZeroBar) {
00502     G4ThreeVector momDir = iep.getMomentum().vect().unit();
00503     G4double ekin = iep.getKineticEnergy()*GeV; // Bertini -> G4 units
00504     
00505     G4ParticleDefinition* pd = G4KaonZeroShort::Definition();
00506     if (G4UniformRand() > 0.5) pd = G4KaonZeroLong::Definition();
00507     
00508     return new G4DynamicParticle(pd, momDir, ekin);
00509   } else {
00510     return new G4DynamicParticle(iep.getDynamicParticle());
00511   }
00512   
00513   return 0;     // Should never get here!
00514 }

void G4CascadeInterface::ModelDescription ( std::ostream &  outFile  )  const [virtual]

Reimplemented from G4VIntraNuclearTransportModel.

Definition at line 164 of file G4CascadeInterface.cc.

00165 {
00166   outFile << "The Bertini-style cascade implements the inelastic scattering\n"
00167           << "of hadrons by nuclei.  Nucleons, pions, kaons and hyperons\n"
00168           << "from 0 to 15 GeV may be used as projectiles in this model.\n"
00169           << "Final state hadrons are produced by a classical cascade\n"
00170           << "consisting of individual hadron-nucleon scatterings which use\n"
00171           << "free-space partial cross sections, corrected for various\n"
00172           << "nuclear medium effects.  The target nucleus is modeled as a\n"
00173           << "set of 1, 3 or 6 spherical shells, in which scattered hadrons\n"
00174           << "travel in straight lines until they are reflected from or\n"
00175           << "transmitted through shell boundaries.\n";
00176 }

G4HadFinalState * G4CascadeInterface::NoInteraction ( const G4HadProjectile aTrack,
G4Nucleus theNucleus 
) [protected]

Definition at line 398 of file G4CascadeInterface.cc.

References G4HadFinalState::Clear(), G4cout, G4endl, G4HadProjectile::GetKineticEnergy(), isAlive, G4HadFinalState::SetEnergyChange(), G4HadFinalState::SetStatusChange(), G4HadronicInteraction::theParticleChange, and G4HadronicInteraction::verboseLevel.

Referenced by ApplyYourself().

00399                                                              {
00400   if (verboseLevel) 
00401     G4cout << " >>> G4CascadeInterface::NoInteraction" << G4endl;
00402 
00403   theParticleChange.Clear();
00404   theParticleChange.SetStatusChange(isAlive);
00405 
00406   G4double ekin = aTrack.GetKineticEnergy()>0. ? aTrack.GetKineticEnergy() : 0.;
00407   theParticleChange.SetEnergyChange(ekin);      // Protect against rounding
00408 
00409   return &theParticleChange;
00410 }

G4ReactionProductVector * G4CascadeInterface::Propagate ( G4KineticTrackVector theSecondaries,
G4V3DNucleus theNucleus 
) [virtual]

Implements G4VIntraNuclearTransportModel.

Definition at line 323 of file G4CascadeInterface.cc.

References clear(), G4HadFinalState::Clear(), G4CascadeCheckBalance::collide(), copyOutputToReactionProducts(), createBullet(), createTarget(), G4cerr, G4cout, G4endl, G4V3DNucleus::GetCharge(), G4V3DNucleus::GetMassNumber(), G4VIntraNuclearTransportModel::GetPrimaryProjectile(), G4CascadeCheckBalance::okay(), G4CollisionOutput::printCollisionOutput(), G4InuclCollider::rescatter(), G4CollisionOutput::reset(), retryInelasticNucleus(), G4HadronicInteraction::theParticleChange, throwNonConservationFailure(), and G4HadronicInteraction::verboseLevel.

00324                                                         {
00325   if (verboseLevel) G4cout << " >>> G4CascadeInterface::Propagate" << G4endl;
00326 
00327 #ifdef G4CASCADE_DEBUG_INTERFACE
00328   if (verboseLevel>1) {
00329     G4cout << " G4V3DNucleus A " << theNucleus->GetMassNumber()
00330            << " Z " << theNucleus->GetCharge()
00331            << "\n " << theSecondaries->size() << " secondaries:" << G4endl;
00332     for (size_t i=0; i<theSecondaries->size(); i++) {
00333       G4KineticTrack* kt = (*theSecondaries)[i];
00334       G4cout << " " << i << ": " << kt->GetDefinition()->GetParticleName() 
00335              << " p " << kt->Get4Momentum() << " @ " << kt->GetPosition()
00336              << " t " << kt->GetFormationTime() << G4endl;
00337     }
00338   }
00339 #endif
00340 
00341   if (!randomFile.empty()) {            // User requested random-seed capture
00342     if (verboseLevel>1) 
00343       G4cout << " Saving random engine state to " << randomFile << G4endl;
00344     CLHEP::HepRandom::saveEngineStatus(randomFile);
00345   }
00346 
00347   theParticleChange.Clear();
00348   clear();
00349 
00350   // Process input secondaries list to eliminate resonances
00351   G4DecayKineticTracks decay(theSecondaries);
00352 
00353   // NOTE:  Requires 9.4-ref-03 mods to base class and G4TheoFSGenerator
00354   const G4HadProjectile* projectile = GetPrimaryProjectile();
00355   if (projectile) createBullet(*projectile);
00356 
00357   if (!createTarget(theNucleus)) {
00358     if (verboseLevel) G4cerr << " Unable to create usable target" << G4endl;
00359     return 0;   // FIXME:  This will cause a segfault later
00360   }
00361 
00362   numberOfTries = 0;
00363   do {
00364     if (verboseLevel > 1)
00365       G4cout << " Generating rescatter attempt " << numberOfTries << G4endl;
00366 
00367     output->reset();
00368     collider->rescatter(bullet, theSecondaries, theNucleus, *output);
00369     balance->collide(bullet, target, *output);
00370 
00371     numberOfTries++;
00372     // FIXME:  retry checks will SEGFAULT until we can define the bullet!
00373   } while (retryInelasticNucleus());
00374 
00375   // Check whether repeated attempts have all failed; report and exit
00376   if (numberOfTries >= maximumTries && !balance->okay()) {
00377     throwNonConservationFailure();      // This terminates the job
00378   }
00379 
00380   // Successful cascade -- clean up and return
00381   if (verboseLevel) {
00382     G4cout << " Cascade rescatter after trials " << numberOfTries << G4endl;
00383     if (verboseLevel > 1) output->printCollisionOutput();
00384   }
00385 
00386   // Does calling code take ownership?  I hope so!
00387   G4ReactionProductVector* propResult = copyOutputToReactionProducts();
00388 
00389   // Clean up and and return final result
00390   clear();
00391   return propResult;
00392 }

G4bool G4CascadeInterface::retryInelasticNucleus (  )  const [protected]

Definition at line 685 of file G4CascadeInterface.cc.

References coulombBarrierViolation(), G4cout, G4endl, G4InuclParticle::getDefinition(), G4CollisionOutput::getOutgoingParticles(), G4CollisionOutput::numberOfOutgoingNuclei(), G4CollisionOutput::numberOfOutgoingParticles(), and G4CascadeCheckBalance::okay().

Referenced by ApplyYourself(), and Propagate().

00685                                                        {
00686   // Quantities necessary for conditional block below
00687   G4int npart = output->numberOfOutgoingParticles();
00688   G4int nfrag = output->numberOfOutgoingNuclei();
00689 
00690   const G4ParticleDefinition* firstOut = (npart == 0) ? 0 :
00691     output->getOutgoingParticles().begin()->getDefinition();
00692 
00693 #ifdef G4CASCADE_DEBUG_INTERFACE
00694   // Report on all retry conditions, in order of return logic
00695   G4cout << " retryInelasticNucleus: numberOfTries "
00696          << ((numberOfTries < maximumTries) ? "RETRY (t)" : "EXIT (f)")
00697          << "\n retryInelasticNucleus: AND outputParticles "
00698          << ((npart != 0) ? "NON-ZERO (t)" : "EMPTY (f)")
00699 #ifdef G4CASCADE_COULOMB_DEV
00700          << "\n retryInelasticNucleus: AND coulombBarrier (COULOMB_DEV) "
00701          << (coulombBarrierViolation() ? "VIOLATED (t)" : "PASSED (f)")
00702          << "\n retryInelasticNucleus: AND collision type (COULOMB_DEV) "
00703          << ((npart+nfrag > 2) ? "INELASTIC (t)" : "ELASTIC (f)")
00704 #else
00705          << "\n retryInelasticNucleus: AND collsion type "
00706          << ((npart+nfrag < 3) ? "ELASTIC (t)" : "INELASTIC (f)")
00707          << "\n retryInelasticNucleus: AND Leading particle bullet "
00708          << ((firstOut == bullet->getDefinition()) ? "YES (t)" : "NO (f)")
00709 #endif
00710          << "\n retryInelasticNucleus: OR conservation "
00711          << (!balance->okay() ? "FAILED (t)" : "PASSED (f)")
00712          << G4endl;
00713 #endif
00714 
00715   return ( ((numberOfTries < maximumTries) &&
00716             (npart != 0) &&
00717 #ifdef G4CASCADE_COULOMB_DEV
00718             (coulombBarrierViolation() && npart+nfrag > 2)
00719 #else
00720             (npart+nfrag < 3 && firstOut == bullet->getDefinition())
00721 #endif
00722             )
00723 #ifndef G4CASCADE_SKIP_ECONS
00724            || (!balance->okay())
00725 #endif
00726            );
00727 }

G4bool G4CascadeInterface::retryInelasticProton (  )  const [protected]

Definition at line 653 of file G4CascadeInterface.cc.

References G4cout, G4endl, G4InuclParticle::getDefinition(), and G4CollisionOutput::getOutgoingParticles().

Referenced by ApplyYourself().

00653                                                       {
00654   const std::vector<G4InuclElementaryParticle>& out =
00655     output->getOutgoingParticles();
00656 
00657 #ifdef G4CASCADE_DEBUG_INTERFACE
00658   // Report on all retry conditions, in order of return logic
00659   G4cout << " retryInelasticProton: number of Tries "
00660          << ((numberOfTries < maximumTries) ? "RETRY (t)" : "EXIT (f)")
00661          << "\n retryInelasticProton: AND collision type ";
00662   if (out.empty()) G4cout << "FAILED" << G4endl;
00663   else {
00664     G4cout << (out.size() == 2 ? "ELASTIC (t)" : "INELASTIC (f)")
00665            << "\n retryInelasticProton: AND Leading particles bullet "
00666            << (out.size() >= 2 &&
00667                (out[0].getDefinition() == bullet->getDefinition() ||
00668                 out[1].getDefinition() == bullet->getDefinition())
00669                ? "YES (t)" : "NO (f)")
00670            << G4endl;
00671   }
00672 #endif
00673 
00674   return ( (numberOfTries < maximumTries) &&
00675            (out.empty() ||
00676             (out.size() == 2 &&
00677              (out[0].getDefinition() == bullet->getDefinition() ||
00678               out[1].getDefinition() == bullet->getDefinition())))
00679            );
00680 }

void G4CascadeInterface::SetVerboseLevel ( G4int  verbose  ) 

Reimplemented from G4HadronicInteraction.

Definition at line 203 of file G4CascadeInterface.cc.

References G4CollisionOutput::setVerboseLevel(), G4VCascadeCollider::setVerboseLevel(), G4InuclCollider::setVerboseLevel(), and G4HadronicInteraction::SetVerboseLevel().

Referenced by G4CascadeInterface().

00203                                                       {
00204   G4HadronicInteraction::SetVerboseLevel(verbose);
00205   collider->setVerboseLevel(verbose);
00206   balance->setVerboseLevel(verbose);
00207   output->setVerboseLevel(verbose);
00208 }

void G4CascadeInterface::throwNonConservationFailure (  )  [protected]

Definition at line 733 of file G4CascadeInterface.cc.

References G4CascadeCheckBalance::baryonOkay(), G4CascadeCheckBalance::chargeOkay(), G4CascadeCheckBalance::deltaB(), G4CascadeCheckBalance::deltaE(), G4CascadeCheckBalance::deltaP(), G4CascadeCheckBalance::deltaQ(), G4CascadeCheckBalance::energyOkay(), G4cerr, G4endl, G4CascadeCheckBalance::momentumOkay(), G4CollisionOutput::printCollisionOutput(), G4CascadeCheckBalance::relativeE(), and G4CascadeCheckBalance::relativeP().

Referenced by ApplyYourself(), and Propagate().

00733                                                      {
00734   // NOTE:  Once G4HadronicException is changed, use the following line!
00735   // G4ExceptionDescription errInfo;
00736   std::ostream& errInfo = G4cerr;
00737 
00738   errInfo << " >>> G4CascadeInterface has non-conserving"
00739           << " cascade after " << numberOfTries << " attempts." << G4endl;
00740 
00741   G4String throwMsg = "G4CascadeInterface - ";
00742   if (!balance->energyOkay()) {
00743     throwMsg += "Energy";
00744     errInfo << " Energy conservation violated by " << balance->deltaE()
00745             << " GeV (" << balance->relativeE() << ")" << G4endl;
00746   }
00747   
00748   if (!balance->momentumOkay()) {
00749     throwMsg += "Momentum";
00750     errInfo << " Momentum conservation violated by " << balance->deltaP()
00751             << " GeV/c (" << balance->relativeP() << ")" << G4endl;
00752   }
00753   
00754   if (!balance->baryonOkay()) {
00755     throwMsg += "Baryon number";
00756     errInfo << " Baryon number violated by " << balance->deltaB() << G4endl;
00757   }
00758   
00759   if (!balance->chargeOkay()) {
00760     throwMsg += "Charge";
00761     errInfo << " Charge conservation violated by " << balance->deltaQ()
00762             << G4endl;
00763   }
00764 
00765   errInfo << " Final event output, for debugging:\n"
00766          << " Bullet:  \n" << *bullet << G4endl
00767          << " Target:  \n" << *target << G4endl;
00768   output->printCollisionOutput(errInfo);
00769   
00770   throwMsg += " non-conservation. More info in output.";
00771   throw G4HadronicException(__FILE__, __LINE__, throwMsg);   // Job ends here!
00772 }

void G4CascadeInterface::useCascadeDeexcitation (  ) 

Definition at line 192 of file G4CascadeInterface.cc.

References G4InuclCollider::useCascadeDeexcitation().

00192                                                 {
00193   collider->useCascadeDeexcitation();
00194 }

void G4CascadeInterface::usePreCompoundDeexcitation (  ) 

Definition at line 196 of file G4CascadeInterface.cc.

References G4InuclCollider::usePreCompoundDeexcitation().

Referenced by G4CascadeInterface(), and G4HadronicAbsorptionBertini::G4HadronicAbsorptionBertini().

00196                                                     {
00197   collider->usePreCompoundDeexcitation();
00198 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:35 2013 for Geant4 by  doxygen 1.4.7