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.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // G4DNAMultipleIonisationManager.cc
 27 //
 28 //  Created at 2024/04/03 (Thu.)
 29 //  Author: Shogo OKADA @KEK-CRC (shogo.okada@kek.jp)
 30 //
 31 
 32 #include "G4DNAMultipleIonisationManager.hh"
 33 #include "G4FindDataDir.hh"
 34 #include "G4Scheduler.hh"
 35 #include "G4SystemOfUnits.hh"
 36 #include "G4Molecule.hh"
 37 #include "G4VITTrackHolder.hh"
 38 #include "G4H2O.hh"
 39 #include "G4DNAChemistryManager.hh"
 40 
 41 //------------------------------------------------------------------------------
 42 void G4DNAMultipleIonisationManager::CreateMultipleIonisedWaterMolecule(
 43   MultipleIonisedModification mod, G4int* shell_level,
 44   const G4Track* incoming_track)
 45 {
 46   if (!G4DNAChemistryManager::IsActivated()) { return; }
 47 
 48   G4int num_shells{0};
 49   switch (mod) {
 50     case eDoubleIonisedMolecule:
 51       num_shells = 2;
 52       break;
 53     case eTripleIonisedMolecule:
 54       num_shells = 3;
 55       break;
 56     case eQuadrupleIonisedMolecule:
 57       num_shells = 4;
 58       break;
 59     default: // never happen
 60       return;
 61   }
 62 
 63   auto* H2O = new G4Molecule(G4H2O::Definition());
 64   for (G4int i = 0; i < num_shells; i++) {
 65     H2O->IonizeMolecule(4 - shell_level[i]);
 66   }
 67 
 68   constexpr G4double kT0 = 1.0 * picosecond;
 69   auto* H2O_track = H2O->BuildTrack(kT0, incoming_track->GetPosition());
 70   H2O_track->SetParentID(incoming_track->GetTrackID());
 71   H2O_track->SetTrackStatus(fStopButAlive);
 72   H2O_track->SetKineticEnergy(0.0);
 73 
 74   G4VITTrackHolder::Instance()->Push(H2O_track);
 75 }
 76 
 77 //------------------------------------------------------------------------------
 78 G4bool G4DNAMultipleIonisationManager::CheckShellEnergy(
 79     MultipleIonisedModification mod, G4double* shell_energy)
 80 {
 81   G4int num_shells{0};
 82   switch (mod) {
 83     case eDoubleIonisedMolecule:
 84       num_shells = 2;
 85       break;
 86     case eTripleIonisedMolecule:
 87       num_shells = 3;
 88       break;
 89     case eQuadrupleIonisedMolecule:
 90       num_shells = 4;
 91       break;
 92     default: // never happen
 93       break;
 94   }
 95 
 96   G4bool stop_process{false};
 97   for (G4int i = 0; i < num_shells; i++) {
 98     if (shell_energy[i] < 0.0) {
 99       stop_process = true;
100       break;
101     }
102   }
103 
104   return stop_process;
105 }
106 
107 //------------------------------------------------------------------------------
108 void G4DNAMultipleIonisationManager::LoadAlphaParam(
109   const G4String& filepath, G4double Z, G4double A)
110 {
111   const char* path = G4FindDataDir("G4LEDATA");
112   if (path == nullptr) {
113     G4Exception("G4DNAMultipleIonisationManager::LoadAlphaParam","em0006",
114                 FatalException,"G4LEDATA environment variable not set.");
115   }
116 
117   std::stringstream fullpath;
118   fullpath << path << "/" << filepath;
119 
120   std::fstream fin(fullpath.str());
121 
122   G4double e, a;
123   std::string line = "";
124   while (getline(fin, line)) {
125     std::stringstream ss;
126     ss << line;
127     ss >> e >> a;
128     Eion_.push_back(e * Z * A * MeV);
129     alpha_.push_back(a);
130   }
131 
132   num_node_ = (G4int)Eion_.size();
133   fin.close();
134 }
135 
136 //------------------------------------------------------------------------------
137 G4double G4DNAMultipleIonisationManager::GetAlphaParam(G4double energy)
138 {
139   auto find_lower_bound = [this](G4double e) {
140     auto low = 0;
141     auto upp = num_node_ - 1;
142     if (e < Eion_[0]) { return low; }
143     while (low <= upp) {
144       const auto mid = static_cast<int>((low + upp) * 0.5);
145       if (e < Eion_[mid]) { upp = mid - 1; }
146       else { low = mid + 1; }
147       if (upp < 0) { upp = 0; }
148     }
149     return upp;
150   };
151 
152   auto interp_log_log = [this](G4int bin1, G4double e) {
153     if (e < Eion_[0]) { return alpha_[0]; }
154     const auto num_bin = num_node_ - 1;
155     const auto bin2 = bin1 + 1;
156     G4double value{0.0};
157     if (bin2 <= num_bin) {
158       auto log10_e  = std::log10(e);
159       auto log10_e1 = Eion_[bin1];
160       auto log10_e2 = Eion_[bin2];
161       auto log10_a1 = alpha_[bin1];
162       auto log10_a2 = alpha_[bin2];
163       if (log10_a1 != 0.0 && log10_a2 != 0.0) {
164         log10_e1 = std::log10(log10_e1);
165         log10_e2 = std::log10(log10_e2);
166         log10_a1 = std::log10(log10_a1);
167         log10_a2 = std::log10(log10_a2);
168         value = log10_a1 + (log10_a2 - log10_a1)
169                   * (log10_e - log10_e1) / (log10_e2 - log10_e1);
170         value = std::pow(10.0, value);
171       }
172     } else {
173       value = alpha_[num_bin];
174     }
175     return value;
176   };
177 
178   const auto bin1 = find_lower_bound(energy);
179   return interp_log_log(bin1, energy);
180 }
181