[819] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4TheoFSGenerator.cc,v 1.9 2007/11/13 16:01:36 gunter Exp $ |
---|
[962] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[819] | 29 | // |
---|
| 30 | // G4TheoFSGenerator |
---|
| 31 | |
---|
| 32 | #include "G4DynamicParticle.hh" |
---|
| 33 | #include "G4TheoFSGenerator.hh" |
---|
| 34 | #include "G4ReactionProductVector.hh" |
---|
| 35 | #include "G4ReactionProduct.hh" |
---|
| 36 | |
---|
| 37 | G4TheoFSGenerator::G4TheoFSGenerator(const G4String& name) |
---|
| 38 | : G4HadronicInteraction(name) |
---|
| 39 | , theQuasielastic(0), theProjectileDiffraction(0) |
---|
| 40 | { |
---|
| 41 | theParticleChange = new G4HadFinalState; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | G4TheoFSGenerator::G4TheoFSGenerator(const G4TheoFSGenerator &) |
---|
| 45 | : G4HadronicInteraction("TheoFSGenerator") |
---|
| 46 | , theQuasielastic(0), theProjectileDiffraction(0) |
---|
| 47 | { |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | G4TheoFSGenerator::~G4TheoFSGenerator() |
---|
| 52 | { |
---|
| 53 | delete theParticleChange; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | const G4TheoFSGenerator & G4TheoFSGenerator::operator=(const G4TheoFSGenerator &) |
---|
| 58 | { |
---|
| 59 | G4String text = "G4CrossSectionBase::operator= meant to not be accessable"; |
---|
| 60 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
| 61 | return *this; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | int G4TheoFSGenerator::operator==(const G4TheoFSGenerator &) const |
---|
| 66 | { |
---|
| 67 | return 0; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | int G4TheoFSGenerator::operator!=(const G4TheoFSGenerator &) const |
---|
| 71 | { |
---|
| 72 | return 1; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | G4HadFinalState * G4TheoFSGenerator::ApplyYourself(const G4HadProjectile & thePrimary, G4Nucleus &theNucleus) |
---|
| 77 | { |
---|
| 78 | // init particle change |
---|
| 79 | theParticleChange->Clear(); |
---|
| 80 | theParticleChange->SetStatusChange(stopAndKill); |
---|
| 81 | |
---|
| 82 | // check if models have been registered, and use default, in case this is not true @@ |
---|
| 83 | |
---|
| 84 | // get result from high energy model |
---|
| 85 | G4DynamicParticle aTemp(const_cast<G4ParticleDefinition *>(thePrimary.GetDefinition()), |
---|
| 86 | thePrimary.Get4Momentum().vect()); |
---|
| 87 | const G4DynamicParticle * aPart = &aTemp; |
---|
| 88 | |
---|
| 89 | if ( theQuasielastic ) { |
---|
| 90 | |
---|
| 91 | if ( theQuasielastic->GetFraction(theNucleus, *aPart) > G4UniformRand() ) |
---|
| 92 | { |
---|
| 93 | G4KineticTrackVector *result= theQuasielastic->Scatter(theNucleus, *aPart); |
---|
| 94 | if (result) |
---|
| 95 | { |
---|
| 96 | for(unsigned int i=0; i<result->size(); i++) |
---|
| 97 | { |
---|
| 98 | G4DynamicParticle * aNew = |
---|
| 99 | new G4DynamicParticle(result->operator[](i)->GetDefinition(), |
---|
| 100 | result->operator[](i)->Get4Momentum().e(), |
---|
| 101 | result->operator[](i)->Get4Momentum().vect()); |
---|
| 102 | theParticleChange->AddSecondary(aNew); |
---|
| 103 | delete result->operator[](i); |
---|
| 104 | } |
---|
| 105 | delete result; |
---|
| 106 | |
---|
| 107 | } else |
---|
| 108 | { |
---|
| 109 | theParticleChange->SetStatusChange(isAlive); |
---|
| 110 | theParticleChange->SetEnergyChange(thePrimary.GetKineticEnergy()); |
---|
| 111 | theParticleChange->SetMomentumChange(thePrimary.Get4Momentum().vect().unit()); |
---|
| 112 | |
---|
| 113 | } |
---|
| 114 | return theParticleChange; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | if ( theProjectileDiffraction) { |
---|
| 118 | |
---|
| 119 | if ( theProjectileDiffraction->GetFraction(theNucleus, *aPart) > G4UniformRand() ) |
---|
| 120 | // strictly, this returns fraction on inelastic, so quasielastic should |
---|
| 121 | // already be substracted, ie. quasielastic should always be used |
---|
| 122 | // before diffractive |
---|
| 123 | { |
---|
| 124 | G4KineticTrackVector *result= theProjectileDiffraction->Scatter(theNucleus, *aPart); |
---|
| 125 | if (result) |
---|
| 126 | { |
---|
| 127 | for(unsigned int i=0; i<result->size(); i++) |
---|
| 128 | { |
---|
| 129 | G4DynamicParticle * aNew = |
---|
| 130 | new G4DynamicParticle(result->operator[](i)->GetDefinition(), |
---|
| 131 | result->operator[](i)->Get4Momentum().e(), |
---|
| 132 | result->operator[](i)->Get4Momentum().vect()); |
---|
| 133 | theParticleChange->AddSecondary(aNew); |
---|
| 134 | delete result->operator[](i); |
---|
| 135 | } |
---|
| 136 | delete result; |
---|
| 137 | |
---|
| 138 | } else |
---|
| 139 | { |
---|
| 140 | theParticleChange->SetStatusChange(isAlive); |
---|
| 141 | theParticleChange->SetEnergyChange(thePrimary.GetKineticEnergy()); |
---|
| 142 | theParticleChange->SetMomentumChange(thePrimary.Get4Momentum().vect().unit()); |
---|
| 143 | |
---|
| 144 | } |
---|
| 145 | return theParticleChange; |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | G4KineticTrackVector * theInitialResult = |
---|
| 150 | theHighEnergyGenerator->Scatter(theNucleus, *aPart); |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | G4ReactionProductVector * theTransportResult = NULL; |
---|
| 154 | G4int hitCount = 0; |
---|
| 155 | const std::vector<G4Nucleon *> & they = theHighEnergyGenerator->GetWoundedNucleus()->GetNucleons(); |
---|
| 156 | for(size_t them=0; them<they.size(); them++) |
---|
| 157 | { |
---|
| 158 | if(they[them]->AreYouHit()) hitCount ++; |
---|
| 159 | } |
---|
| 160 | if(hitCount != theHighEnergyGenerator->GetWoundedNucleus()->GetMassNumber() ) |
---|
| 161 | { |
---|
| 162 | theTransportResult = |
---|
| 163 | theTransport->Propagate(theInitialResult, theHighEnergyGenerator->GetWoundedNucleus()); |
---|
| 164 | if ( !theTransportResult ) { |
---|
| 165 | G4cout << "G4TheoFSGenerator: null ptr from transport propagate " << G4endl; |
---|
| 166 | throw G4HadronicException(__FILE__, __LINE__, "Null ptr from transport propagate"); |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | theTransportResult = theDecay.Propagate(theInitialResult, theHighEnergyGenerator->GetWoundedNucleus()); |
---|
| 172 | if ( !theTransportResult ) { |
---|
| 173 | G4cout << "G4TheoFSGenerator: null ptr from decay propagate " << G4endl; |
---|
| 174 | throw G4HadronicException(__FILE__, __LINE__, "Null ptr from decay propagate"); |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | // Fill particle change |
---|
| 179 | unsigned int i; |
---|
| 180 | for(i=0; i<theTransportResult->size(); i++) |
---|
| 181 | { |
---|
| 182 | G4DynamicParticle * aNew = |
---|
| 183 | new G4DynamicParticle(theTransportResult->operator[](i)->GetDefinition(), |
---|
| 184 | theTransportResult->operator[](i)->GetTotalEnergy(), |
---|
| 185 | theTransportResult->operator[](i)->GetMomentum()); |
---|
| 186 | // @@@ - overkill? G4double newTime = theParticleChange->GetGlobalTime(theTransportResult->operator[](i)->GetFormationTime()); |
---|
| 187 | theParticleChange->AddSecondary(aNew); |
---|
| 188 | delete theTransportResult->operator[](i); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | // some garbage collection |
---|
| 192 | delete theTransportResult; |
---|
| 193 | |
---|
| 194 | // Done |
---|
| 195 | return theParticleChange; |
---|
| 196 | } |
---|
| 197 | |
---|