Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:53

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 //
0027 // MoleculeInserter.cc
0028 //
0029 // Authors: J. Naoki D. Kondo (UCSF, US)
0030 //          J. Ramos-Mendez and B. Faddegon (UCSF, US)
0031 //
0032 /// \file MoleculeInserter.cc
0033 /// \brief Implementation of the DNA chemical species inserter for IRT
0034 
0035 #include "MoleculeInserter.hh"
0036 
0037 #include "G4ITTrackHolder.hh"
0038 #include "G4MolecularConfiguration.hh"
0039 #include "G4Molecule.hh"
0040 #include "G4MoleculeTable.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4Track.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "Randomize.hh"
0045 
0046 #include <cassert>
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0049 
0050 MoleculeInserter::MoleculeInserter() : fSaveTrackID(false) {}
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0053 
0054 MoleculeInserter::MoleculeInserter(G4bool save) : fSaveTrackID(save) {}
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0057 
0058 void MoleculeShoot::Shoot(MoleculeInserter* gun)
0059 {
0060   for (int i = 0; i < fNumber; ++i) {
0061     G4MolecularConfiguration* conf = G4MoleculeTable::Instance()->GetConfiguration(fMoleculeName);
0062 
0063     if (conf == 0) {
0064       G4String msg = "Chemistry Error: Molecule " + fMoleculeName + " don't exists.";
0065       G4Exception("MoleculeInserter::Shoot()", "Invalid_Value", FatalException, msg);
0066     }
0067 
0068     G4Molecule* molecule = new G4Molecule(conf);
0069     gun->PushToChemistry(molecule, fTime, fPosition);
0070   }
0071 }
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0074 
0075 void MoleculeInserter::CreateMolecule(G4Molecule* molecule, G4double time, G4ThreeVector pos)
0076 {
0077   G4Track* MolTrack = molecule->BuildTrack(time, pos);
0078   PushTrack(MolTrack);
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0082 
0083 void MoleculeInserter::CreateMolecule(G4String molecule, G4double time, G4ThreeVector pos)
0084 {
0085   G4MolecularConfiguration* conf = G4MoleculeTable::Instance()->GetConfiguration(molecule);
0086 
0087   if (conf == 0) {
0088     G4String msg = "Chemistry Error: Molecule " + molecule + " don't exists.";
0089     G4Exception("MoleculeInserter::CreateMolecule()", "Invalid_Value", FatalException, msg);
0090   }
0091 
0092   G4Molecule* gmolecule = new G4Molecule(conf);
0093   G4Track* MolTrack = gmolecule->BuildTrack(time, pos);
0094   PushTrack(MolTrack);
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0098 
0099 void MoleculeInserter::PushToChemistry(G4Molecule* mol, G4double time, G4ThreeVector position)
0100 {
0101   G4Track* MolTrack = mol->BuildTrack(time, position);
0102   PushTrack(MolTrack);
0103 
0104   if (fSaveTrackID) {
0105     fInsertedTracks.push_back(MolTrack);
0106   }
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0110 
0111 void MoleculeInserter::DefineTracks()
0112 {
0113   if (fInsertedTracks.size() != 0) {
0114     fInsertedTracks.clear();
0115   }
0116 
0117   for (size_t i = 0; i < fShoots.size(); i++) {
0118     fShoots[i].Shoot(this);
0119   }
0120 }
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0123 
0124 void MoleculeInserter::AddMolecule(const G4String& name, const G4ThreeVector& position, double time)
0125 {
0126   MoleculeShoot shoot;
0127   shoot.fMoleculeName = name;
0128   shoot.fPosition = position;
0129   shoot.fTime = time;
0130   fShoots.push_back(shoot);
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0134 
0135 MoleculeShoot::MoleculeShoot()
0136 {
0137   fMoleculeName = "";
0138   fTime = 0;
0139   fNumber = 1;
0140 }
0141 
0142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0143 
0144 void MoleculeInserter::Clean()
0145 {
0146   if (fShoots.size() != 0) fShoots.clear();
0147 
0148   if (fInsertedTracks.size() != 0) fInsertedTracks.clear();
0149 }
0150 
0151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....