Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:08:43

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Geant4/AlgebraConverters.hpp"
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 
0013 #include "CLHEP/Units/SystemOfUnits.h"
0014 namespace {
0015 constexpr double convertLength = CLHEP::mm / Acts::UnitConstants::mm;
0016 constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns;
0017 constexpr double convertEnergy = Acts::UnitConstants::GeV / CLHEP::GeV;
0018 }  // namespace
0019 
0020 namespace ActsExamples::Geant4 {
0021 Acts::Vector3 convertPosition(const G4ThreeVector& g4vec) {
0022   return Acts::Vector3(g4vec[0] * convertLength, g4vec[1] * convertLength,
0023                        g4vec[2] * convertLength);
0024 };
0025 
0026 Acts::Vector4 convertPosition(const G4ThreeVector& g4vec, const double time) {
0027   return Acts::Vector4(g4vec[0] * convertLength, g4vec[1] * convertLength,
0028                        g4vec[2] * convertLength, time * convertTime);
0029 }
0030 
0031 Acts::Vector4 convertMomentum(const G4ThreeVector& g4vec, const double energy) {
0032   return Acts::Vector4{convertEnergy * g4vec[0], convertEnergy * g4vec[1],
0033                        convertEnergy * g4vec[2], convertEnergy * energy};
0034 }
0035 
0036 G4ThreeVector convertPosition(const Acts::Vector3& actsVec) {
0037   return G4ThreeVector(actsVec[0] / convertLength, actsVec[1] / convertLength,
0038                        actsVec[2] / convertLength);
0039 }
0040 Acts::Vector3 convertDirection(const G4ThreeVector& g4vec) {
0041   return Acts::Vector3{g4vec[0], g4vec[1], g4vec[2]};
0042 }
0043 G4ThreeVector convertDirection(const Acts::Vector3& actsVec) {
0044   return G4ThreeVector{actsVec[0], actsVec[1], actsVec[2]};
0045 }
0046 
0047 }  // namespace ActsExamples::Geant4