Geant4 11.2.2
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"
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
103 return false;
104}
105
106//______________________________________________________________________________
107
110{
111 G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
112 return output > 0. ? output : 0.;
113}
114
115//______________________________________________________________________________
116
118 const G4Step&)
119{
121 auto pMotherMolecule = GetMolecule(track);
122 auto pMotherMoleculeDefinition = pMotherMolecule->GetDefinition();
123
124 if (pMotherMoleculeDefinition->GetDecayTable() != nullptr)
125 {
126 const auto pDissociationChannels = pMotherMolecule->GetDissociationChannels();
127
128 if (pDissociationChannels == nullptr)
129 {
130 G4ExceptionDescription exceptionDescription;
131 pMotherMolecule->PrintState();
132 exceptionDescription << "No decay channel was found for the molecule : "
133 << pMotherMolecule->GetName() << G4endl;
134 G4Exception("G4DNAMolecularDissociation::DecayIt",
135 "G4DNAMolecularDissociation::NoDecayChannel",
137 exceptionDescription);
138 return &aParticleChange;
139 }
140
141 auto decayVectorSize = pDissociationChannels->size();
142 G4double RdmValue = G4UniformRand();
143
144 const G4MolecularDissociationChannel* pDecayChannel = nullptr;
145 size_t i = 0;
146 do
147 {
148 pDecayChannel = (*pDissociationChannels)[i];
149 if (RdmValue < pDecayChannel->GetProbability())
150 {
151 break;
152 }
153 RdmValue -= pDecayChannel->GetProbability();
154 i++;
155 } while (i < decayVectorSize);
156
157 G4double decayEnergy = pDecayChannel->GetEnergy();
158 auto nbProducts = pDecayChannel->GetNbProducts();
159
160 if (decayEnergy > 0.)
161 {
163 }
164
165 if (nbProducts != 0)
166 {
167 std::vector<G4ThreeVector> productsDisplacement(nbProducts);
168 G4ThreeVector motherMoleculeDisplacement;
169
170 auto it = fDisplacementMap.find(pMotherMoleculeDefinition);
171
172 if (it != fDisplacementMap.end())
173 {
174 auto pDisplacer = it->second.get();
175 productsDisplacement = pDisplacer->GetProductsDisplacement(pDecayChannel);
176 motherMoleculeDisplacement =
177 pDisplacer->GetMotherMoleculeDisplacement(pDecayChannel);
178 }
179 else
180 {
182 errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
183 << pMotherMolecule->GetName() + "]";
184 G4Exception("G4MolecularDecayProcess::DecayIt",
185 "DNAMolecularDecay001",
187 errMsg);
188 }
189
191
192#ifdef G4VERBOSE
193 if (fVerbose != 0)
194 {
195 G4cout << "Decay Process : " << pMotherMolecule->GetName()
196 << " (trackID :" << track.GetTrackID() << ") "
197 << pDecayChannel->GetName() << G4endl;
198 }
199#endif
200
202
203 for (G4int j = 0; j < nbProducts; j++)
204 {
205 auto pProduct = new G4Molecule(pDecayChannel->GetProduct(j));
206
207 G4ThreeVector displacement = motherMoleculeDisplacement + productsDisplacement[j];
208 double mag_displacement = displacement.mag();
209 G4ThreeVector displacement_direction = displacement / (mag_displacement + 1e-30);
210
211 double prNewSafety = DBL_MAX;
212
213 //double step =
214 pNavigator->CheckNextStep(track.GetPosition(),
215 displacement_direction,
216 mag_displacement,
217 prNewSafety);
218
219 //if(prNewSafety < mag_displacement || step < mag_displacement)
220 mag_displacement = std::min(prNewSafety * 0.8, mag_displacement);
221
222 G4ThreeVector product_pos = track.GetPosition()
223 + displacement_direction * mag_displacement;
224
225 //Hoang: force changing position track::
226 if(fpBrownianAction != nullptr)
227 {
228 fpBrownianAction->Transport(product_pos);
229 }
230 //Hoang: force changing position track
231
232 const G4AffineTransform& transform = pNavigator->GetGlobalToLocalTransform();
233
234 G4ThreeVector localPoint = transform.TransformPoint(product_pos); //track.GetPosition());
235 // warning if the decayed product is outside of the volume and
236 // the mother volume has no water material (the decayed product
237 // is outside of the world volume will be killed in the next step)
238 if (track.GetTouchable()->GetSolid()->Inside(localPoint) !=
240 {
241 auto WaterMaterial = G4Material::GetMaterial("G4_WATER");
242 auto Motherlogic = track.GetTouchable()->GetVolume()->
243 GetMotherLogical();
244 if (Motherlogic != nullptr
245 && Motherlogic->GetMaterial() != WaterMaterial)
246 {
248 ED << "The decayed product is outside of the volume : "
249 << track.GetTouchable()->GetVolume()->GetName()
250 << " with material : "<< Motherlogic->GetMaterial()
251 ->GetName()<< G4endl;
252 G4Exception("G4DNAMolecularDissociation::DecayIt()",
253 "OUTSIDE_OF_MOTHER_VOLUME",
254 JustWarning, ED);
255 }
256 }
257
258 auto pSecondary = pProduct->BuildTrack(track.GetGlobalTime(), product_pos);
259
260 pSecondary->SetTrackStatus(fAlive);
261#ifdef G4VERBOSE
262 if (fVerbose != 0)
263 {
264 G4cout << "Product : " << pProduct->GetName() << G4endl;
265 }
266#endif
267 // add the secondary track in the List
268 aParticleChange.G4VParticleChange::AddSecondary(pSecondary);
269 }
270#ifdef G4VERBOSE
271 if (fVerbose != 0)
272 {
273 G4cout << "-------------" << G4endl;
274 }
275#endif
276 }
277 //DEBUG
278 else if ((fVerbose != 0) && (decayEnergy != 0.0))
279 {
280 G4cout << "No products for this channel" << G4endl;
281 G4cout << "-------------" << G4endl;
282 }
283 /*
284 else if(!decayEnergy && !nbProducts)
285 {
286 G4ExceptionDescription errMsg;
287 errMsg << "There is no products and no energy specified in the molecular "
288 "dissociation channel";
289 G4Exception("G4MolecularDissociationProcess::DecayIt",
290 "DNAMolecularDissociation002",
291 FatalErrorInArgument,
292 errMsg);
293 }
294 */
295 }
296
298
299 return &aParticleChange;
300}
301
302//______________________________________________________________________________
303
305{
306 fDisplacementMap.emplace(pSpecies, std::unique_ptr<Displacer>(pDisplacer));
307}
308
309//______________________________________________________________________________
310
312{
313 return fDisplacementMap[pSpecies].get();
314}
315
316//______________________________________________________________________________
317
319 G4double,
321{
322 return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
323}
324
325//______________________________________________________________________________
326
328{
329 fVerbose = verbose;
330}
331
332//______________________________________________________________________________
333
341
342//______________________________________________________________________________
343
354
355//______________________________________________________________________________
356
358 const G4Step& step)
359{
360 return AtRestDoIt(track, step);
361}
362
363//______________________________________________________________________________
364
G4double condition(const G4ErrorSymMatrix &m)
@ JustWarning
@ FatalException
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4ForceCondition
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:67
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)
G4double GetDecayTime() const
void Initialize(const G4Track &) override
const G4String & GetParticleType() const
const G4String & GetParticleName() const
virtual G4VSolid * GetSolid(G4int depth=0) const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
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
G4bool enableAtRestDoIt
G4int verboseLevel
G4bool enableAlongStepDoIt
void SetProcessSubType(G4int)
G4bool enablePostStepDoIt
G4VParticleChange * pParticleChange
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void Transport(G4ThreeVector &, G4Track *pTrack=nullptr)=0
@ kInside
Definition geomdefs.hh:70
#define DBL_MAX
Definition templates.hh:62