Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ProjectileDiffractiveChannel.cc
Go to the documentation of this file.
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$
28 //
29 
30 // Author : Gunter Folger Nov 2007
31 // Class Description
32 // Final state production model for theoretical models of hadron inelastic
33 // projectile diffractive scattering in geant4;
34 // Class Description - End
35 //
36 // Modified:
37 
39 
40 #include "G4HadTmpUtil.hh" //lrint
41 #include "G4QHadronVector.hh"
42 #include "G4ParticleTable.hh"
43 #include "G4IonTable.hh"
44 #include "G4Lambda.hh"
45 
46 //#define debug_getFraction 1
47 //#define debug_scatter 1
48 
50 {
51  theQDiffraction=G4QDiffractionRatio::GetPointer();
52 }
53 
55 {}
56 
58  const G4DynamicParticle & thePrimary)
59 {
60  G4double ratio;
61  ratio=theQDiffraction->GetRatio(thePrimary.GetTotalMomentum(),
62  thePrimary.GetDefinition()->GetPDGEncoding(),
63  theNucleus.GetZ_asInt(), theNucleus.GetN_asInt() );
64  #ifdef debug_getFraction
65  G4cout << "G4ProjectileDiffractiveChannel::ratio " << ratio << G4endl;
66  #endif
67 
68  return ratio;
69 }
70 
72  const G4DynamicParticle & thePrimary)
73 {
74 
75 
76  G4int A=theNucleus.GetA_asInt();
77  G4int Z=theNucleus.GetZ_asInt();
78 
79  G4ParticleDefinition * pDef=thePrimary.GetDefinition();
80  #ifdef debug_scatter
81  G4cout << " ProjectileDiffractive: A, Z, proj-pdg" <<" "<< A <<" "<<Z
82  << " "<<" " << pDef->GetParticleName()<< G4endl;
83  #endif
84 
85  G4QHadronVector * result(0);
86  G4KineticTrackVector * ktv(0);
87  G4bool tryAgain;
88 
89  do {
90  tryAgain = false;
91  result=theQDiffraction->ProjFragment(pDef->GetPDGEncoding(),
92  thePrimary.Get4Momentum(),Z, A-Z);
93 
94  if ( result && result->size() > 0 )
95  {
96  ktv=new G4KineticTrackVector();
97  std::vector<G4QHadron *>::iterator i;
98  #ifdef debug_scatter
99  G4int count(0);
100  #endif
101  for (i=result->begin(); i!=result->end(); i++)
102  {
103  G4int pdgCode=(*i)->GetPDGCode();
104  G4ParticleDefinition * secDef(0);
105  if ( pdgCode < 80000000) { // check if ion; should be 90Million, but 89Million is possible
107  }else {
108  G4int qN = pdgCode % 1000;
109  G4int qZ = (pdgCode/1000) %1000;
110  if ( qZ < 500 && qN < 500){ // protect for delta being coded as/in nucleus
111  secDef = G4ParticleTable::GetParticleTable()->GetIon(qZ,qN+qZ, 0);
112  if ( ! secDef )
113  { // exceptions to the rule!
114  if ( pdgCode == 90000001 ) secDef= G4Neutron::Neutron();
115  if ( pdgCode == 91000000 ) secDef= G4Lambda::Lambda();
116  }
117  }
118  }
119 
120  if ( secDef ){
121 
122  G4ThreeVector pos=(*i)->GetPosition(); //GetPosition returns const &
123  G4LorentzVector mom=(*i)->Get4Momentum();
124 
125  G4KineticTrack * sPrim=new G4KineticTrack(secDef,
126  (*i)->GetFormationTime(), pos, mom);
127  ktv->push_back(sPrim);
128 
129  #ifdef debug_scatter
130  G4cout << "G4ProjectileDiffractive sec # " << ++count << ", "
131  << "ChipsPDGCode=" << pdgCode << ", "
132  << secDef->GetParticleName()
133  << ", time(ns) " << (*i)->GetFormationTime()/ns
134  << ", pos " << pos
135  << ", 4mom " << (*i)->Get4Momentum()
136  << G4endl;
137  #endif
138  } else {
139  #ifdef debug_scatter
140  G4cout << "G4ProjectileDiffractiveChannel: Particle with PDG code "<< pdgCode <<" does not converted!!!"<<G4endl;
141  #endif
142  tryAgain=true;
143  }
144  }
145  std::for_each(result->begin(), result->end(), DeleteQHadron());
146  delete result;
147  result=0;
148  }
149 
150  if ( result ) delete result;
151  if ( tryAgain ) { // QDiffraction returned a "difficult" particle in nucleus
152  std::for_each(ktv->begin(), ktv->end(), DeleteKineticTrack());
153  delete ktv;
154  ktv=0;
155  }
156  } while ( ! ktv);
157 
158  return ktv;
159 }