source: trunk/source/processes/hadronic/models/theo_high_energy/src/G4TheoFSGenerator.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 7.5 KB
Line 
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.11 2009/04/09 08:28:42 mkossov Exp $
28// GEANT4 tag $Name: geant4-09-03-ref-09 $
29//
30// G4TheoFSGenerator
31
32#include "G4DynamicParticle.hh"
33#include "G4TheoFSGenerator.hh"
34#include "G4ReactionProductVector.hh"
35#include "G4ReactionProduct.hh"
36
37G4TheoFSGenerator::G4TheoFSGenerator(const G4String& name)
38    : G4HadronicInteraction(name)
39    , theQuasielastic(0), theProjectileDiffraction(0)
40{
41 theParticleChange = new G4HadFinalState;
42}
43
44G4TheoFSGenerator::G4TheoFSGenerator(const G4TheoFSGenerator &) 
45    : G4HadronicInteraction("TheoFSGenerator")
46    , theQuasielastic(0), theProjectileDiffraction(0)
47{
48}
49
50
51G4TheoFSGenerator::~G4TheoFSGenerator()
52{
53  delete theParticleChange;
54}
55
56
57const 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
65int G4TheoFSGenerator::operator==(const G4TheoFSGenerator &) const
66{
67  return 0;
68}
69
70int G4TheoFSGenerator::operator!=(const G4TheoFSGenerator &) const
71{
72  return 1;
73}
74
75
76G4HadFinalState * 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       //G4cout<<"___G4TheoFSGenerator: before Scatter (1) QE=" << theQuasielastic<<G4endl;
94       G4KineticTrackVector *result= theQuasielastic->Scatter(theNucleus, *aPart);
95       //G4cout << "^^G4TheoFSGenerator: after Scatter (1) " << G4endl;
96       if (result)
97       {
98            for(unsigned int  i=0; i<result->size(); i++)
99            {
100              G4DynamicParticle * aNew = 
101                 new G4DynamicParticle(result->operator[](i)->GetDefinition(),
102                                       result->operator[](i)->Get4Momentum().e(),
103                                       result->operator[](i)->Get4Momentum().vect());
104              theParticleChange->AddSecondary(aNew);
105              delete result->operator[](i);
106            }
107            delete result;
108           
109       } else 
110       {
111            theParticleChange->SetStatusChange(isAlive);
112            theParticleChange->SetEnergyChange(thePrimary.GetKineticEnergy());
113            theParticleChange->SetMomentumChange(thePrimary.Get4Momentum().vect().unit());
114 
115       }
116        return theParticleChange;
117     } 
118  }
119  if ( theProjectileDiffraction) {
120 
121     if ( theProjectileDiffraction->GetFraction(theNucleus, *aPart) > G4UniformRand() )
122      // strictly, this returns fraction on inelastic, so quasielastic should
123        //    already be substracted, ie. quasielastic should always be used
124        //     before diffractive
125     {
126       //G4cout << "____G4TheoFSGenerator: before Scatter (2) " << G4endl;
127       G4KineticTrackVector *result= theProjectileDiffraction->Scatter(theNucleus, *aPart);
128       //G4cout << "^^^^G4TheoFSGenerator: after Scatter (2) " << G4endl;
129        if (result)
130        {
131            for(unsigned int  i=0; i<result->size(); i++)
132            {
133              G4DynamicParticle * aNew = 
134                 new G4DynamicParticle(result->operator[](i)->GetDefinition(),
135                                       result->operator[](i)->Get4Momentum().e(),
136                                       result->operator[](i)->Get4Momentum().vect());
137              theParticleChange->AddSecondary(aNew);
138              delete result->operator[](i);
139            }
140            delete result;
141           
142        } else 
143        {
144            theParticleChange->SetStatusChange(isAlive);
145            theParticleChange->SetEnergyChange(thePrimary.GetKineticEnergy());
146            theParticleChange->SetMomentumChange(thePrimary.Get4Momentum().vect().unit());
147 
148        }
149        return theParticleChange;
150     } 
151  }
152  //G4cout << "____G4TheoFSGenerator: before Scatter (3) " << G4endl;
153  G4KineticTrackVector * theInitialResult =
154               theHighEnergyGenerator->Scatter(theNucleus, *aPart);
155  //G4cout << "^^^^G4TheoFSGenerator: after Scatter (3) " << G4endl;
156 
157  G4ReactionProductVector * theTransportResult = NULL;
158  G4int hitCount = 0;
159  const std::vector<G4Nucleon *> & they = theHighEnergyGenerator->GetWoundedNucleus()->GetNucleons();
160  for(size_t them=0; them<they.size(); them++)
161  {
162    if(they[them]->AreYouHit()) hitCount ++;
163  }
164  if(hitCount != theHighEnergyGenerator->GetWoundedNucleus()->GetMassNumber() )
165  {
166    theTransportResult = 
167               theTransport->Propagate(theInitialResult, theHighEnergyGenerator->GetWoundedNucleus());
168    if ( !theTransportResult ) {
169       G4cout << "G4TheoFSGenerator: null ptr from transport propagate " << G4endl;
170       throw G4HadronicException(__FILE__, __LINE__, "Null ptr from transport propagate");
171    } 
172  }
173  else
174  {
175    theTransportResult = theDecay.Propagate(theInitialResult, theHighEnergyGenerator->GetWoundedNucleus());
176    if ( !theTransportResult ) {
177       G4cout << "G4TheoFSGenerator: null ptr from decay propagate " << G4endl;
178       throw G4HadronicException(__FILE__, __LINE__, "Null ptr from decay propagate");
179    }   
180  }
181
182  // Fill particle change
183  unsigned int i;
184  for(i=0; i<theTransportResult->size(); i++)
185  {
186    G4DynamicParticle * aNew = 
187       new G4DynamicParticle(theTransportResult->operator[](i)->GetDefinition(),
188                             theTransportResult->operator[](i)->GetTotalEnergy(),
189                             theTransportResult->operator[](i)->GetMomentum());
190    // @@@ - overkill? G4double newTime = theParticleChange->GetGlobalTime(theTransportResult->operator[](i)->GetFormationTime());
191    theParticleChange->AddSecondary(aNew);
192    delete theTransportResult->operator[](i);
193  }
194 
195  // some garbage collection
196  delete theTransportResult;
197 
198  // Done
199  return theParticleChange;
200}
201
Note: See TracBrowser for help on using the repository browser.