Back to home page

EIC code displayed by LXR

 
 

    


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

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 molecularDNAHit.hh
0028 /// \brief Hit class for an event that interacts with DNA
0029 #ifndef MOLECULAR_DNA_HIT_HH
0030 #define MOLECULAR_DNA_HIT_HH
0031 
0032 #include "MoleculeList.hh"
0033 
0034 #include "G4Allocator.hh"
0035 #include "G4THitsCollection.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4VHit.hh"
0038 #include "globals.hh"
0039 
0040 #include <utility>
0041 
0042 class G4MolecularConfiguration;
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 class DNAHit : public G4VHit
0047 {
0048   public:
0049     // Main constructors
0050     DNAHit() = default;
0051 
0052     DNAHit(const molecule&, G4int, G4int, G4int, int64_t,
0053            const G4ThreeVector&,  // dousatsu
0054            const G4ThreeVector&, const G4double&, const G4double&, const G4String&,  // dousatsu
0055            const G4MolecularConfiguration*);  // dousatsu
0056 
0057     // Constructor delegation
0058     // Physical Hit
0059     DNAHit(const molecule& mol, G4int placement_idx, G4int chain, G4int strand, int64_t bp,
0060            const G4ThreeVector& pos, const G4ThreeVector& localpos, G4double energy, G4double d,
0061            G4String chromo)
0062       : DNAHit(mol, placement_idx, chain, strand, bp, pos, localpos, energy, d, std::move(chromo),
0063                nullptr) {};
0064 
0065     // Chemical hit
0066     DNAHit(const molecule& mol, G4int placement_idx, G4int chain, G4int strand, int64_t bp,
0067            const G4ThreeVector& pos, const G4ThreeVector& localpos, G4String chromo,
0068            const G4MolecularConfiguration* radical)
0069       : DNAHit(mol, placement_idx, chain, strand, bp, pos, localpos, 0, 0, std::move(chromo),
0070                radical) {};
0071 
0072     DNAHit(const DNAHit&);
0073 
0074     ~DNAHit() override = default;
0075 
0076     // Add Method, not as an operator to prevent people making mistakes
0077     void AddHit(const DNAHit&);
0078 
0079     // operators
0080     inline void* operator new(size_t);
0081 
0082     inline void operator delete(void*);
0083 
0084     const DNAHit& operator=(const DNAHit&);
0085 
0086     G4int operator==(const DNAHit&) const;
0087 
0088     // setters
0089     // Avoid setters in general and use the constructor, as it also sets
0090     // the computed quantites
0091     void SetMolecule(const molecule& mol) { fMoleculeEnum = mol; };
0092 
0093     void SetPlacementIdx(G4int place_idx) { fPlacementIdx = place_idx; };
0094 
0095     void SetChainIdx(G4int chainidx) { fChainIdx = chainidx; };
0096 
0097     void SetStrandIdx(G4int strandidx) { fStrandIdx = strandidx; };
0098 
0099     void SetBasePairIdx(int64_t bpidx) { fBasePairIdx = bpidx; };  // dousatsu
0100 
0101     void SetPosition(const G4ThreeVector& p) { fPosition = p; };
0102 
0103     void SetLocalPosition(const G4ThreeVector& p) { fLocalPosition = p; };
0104 
0105     void SetEnergy(const G4double& energy) { fEnergy = energy; };
0106 
0107     void SetDistance(const G4double& dist) { fDistance = dist; };
0108 
0109     void SetChromosome(const G4String& chrom) { fChromosome = chrom; };
0110 
0111     void SetRadical(const G4MolecularConfiguration* r) { fRadical = r; };
0112 
0113     // getters
0114     molecule GetMolecule() const { return fMoleculeEnum; };
0115 
0116     G4int GetPlacementIdx() const { return fPlacementIdx; };
0117 
0118     G4int GetChainIdx() const { return fChainIdx; };
0119 
0120     G4int GetStrandIdx() const { return fStrandIdx; };
0121 
0122     int64_t GetBasePairIdx() const { return fBasePairIdx; };  // dousatsu
0123     G4ThreeVector GetPosition() const { return fPosition; };
0124 
0125     G4ThreeVector GetLocalPosition() const { return fLocalPosition; };
0126 
0127     G4double GetEnergy() const { return fEnergy; };
0128 
0129     G4double GetDistance() const { return fDistance; };
0130 
0131     G4String GetChromosome() const { return fChromosome; };
0132 
0133     const G4MolecularConfiguration* GetRadical() const { return fRadical; };
0134 
0135     // Get Computed Quantites
0136     const G4MolecularConfiguration* GetStrand1Rad() const { return fStrand1Rad; };
0137 
0138     const G4MolecularConfiguration* GetBase1Rad() const { return fBase1Rad; };
0139 
0140     const G4MolecularConfiguration* GetStrand2Rad() const { return fStrand2Rad; };
0141 
0142     const G4MolecularConfiguration* GetBase2Rad() const { return fBase2Rad; };
0143 
0144     G4double GetStrand1Energy() const { return fStrand1Energy; };
0145 
0146     G4double GetStrand2Energy() const { return fStrand2Energy; };
0147 
0148     G4double GetBP1Energy() const { return fBP1Energy; };
0149 
0150     G4double GetBP2Energy() const { return fBP2Energy; };
0151 
0152   private:
0153     molecule fMoleculeEnum = UNSPECIFIED;
0154     G4int fPlacementIdx = -1;  // ORG
0155     G4int fChainIdx = -1;  // ORG
0156     G4int fStrandIdx = -1;  // ORG
0157     int64_t fBasePairIdx = -1;  // dousatsu
0158     G4ThreeVector fPosition = G4ThreeVector();
0159     G4ThreeVector fLocalPosition = G4ThreeVector();
0160     G4double fEnergy = 0.;
0161     G4double fDistance = 0.;
0162     G4String fChromosome = "";
0163     const G4MolecularConfiguration* fRadical = nullptr;
0164     const G4MolecularConfiguration* fStrand1Rad = nullptr;
0165     const G4MolecularConfiguration* fBase1Rad = nullptr;
0166     const G4MolecularConfiguration* fStrand2Rad = nullptr;
0167     const G4MolecularConfiguration* fBase2Rad = nullptr;
0168 
0169     G4double fStrand1Energy = 0.;
0170     G4double fStrand2Energy = 0.;
0171     G4double fBP1Energy = 0.;
0172     G4double fBP2Energy = 0.;
0173 };
0174 
0175 // typedefs
0176 using MolecularDNAHitsCollection = G4THitsCollection<DNAHit>;
0177 
0178 // memory management
0179 extern G4ThreadLocal G4Allocator<DNAHit>* MolecularDNAHitAllocator;
0180 
0181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0182 
0183 inline void* DNAHit::operator new(size_t)
0184 {
0185   if (MolecularDNAHitAllocator == nullptr) {
0186     MolecularDNAHitAllocator = new G4Allocator<DNAHit>;
0187   }
0188   return (void*)MolecularDNAHitAllocator->MallocSingle();
0189 }
0190 
0191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0192 
0193 inline void DNAHit::operator delete(void* hit)
0194 {
0195   MolecularDNAHitAllocator->FreeSingle((DNAHit*)hit);
0196 }
0197 
0198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0199 
0200 #endif  // MOLECULAR_DNA_HIT_HH