Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 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 PhysGeoImport.hh
0028 /// \brief Definition of the PhysGeoImport class
0029 
0030 #ifndef GEOIMPORT_HH
0031 #define GEOIMPORT_HH
0032 
0033 #include <map>
0034 #include <fstream>
0035 #include <algorithm>
0036 #include <array>
0037 #include "G4String.hh"
0038 #include "G4ThreeVector.hh"
0039 #include "G4Orb.hh"
0040 #include "G4Ellipsoid.hh"
0041 #include "G4EllipticalTube.hh"
0042 #include "G4VSolid.hh"
0043 #include "G4Box.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4SubtractionSolid.hh"
0046 #include "G4LogicalVolume.hh"
0047 #include "G4PVPlacement.hh"
0048 #include "G4NistManager.hh"
0049 #include "G4VisAttributes.hh"
0050 #include "G4IntersectionSolid.hh"
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 struct Molecule
0055 {
0056     Molecule(G4String name, G4int copyNumber, G4ThreeVector position, 
0057     G4double radius, G4double waterRadius, G4String material, G4int strand)
0058     {
0059         fName = name;
0060         fMaterial = material;
0061         fCopyNumber = copyNumber;
0062         fPosition = position;
0063         fRadius = radius;
0064         fRadiusWater = waterRadius;
0065         fStrand = strand;
0066     }
0067 
0068     G4String fName{""};
0069     G4String fMaterial{""};
0070 
0071     G4int fCopyNumber{-1};
0072     G4int fStrand{-1};
0073 
0074     G4ThreeVector fPosition;
0075 
0076     G4double fRadius{0.};
0077     G4double fRadiusWater{0.};
0078 
0079     // To sort the molecules in function of their z coordinate
0080     G4bool operator<(const Molecule& str) const
0081     {
0082         return (fPosition.z() < str.fPosition.z() );
0083     }
0084 };
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0087 
0088 struct Voxel
0089 {
0090     enum VoxelType
0091     {
0092     Straight,
0093         Left,
0094         Right,
0095         Up,
0096         Down,
0097         Straight2,
0098         Left2,
0099         Right2,
0100         Up2,
0101         Down2,
0102         Other
0103     };
0104 
0105     Voxel(G4int copyNumber, G4int chromoNum, G4int domainNum, 
0106     VoxelType type, const G4ThreeVector& pos, G4RotationMatrix* rot)
0107     {
0108         fCopyNumber = copyNumber;
0109         fChromoNum = chromoNum;
0110         fDomainNum = domainNum;
0111         fType = type;
0112         fPos = pos;
0113         fpRot = rot;
0114     }
0115 
0116     G4int fCopyNumber{0};
0117     G4int fChromoNum{0};
0118     G4int fDomainNum{0};
0119     G4ThreeVector fPos;
0120     G4RotationMatrix* fpRot{nullptr};
0121     VoxelType fType{VoxelType::Other};
0122 };
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0125 
0126 enum ChromatinType{
0127     fUnspecified = 0,
0128     fHeterochromatin = 1,
0129     fEuchromatin = 2,
0130 };
0131 
0132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0133 
0134 class PhysGeoImport
0135 {
0136 public:
0137     PhysGeoImport();
0138     PhysGeoImport(G4bool isVisu);
0139     ~PhysGeoImport() = default;
0140 
0141     void SetFactor(G4double factor){fFactor=factor;}
0142 
0143     G4double GetFactor() const {return fFactor;}
0144 
0145     G4String GetGeoName() const {return fGeoName;}
0146 
0147     // This method will trigger the parse of the file and the build of the geometry
0148     G4LogicalVolume* CreateLogicVolume(const G4String& fileName, G4String& voxelName);
0149 
0150     G4LogicalVolume* CreateNucleusLogicVolume(const G4String& fileName);
0151 
0152     std::vector<Voxel>* CreateVoxelsData(const G4String& fileName);
0153     std::map<G4String, G4int> GetVoxelNbHistoneMap() {return fVoxelNbHistoneMap;}
0154     std::map<G4String, G4int> GetVoxelNbBpMap() {return fVoxelNbBpMap;}
0155     unsigned long long GetTotalNbBpPlacedInGeo() {return fTotalNbBpPlacedInGeo;}
0156     unsigned long long GetTotalNbHistonePlacedInGeo() {return fTotalNbHistonePlacedInGeo;}
0157     G4double GetNucleusVolume() {return fNucleusVolume;}
0158     G4double GetVoxelFullSize() {return fSize;}
0159     std::map<G4String, G4double> GetNucleusSizeData() {return fNucleusData;}
0160     std::map<ChromatinType, unsigned long long> GetChromatinTypeCountMap() {return fChromatinTypeCount;}
0161 private:
0162 
0163     G4bool fIsVisu{false};
0164 
0165     // Factor to scale the geometry
0166     G4double fFactor{1.};
0167 
0168     G4double fSize{0.};
0169     G4double fNucleusVolume{0.};
0170     unsigned long long fTotalNbBpPlacedInGeo = 0;
0171     unsigned long long fTotalNbHistonePlacedInGeo = 0;
0172     G4String fGeoName="";
0173 
0174     G4String fNucleusName="CellNucleus";
0175     G4String fNucleusType="";
0176     std::map<G4String, G4double> fNucleusData;
0177 
0178     std::map<G4String, G4double> fRadiusMap;
0179     std::map<G4String, G4double> fWaterRadiusMap;
0180     std::map<G4String, G4int> fVoxelNbBpMap;
0181     std::map<G4String, G4int> fVoxelNbHistoneMap;
0182 
0183     // Vector to contain all the molecule structures listed within the imput file
0184     std::vector<Molecule> fMolecules;
0185 
0186     // To check if this is the first voxel of the chromosome
0187     std::map<G4int, G4bool> fFirstMap;
0188 
0189     // Materials
0190     std::vector<G4Material*> fMaterialVect;
0191     G4Material* fpWater{nullptr};
0192     G4Material* fTHF{nullptr};
0193     G4Material* fPY{nullptr};
0194     G4Material* fPU{nullptr};
0195     G4Material* fTMP{nullptr};
0196     G4Material* fSugarMixt{nullptr};
0197     G4Material* fDeoxyribose{nullptr};
0198     G4Material* fPhosphate{nullptr};
0199     G4Material* fCytosine_PY{nullptr};
0200     G4Material* fThymine_PY{nullptr};
0201     G4Material* fGuanine_PU{nullptr};
0202     G4Material* fAdenine_PU{nullptr};
0203     G4Material* fHomogeneous_dna{nullptr};
0204     G4Material* fVacuum{nullptr};
0205     G4String  ParseFile(const G4String& fileName);
0206     G4VSolid* CreateCutSolid(G4Orb *solidOrbRef,
0207                              Molecule &molRef,
0208                              std::vector<Molecule> &molList,
0209                              G4bool in);
0210     void DefineMaterial();
0211 
0212     std::map<ChromatinType, unsigned long long> fChromatinTypeCount;
0213 };
0214 
0215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0216 
0217 #endif // GEOIMPORT_HH