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] [ 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/G4Fragment.cc (Version 11.3.0) and /processes/hadronic/util/src/G4Fragment.cc (Version 6.2.p2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //--------------------------------------------    
 28 //                                                
 29 // Geant4 class G4Fragment                        
 30 //                                                
 31 // Hadronic Process: Nuclear De-excitations       
 32 // by V. Lara (May 1998)                          
 33 //                                                
 34 // Modifications:                                 
 35 // 03.05.2010 V.Ivanchenko General cleanup; mo    
 36 //            inline to source                    
 37 // 25.09.2010 M. Kelsey -- Change "setprecisio    
 38 //        add null pointer check.                 
 39 // 27.10.2021 A.Ribon extension for hypernucle    
 40                                                   
 41 #include "G4Fragment.hh"                          
 42 #include "G4SystemOfUnits.hh"                     
 43 #include "G4Exception.hh"                         
 44 #include "G4ios.hh"                               
 45 #include <iomanip>                                
 46                                                   
 47 G4Allocator<G4Fragment>*& pFragmentAllocator()    
 48 {                                                 
 49   G4ThreadLocalStatic G4Allocator<G4Fragment>*    
 50   return _instance;                               
 51 }                                                 
 52                                                   
 53 // Default constructor                            
 54 G4Fragment::G4Fragment() :                        
 55   theA(0),                                        
 56   theZ(0),                                        
 57   theL(0),                                        
 58   theExcitationEnergy(0.0),                       
 59   theGroundStateMass(0.0),                        
 60   theMomentum(G4LorentzVector(0,0,0,0)),          
 61   thePolarization(nullptr),                       
 62   creatorModel(-1),                               
 63   numberOfParticles(0),                           
 64   numberOfCharged(0),                             
 65   numberOfHoles(0),                               
 66   numberOfChargedHoles(0),                        
 67   numberOfShellElectrons(0),                      
 68   xLevel(0),                                      
 69   theParticleDefinition(nullptr),                 
 70   spin(0.0),                                      
 71   theCreationTime(0.0)                            
 72 {}                                                
 73                                                   
 74 // Copy Constructor                               
 75 G4Fragment::G4Fragment(const G4Fragment &right    
 76    theA(right.theA),                              
 77    theZ(right.theZ),                              
 78    theL(right.theL),                              
 79    theExcitationEnergy(right.theExcitationEner    
 80    theGroundStateMass(right.theGroundStateMass    
 81    theMomentum(right.theMomentum),                
 82    thePolarization(right.thePolarization),        
 83    creatorModel(right.creatorModel),              
 84    numberOfParticles(right.numberOfParticles),    
 85    numberOfCharged(right.numberOfCharged),        
 86    numberOfHoles(right.numberOfHoles),            
 87    numberOfChargedHoles(right.numberOfChargedH    
 88    numberOfShellElectrons(right.numberOfShellE    
 89    xLevel(right.xLevel),                          
 90    theParticleDefinition(right.theParticleDefi    
 91    spin(right.spin),                              
 92    theCreationTime(right.theCreationTime),        
 93    isLongLived(right.isLongLived)                 
 94 {}                                                
 95                                                   
 96 G4Fragment::~G4Fragment()                         
 97 {}                                                
 98                                                   
 99 G4Fragment::G4Fragment(G4int A, G4int Z, const    
100   theA(A),                                        
101   theZ(Z),                                        
102   theL(0),                                        
103   theExcitationEnergy(0.0),                       
104   theGroundStateMass(0.0),                        
105   theMomentum(aMomentum),                         
106   thePolarization(nullptr),                       
107   creatorModel(-1),                               
108   numberOfParticles(0),                           
109   numberOfCharged(0),                             
110   numberOfHoles(0),                               
111   numberOfChargedHoles(0),                        
112   numberOfShellElectrons(0),                      
113   xLevel(0),                                      
114   theParticleDefinition(nullptr),                 
115   spin(0.0),                                      
116   theCreationTime(0.0)                            
117 {                                                 
118   if(theA > 0) {                                  
119     CalculateMassAndExcitationEnergy();           
120   }                                               
121 }                                                 
122                                                   
123 G4Fragment::G4Fragment(G4int A, G4int Z, G4int    
124                        const G4LorentzVector&     
125   theA(A),                                        
126   theZ(Z),                                        
127   theL(std::max(numberOfLambdas,0)),              
128   theExcitationEnergy(0.0),                       
129   theGroundStateMass(0.0),                        
130   theMomentum(aMomentum),                         
131   thePolarization(nullptr),                       
132   creatorModel(-1),                               
133   numberOfParticles(0),                           
134   numberOfCharged(0),                             
135   numberOfHoles(0),                               
136   numberOfChargedHoles(0),                        
137   numberOfShellElectrons(0),                      
138   xLevel(0),                                      
139   theParticleDefinition(nullptr),                 
140   spin(0.0),                                      
141   theCreationTime(0.0)                            
142 {                                                 
143   if(theA > 0) {                                  
144     CalculateMassAndExcitationEnergy();           
145   }                                               
146 }                                                 
147                                                   
148 // This constructor is for initialize photons     
149 G4Fragment::G4Fragment(const G4LorentzVector&     
150            const G4ParticleDefinition * aParti    
151   theA(0),                                        
152   theZ(0),                                        
153   theL(0),                                        
154   theExcitationEnergy(0.0),                       
155   theMomentum(aMomentum),                         
156   thePolarization(nullptr),                       
157   creatorModel(-1),                               
158   numberOfParticles(0),                           
159   numberOfCharged(0),                             
160   numberOfHoles(0),                               
161   numberOfChargedHoles(0),                        
162   numberOfShellElectrons(0),                      
163   xLevel(0),                                      
164   theParticleDefinition(aParticleDefinition),     
165   spin(0.0),                                      
166   theCreationTime(0.0)                            
167 {                                                 
168   if(aParticleDefinition->GetPDGEncoding() !=     
169      aParticleDefinition->GetPDGEncoding() !=     
170     G4ExceptionDescription ed;                    
171     ed << "Particle: " << aParticleDefinition-    
172     G4Exception( "G4Fragment::G4Fragment: cons    
173                  "HAD_FRAGMENT_01", FatalExcep    
174   }                                               
175   theGroundStateMass = aParticleDefinition->Ge    
176 }                                                 
177                                                   
178 void G4Fragment::CalculateMassAndExcitationEne    
179 {                                                 
180   // check input                                  
181   if(theZ > theA || theZ + theL > theA) {         
182     G4ExceptionDescription ed;                    
183     ed << "Fragment: Z=" << theZ << "  A=" <<     
184     G4Exception( "G4Fragment::CalculateMassAnd    
185                  "HAD_FRAGMENT_02", EventMustB    
186   }                                               
187   // compute mass                                 
188   theGroundStateMass = ( theL == 0 )              
189     ? G4NucleiProperties::GetNuclearMass(theA,    
190     : G4HyperNucleiProperties::GetNuclearMass(    
191                                                   
192   // excitation energy                            
193   const G4double minFragExcitation = 10.*CLHEP    
194   theExcitationEnergy = theMomentum.mag() - th    
195   if(theExcitationEnergy < minFragExcitation)     
196     if(theExcitationEnergy < -minFragExcitatio    
197       ExcitationEnergyWarning();                  
198     }                                             
199     theExcitationEnergy = 0.0;                    
200   }                                               
201 }                                                 
202                                                   
203 void G4Fragment::SetExcEnergyAndMomentum(G4dou    
204            const G4LorentzVector& v)              
205 {                                                 
206   theExcitationEnergy = eexc;                     
207   theMomentum.set(0.0, 0.0, 0.0, theGroundStat    
208   theMomentum.boost(v.boostVector());             
209 }                                                 
210                                                   
211 G4double G4Fragment::GetBindingEnergy() const     
212 {                                                 
213   const G4double lambdaMass = 1.115683*CLHEP::    
214   return (theA-theZ-theL)*CLHEP::neutron_mass_    
215     + theZ*CLHEP::proton_mass_c2 + theL*lambda    
216     - theGroundStateMass;                         
217 }                                                 
218                                                   
219 G4Fragment & G4Fragment::operator=(const G4Fra    
220 {                                                 
221   if (this != &right) {                           
222     theA = right.theA;                            
223     theZ = right.theZ;                            
224     theL = right.theL;                            
225     theExcitationEnergy = right.theExcitationE    
226     theGroundStateMass = right.theGroundStateM    
227     theMomentum  = right.theMomentum;             
228     thePolarization = right.thePolarization;      
229     creatorModel = right.creatorModel;            
230     numberOfParticles = right.numberOfParticle    
231     numberOfCharged = right.numberOfCharged;      
232     numberOfHoles = right.numberOfHoles;          
233     numberOfChargedHoles = right.numberOfCharg    
234     numberOfShellElectrons = right.numberOfShe    
235     xLevel = right.xLevel;                        
236     theParticleDefinition = right.theParticleD    
237     spin = right.spin;                            
238     theCreationTime = right.theCreationTime;      
239     isLongLived = right.isLongLived;              
240   }                                               
241   return *this;                                   
242 }                                                 
243                                                   
244 G4bool G4Fragment::operator==(const G4Fragment    
245 {                                                 
246   return (this == (G4Fragment *) &right);         
247 }                                                 
248                                                   
249 G4bool G4Fragment::operator!=(const G4Fragment    
250 {                                                 
251   return (this != (G4Fragment *) &right);         
252 }                                                 
253                                                   
254 std::ostream& operator << (std::ostream &out,     
255 {                                                 
256   std::ios::fmtflags old_floatfield = out.flag    
257   out.setf(std::ios::floatfield);                 
258                                                   
259   out << "Fragment: A = " << std::setw(3) << t    
260       << ", Z = " << std::setw(3) << theFragme    
261       << ", numberOfLambdas = " << std::setw(3    
262   out.setf(std::ios::scientific,std::ios::floa    
263                                                   
264   // Store user's precision setting and reset     
265   std::streamsize floatPrec = out.precision();    
266                                                   
267   out << std::setprecision(3)                     
268       << ", U = " << theFragment.GetExcitation    
269       << " MeV  ";                                
270   if(theFragment.GetCreatorModelID() >= 0) {      
271     out << " creatorModelID= " << theFragment.    
272   }                                               
273   if(theFragment.GetCreationTime() > 0.0) {       
274     out << "  Time= " << theFragment.GetCreati    
275   }                                               
276   out << G4endl                                   
277       << "          P = ("                        
278       << theFragment.GetMomentum().x()/CLHEP::    
279       << theFragment.GetMomentum().y()/CLHEP::    
280       << theFragment.GetMomentum().z()/CLHEP::    
281       << ") MeV   E = "                           
282       << theFragment.GetMomentum().t()/CLHEP::    
283       << G4endl;                                  
284                                                   
285   out << "    #spin= " << theFragment.GetSpin(    
286       << "    #floatLevelNo= " << theFragment.    
287                                                   
288   if (theFragment.GetNumberOfExcitons() != 0)     
289     out << "   "                                  
290   << "#Particles= " << theFragment.GetNumberOf    
291   << ", #Charged= " << theFragment.GetNumberOf    
292   << ", #Holes= "   << theFragment.GetNumberOf    
293   << ", #ChargedHoles= " << theFragment.GetNum    
294   }                                               
295   out << G4endl;                                  
296   if(theFragment.GetNuclearPolarization()) {      
297     out << *(theFragment.GetNuclearPolarizatio    
298   }                                               
299   //out << G4endl;                                
300   out.setf(old_floatfield,std::ios::floatfield    
301   out.precision(floatPrec);                       
302                                                   
303   return out;                                     
304 }                                                 
305                                                   
306 void G4Fragment::ExcitationEnergyWarning()        
307 {                                                 
308 #ifdef G4VERBOSE                                  
309   G4cout << "G4Fragment::CalculateExcitationEn    
310    << " GraundStateMass(MeV)= " << theGroundSt    
311    <<G4endl;                                      
312   G4cout << *this << G4endl;                      
313 #endif                                            
314 }                                                 
315                                                   
316 void G4Fragment::NumberOfExitationWarning(cons    
317 {                                                 
318   G4ExceptionDescription ed;                      
319   ed << "Value=" << value << G4endl;              
320   G4Exception( "G4Fragment::NumberOfExitationW    
321          "HAD_FRAGMENT_03", FatalException, ed    
322 }                                                 
323                                                   
324 void G4Fragment::SetAngularMomentum(const G4Th    
325 {                                                 
326   spin = v.mag();                                 
327 }                                                 
328                                                   
329 G4ThreeVector G4Fragment::GetAngularMomentum()    
330 {                                                 
331   G4ThreeVector v(0.0,0.0,spin);                  
332   return v;                                       
333 }                                                 
334