source: trunk/source/processes/hadronic/models/chiral_inv_phase_space/interface/src/G4QElastic.cc @ 836

Last change on this file since 836 was 819, checked in by garnier, 16 years ago

import all except CVS

File size: 28.0 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// $Id: G4QElastic.cc,v 1.25 2007/11/15 09:36:43 mkossov Exp $
27// GEANT4 tag $Name:  $
28//
29//      ---------------- G4QElastic class -----------------
30//                 by Mikhail Kossov, December 2003.
31// G4QElastic class of the CHIPS Simulation Branch in GEANT4
32// ---------------------------------------------------------------
33// ****************************************************************************************
34// ********** This CLASS is temporary moved from the photolepton_hadron directory *********
35// ****************************************************************************************
36
37//#define debug
38//#define pdebug
39//#define tdebug
40//#define nandebug
41//#define ppdebug
42
43#include "G4QElastic.hh"
44
45// Initialization of static vectors
46G4int    G4QElastic::nPartCWorld=152;        // The#of particles initialized in CHIPS World
47std::vector<G4int> G4QElastic::ElementZ;              // Z of the element(i) in theLastCalc
48std::vector<G4double> G4QElastic::ElProbInMat;        // SumProbabilityElements in Material
49std::vector<std::vector<G4int>*> G4QElastic::ElIsoN;       // N of isotope(j) of Element(i)
50std::vector<std::vector<G4double>*>G4QElastic::IsoProbInEl;//SumProbabIsotopes inElementI
51
52// Constructor
53G4QElastic::G4QElastic(const G4String& processName) : G4VDiscreteProcess(processName)
54{
55#ifdef debug
56  G4cout<<"G4QElastic::Constructor is called processName="<<processName<<G4endl;
57#endif
58  if (verboseLevel>0) G4cout << GetProcessName() << " process is created "<< G4endl;
59
60  //G4QCHIPSWorld::Get()->GetParticles(nPartCWorld); // Create CHIPS World (234 part. max)
61}
62
63// Destructor
64G4QElastic::~G4QElastic() {}
65
66
67G4LorentzVector G4QElastic::GetEnegryMomentumConservation() {return EnMomConservation;}
68
69G4int G4QElastic::GetNumberOfNeutronsInTarget() {return nOfNeutrons;}
70
71// output of the function must be in units of length! L=1/sig_V,sig_V=SUM(n(j,i)*sig(j,i)),
72// where n(i,j) is a number of nuclei of the isotop j of the element i in V=1(lengtUnit^3)
73// ********** All CHIPS cross sections are calculated in the surface units ************
74G4double G4QElastic::GetMeanFreePath(const G4Track& aTrack,G4double Q,G4ForceCondition* Fc)
75{
76  *Fc = NotForced;
77  const G4DynamicParticle* incidentParticle = aTrack.GetDynamicParticle();
78  G4ParticleDefinition* incidentParticleDefinition=incidentParticle->GetDefinition();
79  if( !IsApplicable(*incidentParticleDefinition))
80    G4cout<<"*W*G4QElastic::GetMeanFreePath: is called for notImplementedParticle"<<G4endl;
81  // Calculate the mean Cross Section for the set of Elements(*Isotopes) in the Material
82  G4double Momentum = incidentParticle->GetTotalMomentum(); // 3-momentum of the Particle
83#ifdef debug
84  G4double KinEn = incidentParticle->GetKineticEnergy();
85  G4cout<<"G4QElastic::GetMeanFreePath: kinE="<<KinEn<<",Mom="<<Momentum<<G4endl; // Result
86#endif
87  const G4Material* material = aTrack.GetMaterial();        // Get the current material
88  const G4double* NOfNucPerVolume = material->GetVecNbOfAtomsPerVolume();
89  const G4ElementVector* theElementVector = material->GetElementVector();
90  G4int nE=material->GetNumberOfElements();
91#ifdef debug
92  G4cout<<"G4QElastic::GetMeanFreePath:"<<nE<<" Elem's in theMaterial"<<G4endl;
93#endif
94  G4VQCrossSection* CSmanager=G4QElasticCrossSection::GetPointer();
95  G4int pPDG=0;
96
97  if     (incidentParticleDefinition == G4Proton::Proton()  ) pPDG=2212;
98  else if(incidentParticleDefinition == G4Neutron::Neutron()) pPDG=2112;
99  else G4cout<<"G4QElastic::GetMeanFreePath:only nA & pA are implemented in CHIPS"<<G4endl;
100 
101  G4QIsotope* Isotopes = G4QIsotope::Get(); // Pointer to the G4QIsotopes singleton
102  G4double sigma=0.;                        // Sums over elements for the material
103  G4int IPIE=IsoProbInEl.size();            // How many old elements?
104  if(IPIE) for(G4int ip=0; ip<IPIE; ++ip)   // Clean up the SumProb's of Isotopes (SPI)
105  {
106    std::vector<G4double>* SPI=IsoProbInEl[ip]; // Pointer to the SPI vector
107    SPI->clear();
108    delete SPI;
109    std::vector<G4int>* IsN=ElIsoN[ip];     // Pointer to the N vector
110    IsN->clear();
111    delete IsN;
112  }
113  ElProbInMat.clear();                      // Clean up the SumProb's of Elements (SPE)
114  ElementZ.clear();                         // Clear the body vector for Z of Elements
115  IsoProbInEl.clear();                      // Clear the body vector for SPI
116  ElIsoN.clear();                           // Clear the body vector for N of Isotopes
117  for(G4int i=0; i<nE; ++i)
118  {
119    G4Element* pElement=(*theElementVector)[i]; // Pointer to the current element
120    G4int Z = static_cast<G4int>(pElement->GetZ()); // Z of the Element
121    ElementZ.push_back(Z);                  // Remember Z of the Element
122    G4int isoSize=0;                        // The default for the isoVectorLength is 0
123    G4int indEl=0;                          // Index of non-natural element or 0(default)
124    G4IsotopeVector* isoVector=pElement->GetIsotopeVector(); // Get the predefined IsoVect
125    if(isoVector) isoSize=isoVector->size();// Get size of the existing isotopeVector
126#ifdef debug
127    G4cout<<"G4QElastic::GetMeanFreePath: isovectorLength="<<isoSize<<G4endl; // Result
128#endif
129    if(isoSize)                             // The Element has non-trivial abundance set
130    {
131      indEl=pElement->GetIndex()+1;         // Index of the non-trivial element is an order
132#ifdef debug
133      G4cout<<"G4QEl::GetMFP: iE="<<indEl<<", def="<<Isotopes->IsDefined(Z,indEl)<<G4endl;
134#endif
135      if(!Isotopes->IsDefined(Z,indEl))     // This index is not defined for this Z: define
136      {
137        std::vector<std::pair<G4int,G4double>*>* newAbund =
138                                               new std::vector<std::pair<G4int,G4double>*>;
139        G4double* abuVector=pElement->GetRelativeAbundanceVector();
140        for(G4int j=0; j<isoSize; j++)      // Calculation of abundance vector for isotopes
141        {
142          G4int N=pElement->GetIsotope(j)->GetN()-Z; // N means A=N+Z !
143          if(pElement->GetIsotope(j)->GetZ()!=Z)G4cerr<<"G4QElastic::GetMeanFreePath: Z="
144                                         <<pElement->GetIsotope(j)->GetZ()<<"#"<<Z<<G4endl;
145          G4double abund=abuVector[j];
146                                                                  std::pair<G4int,G4double>* pr= new std::pair<G4int,G4double>(N,abund);
147#ifdef debug
148          G4cout<<"G4QElastic::GetMeanFreePath:pair#="<<j<<",N="<<N<<",ab="<<abund<<G4endl;
149#endif
150          newAbund->push_back(pr);
151                                                  }
152#ifdef debug
153        G4cout<<"G4QElastic::GetMeanFreePath: pairVectorLength="<<newAbund->size()<<G4endl;
154#endif
155        indEl=G4QIsotope::Get()->InitElement(Z,indEl,newAbund); // definition of the newInd
156        for(G4int k=0; k<isoSize; k++) delete (*newAbund)[k];   // Cleaning temporary
157        delete newAbund; // Was "new" in the beginning of the name space
158      }
159    }
160    std::vector<std::pair<G4int,G4double>*>* cs= Isotopes->GetCSVector(Z,indEl);//CSPointer
161    std::vector<G4double>* SPI = new std::vector<G4double>; // Pointer to the SPI vector
162    IsoProbInEl.push_back(SPI);
163    std::vector<G4int>* IsN = new std::vector<G4int>; // Pointer to the N vector
164    ElIsoN.push_back(IsN);
165    G4int nIs=cs->size();                   // A#Of Isotopes in the Element
166#ifdef debug
167    G4cout<<"G4QEl::GMFP:=***=>,#isot="<<nIs<<", Z="<<Z<<", indEl="<<indEl<<G4endl;
168#endif
169    G4double susi=0.;                       // sum of CS over isotopes
170    if(nIs) for(G4int j=0; j<nIs; j++)      // Calculate CS for eachIsotope of El
171    {
172      std::pair<G4int,G4double>* curIs=(*cs)[j]; // A pointer, which is used twice
173      G4int N=curIs->first;                 // #of Neuterons in the isotope j of El i
174      IsN->push_back(N);                    // Remember Min N for the Element
175#ifdef debug
176      G4cout<<"G4QEl::GMFP:*true*,P="<<Momentum<<",Z="<<Z<<",N="<<N<<",PDG="<<pPDG<<G4endl;
177#endif
178                    G4bool ccsf=true;
179      if(Q==-27.) ccsf=false;
180#ifdef debug
181      G4cout<<"G4QEl::GMFP: GetCS #1 j="<<j<<G4endl;
182#endif
183      G4double CSI=CSmanager->GetCrossSection(ccsf,Momentum,Z,N,pPDG);//CS(j,i) for isotope
184
185#ifdef debug
186      G4cout<<"G4QEl::GMFP: jI="<<j<<", Zt="<<Z<<", Nt="<<N<<", Mom="<<Momentum<<", XSec="
187            <<CSI/millibarn<<G4endl;
188#endif
189      curIs->second = CSI;
190      susi+=CSI;                            // Make a sum per isotopes
191      SPI->push_back(susi);                 // Remember summed cross-section
192    } // End of temporary initialization of the cross sections in the G4QIsotope singeltone
193    sigma+=Isotopes->GetMeanCrossSection(Z,indEl)*NOfNucPerVolume[i];//SUM(MeanCS*NOfNperV)
194#ifdef debug
195    G4cout<<"G4QEl::GMFP: <S>="<<Isotopes->GetMeanCrossSection(Z,indEl)<<", AddToSigma="
196          <<Isotopes->GetMeanCrossSection(Z,indEl)*NOfNucPerVolume[i]<<G4endl;
197#endif
198    ElProbInMat.push_back(sigma);
199  } // End of LOOP over Elements
200  // Check that cross section is not zero and return the mean free path
201#ifdef debug
202  G4cout<<"G4QElastic::GetMeanFreePath: MeanFreePath="<<1./sigma<<G4endl;
203#endif
204  if(sigma > 0.) return 1./sigma;                 // Mean path [distance]
205  return DBL_MAX;
206}
207
208
209G4bool G4QElastic::IsApplicable(const G4ParticleDefinition& particle) 
210{
211  if      (particle == *(        G4Proton::Proton()        )) return true;
212  else if (particle == *(       G4Neutron::Neutron()       )) return true;
213  //else if (particle == *(     G4MuonMinus::MuonMinus()     )) return true;
214  //else if (particle == *(       G4TauPlus::TauPlus()       )) return true;
215  //else if (particle == *(      G4TauMinus::TauMinus()      )) return true;
216  //else if (particle == *(      G4Electron::Electron()      )) return true;
217  //else if (particle == *(      G4Positron::Positron()      )) return true;
218  //else if (particle == *(         G4Gamma::Gamma()         )) return true;
219  //else if (particle == *(      G4MuonPlus::MuonPlus()      )) return true;
220  //else if (particle == *(G4AntiNeutrinoMu::AntiNeutrinoMu())) return true;
221  //else if (particle == *(   G4NeutrinoMu::NeutrinoMu()   )) return true;
222  //else if (particle == *(     G4PionMinus::PionMinus()     )) return true;
223  //else if (particle == *(      G4PionPlus::PionPlus()      )) return true;
224  //else if (particle == *(      G4KaonPlus::KaonPlus()      )) return true;
225  //else if (particle == *(     G4KaonMinus::KaonMinus()     )) return true;
226  //else if (particle == *(  G4KaonZeroLong::KaonZeroLong()  )) return true;
227  //else if (particle == *( G4KaonZeroShort::KaonZeroShort() )) return true;
228  //else if (particle == *(        G4Lambda::Lambda()        )) return true;
229  //else if (particle == *(     G4SigmaPlus::SigmaPlus()     )) return true;
230  //else if (particle == *(    G4SigmaMinus::SigmaMinus()    )) return true;
231  //else if (particle == *(     G4SigmaZero::SigmaZero()     )) return true;
232  //else if (particle == *(       G4XiMinus::XiMinus()       )) return true;
233  //else if (particle == *(        G4XiZero::XiZero()        )) return true;
234  //else if (particle == *(    G4OmegaMinus::OmegaMinus()    )) return true;
235  //else if (particle == *(   G4AntiNeutron::AntiNeutron()   )) return true;
236  //else if (particle == *(    G4AntiProton::AntiProton()    )) return true;
237#ifdef debug
238  G4cout<<"***>>G4QElastic::IsApplicable: PDG="<<particle.GetPDGEncoding()<<G4endl;
239#endif
240  return false;
241}
242
243G4VParticleChange* G4QElastic::PostStepDoIt(const G4Track& track, const G4Step& step)
244{
245  //static const G4double mProt=G4Proton::Proton()->GetPDGMass()*GeV; // proton mass (in GeV)
246  //static const G4double mProt= G4QPDGCode(2212).GetMass()*.001;   // CHIPS in GeV
247  //static const G4double mP2=mProt*mProt;                            // squared proton mass
248  //
249  //-------------------------------------------------------------------------------------
250  static G4bool CWinit = true;                       // CHIPS Warld needs to be initted
251  if(CWinit)
252                {
253    CWinit=false;
254    G4QCHIPSWorld::Get()->GetParticles(nPartCWorld); // Create CHIPS World (234 part.max)
255  }
256  //-------------------------------------------------------------------------------------
257  const G4DynamicParticle* projHadron = track.GetDynamicParticle();
258  const G4ParticleDefinition* particle=projHadron->GetDefinition();
259#ifdef debug
260  G4cout<<"G4QElastic::PostStepDoIt: Before the GetMeanFreePath is called In4M="
261        <<projHadron->Get4Momentum()<<" of PDG="<<particle->GetPDGEncoding()<<", Type="
262        <<particle->GetParticleType()<<", Subtp="<<particle->GetParticleSubType()<<G4endl;
263#endif
264  G4ForceCondition cond=NotForced;
265  GetMeanFreePath(track, -27., &cond);                  // @@ ?? jus to update parameters?
266#ifdef debug
267  G4cout<<"G4QElastic::PostStepDoIt: After the GetMeanFreePath is called"<<G4endl;
268#endif
269  G4LorentzVector proj4M=(projHadron->Get4Momentum())/MeV; // Convert to MeV!
270  G4LorentzVector scat4M=proj4M;                      // @@ Must be filled (?)
271  G4double momentum = projHadron->GetTotalMomentum()/MeV; // 3-momentum of the Proj in MeV
272  G4double Momentum = proj4M.rho();                   // @@ Just for the test purposes
273  if(std::fabs(Momentum-momentum)>.000001)
274           G4cerr<<"*War*G4QElastic::PostStepDoIt:P(IU)="<<Momentum<<"#"<<momentum<<G4endl;
275  G4double pM2=proj4M.m2();        // in MeV^2
276  G4double pM=std::sqrt(pM2);      // in MeV
277#ifdef pdebug
278  G4cout<<"G4QElastic::PostStepDoIt: pP(IU)="<<Momentum<<"="<<momentum<<",pM="<<pM
279        <<",scat4M="<<scat4M<<scat4M.m()<<G4endl;
280#endif
281  if (!IsApplicable(*particle))  // Check applicability
282  {
283    G4cerr<<"G4QElastic::PostStepDoIt: Only NA elastic is implemented."<<G4endl;
284    return 0;
285  }
286  const G4Material* material = track.GetMaterial();      // Get the current material
287  G4int Z=0;
288  const G4ElementVector* theElementVector = material->GetElementVector();
289  G4int nE=material->GetNumberOfElements();
290#ifdef debug
291  G4cout<<"G4QElastic::PostStepDoIt: "<<nE<<" elements in the material."<<G4endl;
292#endif
293  G4int projPDG=0;                           // PDG Code prototype for the captured hadron
294  // Not all these particles are implemented yet (see Is Applicable)
295  if      (particle ==          G4Proton::Proton()         ) projPDG= 2212;
296  else if (particle ==         G4Neutron::Neutron()        ) projPDG= 2112;
297  //else if (particle ==       G4PionMinus::PionMinus()      ) projPDG= -211;
298  //else if (particle ==        G4PionPlus::PionPlus()       ) projPDG=  211;
299  //else if (particle ==        G4KaonPlus::KaonPlus()       ) projPDG= 2112;
300  //else if (particle ==       G4KaonMinus::KaonMinus()      ) projPDG= -321;
301  //else if (particle ==    G4KaonZeroLong::KaonZeroLong()   ) projPDG=  130;
302  //else if (particle ==   G4KaonZeroShort::KaonZeroShort()  ) projPDG=  310;
303  //else if (particle ==        G4MuonPlus::MuonPlus()       ) projPDG=  -13;
304  //else if (particle ==       G4MuonMinus::MuonMinus()      ) projPDG=   13;
305  //else if (particle ==      G4NeutrinoMu::NeutrinoMu()     ) projPDG=   14;
306  //else if (particle ==  G4AntiNeutrinoMu::AntiNeutrinoMu() ) projPDG=  -14;
307  //else if (particle ==        G4Electron::Electron()       ) projPDG=   11;
308  //else if (particle ==        G4Positron::Positron()       ) projPDG=  -11;
309  //else if (particle ==       G4NeutrinoE::NeutrinoE()      ) projPDG=   12;
310  //else if (particle ==   G4AntiNeutrinoE::AntiNeutrinoE()  ) projPDG=  -12;
311  //else if (particle ==           G4Gamma::Gamma()          ) projPDG=   22;
312  //else if (particle ==         G4TauPlus::TauPlus()        ) projPDG=  -15;
313  //else if (particle ==        G4TauMinus::TauMinus()       ) projPDG=   15;
314  //else if (particle ==     G4NeutrinoTau::NeutrinoTau()    ) projPDG=   16;
315  //else if (particle == G4AntiNeutrinoTau::AntiNeutrinoTau()) projPDG=  -16;
316  //else if (particle ==          G4Lambda::Lambda()         ) projPDG= 3122;
317  //else if (particle ==       G4SigmaPlus::SigmaPlus()      ) projPDG= 3222;
318  //else if (particle ==      G4SigmaMinus::SigmaMinus()     ) projPDG= 3112;
319  //else if (particle ==       G4SigmaZero::SigmaZero()      ) projPDG= 3212;
320  //else if (particle ==         G4XiMinus::XiMinus()        ) projPDG= 3312;
321  //else if (particle ==          G4XiZero::XiZero()         ) projPDG= 3322;
322  //else if (particle ==      G4OmegaMinus::OmegaMinus()     ) projPDG= 3334;
323  //else if (particle ==     G4AntiNeutron::AntiNeutron()    ) projPDG=-2112;
324  //else if (particle ==      G4AntiProton::AntiProton()     ) projPDG=-2212;
325#ifdef debug
326  G4int prPDG=particle->GetPDGEncoding();
327                G4cout<<"G4QElastic::PostStepDoIt: projPDG="<<projPDG<<", stPDG="<<prPDG<<G4endl;
328#endif
329  if(!projPDG)
330  {
331    G4cerr<<"*Warning*G4QElastic::PostStepDoIt: Undefined interacting hadron"<<G4endl;
332    return 0;
333  }
334  G4int EPIM=ElProbInMat.size();
335#ifdef debug
336                G4cout<<"G4QElastic::PostStDoIt:m="<<EPIM<<",n="<<nE<<",T="<<ElProbInMat[EPIM-1]<<G4endl;
337#endif
338  G4int i=0;
339  if(EPIM>1)
340  {
341    G4double rnd = ElProbInMat[EPIM-1]*G4UniformRand();
342    for(i=0; i<nE; ++i)
343                  {
344#ifdef debug
345                                  G4cout<<"G4QElastic::PostStepDoIt:EPM["<<i<<"]="<<ElProbInMat[i]<<",r="<<rnd<<G4endl;
346#endif
347      if (rnd<ElProbInMat[i]) break;
348    }
349    if(i>=nE) i=nE-1;                        // Top limit for the Element
350  }
351  G4Element* pElement=(*theElementVector)[i];
352  Z=static_cast<G4int>(pElement->GetZ());
353#ifdef debug
354                                G4cout<<"G4QElastic::PostStepDoIt: i="<<i<<", Z(element)="<<Z<<G4endl;
355#endif
356  if(Z<=0)
357  {
358    G4cerr<<"---Warning---G4QElastic::PostStepDoIt: Element with Z="<<Z<<G4endl;
359    if(Z<0) return 0;
360  }
361  std::vector<G4double>* SPI = IsoProbInEl[i];// Vector of summedProbabilities for isotopes
362  std::vector<G4int>* IsN = ElIsoN[i];     // Vector of "#of neutrons" in the isotope El[i]
363  G4int nofIsot=SPI->size();               // #of isotopes in the element i
364#ifdef debug
365                G4cout<<"G4QElastic::PosStDoIt: nI="<<nofIsot<<",T="<<(*SPI)[nofIsot-1]<<G4endl;
366#endif
367  G4int j=0;
368  if(nofIsot>1)
369  {
370    G4double rndI=(*SPI)[nofIsot-1]*G4UniformRand(); // Randomize the isotop of the Element
371    for(j=0; j<nofIsot; ++j)
372    {
373#ifdef debug
374                                  G4cout<<"G4QElastic::PostStepDoIt: SP["<<j<<"]="<<(*SPI)[j]<<", r="<<rndI<<G4endl;
375#endif
376      if(rndI < (*SPI)[j]) break;
377    }
378    if(j>=nofIsot) j=nofIsot-1;            // Top limit for the isotope
379  }
380  G4int N =(*IsN)[j]; ;                    // Randomized number of neutrons
381#ifdef debug
382                G4cout<<"G4QElastic::PostStepDoIt: j="<<i<<", N(isotope)="<<N<<", MeV="<<MeV<<G4endl;
383#endif
384  if(N<0)
385  {
386    G4cerr<<"*Warning*G4QElastic::PostStepDoIt: Isotope with Z="<<Z<<", 0>N="<<N<<G4endl;
387    return 0;
388  }
389  nOfNeutrons=N;                           // Remember it for the energy-momentum check
390#ifdef debug
391  G4cout<<"G4QElastic::PostStepDoIt: N="<<N<<" for element with Z="<<Z<<G4endl;
392#endif
393  if(N<0)
394  {
395    G4cerr<<"*Warning*G4QElastic::PostStepDoIt:Element with N="<<N<< G4endl;
396    return 0;
397  }
398  aParticleChange.Initialize(track);
399#ifdef debug
400  G4cout<<"G4QElastic::PostStepDoIt: track is initialized"<<G4endl;
401#endif
402  G4double weight        = track.GetWeight();
403  G4double localtime     = track.GetGlobalTime();
404  G4ThreeVector position = track.GetPosition();
405#ifdef debug
406  G4cout<<"G4QElastic::PostStepDoIt: before Touchable extraction"<<G4endl;
407#endif
408  G4TouchableHandle trTouchable = track.GetTouchableHandle();
409#ifdef debug
410  G4cout<<"G4QElastic::PostStepDoIt: Touchable is extracted"<<G4endl;
411#endif
412  //
413  G4int targPDG=90000000+Z*1000+N;         // CHIPS PDG Code of the target nucleus
414  G4QPDGCode targQPDG(targPDG);         // @@ one can use G4Ion and get rid of CHIPS World
415  G4double tM=targQPDG.GetMass();          // CHIPS target mass in MeV
416  G4double kinEnergy= projHadron->GetKineticEnergy()*MeV; // Kin energy in MeV (Is *MeV n?)
417  G4ParticleMomentum dir = projHadron->GetMomentumDirection();// It is a unit three-vector
418  G4LorentzVector tot4M=proj4M+G4LorentzVector(0.,0.,0.,tM); // Total 4-mom of the reaction
419#ifdef debug
420  G4cout<<"G4QElastic::PostStepDoIt: tM="<<tM<<", p4M="<<proj4M<<", t4M="<<tot4M<<G4endl;
421#endif
422  EnMomConservation=tot4M;                 // Total 4-mom of reaction for E/M conservation
423  G4VQCrossSection* CSmanager=G4QElasticCrossSection::GetPointer();
424  // @@ Probably this is not necessary any more
425#ifdef debug
426  G4cout<<"G4QElas::PSDI:false,P="<<Momentum<<",Z="<<Z<<",N="<<N<<",PDG="<<projPDG<<G4endl;
427#endif
428  G4double xSec=CSmanager->GetCrossSection(false, Momentum, Z, N, projPDG);// Rec.CrossSect
429#ifdef debug
430  G4cout<<"G4QElast::PSDI:pPDG="<<projPDG<<",P="<<Momentum<<",CS="<<xSec/millibarn<<G4endl;
431#endif
432#ifdef nandebug
433  if(xSec>0. || xSec<0. || xSec==0);
434  else  G4cout<<"*Warning*G4QElastic::PostStDoIt: xSec="<<xSec/millibarn<<G4endl;
435#endif
436  // @@ check a possibility to separate p, n, or alpha (!)
437  if(xSec <= 0.) // The cross-section iz 0 -> Do Nothing
438  {
439#ifdef pdebug
440    G4cerr<<"*Warning*G4QElastic::PostStDoIt: *Zero cross-section* PDG="<<projPDG<<",tPDG="
441          <<targPDG<<",P="<<Momentum<<G4endl;
442#endif
443    //Do Nothing Action insead of the reaction
444    aParticleChange.ProposeEnergy(kinEnergy);
445    aParticleChange.ProposeLocalEnergyDeposit(0.);
446    aParticleChange.ProposeMomentumDirection(dir) ;
447    return G4VDiscreteProcess::PostStepDoIt(track,step);
448  }
449  G4double mint=CSmanager->GetExchangeT(Z,N,projPDG); // functional randomized -t in MeV^2
450#ifdef pdebug
451  G4cout<<"G4QElast::PSDI:pPDG="<<projPDG<<",tPDG="<<targPDG<<",P="<<Momentum<<",CS="
452        <<xSec<<",-t="<<mint<<G4endl;
453#endif
454#ifdef nandebug
455  if(mint>-.0000001);
456  else  G4cout<<"*Warning*G4QElastic::PostStDoIt:-t="<<mint<<G4endl;
457#endif
458  //G4double cost=1.-mint/twop2cm;              // cos(theta) in CMS
459  G4double cost=1.-mint/CSmanager->GetHMaxT();// cos(theta) in CMS
460  //
461#ifdef ppdebug
462  G4cout<<"G4QElastic::PoStDoI:t="<<mint<<",dpcm2="<<CSmanager->GetHMaxT()<<",Ek="
463        <<kinEnergy<<",tM="<<tM<<",pM="<<pM<<",cost="<<cost<<G4endl;
464#endif
465  if(cost>1. || cost<-1. || !(cost>-1. || cost<1.))
466  {
467    if(cost>1.000001 || cost<-1.000001 || !(cost>-1. || cost<1.))
468    {
469      G4double tM2=tM*tM;                         // Squared target mass
470      G4double pEn=pM+kinEnergy;                  // tot projectile Energy in MeV
471      G4double sM=(tM+tM)*pEn+tM2+pM2;            // Mondelstam s
472      G4double twop2cm=(tM2+tM2)*(pEn*pEn-pM2)/sM;// Max_t/2 (2*p^2_cm)
473      G4cout<<"*Warning*G4QElastic::PostStepDoIt:cos="<<cost<<",t="<<mint<<",T="<<kinEnergy
474            <<",tM="<<tM<<",tmax="<<2*kinEnergy*tM<<",p="<<projPDG<<",t="<<targPDG<<G4endl;
475      G4cout<<"..G4QElastic::PoStDoI: dpcm2="<<twop2cm<<"="<<CSmanager->GetHMaxT()<<G4endl;
476    }
477    if     (cost>1.)  cost=1.;
478    else if(cost<-1.) cost=-1.;
479  }
480  G4LorentzVector reco4M=G4LorentzVector(0.,0.,0.,tM);      // 4mom of the recoil target
481  G4LorentzVector dir4M=tot4M-G4LorentzVector(0.,0.,0.,(tot4M.e()-tM-pM)*.01);
482  if(!G4QHadron(tot4M).RelDecayIn2(scat4M, reco4M, dir4M, cost, cost))
483  {
484    G4cerr<<"G4QElastic::PSD:t4M="<<tot4M<<",pM="<<pM<<",tM="<<tM<<",cost="<<cost<<G4endl;
485    //G4Exception("G4QElastic::PostStepDoIt:","009",FatalException,"Decay of ElasticComp");
486  }
487#ifdef debug
488  G4cout<<"G4QElastic::PoStDoIt:s4M="<<scat4M<<"+r4M="<<reco4M<<"="<<scat4M+reco4M<<G4endl;
489  G4cout<<"G4QElastic::PoStDoIt: scatE="<<scat4M.e()-pM<<", recoE="<<reco4M.e()-tM<<",d4M="
490        <<tot4M-scat4M-reco4M<<G4endl;
491#endif
492  // Update G4VParticleChange for the scattered projectile
493  G4double finE=scat4M.e()-pM;             // Final kinetic energy of the scattered proton
494  if(finE>0.0) aParticleChange.ProposeEnergy(finE);
495  else
496  {
497    if(finE<-1.e-8 || !(finE>-1.||finE<1.)) // NAN or negative
498      G4cerr<<"*Warning*G4QElastic::PostStDoIt: Zero or negative scattered E="<<finE
499            <<", s4M="<<scat4M<<", r4M="<<reco4M<<", d4M="<<tot4M-scat4M-reco4M<<G4endl;
500    //G4Exception("G4QElastic::PostStDoIt()","009", FatalException," <0 or nan energy");
501    aParticleChange.ProposeEnergy(0.) ;
502    aParticleChange.ProposeTrackStatus(fStopButAlive);
503  }
504  G4ThreeVector findir=scat4M.vect()/scat4M.rho();  // Unit vector in new direction
505  aParticleChange.ProposeMomentumDirection(findir); // new direction for the scattered part
506  EnMomConservation-=scat4M;                        // It must be initialized by (pE+tM,pP)
507  // This is how in general the secondary should be identified
508                G4DynamicParticle* theSec = new G4DynamicParticle; // A secondary for the recoil hadron
509  //G4int targPDG=2212;                      // PDG for the recoil proton @@only for p targ
510  //G4ParticleDefinition* theDefinition=G4Proton::Proton(); // @@ only for p target
511  G4int aA = Z+N;
512#ifdef pdebug
513                G4cout<<"G4QElastic::PostStepDoIt: Ion Z="<<Z<<", A="<<aA<<G4endl;
514#endif
515  G4ParticleDefinition* theDefinition=G4ParticleTable::GetParticleTable()
516                                                                       ->FindIon(Z,aA,0,Z);
517  if(!theDefinition)G4cout<<"*Warning*G4QElastic::PostStepDoIt:drop PDG="<<targPDG<<G4endl;
518#ifdef pdebug
519  G4cout<<"G4QElastic::PostStepDoIt:RecoilName="<<theDefinition->GetParticleName()<<G4endl;
520#endif
521  theSec->SetDefinition(theDefinition);
522
523  EnMomConservation-=reco4M;
524#ifdef tdebug
525  G4cout<<"G4QElastic::PostSDoIt:"<<targPDG<<reco4M<<reco4M.m()<<EnMomConservation<<G4endl;
526#endif
527  theSec->Set4Momentum(reco4M);
528#ifdef debug
529  G4ThreeVector curD=theSec->GetMomentumDirection();
530  G4double curM=theSec->GetMass();
531  G4double curE=theSec->GetKineticEnergy()+curM;
532  G4cout<<"G4QElastic::PSDoIt:p="<<curD<<curD.mag()<<",e="<<curE<<",m="<<curM<<G4endl;
533#endif
534  // Make a recoil nucleus
535  G4Track* aNewTrack = new G4Track(theSec, localtime, position );
536  aNewTrack->SetWeight(weight);                                   //    weighted
537  aNewTrack->SetTouchableHandle(trTouchable);
538  aParticleChange.AddSecondary( aNewTrack );
539#ifdef debug
540    G4cout<<"G4QElastic::PostStepDoIt: **** PostStepDoIt is done ****"<<G4endl;
541#endif
542  return G4VDiscreteProcess::PostStepDoIt(track, step);
543}
544
545// @@ For future improvement @@
546G4double G4QElastic::CalculateXSt(G4bool oxs, G4bool xst, G4double p, G4int Z, G4int N,
547                                  G4int pPDG) 
548{
549  static G4bool init=false;
550  static G4bool first=true;
551  static G4VQCrossSection* CSmanager;
552  if(first)                              // Connection with a singletone
553  {
554    CSmanager=G4QElasticCrossSection::GetPointer();
555    first=false;
556  }
557  G4double res=0.;
558  if(oxs && xst)                         // Only the Cross-Section can be returened
559  {
560    res=CSmanager->GetCrossSection(true, p, Z, N, pPDG); // XS for isotope
561  }
562  else if(!oxs && xst)                   // Calculate Cross-Section & prepare differential
563  {
564    res=CSmanager->GetCrossSection(false, p, Z, N, pPDG);// XS for isotope + init t-distr.
565    // The XS for the nucleus must be calculated the last
566    init=true;
567  }
568  else if(init)                          // Return t-value for scattering (=G4QElastic)
569  {
570    if(oxs) res=CSmanager->GetHMaxT();   // Calculate the max_t value
571                                else res=CSmanager->GetExchangeT(Z, N, pPDG); // functionally randomized -t in MeV^2
572  }
573  else G4cout<<"*Warning*G4QElastic::CalculateXSt:*NotInitiatedScattering"<<G4endl;
574  return res;
575}
Note: See TracBrowser for help on using the repository browser.