ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DNAMolecularReaction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4DNAMolecularReaction.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@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 "G4VDNAReactionModel.hh"
42 #include "G4Molecule.hh"
43 #include "G4MoleculeFinder.hh"
44 #include "G4ITReactionChange.hh"
45 
48  , fMolReactionTable(reference_cast<const G4DNAMolecularReactionTable*>(fpReactionTable))
49  , fpReactionModel(nullptr)
50 {
51 }
52 
55 {
56  fpReactionModel = pReactionModel;
57 }
58 
60  const G4Track &trackB,
61  double currentStepTime,
62  bool userStepTimeLimit) /*const*/
63 {
64  const auto pMoleculeA = GetMolecule(trackA)->GetMolecularConfiguration();
65  const auto pMoleculeB = GetMolecule(trackB)->GetMolecularConfiguration();
66 
67  const G4double reactionRadius = fpReactionModel->GetReactionRadius(pMoleculeA, pMoleculeB);
68 
69  G4double separationDistance = -1.;
70 
71  if (currentStepTime == 0.)
72  {
73  userStepTimeLimit = false;
74  }
75 
76  G4bool output = fpReactionModel->FindReaction(trackA, trackB, reactionRadius,
77  separationDistance, userStepTimeLimit);
78  return output;
79 }
80 
81 std::unique_ptr<G4ITReactionChange> G4DNAMolecularReaction::MakeReaction(const G4Track &trackA,
82  const G4Track &trackB)
83 {
84  std::unique_ptr<G4ITReactionChange> pChanges(new G4ITReactionChange());
85  pChanges->Initialize(trackA, trackB);
86 
87  const auto pMoleculeA = GetMolecule(trackA)->GetMolecularConfiguration();
88  const auto pMoleculeB = GetMolecule(trackB)->GetMolecularConfiguration();
89 
90  const auto pReactionData = fMolReactionTable->GetReactionData(pMoleculeA, pMoleculeB);
91 
92  const G4int nbProducts = pReactionData->GetNbProducts();
93 
94  if (nbProducts)
95  {
96  const G4double D1 = pMoleculeA->GetDiffusionCoefficient();
97  const G4double D2 = pMoleculeB->GetDiffusionCoefficient();
98  const G4double sqrD1 = D1 == 0. ? 0. : std::sqrt(D1);
99  const G4double sqrD2 = D2 == 0. ? 0. : std::sqrt(D2);
100  const G4double inv_numerator = 1./(sqrD1 + sqrD2);
101  const G4ThreeVector reactionSite = sqrD2 * inv_numerator * trackA.GetPosition()
102  + sqrD1 * inv_numerator * trackB.GetPosition();
103 
104  for (G4int j = 0; j < nbProducts; ++j)
105  {
106  auto pProduct = new G4Molecule(pReactionData->GetProduct(j));
107  auto pProductTrack = pProduct->BuildTrack(trackA.GetGlobalTime(), reactionSite);
108 
109  pProductTrack->SetTrackStatus(fAlive);
110 
111  pChanges->AddSecondary(pProductTrack);
112  G4MoleculeFinder::Instance()->Push(pProductTrack);
113  }
114  }
115 
116  pChanges->KillParents(true);
117  return pChanges;
118 }
119 
121 {
122  fpReactionModel = pReactionModel;
123 }