ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CexmcChargeExchangeProductionModel.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CexmcChargeExchangeProductionModel.hh
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  * =============================================================================
28  *
29  * Filename: CexmcChargeExchangeProductionModel.hh
30  *
31  * Description: charge exchange physics itself
32  *
33  * Version: 1.0
34  * Created: 01.11.2009 00:30:46
35  * Revision: none
36  * Compiler: gcc
37  *
38  * Author: Alexey Radkov (),
39  * Company: PNPI
40  *
41  * =============================================================================
42  */
43 
44 #ifndef CEXMC_CHARGE_EXCHANGE_PRODUCTION_MODEL_HH
45 #define CEXMC_CHARGE_EXCHANGE_PRODUCTION_MODEL_HH
46 
47 #include <G4HadronicInteraction.hh>
48 #include <G4HadFinalState.hh>
49 #include <G4HadProjectile.hh>
50 #include <G4Nucleus.hh>
51 #include <G4Proton.hh>
52 #include <G4Neutron.hh>
53 #include "CexmcProductionModel.hh"
54 #include "CexmcGenbod.hh"
56 #include "CexmcException.hh"
57 
58 
59 template < typename OutputParticle >
62 {
63  public:
65 
67 
68  public:
69  G4HadFinalState * ApplyYourself( const G4HadProjectile & projectile,
70  G4Nucleus & targetNucleus );
71 
72  private:
74 
76 };
77 
78 
79 template < typename OutputParticle >
84  nucleusParticleMass( 0 ), phaseSpaceGenerator( NULL )
85 {
88  outputParticle = OutputParticle::Definition();
90 
92 
97 
99 
100  inVec.push_back( &productionModelData.incidentParticleSCM );
101  inVec.push_back( &productionModelData.nucleusParticleSCM );
102 
104 
105  outVec.push_back( CexmcPhaseSpaceOutVectorElement(
107  outputParticle->GetPDGMass() ) );
108  outVec.push_back( CexmcPhaseSpaceOutVectorElement(
111 
112 #ifdef CEXMC_USE_GENBOD
113  phaseSpaceGenerator = new CexmcGenbod;
114 #else
116 #endif
117 
118  phaseSpaceGenerator->SetParticles( inVec, outVec );
119 }
120 
121 
122 template < typename OutputParticle >
125 {
126  delete phaseSpaceGenerator;
127 }
128 
129 
130 template < typename OutputParticle >
132  ApplyYourself( const G4HadProjectile & projectile,
133  G4Nucleus & targetNucleus )
134 {
135  theParticleChange.Clear();
136 
137  G4double kinEnergy( projectile.GetKineticEnergy() );
138  G4HadProjectile & theProjectile( const_cast< G4HadProjectile & >(
139  projectile ) );
140  const G4LorentzRotation & projToLab(
141  const_cast< const G4LorentzRotation & >(
142  theProjectile.GetTrafoToLab() ) );
143  productionModelData.incidentParticleLAB = projectile.Get4Momentum();
144  productionModelData.incidentParticleLAB.transform( projToLab );
145  productionModelData.nucleusParticleLAB.setPx( 0 );
146  productionModelData.nucleusParticleLAB.setPy( 0 );
147  productionModelData.nucleusParticleLAB.setPz( 0 );
148  productionModelData.nucleusParticleLAB.setE( nucleusParticleMass );
149 
150  if ( fermiMotionIsOn )
151  {
152  G4ThreeVector targetNucleusMomentum(
153  targetNucleus.GetFermiMomentum() );
154  G4double targetNucleusEnergy(
155  std::sqrt( targetNucleusMomentum.mag2() +
156  nucleusParticleMass * nucleusParticleMass ) );
157  productionModelData.nucleusParticleLAB = G4LorentzVector(
158  targetNucleusMomentum, targetNucleusEnergy );
159  }
160  productionModelData.nucleusParticleLAB.transform( projToLab );
161  G4LorentzVector lVecSum( productionModelData.incidentParticleLAB +
162  productionModelData.nucleusParticleLAB );
163  G4ThreeVector boostVec( lVecSum.boostVector() );
164 
165  productionModelData.incidentParticleSCM =
166  productionModelData.incidentParticleLAB;
167  productionModelData.nucleusParticleSCM =
168  productionModelData.nucleusParticleLAB;
169 
170  productionModelData.incidentParticleSCM.boost( -boostVec );
171  productionModelData.nucleusParticleSCM.boost( -boostVec );
172 
173  triggeredAngularRanges.clear();
174 
175  if ( ! phaseSpaceGenerator->CheckKinematics() )
176  {
177  theParticleChange.SetEnergyChange( kinEnergy );
178  theParticleChange.SetMomentumChange(
179  projectile.Get4Momentum().vect().unit());
180  return &theParticleChange;
181  }
182 
183  do
184  {
185  phaseSpaceGenerator->Generate();
186  G4double cosTheta( productionModelData.outputParticleSCM.cosTheta() );
187  for ( CexmcAngularRangeList::iterator k( angularRanges.begin() );
188  k != angularRanges.end(); ++k )
189  {
190  if ( cosTheta <= k->top && cosTheta > k->bottom )
191  triggeredAngularRanges.push_back( CexmcAngularRange(
192  k->top, k->bottom, k->index ) );
193  }
194  } while ( triggeredAngularRanges.empty() );
195 
196  productionModelData.outputParticleLAB =
197  productionModelData.outputParticleSCM;
198  productionModelData.nucleusOutputParticleLAB =
199  productionModelData.nucleusOutputParticleSCM;
200 
201  productionModelData.outputParticleLAB.boost( boostVec );
202  productionModelData.nucleusOutputParticleLAB.boost( boostVec );
203 
204  theParticleChange.SetStatusChange( stopAndKill );
205  theParticleChange.SetEnergyChange( 0.0 );
206 
207  G4DynamicParticle * secOutParticle( new G4DynamicParticle(
208  outputParticle,
209  productionModelData.outputParticleLAB ) );
210  theParticleChange.AddSecondary( secOutParticle );
211  G4DynamicParticle * secNeutron( new G4DynamicParticle(
212  nucleusOutputParticle,
213  productionModelData.nucleusOutputParticleLAB ) );
214  theParticleChange.AddSecondary( secNeutron );
215 
216  /* projectile->GetDefinition() shall always be identical to incidentParticle
217  * as far as CexmcHadronicProcess::IsApplicable() will check that only
218  * incidentParticle is allowed. Here is mostly unnecessary assignment. */
219  productionModelData.incidentParticle = projectile.GetDefinition();
220 
221  return &theParticleChange;
222 }
223 
224 
225 #endif
226