Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:01

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 /// \file DNAHit.cc
0028 /// \brief Hit class for a hit interacting with a DNA molecule
0029 
0030 #include "DNAHit.hh"
0031 
0032 #include <utility>
0033 
0034 G4ThreadLocal G4Allocator<DNAHit>* MolecularDNAHitAllocator = nullptr;
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 DNAHit::DNAHit(const molecule& mol, G4int placement_idx,  // ORG
0039                G4int chain, G4int strand,  // ORG
0040                int64_t bp, const G4ThreeVector& pos,
0041                const G4ThreeVector& localpos,  // dousatsu
0042                const G4double& energy, const G4double& d, const G4String& chromo,
0043                const G4MolecularConfiguration* radical)
0044   : fMoleculeEnum(mol),
0045     fPlacementIdx(placement_idx),
0046     fChainIdx(chain),
0047     fStrandIdx(strand),
0048     fBasePairIdx(bp),
0049     fPosition(pos),
0050     fLocalPosition(localpos),
0051     fEnergy(energy),
0052     fDistance(d),
0053     fChromosome(chromo),
0054     fRadical(radical)
0055 {
0056   // Computed quantities
0057   if (fStrandIdx == 0) {
0058     if ((fMoleculeEnum == SUGAR) || (fMoleculeEnum == PHOSPHATE)) {
0059       fStrand1Rad = fRadical;
0060       fStrand1Energy = fEnergy;
0061     }
0062     else if ((fMoleculeEnum == CYTOSINE) || (fMoleculeEnum == GUANINE) || (fMoleculeEnum == ADENINE)
0063              || (fMoleculeEnum == THYMINE))
0064     {
0065       fBase1Rad = fRadical;
0066       fBP1Energy = fEnergy;
0067     }
0068     else {
0069       G4Exception("DNAHit", "ERR_UNKNOWN_MOLECULE", JustWarning,
0070                   "Chemical Reaction with unknown molecule");
0071     }
0072   }
0073   else if (fStrandIdx == 1) {
0074     if ((fMoleculeEnum == SUGAR) || (fMoleculeEnum == PHOSPHATE)) {
0075       fStrand2Rad = fRadical;
0076       fStrand2Energy = fEnergy;
0077     }
0078     else if ((fMoleculeEnum == CYTOSINE) || (fMoleculeEnum == GUANINE) || (fMoleculeEnum == ADENINE)
0079              || (fMoleculeEnum == THYMINE))
0080     {
0081       fBase2Rad = fRadical;
0082       fBP2Energy = fEnergy;
0083     }
0084     else {
0085       G4Exception("DNAHit", "ERR_UNKNOWN_MOLECULE", JustWarning, "Hit with unknown molecule");
0086     }
0087   }
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 
0092 // This method is used to combine the computed quantities of two hits.
0093 // It keeps the settable parameters of the current hit, but the computed
0094 // parameters come from both, letting the hit reflect what happened on each
0095 // base pair.
0096 void DNAHit::AddHit(const DNAHit& right)
0097 {
0098   this->fStrand1Energy += right.GetStrand1Energy();
0099   this->fStrand2Energy += right.GetStrand2Energy();
0100   this->fBP1Energy += right.GetBP1Energy();
0101   this->fBP2Energy += right.GetBP2Energy();
0102   if (right.GetStrand1Rad() != nullptr) {
0103     this->fStrand1Rad = right.GetStrand1Rad();
0104   }
0105   if (right.GetBase1Rad() != nullptr) {
0106     this->fBase1Rad = right.GetBase1Rad();
0107   }
0108   if (right.GetStrand2Rad() != nullptr) {
0109     this->fStrand2Rad = right.GetStrand2Rad();
0110   }
0111   if (right.GetBase2Rad() != nullptr) {
0112     this->fBase2Rad = right.GetBase2Rad();
0113   }
0114 }
0115 
0116 DNAHit::DNAHit(const DNAHit& right)
0117 {
0118   this->SetPlacementIdx(right.GetPlacementIdx());
0119   this->SetMolecule(right.GetMolecule());
0120   this->SetChainIdx(right.GetChainIdx());
0121   this->SetStrandIdx(right.GetStrandIdx());
0122   this->SetBasePairIdx(right.GetBasePairIdx());
0123   this->SetPosition(right.GetPosition());
0124   this->SetLocalPosition(right.GetLocalPosition());
0125   this->SetEnergy(right.GetEnergy());
0126   this->SetDistance(right.GetDistance());
0127   this->SetChromosome(right.GetChromosome());
0128   this->SetRadical(right.GetRadical());
0129 
0130   // Computed Quantities, no setters.
0131   this->fStrand1Energy = right.GetStrand1Energy();
0132   this->fStrand2Energy = right.GetStrand2Energy();
0133   this->fBP1Energy = right.GetBP1Energy();
0134   this->fBP2Energy = right.GetBP2Energy();
0135   this->fStrand1Rad = right.GetStrand1Rad();
0136   this->fBase1Rad = right.GetBase1Rad();
0137   this->fStrand2Rad = right.GetStrand2Rad();
0138   this->fBase2Rad = right.GetBase2Rad();
0139 }
0140 
0141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0142 
0143 const DNAHit& DNAHit::operator=(const DNAHit& right)
0144 {
0145   this->SetMolecule(right.GetMolecule());
0146   this->SetPlacementIdx(right.GetPlacementIdx());
0147   this->SetChainIdx(right.GetChainIdx());
0148   this->SetStrandIdx(right.GetStrandIdx());
0149   this->SetBasePairIdx(right.GetBasePairIdx());
0150   this->SetPosition(right.GetPosition());
0151   this->SetLocalPosition(right.GetLocalPosition());
0152   this->SetEnergy(right.GetEnergy());
0153   this->SetDistance(right.GetDistance());
0154   this->SetChromosome(right.GetChromosome());
0155   this->SetRadical(right.GetRadical());
0156 
0157   this->fStrand1Energy = right.GetStrand1Energy();
0158   this->fStrand2Energy = right.GetStrand2Energy();
0159   this->fBP1Energy = right.GetBP1Energy();
0160   this->fBP2Energy = right.GetBP2Energy();
0161   this->fStrand1Rad = right.GetStrand1Rad();
0162   this->fBase1Rad = right.GetBase1Rad();
0163   this->fStrand2Rad = right.GetStrand2Rad();
0164   this->fBase2Rad = right.GetBase2Rad();
0165   return *this;
0166 }
0167 
0168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0169 
0170 G4int DNAHit::operator==(const DNAHit& right) const
0171 {
0172   return (this == &right) ? 1 : 0;
0173 }
0174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......