Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/lepto_nuclear/src/G4ANuElNucleusCcModel.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lepto_nuclear/src/G4ANuElNucleusCcModel.cc (Version 11.3.0) and /processes/hadronic/models/lepto_nuclear/src/G4ANuElNucleusCcModel.cc (Version 11.1.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // $Id: G4ANuElNucleusCcModel.cc 91806 2015-08     26 // $Id: G4ANuElNucleusCcModel.cc 91806 2015-08-06 12:20:45Z gcosmo $
 27 //                                                 27 //
 28 // Geant4 Header : G4ANuElNucleusCcModel           28 // Geant4 Header : G4ANuElNucleusCcModel
 29 //                                                 29 //
 30 // Author : V.Grichine 12.2.19                     30 // Author : V.Grichine 12.2.19
 31 //                                                 31 //  
 32                                                    32 
 33 #include <iostream>                                33 #include <iostream>
 34 #include <fstream>                                 34 #include <fstream>
 35 #include <sstream>                                 35 #include <sstream>
 36                                                    36 
 37 #include "G4ANuElNucleusCcModel.hh"                37 #include "G4ANuElNucleusCcModel.hh"
 38 // #include "G4NuMuNuclCcDistrKR.hh"               38 // #include "G4NuMuNuclCcDistrKR.hh" 
 39                                                    39 
 40 // #include "G4NuMuResQX.hh"                       40 // #include "G4NuMuResQX.hh" 
 41                                                    41 
 42 #include "G4SystemOfUnits.hh"                      42 #include "G4SystemOfUnits.hh"
 43 #include "G4ParticleTable.hh"                      43 #include "G4ParticleTable.hh"
 44 #include "G4ParticleDefinition.hh"                 44 #include "G4ParticleDefinition.hh"
 45 #include "G4IonTable.hh"                           45 #include "G4IonTable.hh"
 46 #include "Randomize.hh"                            46 #include "Randomize.hh"
 47 #include "G4RandomDirection.hh"                    47 #include "G4RandomDirection.hh"
 48 // #include "G4Threading.hh"                       48 // #include "G4Threading.hh"
 49                                                    49 
 50 // #include "G4Integrator.hh"                      50 // #include "G4Integrator.hh"
 51 #include "G4DataVector.hh"                         51 #include "G4DataVector.hh"
 52 #include "G4PhysicsTable.hh"                       52 #include "G4PhysicsTable.hh"
 53 /*                                                 53 /*
 54 #include "G4CascadeInterface.hh"                   54 #include "G4CascadeInterface.hh"
 55 // #include "G4BinaryCascade.hh"                   55 // #include "G4BinaryCascade.hh"
 56 #include "G4TheoFSGenerator.hh"                    56 #include "G4TheoFSGenerator.hh"
 57 #include "G4LundStringFragmentation.hh"            57 #include "G4LundStringFragmentation.hh"
 58 #include "G4ExcitedStringDecay.hh"                 58 #include "G4ExcitedStringDecay.hh"
 59 #include "G4FTFModel.hh"                           59 #include "G4FTFModel.hh"
 60 // #include "G4BinaryCascade.hh"                   60 // #include "G4BinaryCascade.hh"
 61 #include "G4HadFinalState.hh"                      61 #include "G4HadFinalState.hh"
 62 #include "G4HadSecondary.hh"                       62 #include "G4HadSecondary.hh"
 63 #include "G4HadronicInteractionRegistry.hh"        63 #include "G4HadronicInteractionRegistry.hh"
 64 // #include "G4INCLXXInterface.hh"                 64 // #include "G4INCLXXInterface.hh"
 65 #include "G4QGSModel.hh"                           65 #include "G4QGSModel.hh"
 66 #include "G4QGSMFragmentation.hh"                  66 #include "G4QGSMFragmentation.hh"
 67 #include "G4QGSParticipants.hh"                    67 #include "G4QGSParticipants.hh"
 68 */                                                 68 */
 69 #include "G4KineticTrack.hh"                       69 #include "G4KineticTrack.hh"
 70 #include "G4DecayKineticTracks.hh"                 70 #include "G4DecayKineticTracks.hh"
 71 #include "G4KineticTrackVector.hh"                 71 #include "G4KineticTrackVector.hh"
 72 #include "G4Fragment.hh"                           72 #include "G4Fragment.hh"
 73 #include "G4NucleiProperties.hh"                   73 #include "G4NucleiProperties.hh"
 74 #include "G4ReactionProductVector.hh"              74 #include "G4ReactionProductVector.hh"
 75                                                    75 
 76 #include "G4GeneratorPrecompoundInterface.hh"      76 #include "G4GeneratorPrecompoundInterface.hh"
 77 #include "G4PreCompoundModel.hh"                   77 #include "G4PreCompoundModel.hh"
 78 #include "G4ExcitationHandler.hh"                  78 #include "G4ExcitationHandler.hh"
 79                                                    79 
 80                                                    80 
 81 #include "G4Positron.hh"                           81 #include "G4Positron.hh"
 82 // #include "G4MuonPlus.hh"                        82 // #include "G4MuonPlus.hh"
 83 #include "G4Nucleus.hh"                            83 #include "G4Nucleus.hh"
 84 #include "G4LorentzVector.hh"                      84 #include "G4LorentzVector.hh"
 85                                                    85 
 86 using namespace std;                               86 using namespace std;
 87 using namespace CLHEP;                             87 using namespace CLHEP;
 88                                                    88 
 89 #ifdef G4MULTITHREADED                             89 #ifdef G4MULTITHREADED
 90     G4Mutex G4ANuElNucleusCcModel::numuNucleus     90     G4Mutex G4ANuElNucleusCcModel::numuNucleusModel = G4MUTEX_INITIALIZER;
 91 #endif                                             91 #endif     
 92                                                    92 
 93                                                    93 
 94 G4ANuElNucleusCcModel::G4ANuElNucleusCcModel(c     94 G4ANuElNucleusCcModel::G4ANuElNucleusCcModel(const G4String& name) 
 95   : G4NeutrinoNucleusModel(name)                   95   : G4NeutrinoNucleusModel(name)
 96 {                                                  96 {
 97   thePositron = G4Positron::Positron();            97   thePositron = G4Positron::Positron();
 98   fData = fMaster = false;                         98   fData = fMaster = false;
 99   fMel = electron_mass_c2;                         99   fMel = electron_mass_c2;
100   InitialiseModel();                              100   InitialiseModel();  
101 }                                                 101 }
102                                                   102 
103                                                   103 
104 G4ANuElNucleusCcModel::~G4ANuElNucleusCcModel(    104 G4ANuElNucleusCcModel::~G4ANuElNucleusCcModel()
105 {}                                                105 {}
106                                                   106 
107                                                   107 
108 void G4ANuElNucleusCcModel::ModelDescription(s    108 void G4ANuElNucleusCcModel::ModelDescription(std::ostream& outFile) const
109 {                                                 109 {
110                                                   110 
111     outFile << "G4ANuElNucleusCcModel is a neu    111     outFile << "G4ANuElNucleusCcModel is a neutrino-nucleus (charge current)  scattering\n"
112             << "model which uses the standard     112             << "model which uses the standard model \n"
113             << "transfer parameterization.  Th    113             << "transfer parameterization.  The model is fully relativistic\n";
114                                                   114 
115 }                                                 115 }
116                                                   116 
117 //////////////////////////////////////////////    117 /////////////////////////////////////////////////////////
118 //                                                118 //
119 // Read data from G4PARTICLEXSDATA (locally PA    119 // Read data from G4PARTICLEXSDATA (locally PARTICLEXSDATA)
120                                                   120 
121 void G4ANuElNucleusCcModel::InitialiseModel()     121 void G4ANuElNucleusCcModel::InitialiseModel()
122 {                                                 122 {
123   G4String pName  = "anti_nu_e";                  123   G4String pName  = "anti_nu_e";
124                                                   124   
125   G4int nSize(0), i(0), j(0), k(0);               125   G4int nSize(0), i(0), j(0), k(0);
126                                                   126 
127   if(!fData)                                      127   if(!fData)
128   {                                               128   { 
129 #ifdef G4MULTITHREADED                            129 #ifdef G4MULTITHREADED
130     G4MUTEXLOCK(&numuNucleusModel);               130     G4MUTEXLOCK(&numuNucleusModel);
131     if(!fData)                                    131     if(!fData)
132     {                                             132     { 
133 #endif                                            133 #endif     
134       fMaster = true;                             134       fMaster = true;
135 #ifdef G4MULTITHREADED                            135 #ifdef G4MULTITHREADED
136     }                                             136     }
137     G4MUTEXUNLOCK(&numuNucleusModel);             137     G4MUTEXUNLOCK(&numuNucleusModel);
138 #endif                                            138 #endif
139   }                                               139   }
140                                                   140   
141   if(fMaster)                                     141   if(fMaster)
142   {                                               142   {  
143     const char* path = G4FindDataDir("G4PARTIC    143     const char* path = G4FindDataDir("G4PARTICLEXSDATA");
144     std::ostringstream ost1, ost2, ost3, ost4;    144     std::ostringstream ost1, ost2, ost3, ost4;
145     ost1 << path << "/" << "neutrino" << "/" <    145     ost1 << path << "/" << "neutrino" << "/" << pName << "/xarraycckr";
146                                                   146 
147     std::ifstream filein1( ost1.str().c_str()     147     std::ifstream filein1( ost1.str().c_str() );
148                                                   148 
149     // filein.open("$PARTICLEXSDATA/");           149     // filein.open("$PARTICLEXSDATA/");
150                                                   150 
151     filein1>>nSize;                               151     filein1>>nSize;
152                                                   152 
153     for( k = 0; k < fNbin; ++k )                  153     for( k = 0; k < fNbin; ++k )
154     {                                             154     {
155       for( i = 0; i <= fNbin; ++i )               155       for( i = 0; i <= fNbin; ++i )
156       {                                           156       {
157         filein1 >> fNuMuXarrayKR[k][i];           157         filein1 >> fNuMuXarrayKR[k][i];
158         // G4cout<< fNuMuXarrayKR[k][i] << "      158         // G4cout<< fNuMuXarrayKR[k][i] << "  ";
159       }                                           159       }
160     }                                             160     }
161     // G4cout<<G4endl<<G4endl;                    161     // G4cout<<G4endl<<G4endl;
162                                                   162 
163     ost2 << path << "/" << "neutrino" << "/" <    163     ost2 << path << "/" << "neutrino" << "/" << pName << "/xdistrcckr";
164     std::ifstream  filein2( ost2.str().c_str()    164     std::ifstream  filein2( ost2.str().c_str() );
165                                                   165 
166     filein2>>nSize;                               166     filein2>>nSize;
167                                                   167 
168     for( k = 0; k < fNbin; ++k )                  168     for( k = 0; k < fNbin; ++k )
169     {                                             169     {
170       for( i = 0; i < fNbin; ++i )                170       for( i = 0; i < fNbin; ++i )
171       {                                           171       {
172         filein2 >> fNuMuXdistrKR[k][i];           172         filein2 >> fNuMuXdistrKR[k][i];
173         // G4cout<< fNuMuXdistrKR[k][i] << "      173         // G4cout<< fNuMuXdistrKR[k][i] << "  ";
174       }                                           174       }
175     }                                             175     }
176     // G4cout<<G4endl<<G4endl;                    176     // G4cout<<G4endl<<G4endl;
177                                                   177 
178     ost3 << path << "/" << "neutrino" << "/" <    178     ost3 << path << "/" << "neutrino" << "/" << pName << "/q2arraycckr";
179     std::ifstream  filein3( ost3.str().c_str()    179     std::ifstream  filein3( ost3.str().c_str() );
180                                                   180 
181     filein3>>nSize;                               181     filein3>>nSize;
182                                                   182 
183     for( k = 0; k < fNbin; ++k )                  183     for( k = 0; k < fNbin; ++k )
184     {                                             184     {
185       for( i = 0; i <= fNbin; ++i )               185       for( i = 0; i <= fNbin; ++i )
186       {                                           186       {
187         for( j = 0; j <= fNbin; ++j )             187         for( j = 0; j <= fNbin; ++j )
188         {                                         188         {
189           filein3 >> fNuMuQarrayKR[k][i][j];      189           filein3 >> fNuMuQarrayKR[k][i][j];
190           // G4cout<< fNuMuQarrayKR[k][i][j] <    190           // G4cout<< fNuMuQarrayKR[k][i][j] << "  ";
191         }                                         191         }
192       }                                           192       }
193     }                                             193     }
194     // G4cout<<G4endl<<G4endl;                    194     // G4cout<<G4endl<<G4endl;
195                                                   195 
196     ost4 << path << "/" << "neutrino" << "/" <    196     ost4 << path << "/" << "neutrino" << "/" << pName << "/q2distrcckr";
197     std::ifstream  filein4( ost4.str().c_str()    197     std::ifstream  filein4( ost4.str().c_str() );
198                                                   198 
199     filein4>>nSize;                               199     filein4>>nSize;
200                                                   200 
201     for( k = 0; k < fNbin; ++k )                  201     for( k = 0; k < fNbin; ++k )
202     {                                             202     {
203       for( i = 0; i <= fNbin; ++i )               203       for( i = 0; i <= fNbin; ++i )
204       {                                           204       {
205         for( j = 0; j < fNbin; ++j )              205         for( j = 0; j < fNbin; ++j )
206         {                                         206         {
207           filein4 >> fNuMuQdistrKR[k][i][j];      207           filein4 >> fNuMuQdistrKR[k][i][j];
208           // G4cout<< fNuMuQdistrKR[k][i][j] <    208           // G4cout<< fNuMuQdistrKR[k][i][j] << "  ";
209         }                                         209         }
210       }                                           210       }
211     }                                             211     }
212     fData = true;                                 212     fData = true;
213   }                                               213   }
214 }                                                 214 }
215                                                   215 
216 //////////////////////////////////////////////    216 /////////////////////////////////////////////////////////
217                                                   217 
218 G4bool G4ANuElNucleusCcModel::IsApplicable(con    218 G4bool G4ANuElNucleusCcModel::IsApplicable(const G4HadProjectile & aPart, 
219                    G4Nucleus & )                  219                    G4Nucleus & )
220 {                                                 220 {
221   G4bool result  = false;                         221   G4bool result  = false;
222   G4String pName = aPart.GetDefinition()->GetP    222   G4String pName = aPart.GetDefinition()->GetParticleName();
223   G4double energy = aPart.GetTotalEnergy();       223   G4double energy = aPart.GetTotalEnergy();
224   fMinNuEnergy = GetMinNuElEnergy();              224   fMinNuEnergy = GetMinNuElEnergy();
225                                                   225   
226   if(  pName == "anti_nu_e"                       226   if(  pName == "anti_nu_e"    
227         &&                                        227         &&
228         energy > fMinNuEnergy                     228         energy > fMinNuEnergy                                )
229   {                                               229   {
230     result = true;                                230     result = true;
231   }                                               231   }
232                                                   232 
233   return result;                                  233   return result;
234 }                                                 234 }
235                                                   235 
236 /////////////////////////////////////////// Cl    236 /////////////////////////////////////////// ClusterDecay ////////////////////////////////////////////////////////////
237 //                                                237 //
238 //                                                238 //
239                                                   239 
240 G4HadFinalState* G4ANuElNucleusCcModel::ApplyY    240 G4HadFinalState* G4ANuElNucleusCcModel::ApplyYourself(
241      const G4HadProjectile& aTrack, G4Nucleus&    241      const G4HadProjectile& aTrack, G4Nucleus& targetNucleus)
242 {                                                 242 {
243   theParticleChange.Clear();                      243   theParticleChange.Clear();
244   fProton = f2p2h = fBreak = false;               244   fProton = f2p2h = fBreak = false;
245   fCascade = fString  = false;                    245   fCascade = fString  = false;
246   fLVh = fLVl = fLVt = fLVcpi = G4LorentzVecto    246   fLVh = fLVl = fLVt = fLVcpi = G4LorentzVector(0.,0.,0.,0.);
247                                                   247 
248   const G4HadProjectile* aParticle = &aTrack;     248   const G4HadProjectile* aParticle = &aTrack;
249   G4double energy = aParticle->GetTotalEnergy(    249   G4double energy = aParticle->GetTotalEnergy();
250                                                   250 
251   G4String pName  = aParticle->GetDefinition()    251   G4String pName  = aParticle->GetDefinition()->GetParticleName();
252                                                   252 
253   if( energy < fMinNuEnergy )                     253   if( energy < fMinNuEnergy ) 
254   {                                               254   {
255     theParticleChange.SetEnergyChange(energy);    255     theParticleChange.SetEnergyChange(energy);
256     theParticleChange.SetMomentumChange(aTrack    256     theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
257     return &theParticleChange;                    257     return &theParticleChange;
258   }                                               258   }
259                                                   259 
260   SampleLVkr( aTrack, targetNucleus);             260   SampleLVkr( aTrack, targetNucleus);
261                                                   261 
262   if( fBreak == true || fEmu < fMel ) // ~5*10    262   if( fBreak == true || fEmu < fMel ) // ~5*10^-6
263   {                                               263   {
264     // G4cout<<"ni, ";                            264     // G4cout<<"ni, ";
265     theParticleChange.SetEnergyChange(energy);    265     theParticleChange.SetEnergyChange(energy);
266     theParticleChange.SetMomentumChange(aTrack    266     theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
267     return &theParticleChange;                    267     return &theParticleChange;
268   }                                               268   }
269                                                   269 
270   // LVs of initial state                         270   // LVs of initial state
271                                                   271 
272   G4LorentzVector lvp1 = aParticle->Get4Moment    272   G4LorentzVector lvp1 = aParticle->Get4Momentum();
273   G4LorentzVector lvt1( 0., 0., 0., fM1 );        273   G4LorentzVector lvt1( 0., 0., 0., fM1 );
274   G4double mPip = G4ParticleTable::GetParticle    274   G4double mPip = G4ParticleTable::GetParticleTable()->FindParticle(211)->GetPDGMass();
275                                                   275 
276   // 1-pi by fQtransfer && nu-energy              276   // 1-pi by fQtransfer && nu-energy
277   G4LorentzVector lvpip1( 0., 0., 0., mPip );     277   G4LorentzVector lvpip1( 0., 0., 0., mPip );
278   G4LorentzVector lvsum, lv2, lvX;                278   G4LorentzVector lvsum, lv2, lvX;
279   G4ThreeVector eP;                               279   G4ThreeVector eP;
280   G4double cost(1.), sint(0.), phi(0.), muMom(    280   G4double cost(1.), sint(0.), phi(0.), muMom(0.), massX2(0.), massX(0.), massR(0.), eCut(0.);
281   G4DynamicParticle* aLept = nullptr; // lepto    281   G4DynamicParticle* aLept = nullptr; // lepton lv
282                                                   282 
283   G4int Z = targetNucleus.GetZ_asInt();           283   G4int Z = targetNucleus.GetZ_asInt();
284   G4int A = targetNucleus.GetA_asInt();           284   G4int A = targetNucleus.GetA_asInt();
285   G4double  mTarg = targetNucleus.AtomicMass(A    285   G4double  mTarg = targetNucleus.AtomicMass(A,Z);
286   G4int pdgP(0), qB(0);                           286   G4int pdgP(0), qB(0);
287   // G4double mSum = G4ParticleTable::GetParti    287   // G4double mSum = G4ParticleTable::GetParticleTable()->FindParticle(2212)->GetPDGMass() + mPip;
288                                                   288 
289   G4int iPi     = GetOnePionIndex(energy);        289   G4int iPi     = GetOnePionIndex(energy);
290   G4double p1pi = GetNuMuOnePionProb( iPi, ene    290   G4double p1pi = GetNuMuOnePionProb( iPi, energy);
291                                                   291 
292   if( p1pi > G4UniformRand()  && fCosTheta > 0    292   if( p1pi > G4UniformRand()  && fCosTheta > 0.9  ) // && fQtransfer < 0.95*GeV ) // mu- & coherent pion + nucleus
293   {                                               293   {
294     // lvsum = lvp1 + lvpip1;                     294     // lvsum = lvp1 + lvpip1;
295     lvsum = lvp1 + lvt1;                          295     lvsum = lvp1 + lvt1;
296     // cost = fCosThetaPi;                        296     // cost = fCosThetaPi;
297     cost = fCosTheta;                             297     cost = fCosTheta;
298     sint = std::sqrt( (1.0 - cost)*(1.0 + cost    298     sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
299     phi  = G4UniformRand()*CLHEP::twopi;          299     phi  = G4UniformRand()*CLHEP::twopi;
300     eP   = G4ThreeVector( sint*std::cos(phi),     300     eP   = G4ThreeVector( sint*std::cos(phi), sint*std::sin(phi), cost );
301                                                   301 
302     // muMom = sqrt(fEmuPi*fEmuPi-fMel*fMel);     302     // muMom = sqrt(fEmuPi*fEmuPi-fMel*fMel);
303     muMom = sqrt(fEmu*fEmu-fMel*fMel);            303     muMom = sqrt(fEmu*fEmu-fMel*fMel);
304                                                   304 
305     eP *= muMom;                                  305     eP *= muMom;
306                                                   306 
307     // lv2 = G4LorentzVector( eP, fEmuPi );       307     // lv2 = G4LorentzVector( eP, fEmuPi );
308     // lv2 = G4LorentzVector( eP, fEmu );         308     // lv2 = G4LorentzVector( eP, fEmu );
309     lv2 = fLVl;                                   309     lv2 = fLVl;
310                                                   310 
311     // lvX = lvsum - lv2;                         311     // lvX = lvsum - lv2;
312     lvX = fLVh;                                   312     lvX = fLVh;
313     massX2 = lvX.m2();                            313     massX2 = lvX.m2();
314     massX = lvX.m();                              314     massX = lvX.m();
315     massR = fLVt.m();                             315     massR = fLVt.m();
316                                                   316     
317     if ( massX2 <= 0. ) // vmg: very rarely ~     317     if ( massX2 <= 0. ) // vmg: very rarely ~ (1-4)e-6 due to big Q2/x, to be improved
318     {                                             318     {
319       fCascade = true;                            319       fCascade = true;
320       theParticleChange.SetEnergyChange(energy    320       theParticleChange.SetEnergyChange(energy);
321       theParticleChange.SetMomentumChange(aTra    321       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
322       return &theParticleChange;                  322       return &theParticleChange;
323     }                                             323     }
324     fW2 = massX2;                                 324     fW2 = massX2;
325                                                   325 
326     if(  pName == "anti_nu_e" )         aLept     326     if(  pName == "anti_nu_e" )         aLept = new G4DynamicParticle( thePositron, lv2 );  
327     else                                          327     else
328     {                                             328     {
329       theParticleChange.SetEnergyChange(energy    329       theParticleChange.SetEnergyChange(energy);
330       theParticleChange.SetMomentumChange(aTra    330       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
331       return &theParticleChange;                  331       return &theParticleChange;
332     }                                             332     }
333     if( pName == "anti_nu_e" ) pdgP =  211;       333     if( pName == "anti_nu_e" ) pdgP =  211;
334     // else                   pdgP = -211;        334     // else                   pdgP = -211;
335     // eCut = fMpi + 0.5*(fMpi*fMpi-massX2)/mT    335     // eCut = fMpi + 0.5*(fMpi*fMpi-massX2)/mTarg; // massX -> fMpi
336                                                   336 
337     if( A > 1 )                                   337     if( A > 1 )
338     {                                             338     {
339       eCut = (fMpi + mTarg)*(fMpi + mTarg) - (    339       eCut = (fMpi + mTarg)*(fMpi + mTarg) - (massX + massR)*(massX + massR);
340       eCut /= 2.*massR;                           340       eCut /= 2.*massR;
341       eCut += massX;                              341       eCut += massX;
342     }                                             342     }
343     else  eCut = fM1 + fMpi;                      343     else  eCut = fM1 + fMpi;
344                                                   344 
345     if ( lvX.e() > eCut ) // && sqrt( GetW2()     345     if ( lvX.e() > eCut ) // && sqrt( GetW2() ) < 1.4*GeV ) // 
346     {                                             346     {
347       CoherentPion( lvX, pdgP, targetNucleus);    347       CoherentPion( lvX, pdgP, targetNucleus);
348     }                                             348     }
349     else                                          349     else
350     {                                             350     {
351       fCascade = true;                            351       fCascade = true;
352       theParticleChange.SetEnergyChange(energy    352       theParticleChange.SetEnergyChange(energy);
353       theParticleChange.SetMomentumChange(aTra    353       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
354       return &theParticleChange;                  354       return &theParticleChange;
355     }                                             355     } 
356     theParticleChange.AddSecondary( aLept, fSe    356     theParticleChange.AddSecondary( aLept, fSecID );
357                                                   357 
358     return &theParticleChange;                    358     return &theParticleChange;
359   }                                               359   }
360   else // lepton part in lab                      360   else // lepton part in lab
361   {                                               361   { 
362     lvsum = lvp1 + lvt1;                          362     lvsum = lvp1 + lvt1;
363     cost = fCosTheta;                             363     cost = fCosTheta;
364     sint = std::sqrt( (1.0 - cost)*(1.0 + cost    364     sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
365     phi  = G4UniformRand()*CLHEP::twopi;          365     phi  = G4UniformRand()*CLHEP::twopi;
366     eP   = G4ThreeVector( sint*std::cos(phi),     366     eP   = G4ThreeVector( sint*std::cos(phi), sint*std::sin(phi), cost );
367                                                   367 
368     muMom = sqrt(fEmu*fEmu-fMel*fMel);            368     muMom = sqrt(fEmu*fEmu-fMel*fMel);
369                                                   369 
370     eP *= muMom;                                  370     eP *= muMom;
371                                                   371 
372     lv2 = G4LorentzVector( eP, fEmu );            372     lv2 = G4LorentzVector( eP, fEmu );
373     lv2 = fLVl;                                   373     lv2 = fLVl;
374     lvX = lvsum - lv2;                            374     lvX = lvsum - lv2;
375     lvX = fLVh;                                   375     lvX = fLVh;
376     massX2 = lvX.m2();                            376     massX2 = lvX.m2();
377                                                   377 
378     if ( massX2 <= 0. ) // vmg: very rarely ~     378     if ( massX2 <= 0. ) // vmg: very rarely ~ (1-4)e-6 due to big Q2/x, to be improved
379     {                                             379     {
380       fCascade = true;                            380       fCascade = true;
381       theParticleChange.SetEnergyChange(energy    381       theParticleChange.SetEnergyChange(energy);
382       theParticleChange.SetMomentumChange(aTra    382       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
383       return &theParticleChange;                  383       return &theParticleChange;
384     }                                             384     }
385     fW2 = massX2;                                 385     fW2 = massX2;
386                                                   386 
387     if(  pName == "anti_nu_e" )         aLept     387     if(  pName == "anti_nu_e" )         aLept = new G4DynamicParticle( thePositron, lv2 );  
388     else                                          388     else
389     {                                             389     {
390       theParticleChange.SetEnergyChange(energy    390       theParticleChange.SetEnergyChange(energy);
391       theParticleChange.SetMomentumChange(aTra    391       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
392       return &theParticleChange;                  392       return &theParticleChange;
393     }                                             393     }
394     theParticleChange.AddSecondary( aLept, fSe    394     theParticleChange.AddSecondary( aLept, fSecID );
395   }                                               395   }
396                                                   396 
397   // hadron part                                  397   // hadron part
398                                                   398 
399   fRecoil  = nullptr;                             399   fRecoil  = nullptr;
400                                                   400   
401   if( A == 1 )                                    401   if( A == 1 )
402   {                                               402   {
403     if( pName == "anti_nu_e" ) qB = 2;            403     if( pName == "anti_nu_e" ) qB = 2;
404     // else                   qB = 0;             404     // else                   qB = 0;
405                                                   405 
406     // if( G4UniformRand() > 0.1 ) //  > 0.999    406     // if( G4UniformRand() > 0.1 ) //  > 0.9999 ) // > 0.0001 ) //
407     {                                             407     {
408       ClusterDecay( lvX, qB );                    408       ClusterDecay( lvX, qB );
409     }                                             409     }
410     return &theParticleChange;                    410     return &theParticleChange;
411   }                                               411   }
412     /*                                            412     /*
413     // else                                       413     // else
414     {                                             414     {
415       if( pName == "nu_mu" ) pdgP =  211;         415       if( pName == "nu_mu" ) pdgP =  211;
416       else                   pdgP = -211;         416       else                   pdgP = -211;
417                                                   417 
418                                                   418 
419       if ( fQtransfer < 0.95*GeV ) // < 0.35*G    419       if ( fQtransfer < 0.95*GeV ) // < 0.35*GeV ) //
420       {                                           420       {
421   if( lvX.m() > mSum ) CoherentPion( lvX, pdgP    421   if( lvX.m() > mSum ) CoherentPion( lvX, pdgP, targetNucleus);
422       }                                           422       }
423     }                                             423     }
424     return &theParticleChange;                    424     return &theParticleChange;
425   }                                               425   }
426   */                                              426   */
427   G4Nucleus recoil;                               427   G4Nucleus recoil;
428   G4double ratio = G4double(Z)/G4double(A);    << 428   G4double rM(0.), ratio = G4double(Z)/G4double(A);
429                                                   429 
430   if( ratio > G4UniformRand() ) // proton is e    430   if( ratio > G4UniformRand() ) // proton is excited
431   {                                               431   {
432     fProton = true;                               432     fProton = true;
433     recoil = G4Nucleus(A-1,Z-1);                  433     recoil = G4Nucleus(A-1,Z-1);
434     fRecoil = &recoil;                            434     fRecoil = &recoil;
                                                   >> 435     rM = recoil.AtomicMass(A-1,Z-1);
                                                   >> 436 
435     if( pName == "anti_nu_e" ) // (++) state -    437     if( pName == "anti_nu_e" ) // (++) state -> p + pi+
436     {                                             438     { 
437       fMt = G4ParticleTable::GetParticleTable(    439       fMt = G4ParticleTable::GetParticleTable()->FindParticle(2212)->GetPDGMass()
438           + G4ParticleTable::GetParticleTable(    440           + G4ParticleTable::GetParticleTable()->FindParticle(211)->GetPDGMass();
439     }                                             441     }
440     else // (0) state -> p + pi-, n + pi0         442     else // (0) state -> p + pi-, n + pi0
441     {                                             443     {
442       // fMt = G4ParticleTable::GetParticleTab    444       // fMt = G4ParticleTable::GetParticleTable()->FindParticle(2212)->GetPDGMass()
443       //     + G4ParticleTable::GetParticleTab    445       //     + G4ParticleTable::GetParticleTable()->FindParticle(-211)->GetPDGMass();
444     }                                             446     } 
445   }                                               447   }
446   else // excited neutron                         448   else // excited neutron
447   {                                               449   {
448     fProton = false;                              450     fProton = false;
449     recoil = G4Nucleus(A-1,Z);                    451     recoil = G4Nucleus(A-1,Z);
450     fRecoil = &recoil;                            452     fRecoil = &recoil;
                                                   >> 453     rM = recoil.AtomicMass(A-1,Z);
                                                   >> 454 
451     if( pName == "anti_nu_e" ) // (+) state ->    455     if( pName == "anti_nu_e" ) // (+) state -> n + pi+
452     {                                             456     {      
453       fMt = G4ParticleTable::GetParticleTable(    457       fMt = G4ParticleTable::GetParticleTable()->FindParticle(2112)->GetPDGMass()
454           + G4ParticleTable::GetParticleTable(    458           + G4ParticleTable::GetParticleTable()->FindParticle(211)->GetPDGMass();
455     }                                             459     }
456     else // (-) state -> n + pi-, // n + pi0      460     else // (-) state -> n + pi-, // n + pi0
457     {                                             461     {
458       // fMt = G4ParticleTable::GetParticleTab    462       // fMt = G4ParticleTable::GetParticleTable()->FindParticle(2112)->GetPDGMass()
459       //     + G4ParticleTable::GetParticleTab    463       //     + G4ParticleTable::GetParticleTable()->FindParticle(-211)->GetPDGMass();
460     }                                             464     } 
461   }                                               465   }
462   // G4int       index = GetEnergyIndex(energy    466   // G4int       index = GetEnergyIndex(energy);
463   G4int nepdg = aParticle->GetDefinition()->Ge    467   G4int nepdg = aParticle->GetDefinition()->GetPDGEncoding();
464                                                   468 
465   G4double qeTotRat; //  = GetNuMuQeTotRat(ind    469   G4double qeTotRat; //  = GetNuMuQeTotRat(index, energy);
466   qeTotRat = CalculateQEratioA( Z, A, energy,     470   qeTotRat = CalculateQEratioA( Z, A, energy, nepdg);
467                                                   471 
468   G4ThreeVector dX = (lvX.vect()).unit();         472   G4ThreeVector dX = (lvX.vect()).unit();
469   G4double eX   = lvX.e();  // excited nucleon    473   G4double eX   = lvX.e();  // excited nucleon
470   G4double mX   = sqrt(massX2);                   474   G4double mX   = sqrt(massX2);
471   // G4double pX   = sqrt( eX*eX - mX*mX );       475   // G4double pX   = sqrt( eX*eX - mX*mX );
472   // G4double sumE = eX + rM;                     476   // G4double sumE = eX + rM;
473                                                   477 
474   if( qeTotRat > G4UniformRand() || mX <= fMt     478   if( qeTotRat > G4UniformRand() || mX <= fMt ) // || eX <= 1232.*MeV) // QE
475   {                                               479   {  
476     fString = false;                              480     fString = false;
477                                                   481 
478     G4double rM;                               << 
479     if( fProton )                                 482     if( fProton ) 
480     {                                             483     {  
481       fPDGencoding = 2212;                        484       fPDGencoding = 2212;
482       fMr =  proton_mass_c2;                      485       fMr =  proton_mass_c2;
483       recoil = G4Nucleus(A-1,Z-1);                486       recoil = G4Nucleus(A-1,Z-1);
484       fRecoil = &recoil;                          487       fRecoil = &recoil;
485       rM = recoil.AtomicMass(A-1,Z-1);            488       rM = recoil.AtomicMass(A-1,Z-1);
486     }                                             489     } 
487     else                                          490     else 
488     {                                             491     {  
489       fPDGencoding = 2112;                        492       fPDGencoding = 2112;
490       fMr =   G4ParticleTable::GetParticleTabl    493       fMr =   G4ParticleTable::GetParticleTable()->
491   FindParticle(fPDGencoding)->GetPDGMass(); //    494   FindParticle(fPDGencoding)->GetPDGMass(); // 939.5654133*MeV;
492       recoil = G4Nucleus(A-1,Z);                  495       recoil = G4Nucleus(A-1,Z);
493       fRecoil = &recoil;                          496       fRecoil = &recoil;
494       rM = recoil.AtomicMass(A-1,Z);              497       rM = recoil.AtomicMass(A-1,Z);
495     }                                             498     } 
496     // sumE = eX + rM;                            499     // sumE = eX + rM;   
497     G4double eTh = fMr + 0.5*(fMr*fMr - mX*mX)    500     G4double eTh = fMr + 0.5*(fMr*fMr - mX*mX)/rM;
498                                                   501 
499     if( eX <= eTh ) // vmg, very rarely out of    502     if( eX <= eTh ) // vmg, very rarely out of kinematics
500     {                                             503     {
501       fString = true;                             504       fString = true;
502       theParticleChange.SetEnergyChange(energy    505       theParticleChange.SetEnergyChange(energy);
503       theParticleChange.SetMomentumChange(aTra    506       theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
504       return &theParticleChange;                  507       return &theParticleChange;
505     }                                             508     }
506     // FinalBarion( fLVh, 0, fPDGencoding ); /    509     // FinalBarion( fLVh, 0, fPDGencoding ); // p(n)+deexcited recoil
507     FinalBarion( lvX, 0, fPDGencoding ); // p(    510     FinalBarion( lvX, 0, fPDGencoding ); // p(n)+deexcited recoil
508   }                                               511   }
509   else // if ( eX < 9500000.*GeV ) // <  25.*G    512   else // if ( eX < 9500000.*GeV ) // <  25.*GeV) // < 95.*GeV ) // < 2.5*GeV ) //cluster decay
510   {                                               513   {  
511     if     (  fProton && pName == "anti_nu_e"     514     if     (  fProton && pName == "anti_nu_e" )      qB =  2;
512     else if( !fProton && pName == "anti_nu_e"     515     else if( !fProton && pName == "anti_nu_e" )      qB =  1;
513                                                   516 
514     ClusterDecay( lvX, qB );                      517     ClusterDecay( lvX, qB );
515   }                                               518   }
516   return &theParticleChange;                      519   return &theParticleChange;
517 }                                                 520 }
518                                                   521 
519                                                   522 
520 //////////////////////////////////////////////    523 /////////////////////////////////////////////////////////////////////
521 //////////////////////////////////////////////    524 ////////////////////////////////////////////////////////////////////
522 //////////////////////////////////////////////    525 ///////////////////////////////////////////////////////////////////
523                                                   526 
524 //////////////////////////////////////////////    527 /////////////////////////////////////////////////
525 //                                                528 //
526 // sample x, then Q2                              529 // sample x, then Q2
527                                                   530 
528 void G4ANuElNucleusCcModel::SampleLVkr(const G    531 void G4ANuElNucleusCcModel::SampleLVkr(const G4HadProjectile & aTrack, G4Nucleus& targetNucleus)
529 {                                                 532 {
530   fBreak = false;                                 533   fBreak = false;
531   G4int A = targetNucleus.GetA_asInt(), iTer(0    534   G4int A = targetNucleus.GetA_asInt(), iTer(0), iTerMax(100); 
532   G4int Z = targetNucleus.GetZ_asInt();           535   G4int Z = targetNucleus.GetZ_asInt(); 
533   G4double e3(0.), pMu2(0.), pX2(0.), nMom(0.)    536   G4double e3(0.), pMu2(0.), pX2(0.), nMom(0.), rM(0.), hM(0.), tM = targetNucleus.AtomicMass(A,Z);
534   G4double Ex(0.), ei(0.), nm2(0.);               537   G4double Ex(0.), ei(0.), nm2(0.);
535   G4double cost(1.), sint(0.), phi(0.), muMom(    538   G4double cost(1.), sint(0.), phi(0.), muMom(0.); 
536   G4ThreeVector eP, bst;                          539   G4ThreeVector eP, bst;
537   const G4HadProjectile* aParticle = &aTrack;     540   const G4HadProjectile* aParticle = &aTrack;
538   G4LorentzVector lvp1 = aParticle->Get4Moment    541   G4LorentzVector lvp1 = aParticle->Get4Momentum();
539                                                   542 
540   if( A == 1 ) // hydrogen, no Fermi motion ??    543   if( A == 1 ) // hydrogen, no Fermi motion ???
541   {                                               544   {
542     fNuEnergy = aParticle->GetTotalEnergy();      545     fNuEnergy = aParticle->GetTotalEnergy();
543     iTer = 0;                                     546     iTer = 0;
544                                                   547 
545     do                                            548     do
546     {                                             549     {
547       fXsample = SampleXkr(fNuEnergy);            550       fXsample = SampleXkr(fNuEnergy);
548       fQtransfer = SampleQkr(fNuEnergy, fXsamp    551       fQtransfer = SampleQkr(fNuEnergy, fXsample);
549       fQ2 = fQtransfer*fQtransfer;                552       fQ2 = fQtransfer*fQtransfer;
550                                                   553 
551      if( fXsample > 0. )                          554      if( fXsample > 0. )
552       {                                           555       {
553         fW2 = fM1*fM1 - fQ2 + fQ2/fXsample; //    556         fW2 = fM1*fM1 - fQ2 + fQ2/fXsample; // sample excited hadron mass
554         fEmu = fNuEnergy - fQ2/2./fM1/fXsample    557         fEmu = fNuEnergy - fQ2/2./fM1/fXsample;
555       }                                           558       }
556       else                                        559       else
557       {                                           560       {
558         fW2 = fM1*fM1;                            561         fW2 = fM1*fM1;
559         fEmu = fNuEnergy;                         562         fEmu = fNuEnergy;
560       }                                           563       }
561       e3 = fNuEnergy + fM1 - fEmu;                564       e3 = fNuEnergy + fM1 - fEmu;
562                                                   565 
563       if( e3 < sqrt(fW2) )  G4cout<<"energyX =    566       if( e3 < sqrt(fW2) )  G4cout<<"energyX = "<<e3/GeV<<", fW = "<<sqrt(fW2)/GeV<<G4endl;
564                                                   567     
565       pMu2 = fEmu*fEmu - fMel*fMel;               568       pMu2 = fEmu*fEmu - fMel*fMel;
566                                                   569 
567       if(pMu2 < 0.) { fBreak = true; return; }    570       if(pMu2 < 0.) { fBreak = true; return; }
568                                                   571 
569       pX2  = e3*e3 - fW2;                         572       pX2  = e3*e3 - fW2;
570                                                   573 
571       fCosTheta  = fNuEnergy*fNuEnergy  + pMu2    574       fCosTheta  = fNuEnergy*fNuEnergy  + pMu2 - pX2;
572       fCosTheta /= 2.*fNuEnergy*sqrt(pMu2);       575       fCosTheta /= 2.*fNuEnergy*sqrt(pMu2);
573       iTer++;                                     576       iTer++;
574     }                                             577     }
575     while( ( abs(fCosTheta) > 1. || fEmu < fMe    578     while( ( abs(fCosTheta) > 1. || fEmu < fMel ) && iTer < iTerMax );
576                                                   579 
577     if( iTer >= iTerMax ) { fBreak = true; ret    580     if( iTer >= iTerMax ) { fBreak = true; return; }
578                                                   581 
579     if( abs(fCosTheta) > 1.) // vmg: due to bi    582     if( abs(fCosTheta) > 1.) // vmg: due to big Q2/x values. To be improved ...
580     {                                             583     { 
581       G4cout<<"H2: fCosTheta = "<<fCosTheta<<"    584       G4cout<<"H2: fCosTheta = "<<fCosTheta<<", fEmu = "<<fEmu<<G4endl;
582       // fCosTheta = -1. + 2.*G4UniformRand();    585       // fCosTheta = -1. + 2.*G4UniformRand(); 
583       if(fCosTheta < -1.) fCosTheta = -1.;        586       if(fCosTheta < -1.) fCosTheta = -1.;
584       if(fCosTheta >  1.) fCosTheta =  1.;        587       if(fCosTheta >  1.) fCosTheta =  1.;
585     }                                             588     }
586     // LVs                                        589     // LVs
587                                                   590 
588     G4LorentzVector lvt1  = G4LorentzVector( 0    591     G4LorentzVector lvt1  = G4LorentzVector( 0., 0., 0., fM1 );
589     G4LorentzVector lvsum = lvp1 + lvt1;          592     G4LorentzVector lvsum = lvp1 + lvt1;
590                                                   593 
591     cost = fCosTheta;                             594     cost = fCosTheta;
592     sint = std::sqrt( (1.0 - cost)*(1.0 + cost    595     sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
593     phi  = G4UniformRand()*CLHEP::twopi;          596     phi  = G4UniformRand()*CLHEP::twopi;
594     eP   = G4ThreeVector( sint*std::cos(phi),     597     eP   = G4ThreeVector( sint*std::cos(phi), sint*std::sin(phi), cost );
595     muMom = sqrt(fEmu*fEmu-fMel*fMel);            598     muMom = sqrt(fEmu*fEmu-fMel*fMel);
596     eP *= muMom;                                  599     eP *= muMom;
597     fLVl = G4LorentzVector( eP, fEmu );           600     fLVl = G4LorentzVector( eP, fEmu );
598                                                   601 
599     fLVh = lvsum - fLVl;                          602     fLVh = lvsum - fLVl;
600     fLVt = G4LorentzVector( 0., 0., 0., 0. );     603     fLVt = G4LorentzVector( 0., 0., 0., 0. ); // no recoil
601   }                                               604   }
602   else // Fermi motion, Q2 in nucleon rest fra    605   else // Fermi motion, Q2 in nucleon rest frame
603   {                                               606   {
604     G4Nucleus recoil1( A-1, Z );                  607     G4Nucleus recoil1( A-1, Z );
605     rM = recoil1.AtomicMass(A-1,Z);               608     rM = recoil1.AtomicMass(A-1,Z);   
606     do                                            609     do
607     {                                             610     {
608       // nMom = NucleonMomentumBR( targetNucle    611       // nMom = NucleonMomentumBR( targetNucleus ); // BR
609       nMom = GgSampleNM( targetNucleus ); // G    612       nMom = GgSampleNM( targetNucleus ); // Gg
610       Ex = GetEx(A-1, fProton);                   613       Ex = GetEx(A-1, fProton);
611       ei = tM - sqrt( (rM + Ex)*(rM + Ex) + nM    614       ei = tM - sqrt( (rM + Ex)*(rM + Ex) + nMom*nMom );
612       //   ei = 0.5*( tM - s2M - 2*eX );          615       //   ei = 0.5*( tM - s2M - 2*eX );
613                                                   616     
614       nm2 = ei*ei - nMom*nMom;                    617       nm2 = ei*ei - nMom*nMom;
615       iTer++;                                     618       iTer++;
616     }                                             619     }
617     while( nm2 < 0. && iTer < iTerMax );          620     while( nm2 < 0. && iTer < iTerMax ); 
618                                                   621 
619     if( iTer >= iTerMax ) { fBreak = true; ret    622     if( iTer >= iTerMax ) { fBreak = true; return; }
620                                                   623     
621     G4ThreeVector nMomDir = nMom*G4RandomDirec    624     G4ThreeVector nMomDir = nMom*G4RandomDirection();
622                                                   625 
623     if( !f2p2h || A < 3 ) // 1p1h                 626     if( !f2p2h || A < 3 ) // 1p1h
624     {                                             627     {
625       // hM = tM - rM;                            628       // hM = tM - rM;
626                                                   629 
627       fLVt = G4LorentzVector( -nMomDir, sqrt(     630       fLVt = G4LorentzVector( -nMomDir, sqrt( (rM + Ex)*(rM + Ex) + nMom*nMom ) ); // rM ); //
628       fLVh = G4LorentzVector(  nMomDir, ei );     631       fLVh = G4LorentzVector(  nMomDir, ei ); // hM); //
629     }                                             632     }
630     else // 2p2h                                  633     else // 2p2h
631     {                                             634     {
632       G4Nucleus recoil(A-2,Z-1);                  635       G4Nucleus recoil(A-2,Z-1);
633       rM = recoil.AtomicMass(A-2,Z-1)+sqrt(nMo    636       rM = recoil.AtomicMass(A-2,Z-1)+sqrt(nMom*nMom+fM1*fM1);
634       hM = tM - rM;                               637       hM = tM - rM;
635                                                   638 
636       fLVt = G4LorentzVector( nMomDir, sqrt( r    639       fLVt = G4LorentzVector( nMomDir, sqrt( rM*rM+nMom*nMom ) );
637       fLVh = G4LorentzVector(-nMomDir, sqrt( h    640       fLVh = G4LorentzVector(-nMomDir, sqrt( hM*hM+nMom*nMom )  ); 
638     }                                             641     }
639     // G4cout<<hM<<", ";                          642     // G4cout<<hM<<", ";
640     // bst = fLVh.boostVector();                  643     // bst = fLVh.boostVector();
641                                                   644 
642     // lvp1.boost(-bst); // -> nucleon rest sy    645     // lvp1.boost(-bst); // -> nucleon rest system, where Q2 transfer is ???
643                                                   646 
644     fNuEnergy  = lvp1.e();                        647     fNuEnergy  = lvp1.e();
645     // G4double mN = fLVh.m(); // better mN =     648     // G4double mN = fLVh.m(); // better mN = fM1 !? vmg
646     iTer = 0;                                     649     iTer = 0;
647                                                   650 
648     do // no FM!?, 5.4.20 vmg                     651     do // no FM!?, 5.4.20 vmg
649     {                                             652     {
650       fXsample = SampleXkr(fNuEnergy);            653       fXsample = SampleXkr(fNuEnergy);
651       fQtransfer = SampleQkr(fNuEnergy, fXsamp    654       fQtransfer = SampleQkr(fNuEnergy, fXsample);
652       fQ2 = fQtransfer*fQtransfer;                655       fQ2 = fQtransfer*fQtransfer;
653                                                   656 
654       // G4double mR = mN + fM1*(A-1.)*std::ex    657       // G4double mR = mN + fM1*(A-1.)*std::exp(-2.0*fQtransfer/mN); // recoil mass in+el
655                                                   658 
656       if( fXsample > 0. )                         659       if( fXsample > 0. )
657       {                                           660       {
658         fW2 = fM1*fM1 - fQ2 + fQ2/fXsample; //    661         fW2 = fM1*fM1 - fQ2 + fQ2/fXsample; // sample excited hadron mass
659                                                   662 
660         // fW2 = mN*mN - fQ2 + fQ2/fXsample; /    663         // fW2 = mN*mN - fQ2 + fQ2/fXsample; // sample excited hadron mass
661         // fEmu = fNuEnergy - fQ2/2./mR/fXsamp    664         // fEmu = fNuEnergy - fQ2/2./mR/fXsample; // fM1->mN
662                                                   665 
663         fEmu = fNuEnergy - fQ2/2./fM1/fXsample    666         fEmu = fNuEnergy - fQ2/2./fM1/fXsample; // fM1->mN
664       }                                           667       }
665       else                                        668       else
666       {                                           669       {
667         // fW2 = mN*mN;                           670         // fW2 = mN*mN;
668                                                   671 
669         fW2 = fM1*fM1;                            672         fW2 = fM1*fM1; 
670         fEmu = fNuEnergy;                         673         fEmu = fNuEnergy;
671       }                                           674       }
672       // if(fEmu < 0.) G4cout<<"fEmu = "<<fEmu    675       // if(fEmu < 0.) G4cout<<"fEmu = "<<fEmu<<" hM = "<<hM<<G4endl;
673       // e3 = fNuEnergy + mR - fEmu;              676       // e3 = fNuEnergy + mR - fEmu;
674                                                   677 
675       e3 = fNuEnergy + fM1 - fEmu;                678       e3 = fNuEnergy + fM1 - fEmu;
676                                                   679 
677       // if( e3 < sqrt(fW2) )  G4cout<<"energy    680       // if( e3 < sqrt(fW2) )  G4cout<<"energyX = "<<e3/GeV<<", fW = "<<sqrt(fW2)/GeV<<G4endl;
678                                                   681     
679       pMu2 = fEmu*fEmu - fMel*fMel;               682       pMu2 = fEmu*fEmu - fMel*fMel;
680       pX2  = e3*e3 - fW2;                         683       pX2  = e3*e3 - fW2;
681                                                   684 
682       if(pMu2 < 0.) { fBreak = true; return; }    685       if(pMu2 < 0.) { fBreak = true; return; }
683                                                   686 
684       fCosTheta  = fNuEnergy*fNuEnergy  + pMu2    687       fCosTheta  = fNuEnergy*fNuEnergy  + pMu2 - pX2;
685       fCosTheta /= 2.*fNuEnergy*sqrt(pMu2);       688       fCosTheta /= 2.*fNuEnergy*sqrt(pMu2);
686       iTer++;                                     689       iTer++;
687     }                                             690     }
688     while( ( abs(fCosTheta) > 1. || fEmu < fMe    691     while( ( abs(fCosTheta) > 1. || fEmu < fMel ) && iTer < iTerMax );
689                                                   692 
690     if( iTer >= iTerMax ) { fBreak = true; ret    693     if( iTer >= iTerMax ) { fBreak = true; return; }
691                                                   694 
692     if( abs(fCosTheta) > 1.) // vmg: due to bi    695     if( abs(fCosTheta) > 1.) // vmg: due to big Q2/x values. To be improved ...
693     {                                             696     { 
694       G4cout<<"FM: fCosTheta = "<<fCosTheta<<"    697       G4cout<<"FM: fCosTheta = "<<fCosTheta<<", fEmu = "<<fEmu<<G4endl;
695       // fCosTheta = -1. + 2.*G4UniformRand();    698       // fCosTheta = -1. + 2.*G4UniformRand(); 
696       if( fCosTheta < -1.) fCosTheta = -1.;       699       if( fCosTheta < -1.) fCosTheta = -1.;
697       if( fCosTheta >  1.) fCosTheta =  1.;       700       if( fCosTheta >  1.) fCosTheta =  1.;
698     }                                             701     }
699     // LVs                                        702     // LVs
700     // G4LorentzVector lvt1  = G4LorentzVector    703     // G4LorentzVector lvt1  = G4LorentzVector( 0., 0., 0., mN ); // fM1 );
701                                                   704 
702     G4LorentzVector lvt1  = G4LorentzVector( 0    705     G4LorentzVector lvt1  = G4LorentzVector( 0., 0., 0., fM1 ); // fM1 );
703     G4LorentzVector lvsum = lvp1 + lvt1;          706     G4LorentzVector lvsum = lvp1 + lvt1;
704                                                   707 
705     cost = fCosTheta;                             708     cost = fCosTheta;
706     sint = std::sqrt( (1.0 - cost)*(1.0 + cost    709     sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
707     phi  = G4UniformRand()*CLHEP::twopi;          710     phi  = G4UniformRand()*CLHEP::twopi;
708     eP   = G4ThreeVector( sint*std::cos(phi),     711     eP   = G4ThreeVector( sint*std::cos(phi), sint*std::sin(phi), cost );
709     muMom = sqrt(fEmu*fEmu-fMel*fMel);            712     muMom = sqrt(fEmu*fEmu-fMel*fMel);
710     eP *= muMom;                                  713     eP *= muMom;
711     fLVl = G4LorentzVector( eP, fEmu );           714     fLVl = G4LorentzVector( eP, fEmu );
712     fLVh = lvsum - fLVl;                          715     fLVh = lvsum - fLVl;
713                                                   716 
714     // if( fLVh.e() < mN || fLVh.m2() < 0.) {     717     // if( fLVh.e() < mN || fLVh.m2() < 0.) { fBreak = true; return; }
715                                                   718 
716     if( fLVh.e() < fM1 || fLVh.m2() < 0.) { fB    719     if( fLVh.e() < fM1 || fLVh.m2() < 0.) { fBreak = true; return; }
717                                                   720 
718     // back to lab system                         721     // back to lab system
719                                                   722 
720     // fLVl.boost(bst);                           723     // fLVl.boost(bst);
721     // fLVh.boost(bst);                           724     // fLVh.boost(bst);
722   }                                               725   }
723   //G4cout<<iTer<<", "<<fBreak<<"; ";             726   //G4cout<<iTer<<", "<<fBreak<<"; ";
724 }                                                 727 }
725                                                   728 
726 //                                                729 //
727 //                                                730 //
728 ///////////////////////////                       731 ///////////////////////////
729                                                   732