ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DNAMolecularDissociation.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4DNAMolecularDissociation.cc
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 
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 
83 IsApplicable(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  {
179  G4ExceptionDescription errMsg;
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) !=
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 }