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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 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 //---------------------------------------------------------------------
 28 //
 29 // 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; moved obsolete methods from
 36 //            inline to source 
 37 // 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
 38 //        add null pointer check.
 39 // 27.10.2021 A.Ribon extension for hypernuclei.
 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>* _instance = nullptr;
 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.theExcitationEnergy),
 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.numberOfChargedHoles),
 88    numberOfShellElectrons(right.numberOfShellElectrons),
 89    xLevel(right.xLevel),
 90    theParticleDefinition(right.theParticleDefinition),
 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 G4LorentzVector& aMomentum) :
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 numberOfLambdas,
124                        const G4LorentzVector& aMomentum) :
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 or electrons
149 G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, 
150            const G4ParticleDefinition * aParticleDefinition) :
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() != 22 && 
169      aParticleDefinition->GetPDGEncoding() != 11) {
170     G4ExceptionDescription ed;
171     ed << "Particle: " << aParticleDefinition->GetParticleName() << G4endl;
172     G4Exception( "G4Fragment::G4Fragment: constructor for gamma used for another type of particle ! ",
173                  "HAD_FRAGMENT_01", FatalException, ed );
174   }
175   theGroundStateMass = aParticleDefinition->GetPDGMass();
176 }
177 
178 void G4Fragment::CalculateMassAndExcitationEnergy()
179 {
180   // check input
181   if(theZ > theA || theZ + theL > theA) {
182     G4ExceptionDescription ed;
183     ed << "Fragment: Z=" << theZ << "  A=" << theA << "  nLambdas=" << theL << G4endl;
184     G4Exception( "G4Fragment::CalculateMassAndExcitationEnergy: inconsistent number of nucleons ! ",
185                  "HAD_FRAGMENT_02", EventMustBeAborted, ed );
186   }
187   // compute mass
188   theGroundStateMass = ( theL == 0 )
189     ? G4NucleiProperties::GetNuclearMass(theA, theZ)
190     : G4HyperNucleiProperties::GetNuclearMass(theA, theZ, theL); 
191 
192   // excitation energy
193   const G4double minFragExcitation = 10.*CLHEP::eV;
194   theExcitationEnergy = theMomentum.mag() - theGroundStateMass;
195   if(theExcitationEnergy < minFragExcitation) {
196     if(theExcitationEnergy < -minFragExcitation) {
197       ExcitationEnergyWarning();
198     }
199     theExcitationEnergy = 0.0;
200   }
201 }
202 
203 void G4Fragment::SetExcEnergyAndMomentum(G4double eexc, 
204            const G4LorentzVector& v)
205 {
206   theExcitationEnergy = eexc;
207   theMomentum.set(0.0, 0.0, 0.0, theGroundStateMass + eexc);
208   theMomentum.boost(v.boostVector());
209 }
210 
211 G4double G4Fragment::GetBindingEnergy() const
212 {
213   const G4double lambdaMass = 1.115683*CLHEP::GeV;
214   return (theA-theZ-theL)*CLHEP::neutron_mass_c2 
215     + theZ*CLHEP::proton_mass_c2 + theL*lambdaMass
216     - theGroundStateMass;
217 }
218 
219 G4Fragment & G4Fragment::operator=(const G4Fragment &right)
220 {
221   if (this != &right) {
222     theA = right.theA;
223     theZ = right.theZ;
224     theL = right.theL;
225     theExcitationEnergy = right.theExcitationEnergy;
226     theGroundStateMass = right.theGroundStateMass;
227     theMomentum  = right.theMomentum;
228     thePolarization = right.thePolarization;
229     creatorModel = right.creatorModel;
230     numberOfParticles = right.numberOfParticles;
231     numberOfCharged = right.numberOfCharged;
232     numberOfHoles = right.numberOfHoles;
233     numberOfChargedHoles = right.numberOfChargedHoles;
234     numberOfShellElectrons = right.numberOfShellElectrons;
235     xLevel = right.xLevel;
236     theParticleDefinition = right.theParticleDefinition;
237     spin = right.spin;
238     theCreationTime = right.theCreationTime;
239     isLongLived = right.isLongLived;
240   }
241   return *this;
242 }
243 
244 G4bool G4Fragment::operator==(const G4Fragment &right) const
245 {
246   return (this == (G4Fragment *) &right);
247 }
248 
249 G4bool G4Fragment::operator!=(const G4Fragment &right) const
250 {
251   return (this != (G4Fragment *) &right);
252 }
253 
254 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
255 {
256   std::ios::fmtflags old_floatfield = out.flags();
257   out.setf(std::ios::floatfield);
258 
259   out << "Fragment: A = " << std::setw(3) << theFragment.theA 
260       << ", Z = " << std::setw(3) << theFragment.theZ
261       << ", numberOfLambdas = " << std::setw(3) << theFragment.theL ;
262   out.setf(std::ios::scientific,std::ios::floatfield);
263 
264   // Store user's precision setting and reset to (3) here: back-compatibility
265   std::streamsize floatPrec = out.precision();
266 
267   out << std::setprecision(3)
268       << ", U = " << theFragment.GetExcitationEnergy()/CLHEP::MeV 
269       << " MeV  ";
270   if(theFragment.GetCreatorModelID() >= 0) { 
271     out << " creatorModelID= " << theFragment.GetCreatorModelID(); 
272   }
273   if(theFragment.GetCreationTime() > 0.0) { 
274     out << "  Time= " << theFragment.GetCreationTime()/CLHEP::ns << " ns"; 
275   }
276   out << G4endl
277       << "          P = (" 
278       << theFragment.GetMomentum().x()/CLHEP::MeV << ","
279       << theFragment.GetMomentum().y()/CLHEP::MeV << ","
280       << theFragment.GetMomentum().z()/CLHEP::MeV 
281       << ") MeV   E = " 
282       << theFragment.GetMomentum().t()/CLHEP::MeV << " MeV"
283       << G4endl;
284 
285   out << "    #spin= " << theFragment.GetSpin()
286       << "    #floatLevelNo= " << theFragment.GetFloatingLevelNumber() << "  ";
287         
288   if (theFragment.GetNumberOfExcitons() != 0) {
289     out << "   " 
290   << "#Particles= " << theFragment.GetNumberOfParticles() 
291   << ", #Charged= " << theFragment.GetNumberOfCharged()
292   << ", #Holes= "   << theFragment.GetNumberOfHoles()
293   << ", #ChargedHoles= " << theFragment.GetNumberOfChargedHoles();
294   } 
295   out << G4endl;
296   if(theFragment.GetNuclearPolarization()) { 
297     out << *(theFragment.GetNuclearPolarization()); 
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::CalculateExcitationEnergy(): WARNING "
310    << " GraundStateMass(MeV)= " << theGroundStateMass 
311    <<G4endl;
312   G4cout << *this << G4endl;
313 #endif
314 }
315 
316 void G4Fragment::NumberOfExitationWarning(const G4String& value)
317 {
318   G4ExceptionDescription ed;
319   ed << "Value=" << value << G4endl;
320   G4Exception( "G4Fragment::NumberOfExitationWarning : wrong exciton number ! ",
321          "HAD_FRAGMENT_03", FatalException, ed );
322 }
323 
324 void G4Fragment::SetAngularMomentum(const G4ThreeVector& v)
325 {
326   spin = v.mag();
327 }
328 
329 G4ThreeVector G4Fragment::GetAngularMomentum() const
330 {
331   G4ThreeVector v(0.0,0.0,spin);
332   return v;
333 }
334