Back to home page

EIC code displayed by LXR

 
 

    


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

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: CylindricalChromosome.cc
0028 /// brief: Implementation of virt chromosome class for cylindrical chromosomes
0029 
0030 #include "CylindricalChromosome.hh"
0031 
0032 #include "G4PhysicalConstants.hh"
0033 #include "G4RandomDirection.hh"
0034 #include "Randomize.hh"
0035 
0036 #include <utility>
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 const G4String CylindricalChromosome::fShape = "cyl";
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 CylindricalChromosome::CylindricalChromosome(const G4String& name, const G4ThreeVector& pos,
0045                                              const G4double& radius, const G4double& height)
0046   : VirtualChromosome(name),
0047     fCenter(pos),
0048     fRadius(radius),
0049     fHeight(height),
0050     fRotation(G4RotationMatrix())
0051 {
0052   fInverseRotation = fRotation.inverse();
0053 }
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 CylindricalChromosome::CylindricalChromosome(const G4String& name, const G4ThreeVector& pos,
0058                                              const G4double& radius, const G4double& height,
0059                                              const G4RotationMatrix& rot)
0060   : VirtualChromosome(name), fCenter(pos), fRadius(radius), fHeight(height), fRotation(rot)
0061 {
0062   fInverseRotation = fRotation.inverse();
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 bool CylindricalChromosome::PointInChromosome(G4ThreeVector const& pos)
0068 {
0069   G4ThreeVector rpos = pos - fCenter;
0070   rpos = fInverseRotation(rpos);
0071 
0072   G4bool height_ok;
0073   G4bool radius_ok;
0074   G4double height;
0075   G4double rad2;
0076 
0077   height = std::abs(rpos.getZ());
0078   rad2 = rpos.getX() * rpos.getX() + rpos.getY() * rpos.getY();
0079 
0080   height_ok = (height < fHeight);
0081   radius_ok = (rad2 < (fRadius * fRadius));
0082 
0083   return height_ok && radius_ok;
0084 }
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 G4ThreeVector CylindricalChromosome::RandomPointInChromosome()
0088 {
0089   G4ThreeVector point;
0090   G4double z = 2 * (G4UniformRand() - 0.5) * fHeight;
0091   G4double theta = twopi * G4UniformRand();
0092   G4double r = fRadius * std::pow(G4UniformRand(), 0.5);
0093   G4double x = r * std::cos(theta);
0094   G4double y = r * std::sin(theta);
0095   point = G4ThreeVector(x, y, z);
0096   point = fRotation(point) + fCenter;
0097 
0098   return point;
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......