Geant4-11
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"
47
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//______________________________________________________________________________
82
84IsApplicable(const G4ParticleDefinition& aParticleType)
85{
86 if (aParticleType.GetParticleType() == "Molecule")
87 {
88#ifdef G4VERBOSE
89
90 if (fVerbose > 1)
91 {
92 G4cout << "G4MolecularDissociation::IsApplicable(";
93 G4cout << aParticleType.GetParticleName() << ",";
94 G4cout << aParticleType.GetParticleType() << ")" << G4endl;
95 }
96#endif
97 return (true);
98 }
99 else
100 {
101 return false;
102 }
103}
104
105//______________________________________________________________________________
106
109{
110 G4double output = GetMolecule(track)->GetDecayTime() - track.GetProperTime();
111 return output > 0. ? output : 0.;
112}
113
114//______________________________________________________________________________
115
117 const G4Step&)
118{
120 auto pMotherMolecule = GetMolecule(track);
121 auto pMotherMoleculeDefinition = pMotherMolecule->GetDefinition();
122
123 if (pMotherMoleculeDefinition->GetDecayTable())
124 {
125 const auto pDissociationChannels = pMotherMolecule->GetDissociationChannels();
126
127 if (pDissociationChannels == nullptr)
128 {
129 G4ExceptionDescription exceptionDescription;
130 pMotherMolecule->PrintState();
131 exceptionDescription << "No decay channel was found for the molecule : "
132 << pMotherMolecule->GetName() << G4endl;
133 G4Exception("G4DNAMolecularDissociation::DecayIt",
134 "G4DNAMolecularDissociation::NoDecayChannel",
136 exceptionDescription);
137 return &aParticleChange;
138 }
139
140 auto decayVectorSize = pDissociationChannels->size();
141 G4double RdmValue = G4UniformRand();
142
143 const G4MolecularDissociationChannel* pDecayChannel = nullptr;
144 size_t i = 0;
145 do
146 {
147 pDecayChannel = (*pDissociationChannels)[i];
148 if (RdmValue < pDecayChannel->GetProbability())
149 {
150 break;
151 }
152 RdmValue -= pDecayChannel->GetProbability();
153 i++;
154 } while (i < decayVectorSize);
155
156 G4double decayEnergy = pDecayChannel->GetEnergy();
157 auto nbProducts = pDecayChannel->GetNbProducts();
158
159 if (decayEnergy > 0.)
160 {
162 }
163
164 if (nbProducts)
165 {
166 std::vector<G4ThreeVector> productsDisplacement(nbProducts);
167 G4ThreeVector motherMoleculeDisplacement;
168
169 auto it = fDisplacementMap.find(pMotherMoleculeDefinition);
170
171 if (it != fDisplacementMap.end())
172 {
173 auto pDisplacer = it->second.get();
174 productsDisplacement = pDisplacer->GetProductsDisplacement(pDecayChannel);
175 motherMoleculeDisplacement =
176 pDisplacer->GetMotherMoleculeDisplacement(pDecayChannel);
177 }
178 else
179 {
181 errMsg << "No G4MolecularDecayProcess::theDecayDisplacementMap["
182 << pMotherMolecule->GetName() + "]";
183 G4Exception("G4MolecularDecayProcess::DecayIt",
184 "DNAMolecularDecay001",
186 errMsg);
187 }
188
190
191#ifdef G4VERBOSE
192 if (fVerbose)
193 {
194 G4cout << "Decay Process : " << pMotherMolecule->GetName()
195 << " (trackID :" << track.GetTrackID() << ") "
196 << pDecayChannel->GetName() << G4endl;
197 }
198#endif
199
201
202 for (G4int j = 0; j < nbProducts; j++)
203 {
204 auto pProduct = new G4Molecule(pDecayChannel->GetProduct(j));
205
206 G4ThreeVector displacement = motherMoleculeDisplacement + productsDisplacement[j];
207 double mag_displacement = displacement.mag();
208 G4ThreeVector displacement_direction = displacement / (mag_displacement + 1e-30);
209
210 double prNewSafety = DBL_MAX;
211
212 //double step =
213 pNavigator->CheckNextStep(track.GetPosition(),
214 displacement_direction,
215 mag_displacement,
216 prNewSafety);
217
218 //if(prNewSafety < mag_displacement || step < mag_displacement)
219 mag_displacement = std::min(prNewSafety * 0.8, mag_displacement);
220
221 G4ThreeVector product_pos = track.GetPosition()
222 + displacement_direction * mag_displacement;
223
224 const G4AffineTransform& transform = pNavigator->GetGlobalToLocalTransform();
225
226 G4ThreeVector localPoint = transform.TransformPoint(product_pos); //track.GetPosition());
227
228 if (track.GetTouchable()->GetSolid()->Inside(localPoint) !=
230 {
232 ED << "The decayed product is outside of the volume : "
233 << track.GetTouchable()->GetVolume()->GetName() << G4endl;
234 G4Exception("G4DNAMolecularDissociation::DecayIt()",
235 "OUTSIDE_OF_MOTHER_VOLUME",
236 JustWarning, ED);
237 }
238
239 auto pSecondary = pProduct->BuildTrack(track.GetGlobalTime(), product_pos);
240
241 pSecondary->SetTrackStatus(fAlive);
242#ifdef G4VERBOSE
243 if (fVerbose)
244 {
245 G4cout << "Product : " << pProduct->GetName() << G4endl;
246 }
247#endif
248 // add the secondary track in the List
249 aParticleChange.G4VParticleChange::AddSecondary(pSecondary);
250 }
251#ifdef G4VERBOSE
252 if (fVerbose)
253 {
254 G4cout << "-------------" << G4endl;
255 }
256#endif
257 }
258 //DEBUG
259 else if (fVerbose && decayEnergy)
260 {
261 G4cout << "No products for this channel" << G4endl;
262 G4cout << "-------------" << G4endl;
263 }
264 /*
265 else if(!decayEnergy && !nbProducts)
266 {
267 G4ExceptionDescription errMsg;
268 errMsg << "There is no products and no energy specified in the molecular "
269 "dissociation channel";
270 G4Exception("G4MolecularDissociationProcess::DecayIt",
271 "DNAMolecularDissociation002",
272 FatalErrorInArgument,
273 errMsg);
274 }
275 */
276 }
277
279
280 return &aParticleChange;
281}
282
283//______________________________________________________________________________
284
286{
287 fDisplacementMap.emplace(pSpecies, std::unique_ptr<Displacer>(pDisplacer));
288}
289
290//______________________________________________________________________________
291
293{
294 return fDisplacementMap[pSpecies].get();
295}
296
297//______________________________________________________________________________
298
300 G4double,
302{
303 return 0; //-1*(-log(1-G4UniformRand())*100*1e-15*s);
304}
305
306//______________________________________________________________________________
307
309{
310 fVerbose = verbose;
311}
312
313//______________________________________________________________________________
314
316 const G4Step& step)
317{
320 return DecayIt(track, step);
321}
322
323//______________________________________________________________________________
324
327{
329 {
330 return GetMeanLifeTime(track, condition);
331 }
332
334}
335
336//______________________________________________________________________________
337
339 const G4Step& step)
340{
341 return AtRestDoIt(track, step);
342}
343
344//______________________________________________________________________________
345
347 G4double,
349{
350 return 0;
351}
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
@ fLowEnergyMolecularDecay
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
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:42
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:34
@ kInside
Definition: geomdefs.hh:70
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool transform(G4String &input, const G4String &type)
#define DBL_MAX
Definition: templates.hh:62