Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:30:34

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file MoleculeInserter.cc
0027 /// \brief Implementation of the MoleculeInserter class
0028 ///
0029 /// Implementation of the DNA chemical species inserter for IRT
0030 
0031 // MoleculeInserter.cc
0032 //
0033 // Authors: J. Naoki D. Kondo (UCSF, US)
0034 //          J. Ramos-Mendez and B. Faddegon (UCSF, US)
0035 //
0036 
0037 #include "MoleculeInserter.hh"
0038 
0039 #include "G4ITTrackHolder.hh"
0040 #include "G4MolecularConfiguration.hh"
0041 #include "G4Molecule.hh"
0042 #include "G4MoleculeTable.hh"
0043 #include "G4PhysicalVolumeStore.hh"
0044 #include "G4Track.hh"
0045 #include "G4VPhysicalVolume.hh"
0046 #include "Randomize.hh"
0047 
0048 #include <cassert>
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0051 
0052 MoleculeInserter::MoleculeInserter() : fSaveTrackID(false) {}
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0055 
0056 MoleculeInserter::MoleculeInserter(G4bool save) : fSaveTrackID(save) {}
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0059 
0060 void MoleculeShoot::Shoot(MoleculeInserter* gun)
0061 {
0062   for (int i = 0; i < fNumber; ++i) {
0063     G4MolecularConfiguration* conf = G4MoleculeTable::Instance()->GetConfiguration(fMoleculeName);
0064 
0065     if (conf == 0) {
0066       G4String msg = "Chemistry Error: Molecule " + fMoleculeName + " don't exists.";
0067       G4Exception("MoleculeInserter::Shoot()", "Invalid_Value", FatalException, msg);
0068     }
0069 
0070     G4Molecule* molecule = new G4Molecule(conf);
0071     gun->PushToChemistry(molecule, fTime, fPosition);
0072   }
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0076 
0077 void MoleculeInserter::CreateMolecule(G4Molecule* molecule, G4double time, G4ThreeVector pos)
0078 {
0079   G4Track* MolTrack = molecule->BuildTrack(time, pos);
0080   PushTrack(MolTrack);
0081 }
0082 
0083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0084 
0085 void MoleculeInserter::CreateMolecule(G4String molecule, G4double time, G4ThreeVector pos)
0086 {
0087   G4MolecularConfiguration* conf = G4MoleculeTable::Instance()->GetConfiguration(molecule);
0088 
0089   if (conf == 0) {
0090     G4String msg = "Chemistry Error: Molecule " + molecule + " don't exists.";
0091     G4Exception("MoleculeInserter::CreateMolecule()", "Invalid_Value", FatalException, msg);
0092   }
0093 
0094   G4Molecule* gmolecule = new G4Molecule(conf);
0095   G4Track* MolTrack = gmolecule->BuildTrack(time, pos);
0096   PushTrack(MolTrack);
0097 }
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0100 
0101 void MoleculeInserter::PushToChemistry(G4Molecule* mol, G4double time, G4ThreeVector position)
0102 {
0103   G4Track* MolTrack = mol->BuildTrack(time, position);
0104   PushTrack(MolTrack);
0105 
0106   if (fSaveTrackID) {
0107     fInsertedTracks.push_back(MolTrack);
0108   }
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0112 
0113 void MoleculeInserter::DefineTracks()
0114 {
0115   if (fInsertedTracks.size() != 0) {
0116     fInsertedTracks.clear();
0117   }
0118 
0119   for (size_t i = 0; i < fShoots.size(); i++) {
0120     fShoots[i].Shoot(this);
0121   }
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0125 
0126 void MoleculeInserter::AddMolecule(const G4String& name, const G4ThreeVector& position, double time)
0127 {
0128   MoleculeShoot shoot;
0129   shoot.fMoleculeName = name;
0130   shoot.fPosition = position;
0131   shoot.fTime = time;
0132   fShoots.push_back(shoot);
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0136 
0137 MoleculeShoot::MoleculeShoot()
0138 {
0139   fMoleculeName = "";
0140   fTime = 0;
0141   fNumber = 1;
0142 }
0143 
0144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0145 
0146 void MoleculeInserter::Clean()
0147 {
0148   if (fShoots.size() != 0) fShoots.clear();
0149 
0150   if (fInsertedTracks.size() != 0) fInsertedTracks.clear();
0151 }
0152 
0153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....