Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/util/src/G4ReactionProduct.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/util/src/G4ReactionProduct.cc (Version 11.3.0) and /processes/hadronic/util/src/G4ReactionProduct.cc (Version 5.2.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // J.L. Chuma, TRIUMF, 31-Oct-1996             <<  23 //
 27 // last modified: 19-Dec-1996                  <<  24 // $Id: G4ReactionProduct.cc,v 1.6 2002/12/12 19:18:40 gunter Exp $
 28 // Modified by J.L.Chuma, 05-May-97            <<  25 // GEANT4 tag $Name: geant4-05-02-patch-01 $
 29 // M. Kelsey 29-Aug-2011 -- Use G4Allocator fo <<  26 //
 30                                                <<  27  // J.L. Chuma, TRIUMF, 31-Oct-1996
                                                   >>  28  // last modified: 19-Dec-1996
                                                   >>  29  // Modified by J.L.Chuma, 05-May-97
                                                   >>  30  
 31 #include "G4ReactionProduct.hh"                    31 #include "G4ReactionProduct.hh"
 32                                                    32 
 33 G4Allocator<G4ReactionProduct>*& aRPAllocator( << 
 34 {                                              << 
 35     G4ThreadLocalStatic G4Allocator<G4Reaction << 
 36     return _instance;                          << 
 37 }                                              << 
 38                                                << 
 39  G4ReactionProduct::G4ReactionProduct() :          33  G4ReactionProduct::G4ReactionProduct() :
 40     theParticleDefinition(NULL),                   34     theParticleDefinition(NULL),
 41     formationTime(0.0),                            35     formationTime(0.0),
 42     hasInitialStateParton(false),                  36     hasInitialStateParton(false),
 43     mass(0.0),                                     37     mass(0.0),
 44     totalEnergy(0.0),                              38     totalEnergy(0.0),
 45     kineticEnergy(0.0),                            39     kineticEnergy(0.0),
 46     timeOfFlight(0.0),                             40     timeOfFlight(0.0),
 47     side(0),                                       41     side(0),
 48     theCreatorModel(-1),                       << 
 49     theParentResonanceDef(nullptr),            << 
 50     theParentResonanceID(0),                   << 
 51     NewlyAdded(false),                             42     NewlyAdded(false),
 52     MayBeKilled(true)                              43     MayBeKilled(true)
 53   {                                                44   {
 54     SetMomentum( 0.0, 0.0, 0.0 );                  45     SetMomentum( 0.0, 0.0, 0.0 );
 55     SetPositionInNucleus( 0.0, 0.0, 0.0 );         46     SetPositionInNucleus( 0.0, 0.0, 0.0 );
 56   }                                                47   }
 57                                                    48  
 58  G4ReactionProduct::G4ReactionProduct(             49  G4ReactionProduct::G4ReactionProduct(
 59   const G4ParticleDefinition *aParticleDefinit <<  50   G4ParticleDefinition *aParticleDefinition )
 60   {                                                51   {
 61     SetMomentum( 0.0, 0.0, 0.0 );                  52     SetMomentum( 0.0, 0.0, 0.0 );
 62     SetPositionInNucleus( 0.0, 0.0, 0.0 );         53     SetPositionInNucleus( 0.0, 0.0, 0.0 );
 63     formationTime = 0.0;                           54     formationTime = 0.0;
 64     hasInitialStateParton = false;                 55     hasInitialStateParton = false;
 65     theParticleDefinition = aParticleDefinitio     56     theParticleDefinition = aParticleDefinition;
 66     mass = aParticleDefinition->GetPDGMass();      57     mass = aParticleDefinition->GetPDGMass();
 67     totalEnergy = mass;                            58     totalEnergy = mass;
 68     kineticEnergy = 0.0;                           59     kineticEnergy = 0.0;
 69     (aParticleDefinition->GetPDGEncoding()<0)      60     (aParticleDefinition->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0;
 70     side = 0;                                      61     side = 0;
 71     theCreatorModel = -1;                      << 
 72     theParentResonanceDef = nullptr;           << 
 73     theParentResonanceID = 0;                  << 
 74     NewlyAdded = false;                            62     NewlyAdded = false;
 75     MayBeKilled = true;                            63     MayBeKilled = true;
 76   }                                                64   }
 77                                                    65  
 78  G4ReactionProduct::G4ReactionProduct(             66  G4ReactionProduct::G4ReactionProduct(
 79   const G4ReactionProduct &right )                 67   const G4ReactionProduct &right )
 80   {                                                68   {
 81     theParticleDefinition = right.theParticleD     69     theParticleDefinition = right.theParticleDefinition;
 82     positionInNucleus = right.positionInNucleu     70     positionInNucleus = right.positionInNucleus;
 83     formationTime = right.formationTime;           71     formationTime = right.formationTime;
 84     hasInitialStateParton = right.hasInitialSt     72     hasInitialStateParton = right.hasInitialStateParton;
 85     momentum = right.momentum;                     73     momentum = right.momentum;
 86     mass = right.mass;                             74     mass = right.mass;
 87     totalEnergy = right.totalEnergy;               75     totalEnergy = right.totalEnergy;
 88     kineticEnergy = right.kineticEnergy;           76     kineticEnergy = right.kineticEnergy;
 89     timeOfFlight = right.timeOfFlight;             77     timeOfFlight = right.timeOfFlight;
 90     side = right.side;                             78     side = right.side;
 91     theCreatorModel = right.theCreatorModel;   << 
 92     theParentResonanceDef = right.theParentRes << 
 93     theParentResonanceID = right.theParentReso << 
 94     NewlyAdded = right.NewlyAdded;                 79     NewlyAdded = right.NewlyAdded;
 95     MayBeKilled = right.MayBeKilled;               80     MayBeKilled = right.MayBeKilled;
 96   }                                                81   }
 97                                                    82  
 98  G4ReactionProduct &G4ReactionProduct::operato     83  G4ReactionProduct &G4ReactionProduct::operator=(
 99   const G4ReactionProduct &right )                 84   const G4ReactionProduct &right )
100   {                                                85   {
101     if( this != &right ) {                         86     if( this != &right ) {
102       theParticleDefinition = right.theParticl     87       theParticleDefinition = right.theParticleDefinition;
103       positionInNucleus = right.positionInNucl     88       positionInNucleus = right.positionInNucleus;
104       formationTime = right.formationTime;         89       formationTime = right.formationTime;
105       hasInitialStateParton = right.hasInitial     90       hasInitialStateParton = right.hasInitialStateParton;
106       momentum = right.momentum;                   91       momentum = right.momentum;
107       mass = right.mass;                           92       mass = right.mass;
108       totalEnergy = right.totalEnergy;             93       totalEnergy = right.totalEnergy;
109       kineticEnergy = right.kineticEnergy;         94       kineticEnergy = right.kineticEnergy;
110       timeOfFlight = right.timeOfFlight;           95       timeOfFlight = right.timeOfFlight;
111       side = right.side;                           96       side = right.side;
112       theCreatorModel = right.theCreatorModel; << 
113       theParentResonanceDef = right.theParentR << 
114       theParentResonanceID = right.theParentRe << 
115       NewlyAdded = right.NewlyAdded;               97       NewlyAdded = right.NewlyAdded;
116       MayBeKilled = right.MayBeKilled;             98       MayBeKilled = right.MayBeKilled;
117     }                                              99     }
118     return *this;                                 100     return *this;
119   }                                               101   }
120                                                   102     
121  G4ReactionProduct &G4ReactionProduct::operato    103  G4ReactionProduct &G4ReactionProduct::operator=(
122   const G4DynamicParticle &right )                104   const G4DynamicParticle &right )
123   {                                               105   {
124     theParticleDefinition = right.GetDefinitio    106     theParticleDefinition = right.GetDefinition();
125     SetPositionInNucleus( 0.0, 0.0, 0.0 );        107     SetPositionInNucleus( 0.0, 0.0, 0.0 );
126     formationTime = 0.0;                          108     formationTime = 0.0;
127     hasInitialStateParton = false;                109     hasInitialStateParton = false;
128     momentum = right.GetMomentum();               110     momentum = right.GetMomentum();
129     mass = right.GetDefinition()->GetPDGMass()    111     mass = right.GetDefinition()->GetPDGMass();
130     totalEnergy = right.GetTotalEnergy();         112     totalEnergy = right.GetTotalEnergy();
131     kineticEnergy = right.GetKineticEnergy();     113     kineticEnergy = right.GetKineticEnergy();
132     (right.GetDefinition()->GetPDGEncoding()<0    114     (right.GetDefinition()->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0;
133     side = 0;                                     115     side = 0;
134     theCreatorModel = -1;                      << 
135     theParentResonanceDef = nullptr;           << 
136     theParentResonanceID = 0;                  << 
137     NewlyAdded = false;                        << 
138     MayBeKilled = true;                        << 
139     return *this;                              << 
140   }                                            << 
141                                                << 
142  G4ReactionProduct &G4ReactionProduct::operato << 
143   const G4HadProjectile &right )               << 
144   {                                            << 
145     theParticleDefinition = right.GetDefinitio << 
146     SetPositionInNucleus( 0.0, 0.0, 0.0 );     << 
147     formationTime = 0.0;                       << 
148     hasInitialStateParton = false;             << 
149     momentum = right.Get4Momentum().vect();    << 
150     mass = right.GetDefinition()->GetPDGMass() << 
151     totalEnergy = right.Get4Momentum().e();    << 
152     kineticEnergy = right.GetKineticEnergy();  << 
153     (right.GetDefinition()->GetPDGEncoding()<0 << 
154     side = 0;                                  << 
155     theCreatorModel = -1;                      << 
156     theParentResonanceDef = nullptr;           << 
157     theParentResonanceID = 0;                  << 
158     NewlyAdded = false;                           116     NewlyAdded = false;
159     MayBeKilled = true;                           117     MayBeKilled = true;
160     return *this;                                 118     return *this;
161   }                                               119   }
162                                                   120  
163  void G4ReactionProduct::SetDefinitionAndUpdat    121  void G4ReactionProduct::SetDefinitionAndUpdateE(
164   const G4ParticleDefinition *aParticleDefinit << 122   G4ParticleDefinition *aParticleDefinition )
165   {    G4double aKineticEnergy = GetKineticEne << 123   {
                                                   >> 124     G4double aKineticEnergy = GetKineticEnergy();
166     G4double pp = GetMomentum().mag();            125     G4double pp = GetMomentum().mag();
167     G4ThreeVector aMomentum = GetMomentum();      126     G4ThreeVector aMomentum = GetMomentum();
168     SetDefinition( aParticleDefinition );         127     SetDefinition( aParticleDefinition );
169     SetKineticEnergy( aKineticEnergy );           128     SetKineticEnergy( aKineticEnergy );
170     if( pp > DBL_MIN )                            129     if( pp > DBL_MIN )
171       SetMomentum( aMomentum * (std::sqrt(aKin << 130       SetMomentum( aMomentum * (sqrt(aKineticEnergy*aKineticEnergy +
172                                     2*aKinetic    131                                     2*aKineticEnergy*GetMass())/pp) );
173   }                                               132   }
174                                                   133 
175  void G4ReactionProduct::SetDefinition(           134  void G4ReactionProduct::SetDefinition(
176   const G4ParticleDefinition *aParticleDefinit << 135   G4ParticleDefinition *aParticleDefinition )
177   {                                               136   {
178     theParticleDefinition = aParticleDefinitio    137     theParticleDefinition = aParticleDefinition;
179     mass = aParticleDefinition->GetPDGMass();     138     mass = aParticleDefinition->GetPDGMass();
180     totalEnergy = mass;                           139     totalEnergy = mass;
181     kineticEnergy = 0.0;                          140     kineticEnergy = 0.0;
182     (aParticleDefinition->GetPDGEncoding()<0)     141     (aParticleDefinition->GetPDGEncoding()<0) ?
183       timeOfFlight=-1.0 : timeOfFlight=1.0;       142       timeOfFlight=-1.0 : timeOfFlight=1.0;
184   }                                               143   }
185                                                   144  
186  void G4ReactionProduct::SetMomentum(             145  void G4ReactionProduct::SetMomentum(
187   const G4double x, const G4double y, const G4    146   const G4double x, const G4double y, const G4double z )
188   {                                               147   {
189     momentum.setX( x );                           148     momentum.setX( x );
190     momentum.setY( y );                           149     momentum.setY( y );
191     momentum.setZ( z );                           150     momentum.setZ( z );
192   }                                               151   }
193                                                   152  
194  void G4ReactionProduct::SetMomentum(             153  void G4ReactionProduct::SetMomentum(
195   const G4double x, const G4double y )            154   const G4double x, const G4double y )
196   {                                               155   {
197     momentum.setX( x );                           156     momentum.setX( x );
198     momentum.setY( y );                           157     momentum.setY( y );
199   }                                               158   }
200                                                   159  
201  void G4ReactionProduct::SetMomentum( const G4    160  void G4ReactionProduct::SetMomentum( const G4double z )
202   {                                               161   {
203     momentum.setZ( z );                           162     momentum.setZ( z );
204   }                                               163   }
205                                                   164  
206  void G4ReactionProduct::SetZero()                165  void G4ReactionProduct::SetZero()
207   {                                               166   {
208     SetMomentum( 0.0, 0.0, 0.0 );                 167     SetMomentum( 0.0, 0.0, 0.0 );
209     totalEnergy = 0.0;                            168     totalEnergy = 0.0;
210     kineticEnergy = 0.0;                          169     kineticEnergy = 0.0;
211     mass = 0.0;                                   170     mass = 0.0;
212     timeOfFlight = 0.0;                           171     timeOfFlight = 0.0;
213     side = 0;                                     172     side = 0;
214     theCreatorModel = -1;                      << 
215     theParentResonanceDef = nullptr;           << 
216     theParentResonanceID = 0;                  << 
217     NewlyAdded = false;                           173     NewlyAdded = false;
218     SetPositionInNucleus( 0.0, 0.0, 0.0 );        174     SetPositionInNucleus( 0.0, 0.0, 0.0 );
219     formationTime = 0.0;                          175     formationTime = 0.0;
220     hasInitialStateParton = false;                176     hasInitialStateParton = false;
221   }                                               177   }
222                                                   178  
223  void G4ReactionProduct::Lorentz(                 179  void G4ReactionProduct::Lorentz(
224    const G4ReactionProduct &p1, const G4Reacti    180    const G4ReactionProduct &p1, const G4ReactionProduct &p2 )
225   {                                               181   {
226     G4ThreeVector p1M = p1.momentum;              182     G4ThreeVector p1M = p1.momentum;
227     G4ThreeVector p2M = p2.momentum;              183     G4ThreeVector p2M = p2.momentum;
228     G4double p1x = p1M.x(); G4double p1y = p1M    184     G4double p1x = p1M.x(); G4double p1y = p1M.y(); G4double p1z = p1M.z();
229     G4double p2x = p2M.x(); G4double p2y = p2M    185     G4double p2x = p2M.x(); G4double p2y = p2M.y(); G4double p2z = p2M.z();
230     G4double a = ( (p1x*p2x+p1y*p2y+p1z*p2z)/(    186     G4double a = ( (p1x*p2x+p1y*p2y+p1z*p2z)/(p2.totalEnergy+p2.mass) -
231                    p1.totalEnergy ) / p2.mass;    187                    p1.totalEnergy ) / p2.mass;
232     G4double x = p1x+a*p2x;                       188     G4double x = p1x+a*p2x;
233     G4double y = p1y+a*p2y;                       189     G4double y = p1y+a*p2y;
234     G4double z = p1z+a*p2z;                       190     G4double z = p1z+a*p2z;
235     G4double p = std::sqrt(x*x+y*y+z*z);       << 191     G4double p = sqrt(x*x+y*y+z*z);
236     SetMass( p1.mass );                           192     SetMass( p1.mass );
237     SetTotalEnergy( std::sqrt( (p1.mass+p)*(p1 << 193     SetTotalEnergy( sqrt( (p1.mass+p)*(p1.mass+p) - 2.*p1.mass*p ) );
238     //SetTotalEnergy( std::sqrt( p1.mass*p1.ma << 194     //SetTotalEnergy( sqrt( p1.mass*p1.mass + x*x + y*y + z*z ) );
239     SetMomentum( x, y, z );                       195     SetMomentum( x, y, z );
240   }                                               196   }
241                                                   197  
242  G4double G4ReactionProduct::Angle(               198  G4double G4ReactionProduct::Angle(
243   const G4ReactionProduct& p ) const              199   const G4ReactionProduct& p ) const
244   {                                               200   {
245     G4ThreeVector tM = momentum;                  201     G4ThreeVector tM = momentum;
246     G4ThreeVector pM = p.momentum;                202     G4ThreeVector pM = p.momentum;
247     G4double tx = tM.x(); G4double ty = tM.y()    203     G4double tx = tM.x(); G4double ty = tM.y(); G4double tz = tM.z();
248     G4double px = pM.x(); G4double py = pM.y()    204     G4double px = pM.x(); G4double py = pM.y(); G4double pz = pM.z();
249     G4double a = std::sqrt( ( px*px + py*py +  << 205     G4double a = sqrt( ( px*px + py*py + pz*pz ) * ( tx*tx + ty*ty + tz*tz ) );
250     if( a == 0.0 ) {                              206     if( a == 0.0 ) {
251       return 0.0;                                 207       return 0.0;
252     } else {                                      208     } else {
253       a = ( tx*px + ty*py + tz*pz ) / a;          209       a = ( tx*px + ty*py + tz*pz ) / a;
254       if( std::abs(a) > 1.0 ) { a<0.0 ? a=-1.0 << 210       if( fabs(a) > 1.0 ) { a<0.0 ? a=-1.0 : a=1.0; }
255       return std::acos( a );                   << 211       return acos( a );
256     }                                             212     }
257   }                                               213   }
258                                                   214  
259  G4ReactionProduct operator+(                     215  G4ReactionProduct operator+(
260   const G4ReactionProduct& p1, const G4Reactio    216   const G4ReactionProduct& p1, const G4ReactionProduct& p2 )
261   {                                               217   {
262     G4double totEnergy = p1.totalEnergy + p2.t    218     G4double totEnergy = p1.totalEnergy + p2.totalEnergy;
263     G4double x = p1.momentum.x() + p2.momentum    219     G4double x = p1.momentum.x() + p2.momentum.x();
264     G4double y = p1.momentum.y() + p2.momentum    220     G4double y = p1.momentum.y() + p2.momentum.y();
265     G4double z = p1.momentum.z() + p2.momentum    221     G4double z = p1.momentum.z() + p2.momentum.z();
266     G4double newMass = totEnergy*totEnergy - (    222     G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z );
267     if( newMass < 0.0 )                           223     if( newMass < 0.0 )
268       newMass = -1. * std::sqrt( -newMass );   << 224       newMass = -1. * sqrt( -newMass );
269     else                                          225     else
270       newMass = std::sqrt( newMass );          << 226       newMass = sqrt( newMass );
271     G4ReactionProduct result;                     227     G4ReactionProduct result;
272     result.SetMass( newMass );                    228     result.SetMass( newMass );
273     result.SetMomentum( x, y, z );                229     result.SetMomentum( x, y, z );
274     result.SetTotalEnergy( totEnergy );           230     result.SetTotalEnergy( totEnergy );
275     result.SetPositionInNucleus( 0.0, 0.0, 0.0    231     result.SetPositionInNucleus( 0.0, 0.0, 0.0 );
276     result.SetFormationTime(0.0);                 232     result.SetFormationTime(0.0);
277     result.HasInitialStateParton(false);          233     result.HasInitialStateParton(false);
278     return result;                                234     return result;
279   }                                               235   }
280                                                   236  
281  G4ReactionProduct operator-(                     237  G4ReactionProduct operator-(
282   const G4ReactionProduct& p1, const G4Reactio    238   const G4ReactionProduct& p1, const G4ReactionProduct& p2 )
283   {                                               239   {
284     G4double totEnergy = p1.totalEnergy - p2.t    240     G4double totEnergy = p1.totalEnergy - p2.totalEnergy;
285     G4double x = p1.momentum.x() - p2.momentum    241     G4double x = p1.momentum.x() - p2.momentum.x();
286     G4double y = p1.momentum.y() - p2.momentum    242     G4double y = p1.momentum.y() - p2.momentum.y();
287     G4double z = p1.momentum.z() - p2.momentum    243     G4double z = p1.momentum.z() - p2.momentum.z();
288     G4double newMass = totEnergy*totEnergy - (    244     G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z );
289     if( newMass < 0.0 )                           245     if( newMass < 0.0 )
290       newMass = -1. * std::sqrt( -newMass );   << 246       newMass = -1. * sqrt( -newMass );
291     else                                          247     else
292       newMass = std::sqrt( newMass );          << 248       newMass = sqrt( newMass );
293     G4ReactionProduct result;                     249     G4ReactionProduct result;
294     result.SetMass( newMass );                    250     result.SetMass( newMass );
295     result.SetMomentum( x, y, z );                251     result.SetMomentum( x, y, z );
296     result.SetTotalEnergy( totEnergy );           252     result.SetTotalEnergy( totEnergy );
297     result.SetPositionInNucleus( 0.0, 0.0, 0.0    253     result.SetPositionInNucleus( 0.0, 0.0, 0.0 );
298     result.SetFormationTime(0.0);                 254     result.SetFormationTime(0.0);
299     result.HasInitialStateParton(false);          255     result.HasInitialStateParton(false);
300     return result;                                256     return result;
301   }                                               257   }
302  /* end of code */                                258  /* end of code */
303                                                   259  
304                                                   260