Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAMolecularDissociation.cc
Go to the documentation of this file.
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// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
28//
29// WARNING : This class is released as a prototype.
30// It might strongly evolve or even disapear in the next releases.
31//
32// History:
33// -----------
34// 10 Oct 2011 M.Karamitros created
35//
36// -------------------------------------------------------------------
37
40#include "G4SystemOfUnits.hh"
41#include "G4Track.hh"
42#include "G4Molecule.hh"
43#include "G4ParticleChange.hh"
45#include "G4ITNavigator.hh"
46
47//______________________________________________________________________________
48
50G4DNAMolecularDissociation(const G4String& processName,
51 G4ProcessType type)
52 : G4VITRestDiscreteProcess(processName, type)
53{
54 // set Process Sub Type
55 SetProcessSubType(59); // DNA sub-type
56 enableAlongStepDoIt = false;
57 enablePostStepDoIt = true;
58 enableAtRestDoIt = true;
59
60 fVerbose = 0;
61
62#ifdef G4VERBOSE
63 if (verboseLevel > 1)
64 {
65 G4cout << "G4MolecularDissociationProcess constructor " << " Name:"
66 << processName << G4endl;
67 }
68#endif
69
71
72 fDecayAtFixedTime = true;
73 fProposesTimeStep = true;
74}
75
76//______________________________________________________________________________
77
79
80//______________________________________________________________________________
81
83IsApplicable(const G4ParticleDefinition& aParticleType)
84{
85 if (aParticleType.GetParticleType() == "Molecule")
86 {
87#ifdef G4VERBOSE
88
89 if (fVerbose > 1)
90 {
91 G4cout << "G4MolecularDissociation::IsApplicable(";
92 G4cout << aParticleType.GetParticleName() << ",";
93 G4cout << aParticleType.GetParticleType() << ")" << G4endl;
94 }
95#endif
96 return (true);
97 }
98 else
99 {
100 return false;
101 }
102}
103
104//______________________________________________________________________________
105
108{
109 G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
110 return output > 0. ? output : 0.;
111}
112
113//______________________________________________________________________________
114
116 const G4Step&)
117{
119 auto pMotherMolecule = GetMolecule(track);
120 auto pMotherMoleculeDefinition = pMotherMolecule->GetDefinition();
121
122 if (pMotherMoleculeDefinition->GetDecayTable())
123 {
124 const auto pDissociationChannels = pMotherMolecule->GetDissociationChannels();
125
126 if (pDissociationChannels == nullptr)
127 {
128 G4ExceptionDescription exceptionDescription;
129 pMotherMolecule->PrintState();
130 exceptionDescription << "No decay channel was found for the molecule : "
131 << pMotherMolecule->GetName() << G4endl;
132 G4Exception("G4DNAMolecularDissociation::DecayIt",
133 "G4DNAMolecularDissociation::NoDecayChannel",
135 exceptionDescription);
136 return &aParticleChange;
137 }
138
139 auto decayVectorSize = pDissociationChannels->size();
140 G4double RdmValue = G4UniformRand();
141
142 const G4MolecularDissociationChannel* pDecayChannel = nullptr;
143 size_t i = 0;
144 do
145 {
146 pDecayChannel = (*pDissociationChannels)[i];
147 if (RdmValue < pDecayChannel->GetProbability())
148 {
149 break;
150 }
151 RdmValue -= pDecayChannel->GetProbability();
152 i++;
153 } while (i < decayVectorSize);
154
155 G4double decayEnergy = pDecayChannel->GetEnergy();
156 auto nbProducts = pDecayChannel->GetNbProducts();
157
158 if (decayEnergy > 0.)
159 {
161 }
162
163 if (nbProducts)
164 {
165 std::vector<G4ThreeVector> productsDisplacement(nbProducts);
166 G4ThreeVector motherMoleculeDisplacement;
167
168 auto it = fDisplacementMap.find(pMotherMoleculeDefinition);
169
170 if (it != fDisplacementMap.end())
171 {
172 auto pDisplacer = it->second.get();
173 productsDisplacement = pDisplacer->GetProductsDisplacement(pDecayChannel);
174 motherMoleculeDisplacement =
175 pDisplacer->GetMotherMoleculeDisplacement(pDecayChannel);
176 }
177 else
178 {
180 errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
181 << pMotherMolecule->GetName() + "]";
182 G4Exception("G4MolecularDecayProcess::DecayIt",
183 "DNAMolecularDecay001",
185 errMsg);
186 }
187
189
190#ifdef G4VERBOSE
191 if (fVerbose)
192 {
193 G4cout << "Decay Process : " << pMotherMolecule->GetName()
194 << " (trackID :" << track.GetTrackID() << ") "
195 << pDecayChannel->GetName() << G4endl;
196 }
197#endif
198
200
201 for (G4int j = 0; j < nbProducts; j++)
202 {
203 auto pProduct = new G4Molecule(pDecayChannel->GetProduct(j));
204
205 G4ThreeVector displacement = motherMoleculeDisplacement + productsDisplacement[j];
206 double mag_displacement = displacement.mag();
207 G4ThreeVector displacement_direction = displacement / (mag_displacement + 1e-30);
208
209 double prNewSafety = DBL_MAX;
210
211 //double step =
212 pNavigator->CheckNextStep(track.GetPosition(),
213 displacement_direction,
214 mag_displacement,
215 prNewSafety);
216
217 //if(prNewSafety < mag_displacement || step < mag_displacement)
218 mag_displacement = std::min(prNewSafety * 0.8, mag_displacement);
219
220 G4ThreeVector product_pos = track.GetPosition()
221 + displacement_direction * mag_displacement;
222
223 const G4AffineTransform& transform = pNavigator->GetGlobalToLocalTransform();
224
225 G4ThreeVector localPoint = transform.TransformPoint(product_pos); //track.GetPosition());
226
227 if (track.GetTouchable()->GetSolid()->Inside(localPoint) !=
228 EInside::kInside)
229 {
231 ED << "The decayed product is outside of the volume : "
232 << track.GetTouchable()->GetVolume()->GetName() << G4endl;
233 G4Exception("G4DNAMolecularDissociation::DecayIt()",
234 "OUTSIDE_OF_MOTHER_VOLUME",
235 JustWarning, ED);
236 }
237
238 auto pSecondary = pProduct->BuildTrack(track.GetGlobalTime(), product_pos);
239
240 pSecondary->SetTrackStatus(fAlive);
241#ifdef G4VERBOSE
242 if (fVerbose)
243 {
244 G4cout << "Product : " << pProduct->GetName() << G4endl;
245 }
246#endif
247 // add the secondary track in the List
248 aParticleChange.G4VParticleChange::AddSecondary(pSecondary);
249 }
250#ifdef G4VERBOSE
251 if (fVerbose)
252 {
253 G4cout << "-------------" << G4endl;
254 }
255#endif
256 }
257 //DEBUG
258 else if (fVerbose && decayEnergy)
259 {
260 G4cout << "No products for this channel" << G4endl;
261 G4cout << "-------------" << G4endl;
262 }
263 /*
264 else if(!decayEnergy && !nbProducts)
265 {
266 G4ExceptionDescription errMsg;
267 errMsg << "There is no products and no energy specified in the molecular "
268 "dissociation channel";
269 G4Exception("G4MolecularDissociationProcess::DecayIt",
270 "DNAMolecularDissociation002",
271 FatalErrorInArgument,
272 errMsg);
273 }
274 */
275 }
276
278
279 return &aParticleChange;
280}
281
282//______________________________________________________________________________
283
285{
286 fDisplacementMap.emplace(pSpecies, std::unique_ptr<Displacer>(pDisplacer));
287}
288
289//______________________________________________________________________________
290
292{
293 return fDisplacementMap[pSpecies].get();
294}
295
296//______________________________________________________________________________
297
299 G4double,
301{
302 return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
303}
304
305//______________________________________________________________________________
306
308{
309 fVerbose = verbose;
310}
311
312//______________________________________________________________________________
313
315 const G4Step& step)
316{
319 return DecayIt(track, step);
320}
321
322//______________________________________________________________________________
323
326{
327 if (fDecayAtFixedTime)
328 {
329 return GetMeanLifeTime(track, condition);
330 }
331
333}
334
335//______________________________________________________________________________
336
338 const G4Step& step)
339{
340 return AtRestDoIt(track, step);
341}
342
343//______________________________________________________________________________
344
346 G4double,
348{
349 return 0;
350}
G4double condition(const G4ErrorSymMatrix &m)
@ JustWarning
@ FatalException
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4ForceCondition
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:76
G4ProcessType
@ fAlive
@ fStopAndKill
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
double mag() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
void SetDisplacer(Species *, Displacer *)
G4bool IsApplicable(const G4ParticleDefinition &) override
G4double AtRestGetPhysicalInteractionLength(const G4Track &track, G4ForceCondition *condition) override
virtual G4VParticleChange * DecayIt(const G4Track &, const G4Step &)
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *) override
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step) override
G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &step) override
G4double GetMeanLifeTime(const G4Track &, G4ForceCondition *) override
G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override
~G4DNAMolecularDissociation() override
static G4ITTransportationManager * GetTransportationManager()
G4ITNavigator * GetNavigatorForTracking() const
G4double GetDecayTime() const
Definition: G4Molecule.cc:474
virtual void Initialize(const G4Track &)
const G4String & GetParticleType() const
const G4String & GetParticleName() const
Definition: G4Step.hh:62
G4int GetTrackID() const
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
G4double GetProperTime() const
const G4VTouchable * GetTouchable() const
virtual void ClearInteractionTimeLeft()
virtual void ClearNumberOfInteractionLengthLeft()
G4bool fProposesTimeStep
Identical to G4VRestDiscreteProcess with dependency from G4VITProcess.
G4double AtRestGetPhysicalInteractionLength(const G4Track &, G4ForceCondition *) override
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetNumberOfSecondaries(G4int totSecondaries)
const G4String & GetName() const
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:327
G4bool enableAtRestDoIt
Definition: G4VProcess.hh:359
G4int verboseLevel
Definition: G4VProcess.hh:356
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:360
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:406
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:361
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:321
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4VSolid * GetSolid(G4int depth=0) const
Definition: G4VTouchable.cc:48
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:41
#define DBL_MAX
Definition: templates.hh:62