Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ runs:
- name: build ucesb
if: steps.cache-ucesb.outputs.cache-hit == ''
run: |
echo "ucesb directory is set as ${UCESB_DIR}"
echo "UCESB directory is set as ${UCESB_DIR}"
export LD_LIBRARY_PATH="${SIMPATH}/lib/:${LD_LIBRARY_PATH}"
git clone https://git.chalmers.se/expsubphys/ucesb.git ${UCESB_DIR}
cd ${UCESB_DIR} && make -j${NUM_THREADS} empty/empty
echo "ATIMA directory is set as ${ATIMAPATH}"
git clone https://github.com/hrosiak/catima.git ${ATIMAPATH}
cd ${ATIMAPATH} && mkdir build && mkdir install && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=../install/ && make -j${NUM_THREADS} && make install
echo "ATIMAPATH=${ATIMAPATH}/install" >> $GITHUB_ENV
shell: bash
2 changes: 2 additions & 0 deletions .github/actions/pre-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ runs:
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
echo "UCESB_DIR=$GITHUB_WORKSPACE/ucesb/" >> $GITHUB_ENV
echo "ATIMAPATH=$GITHUB_WORKSPACE/catima/" >> $GITHUB_ENV
if [ "${{ matrix.cpp }}" == "20" ]; then
export SIMPATH=${CVMDIR}/${{ matrix.os }}/fairsoft/cpp20/${{ matrix.fsv }}
echo "SIMPATH=${SIMPATH}" >> $GITHUB_ENV
Expand Down Expand Up @@ -49,5 +50,6 @@ runs:
mkdir -p ${CVMDIR}
mount -t cvmfs fairsoft.gsi.de ${CVMDIR}
mkdir -p ${UCESB_DIR}
mkdir -p ${ATIMAPATH}
mkdir -p ${CCACHE_DIR}
shell: bash
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ else(ucesb_FOUND)
" to a ucesb installation to fix this.${CR}")
endif(ucesb_FOUND)

find_package(EPICS)
find_package2(PUBLIC EPICS)
if(EPICS_FOUND)
set(WITH_EPICS ON)
set(epics_summary "${BGreen}YES${CR} ${BMagenta}${EPICS_LIBRARY_DIR}${CR}")
Expand All @@ -456,7 +456,7 @@ else(EPICS_FOUND)
set(epics_summary "${BYellow}NO${CR}")
endif(EPICS_FOUND)

find_package(Atima)
find_package2(PUBLIC Atima)
if(ATIMA_FOUND)
set(atima_summary "${BGreen}YES${CR} ${BMagenta}$ENV{ATIMAPATH}${CR}")
else(ATIMA_FOUND)
Expand Down Expand Up @@ -767,7 +767,13 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
get_filename_component(prefix ${IWYU_BINARY}/.. ABSOLUTE)
elseif(${dep} STREQUAL yaml-cpp)
get_filename_component(prefix ${YAML_CPP_INCLUDE_DIR}/.. ABSOLUTE)
endif()
elseif(${dep} STREQUAL Atima)
if(DEFINED ENV{ATIMAPATH})
get_filename_component(prefix $ENV{ATIMAPATH} ABSOLUTE)
else()
set(prefix "unknown")
endif()
endif()
message(STATUS " ${BWhite}${dep_padded}${CR}${version_padded}${prefix}")
if(${dep} STREQUAL Geant4)
foreach(dataset IN LISTS Geant4_DATASETS)
Expand Down
2 changes: 0 additions & 2 deletions atima/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@

set(SRCS
R3BAtima.cxx
R3BAtimaCache.cxx
)

set(HEADERS
R3BAtima.h
R3BAtimaCache.h
)

add_library_with_dictionary(
Expand Down
181 changes: 84 additions & 97 deletions atima/R3BAtima.cxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
* Copyright (C) 2019-2025 Members of R3B Collaboration *
* Copyright (C) 2020 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
* Copyright (C) 2020-2026 Members of R3B Collaboration *
* *
* This software is distributed under the terms of the *
* GNU General Public Licence (GPL) version 3, *
Expand All @@ -13,113 +13,100 @@

#include "R3BAtima.h"

#include <numeric>
#include <FairLogger.h>

extern "C"
R3B::Atima::Atima(double density, std::vector<std::tuple<int, int, int>> materialComponents)
{
void calculate_(double* proj,
int* pn,
double* ein,
double* targ,
int* nnuca,
int* tm,
double* rhoa,
int* igasa,
double* thick,
double* eout,
double* range,
double* dedxi,
double* dedxo,
double* remra,
double* rstr,
double* estr,
double* astr,
double* tof,
double* intrthick);
fMaterial = std::make_unique<catima::Material>();

for (auto materialComponent : materialComponents)
fMaterial->add_element(
std::get<0>(materialComponent), std::get<1>(materialComponent), std::get<2>(materialComponent));
}

namespace R3BAtima
double R3B::Atima::GetdEdx(double energy) const
{
if (fProjectile == nullptr)
{
LOG(warning)
<< " Warning in AtTools::AtELossCATIMA::GetdEdx : The projectile was not set! GetdEdx will return 0!";
return 0;
}

const TargetMaterial TargetMaterial::Air = TargetMaterial({ MaterialCompound(14, 7, 0.755267),
MaterialCompound(16, 8, 0.231781),
MaterialCompound(39.948, 18, 0.012827),
MaterialCompound(12, 6, 0.000124) },
0.0012,
kTRUE);
const TargetMaterial TargetMaterial::LH2 = TargetMaterial({ MaterialCompound(1, 1) }, 0.0708, kFALSE);
const TargetMaterial TargetMaterial::Si = TargetMaterial({ MaterialCompound(28, 14) }, 2.336, kFALSE);
const TargetMaterial TargetMaterial::BC400 =
TargetMaterial({ MaterialCompound(1, 1, 0.085292), MaterialCompound(12, 6, 0.914708) }, 1.032, kFALSE);

TransportResult Calculate(Double_t projMass_u,
Double_t projCharge_e,
Double_t projEnergy_MeV_per_u,
const TargetMaterial& targetMaterial,
Double_t tarThickness_mg_per_cm2)
if (fProjectileMassUma <= 0)
{
TransportResult res;
LOG(error) << " Error in AtTools::AtELossCATIMA::GetdEdx : The projectile's mass in umas can not be <= 0! "
"GetdEdx will return 0!";
return 0;
}

const auto invTotRatio = std::accumulate(targetMaterial.Compounds.begin(),
targetMaterial.Compounds.end(),
0.,
[](const Double_t sum, const MaterialCompound& comp) -> Double_t
{ return sum + comp.Ratio; });
catima::Result result = catima::calculate(*fProjectile, *fMaterial, energy / fProjectileMassUma);
double dEdx = result.dEdxi * fDensity;
return dEdx;
}

Int_t tcompsize = 3, tcompnum = targetMaterial.Compounds.size(), pn = 2;
std::vector<Double_t> tarFortran;
tarFortran.resize(tcompnum * tcompsize);
for (int i = 0; i < tcompnum; ++i)
{
tarFortran[i + tcompnum * 0] = targetMaterial.Compounds[i].Mass_u;
tarFortran[i + tcompnum * 1] = targetMaterial.Compounds[i].Charge_e;
tarFortran[i + tcompnum * 2] = targetMaterial.Compounds[i].Ratio * invTotRatio;
}
double R3B::Atima::GetRange(double energyIni, double energyFin) const
{
if (energyFin < 0)
{
LOG(warning) << " Warning in AtTools::AtELossCATIMA::GetRange : The final energy was set to a negative value! "
"Setting energyFin to 0!";
energyFin = 0;
}

Double_t proj[2] = { projMass_u, projCharge_e };
Double_t density = targetMaterial.Density;
Int_t tGas = 0;
if (targetMaterial.IsGas)
tGas = 1;
if (energyFin == 0)
{
fProjectile->T = energyIni / fProjectileMassUma;
return catima::range(*fProjectile, *fMaterial) / fDensity * 10.;
}

calculate_(proj,
&pn,
&projEnergy_MeV_per_u,
&tarFortran[0],
&tcompnum,
&tcompsize,
&density,
&tGas,
&tarThickness_mg_per_cm2,
&res.EnergyOut_MeV_per_u,
&res.Range_mg_per_cm2,
&res.dEdXIn_MeVcm2_per_mg,
&res.dEdXOut_MeVcm2_per_mg,
&res.RemainingRange_mg_per_cm2,
&res.RangeStrag_mg_per_cm2,
&res.EStrag_MeV_per_u,
&res.AngStrag_mRad,
&res.ToF_ns,
&res.InterpolatedTargetThickness);
double remainingEnergy{ energyIni };
double range{ 0 };
while (remainingEnergy > energyFin)
{
catima::Result result = catima::calculate(*fProjectile, *fMaterial, remainingEnergy / fProjectileMassUma);
double dEdx = result.dEdxi * fDensity;
double DE = dEdx * fRangeStepSize / 10.;

res.EnergyIn_MeV_per_u = projEnergy_MeV_per_u;
res.EStrag_MeV_per_u *= res.dEdXOut_MeVcm2_per_mg;
res.ELoss_MeV_per_u = res.EnergyIn_MeV_per_u - res.EnergyOut_MeV_per_u;
res.AngStrag_mRad *= 1e3;
res.dEdXIn_MeVcm2_per_mg *= projMass_u;
res.dEdXOut_MeVcm2_per_mg *= projMass_u;
return res;
if (remainingEnergy - energyFin > DE)
{
range += fRangeStepSize;
remainingEnergy -= DE;
}
else
{
range += (remainingEnergy - energyFin) / dEdx * 10.;
remainingEnergy = energyFin;
break;
}
}
TransportResult Calculate_mm(Double_t projMass_u,
Double_t projCharge_e,
Double_t projEnergy_MeV_per_u,
const TargetMaterial& targetMaterial,
Double_t tarThickness_mm)
return range;
}

double R3B::Atima::GetEnergy(double energyIni, double distance) const
{
double remainingEnergy{ energyIni };
double range{ 0 };
while (range < distance)
{
return Calculate(projMass_u,
projCharge_e,
projEnergy_MeV_per_u,
targetMaterial,
targetMaterial.Density * tarThickness_mm * 100);
catima::Result result = catima::calculate(*fProjectile, *fMaterial, remainingEnergy / fProjectileMassUma);
double dEdx = result.dEdxi * fDensity;
double DE{};

if (range + fRangeStepSize < distance)
{
DE = dEdx * fRangeStepSize / 10.;
range += fRangeStepSize;
remainingEnergy -= DE;
}
else
{
DE = dEdx * (distance - range) / 10.;
range = distance;
remainingEnergy -= DE;
break;
}
}
} // namespace R3BAtima

return remainingEnergy;
}
Loading
Loading