Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
48//______________________________________________________________________________
49
51G4DNAMolecularDissociation(const G4String& processName,
52 G4ProcessType type)
53 : G4VITRestDiscreteProcess(processName, type)
54{
55 // set Process Sub Type
57 enableAlongStepDoIt = false;
58 enablePostStepDoIt = true;
59 enableAtRestDoIt = true;
60
61 fVerbose = 0;
62
63#ifdef G4VERBOSE
64 if (verboseLevel > 1)
65 {
66 G4cout << "G4MolecularDissociationProcess constructor " << " Name:"
67 << processName << G4endl;
68 }
69#endif
70
72
73 fDecayAtFixedTime = true;
74 fProposesTimeStep = true;
75}
76
77//______________________________________________________________________________
78
80{
81 delete fpBrownianAction;
82}
83
84//______________________________________________________________________________
85
87IsApplicable(const G4ParticleDefinition& aParticleType)
88{
89 if (aParticleType.GetParticleType() == "Molecule")
90 {
91#ifdef G4VERBOSE
92
93 if (fVerbose > 1)
94 {
95 G4cout << "G4MolecularDissociation::IsApplicable(";
96 G4cout << aParticleType.GetParticleName() << ",";
97 G4cout << aParticleType.GetParticleType() << ")" << G4endl;
98 }
99#endif
100 return (true);
101 }
102 else
103 {
104 return false;
105 }
106}
107
108//______________________________________________________________________________
109
112{
113 G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
114 return output > 0. ? output : 0.;
115}
116
117//______________________________________________________________________________
118
120 const G4Step&)
121{
123 auto pMotherMolecule = GetMolecule(track);
124 auto pMotherMoleculeDefinition = pMotherMolecule->GetDefinition();
125
126 if (pMotherMoleculeDefinition->GetDecayTable())
127 {
128 const auto pDissociationChannels = pMotherMolecule->GetDissociationChannels();
129
130 if (pDissociationChannels == nullptr)
131 {
132 G4ExceptionDescription exceptionDescription;
133 pMotherMolecule->PrintState();
134 exceptionDescription << "No decay channel was found for the molecule : "
135 << pMotherMolecule->GetName() << G4endl;
136 G4Exception("G4DNAMolecularDissociation::DecayIt",
137 "G4DNAMolecularDissociation::NoDecayChannel",
139 exceptionDescription);
140 return &aParticleChange;
141 }
142
143 auto decayVectorSize = pDissociationChannels->size();
144 G4double RdmValue = G4UniformRand();
145
146 const G4MolecularDissociationChannel* pDecayChannel = nullptr;
147 size_t i = 0;
148 do
149 {
150 pDecayChannel = (*pDissociationChannels)[i];
151 if (RdmValue < pDecayChannel->GetProbability())
152 {
153 break;
154 }
155 RdmValue -= pDecayChannel->GetProbability();
156 i++;
157 } while (i < decayVectorSize);
158
159 G4double decayEnergy = pDecayChannel->GetEnergy();
160 auto nbProducts = pDecayChannel->GetNbProducts();
161
162 if (decayEnergy > 0.)
163 {
165 }
166
167 if (nbProducts)
168 {
169 std::vector<G4ThreeVector> productsDisplacement(nbProducts);
170 G4ThreeVector motherMoleculeDisplacement;
171
172 auto it = fDisplacementMap.find(pMotherMoleculeDefinition);
173
174 if (it != fDisplacementMap.end())
175 {
176 auto pDisplacer = it->second.get();
177 productsDisplacement = pDisplacer->GetProductsDisplacement(pDecayChannel);
178 motherMoleculeDisplacement =
179 pDisplacer->GetMotherMoleculeDisplacement(pDecayChannel);
180 }
181 else
182 {
184 errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
185 << pMotherMolecule->GetName() + "]";
186 G4Exception("G4MolecularDecayProcess::DecayIt",
187 "DNAMolecularDecay001",
189 errMsg);
190 }
191
193
194#ifdef G4VERBOSE
195 if (fVerbose)
196 {
197 G4cout << "Decay Process : " << pMotherMolecule->GetName()
198 << " (trackID :" << track.GetTrackID() << ") "
199 << pDecayChannel->GetName() << G4endl;
200 }
201#endif
202
204
205 for (G4int j = 0; j < nbProducts; j++)
206 {
207 auto pProduct = new G4Molecule(pDecayChannel->GetProduct(j));
208
209 G4ThreeVector displacement = motherMoleculeDisplacement + productsDisplacement[j];
210 double mag_displacement = displacement.mag();
211 G4ThreeVector displacement_direction = displacement / (mag_displacement + 1e-30);
212
213 double prNewSafety = DBL_MAX;
214
215 //double step =
216 pNavigator->CheckNextStep(track.GetPosition(),
217 displacement_direction,
218 mag_displacement,
219 prNewSafety);
220
221 //if(prNewSafety < mag_displacement || step < mag_displacement)
222 mag_displacement = std::min(prNewSafety * 0.8, mag_displacement);
223
224 G4ThreeVector product_pos = track.GetPosition()
225 + displacement_direction * mag_displacement;
226
227 //Hoang: force changing position track::
228 if(fpBrownianAction != nullptr)
229 {
230 fpBrownianAction->Transport(product_pos);
231 }
232 //Hoang: force changing position track
233
234 const G4AffineTransform& transform = pNavigator->GetGlobalToLocalTransform();
235
236 G4ThreeVector localPoint = transform.TransformPoint(product_pos); //track.GetPosition());
237 // warning if the decayed product is outside of the volume and
238 // the mother volume has no water material (the decayed product
239 // is outside of the world volume will be killed in the next step)
240 if (track.GetTouchable()->GetSolid()->Inside(localPoint) !=
241 EInside::kInside)
242 {
243 auto WaterMaterial = G4Material::GetMaterial("G4_WATER");
244 auto Motherlogic = track.GetTouchable()->GetVolume()->
245 GetMotherLogical();
246 if (Motherlogic != nullptr
247 && Motherlogic->GetMaterial() != WaterMaterial)
248 {
250 ED << "The decayed product is outside of the volume : "
251 << track.GetTouchable()->GetVolume()->GetName()
252 << " with material : "<< Motherlogic->GetMaterial()
253 ->GetName()<< G4endl;
254 G4Exception("G4DNAMolecularDissociation::DecayIt()",
255 "OUTSIDE_OF_MOTHER_VOLUME",
256 JustWarning, ED);
257 }
258 }
259
260 auto pSecondary = pProduct->BuildTrack(track.GetGlobalTime(), product_pos);
261
262 pSecondary->SetTrackStatus(fAlive);
263#ifdef G4VERBOSE
264 if (fVerbose)
265 {
266 G4cout << "Product : " << pProduct->GetName() << G4endl;
267 }
268#endif
269 // add the secondary track in the List
270 aParticleChange.G4VParticleChange::AddSecondary(pSecondary);
271 }
272#ifdef G4VERBOSE
273 if (fVerbose)
274 {
275 G4cout << "-------------" << G4endl;
276 }
277#endif
278 }
279 //DEBUG
280 else if (fVerbose && decayEnergy)
281 {
282 G4cout << "No products for this channel" << G4endl;
283 G4cout << "-------------" << G4endl;
284 }
285 /*
286 else if(!decayEnergy && !nbProducts)
287 {
288 G4ExceptionDescription errMsg;
289 errMsg << "There is no products and no energy specified in the molecular "
290 "dissociation channel";
291 G4Exception("G4MolecularDissociationProcess::DecayIt",
292 "DNAMolecularDissociation002",
293 FatalErrorInArgument,
294 errMsg);
295 }
296 */
297 }
298
300
301 return &aParticleChange;
302}
303
304//______________________________________________________________________________
305
307{
308 fDisplacementMap.emplace(pSpecies, std::unique_ptr<Displacer>(pDisplacer));
309}
310
311//______________________________________________________________________________
312
314{
315 return fDisplacementMap[pSpecies].get();
316}
317
318//______________________________________________________________________________
319
321 G4double,
323{
324 return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
325}
326
327//______________________________________________________________________________
328
330{
331 fVerbose = verbose;
332}
333
334//______________________________________________________________________________
335
337 const G4Step& step)
338{
341 return DecayIt(track, step);
342}
343
344//______________________________________________________________________________
345
348{
349 if (fDecayAtFixedTime)
350 {
351 return GetMeanLifeTime(track, condition);
352 }
353
355}
356
357//______________________________________________________________________________
358
360 const G4Step& step)
361{
362 return AtRestDoIt(track, step);
363}
364
365//______________________________________________________________________________
366
368 G4double,
370{
371 return 0;
372}
G4double condition(const G4ErrorSymMatrix &m)
@ JustWarning
@ FatalException
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4ForceCondition
@ fLowEnergyMolecularDecay
G4Molecule * GetMolecule(const G4Track &track)
Definition: G4Molecule.cc:74
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
static G4ITTransportationManager * GetTransportationManager()
G4ITNavigator * GetNavigatorForTracking() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:691
G4double GetDecayTime() const
Definition: G4Molecule.cc:472
void Initialize(const G4Track &) override
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:331
G4bool enableAtRestDoIt
Definition: G4VProcess.hh:363
G4int verboseLevel
Definition: G4VProcess.hh:360
G4bool enableAlongStepDoIt
Definition: G4VProcess.hh:364
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:410
G4bool enablePostStepDoIt
Definition: G4VProcess.hh:365
G4VParticleChange * pParticleChange
Definition: G4VProcess.hh:325
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4VSolid * GetSolid(G4int depth=0) const
Definition: G4VTouchable.cc:42
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:34
virtual void Transport(G4ThreeVector &, G4Track *pTrack=nullptr)=0
#define DBL_MAX
Definition: templates.hh:62