ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Fragment.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Fragment.cc
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 
40 #include "G4Fragment.hh"
41 #include "G4HadronicException.hh"
42 #include "G4ios.hh"
43 #include <iomanip>
44 
46 {
47  G4ThreadLocalStatic G4Allocator<G4Fragment>* _instance = nullptr;
48  return _instance;
49 }
50 
52 
53 // Default constructor
55  theA(0),
56  theZ(0),
57  theExcitationEnergy(0.0),
58  theGroundStateMass(0.0),
59  theMomentum(G4LorentzVector(0,0,0,0)),
60  thePolarization(nullptr),
61  creatorModel(-1),
63  numberOfCharged(0),
64  numberOfHoles(0),
65  numberOfChargedHoles(0),
66  numberOfShellElectrons(0),
67  xLevel(0),
68  theParticleDefinition(nullptr),
69  spin(0.0),
70  theCreationTime(0.0)
71 {}
72 
73 // Copy Constructor
75  theA(right.theA),
76  theZ(right.theZ),
77  theExcitationEnergy(right.theExcitationEnergy),
78  theGroundStateMass(right.theGroundStateMass),
79  theMomentum(right.theMomentum),
80  thePolarization(right.thePolarization),
81  creatorModel(right.creatorModel),
83  numberOfCharged(right.numberOfCharged),
84  numberOfHoles(right.numberOfHoles),
85  numberOfChargedHoles(right.numberOfChargedHoles),
86  numberOfShellElectrons(right.numberOfShellElectrons),
87  xLevel(right.xLevel),
88  theParticleDefinition(right.theParticleDefinition),
89  spin(right.spin),
90  theCreationTime(right.theCreationTime)
91 {}
92 
94 {}
95 
97  theA(A),
98  theZ(Z),
99  theExcitationEnergy(0.0),
100  theGroundStateMass(0.0),
101  theMomentum(aMomentum),
102  thePolarization(nullptr),
103  creatorModel(-1),
105  numberOfCharged(0),
106  numberOfHoles(0),
107  numberOfChargedHoles(0),
108  numberOfShellElectrons(0),
109  xLevel(0),
110  theParticleDefinition(nullptr),
111  spin(0.0),
112  theCreationTime(0.0)
113 {
114  if(theA > 0) {
117  }
118 }
119 
120 // This constructor is for initialize photons or electrons
122  const G4ParticleDefinition * aParticleDefinition) :
123  theA(0),
124  theZ(0),
125  theExcitationEnergy(0.0),
126  theMomentum(aMomentum),
127  thePolarization(nullptr),
128  creatorModel(-1),
130  numberOfCharged(0),
131  numberOfHoles(0),
132  numberOfChargedHoles(0),
133  numberOfShellElectrons(0),
134  xLevel(0),
135  theParticleDefinition(aParticleDefinition),
136  spin(0.0),
137  theCreationTime(0.0)
138 {
139  if(aParticleDefinition->GetPDGEncoding() != 22 &&
140  aParticleDefinition->GetPDGEncoding() != 11) {
141  G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
142  + aParticleDefinition->GetParticleName();
143  throw G4HadronicException(__FILE__, __LINE__, text);
144  }
145  theGroundStateMass = aParticleDefinition->GetPDGMass();
146 }
147 
149 {
150  if (this != &right) {
151  theA = right.theA;
152  theZ = right.theZ;
155  theMomentum = right.theMomentum;
157  creatorModel = right.creatorModel;
163  xLevel = right.xLevel;
165  spin = right.spin;
167  }
168  return *this;
169 }
170 
172 {
173  return (this == (G4Fragment *) &right);
174 }
175 
177 {
178  return (this != (G4Fragment *) &right);
179 }
180 
181 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
182 {
183  std::ios::fmtflags old_floatfield = out.flags();
184  out.setf(std::ios::floatfield);
185 
186  out << "Fragment: A = " << std::setw(3) << theFragment.theA
187  << ", Z = " << std::setw(3) << theFragment.theZ ;
188  out.setf(std::ios::scientific,std::ios::floatfield);
189 
190  // Store user's precision setting and reset to (3) here: back-compatibility
191  std::streamsize floatPrec = out.precision();
192 
193  out << std::setprecision(3)
194  << ", U = " << theFragment.GetExcitationEnergy()/CLHEP::MeV
195  << " MeV ";
196  if(theFragment.GetCreatorModelType() >= 0) {
197  out << " creatorModelType= " << theFragment.GetCreatorModelType();
198  }
199  if(theFragment.GetCreationTime() > 0.0) {
200  out << " Time= " << theFragment.GetCreationTime()/CLHEP::ns << " ns";
201  }
202  out << G4endl
203  << " P = ("
204  << theFragment.GetMomentum().x()/CLHEP::MeV << ","
205  << theFragment.GetMomentum().y()/CLHEP::MeV << ","
206  << theFragment.GetMomentum().z()/CLHEP::MeV
207  << ") MeV E = "
208  << theFragment.GetMomentum().t()/CLHEP::MeV << " MeV"
209  << G4endl;
210 
211  out << " #spin= " << theFragment.GetSpin()
212  << " #floatLevelNo= " << theFragment.GetFloatingLevelNumber() << " ";
213 
214  if (theFragment.GetNumberOfExcitons() != 0) {
215  out << " "
216  << "#Particles= " << theFragment.GetNumberOfParticles()
217  << ", #Charged= " << theFragment.GetNumberOfCharged()
218  << ", #Holes= " << theFragment.GetNumberOfHoles()
219  << ", #ChargedHoles= " << theFragment.GetNumberOfChargedHoles();
220  }
221  out << G4endl;
222  if(theFragment.GetNuclearPolarization()) {
223  out << *(theFragment.GetNuclearPolarization());
224  }
225  //out << G4endl;
226  out.setf(old_floatfield,std::ios::floatfield);
227  out.precision(floatPrec);
228 
229  return out;
230 }
231 
233 {
234 #ifdef G4VERBOSE
235  G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
236  G4cout << *this << G4endl;
237 #endif
238 }
239 
241 {
242  G4cout << "G4Fragment::"<< value << " ERROR "
243  << G4endl;
244  G4cout << this << G4endl;
245  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
246  throw G4HadronicException(__FILE__, __LINE__, text);
247 }
248 
250 {
251  spin = v.mag();
252 }
253 
255 {
256  G4ThreeVector v(0.0,0.0,spin);
257  return v;
258 }