forked from cms-externals/geant4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathG4ReactionProduct.hh
More file actions
263 lines (190 loc) · 8.78 KB
/
Copy pathG4ReactionProduct.hh
File metadata and controls
263 lines (190 loc) · 8.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// J.L. Chuma, TRIUMF, 31-Oct-1996
// last modified: 19-Dec-1996
// modified by J.L.Chuma, 24-Jul-1997 to include total momentum
// inluded operator *, and some minor modifications.
// modified by H.P.Wellisch to add functionality needed by string models,
// cascade and Nucleus. (Mon Mar 16 1998)
// M. Kelsey 29-Aug-2011 -- Use G4Allocator model to avoid memory churn.
#ifndef G4REACTIONPRODUCT_HH
#define G4REACTIONPRODUCT_HH
#include "globals.hh"
#include "G4Allocator.hh"
#include "G4DynamicParticle.hh"
#include "G4HadProjectile.hh"
#include "G4ThreeVector.hh"
class G4ReactionProduct;
// To support better memory management and reduced fragmentation
//
#if defined G4HADRONIC_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4ReactionProduct>*& aRPAllocator();
#else
extern G4DLLIMPORT G4Allocator<G4ReactionProduct>*& aRPAllocator();
#endif
class G4ReactionProduct
{
friend G4ReactionProduct operator+(
const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
friend G4ReactionProduct operator-(
const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
friend G4ReactionProduct operator*(
const G4double aDouble, const G4ReactionProduct &p2 )
{
G4ReactionProduct result;
result.SetMomentum(aDouble*p2.GetMomentum());
result.SetMass(p2.GetMass());
result.SetTotalEnergy(std::sqrt(result.GetMass()*result.GetMass()+
result.GetMomentum()*result.GetMomentum()));
return result;
}
public:
G4ReactionProduct();
G4ReactionProduct(const G4ParticleDefinition *aParticleDefinition );
~G4ReactionProduct() = default;
G4ReactionProduct( const G4ReactionProduct &right ) = default;
// Override new and delete for use with G4Allocator
inline void* operator new(std::size_t) {
if (!aRPAllocator()) aRPAllocator() = new G4Allocator<G4ReactionProduct>;
return (void *)aRPAllocator()->MallocSingle();
}
inline void operator delete(void* aReactionProduct) {
aRPAllocator()->FreeSingle((G4ReactionProduct*)aReactionProduct);
}
G4ReactionProduct &operator= ( const G4ReactionProduct &right ) = default;
G4ReactionProduct &operator= ( const G4DynamicParticle &right );
G4ReactionProduct &operator= ( const G4HadProjectile &right );
inline G4bool operator== ( const G4ReactionProduct &right ) const
{ return ( this == (G4ReactionProduct*) &right ); }
inline G4bool operator!= ( const G4ReactionProduct &right ) const
{ return ( this != (G4ReactionProduct*) &right ); }
G4ReactionProduct(G4ReactionProduct&& from) = default;
G4ReactionProduct& operator=(G4ReactionProduct&& from) = default;
inline const G4ParticleDefinition* GetDefinition() const
{ return theParticleDefinition; }
void SetDefinition(const G4ParticleDefinition* aParticleDefinition );
inline void SetDefinitionAndUpdateE(const G4ParticleDefinition* p)
{ SetDefinition(p); }
void SetMomentum( const G4double x, const G4double y, const G4double z );
void SetMomentum( const G4double x, const G4double y );
void SetMomentum( const G4double z );
inline void SetMomentum( const G4ThreeVector &mom )
{ momentum = mom; }
inline G4ThreeVector GetMomentum() const
{ return momentum; }
inline G4double GetTotalMomentum() const
{ return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
inline G4double GetTotalEnergy() const
{ return totalEnergy; }
inline void SetKineticEnergy( const G4double en )
{
kineticEnergy = std::max(en, 0.0);
totalEnergy = kineticEnergy + mass;
}
inline G4double GetKineticEnergy() const
{ return kineticEnergy; }
inline void SetTotalEnergy( const G4double en )
{
totalEnergy = std::max(en, mass);
kineticEnergy = totalEnergy - mass;
}
inline void SetMass( const G4double mas )
{ mass = mas; totalEnergy = kineticEnergy + mas; }
inline G4double GetMass() const
{ return mass; }
inline void SetTOF( const G4double t )
{ timeOfFlight = t; }
inline G4double GetTOF() const
{ return timeOfFlight; }
inline void SetSide( const G4int sid )
{ side = sid; }
inline G4int GetSide() const
{ return side; }
inline void SetCreatorModelID( const G4int mod )
{ theCreatorModel = mod; }
inline G4int GetCreatorModelID() const
{ return theCreatorModel; }
inline const G4ParticleDefinition* GetParentResonanceDef() const
{ return theParentResonanceDef; }
inline void SetParentResonanceDef( const G4ParticleDefinition* parentDef )
{ theParentResonanceDef = parentDef; }
inline G4int GetParentResonanceID() const { return theParentResonanceID; }
inline void SetParentResonanceID ( const G4int parentID )
{ theParentResonanceID = parentID; }
inline void SetNewlyAdded( const G4bool f )
{ NewlyAdded = f; }
inline G4bool GetNewlyAdded() const
{ return NewlyAdded; }
inline void SetMayBeKilled( const G4bool f )
{ MayBeKilled = f; }
inline G4bool GetMayBeKilled() const
{ return MayBeKilled; }
void SetZero();
void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
G4double Angle( const G4ReactionProduct &p ) const;
inline void SetPositionInNucleus(G4double x, G4double y, G4double z)
{ positionInNucleus.set(x, y, z); }
inline void SetPositionInNucleus( G4ThreeVector & aPosition )
{ positionInNucleus = aPosition; }
inline const G4ThreeVector& GetPositionInNucleus() const
{ return positionInNucleus; }
inline G4double GetXPositionInNucleus() const
{ return positionInNucleus.x(); }
inline G4double GetYPositionInNucleus() const
{ return positionInNucleus.y(); }
inline G4double GetZPositionInNucleus() const
{ return positionInNucleus.z(); }
inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
inline G4double GetFormationTime() const { return formationTime; }
inline void HasInitialStateParton(G4bool aFlag)
{ hasInitialStateParton = aFlag; }
inline G4bool HasInitialStateParton() const
{ return hasInitialStateParton; }
private:
const G4ParticleDefinition *theParticleDefinition;
// for use with string models and cascade.
G4ThreeVector positionInNucleus;
G4double formationTime;
G4bool hasInitialStateParton;
// dynamic mass is included here, which is different from nominal
// mass of resonances
G4double mass;
G4ThreeVector momentum;
G4double totalEnergy;
G4double kineticEnergy;
G4double timeOfFlight;
// side refers to how the particles are distributed in the
// forward (+) and backward (-) hemispheres in the center of mass system
G4int side;
G4int theCreatorModel;
const G4ParticleDefinition* theParentResonanceDef = nullptr;
G4int theParentResonanceID;
// NewlyAdded refers to particles added by "nuclear excitation", or as
// "black track" particles, or as deuterons, tritons, and alphas
G4bool NewlyAdded;
G4bool MayBeKilled;
};
#endif