Skip to content

Commit 7fba4ce

Browse files
committed
MathUtils: move BetheBlochAleph to a common header
1 parent 426059f commit 7fba4ce

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#ifndef AliceO2_COMMON_BETHEBLOCH_H_
13+
#define AliceO2_COMMON_BETHEBLOCH_H_
14+
15+
#include "GPUCommonDef.h"
16+
#include "GPUCommonMath.h"
17+
18+
namespace o2::common
19+
{
20+
21+
template <typename T>
22+
GPUdi() T BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5)
23+
{
24+
T beta = bg / o2::gpu::GPUCommonMath::Sqrt(static_cast<T>(1.) + bg * bg);
25+
26+
T aa = o2::gpu::GPUCommonMath::Pow(beta, kp4);
27+
T bb = o2::gpu::GPUCommonMath::Pow(static_cast<T>(1.) / bg, kp5);
28+
bb = o2::gpu::GPUCommonMath::Log(kp3 + bb);
29+
30+
return (kp2 - aa - bb) * kp1 / aa;
31+
}
32+
33+
} // namespace o2::common
34+
35+
#endif

DataFormats/Detectors/TPC/include/DataFormatsTPC/BetheBlochAleph.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,17 @@
1212
#ifndef AliceO2_TPC_BETHEBLOCH_H_
1313
#define AliceO2_TPC_BETHEBLOCH_H_
1414

15-
#include "GPUCommonDef.h"
16-
#include "GPUCommonMath.h"
15+
#include "MathUtils/BetheBlochAleph.h"
1716

18-
namespace o2
19-
{
20-
namespace tpc
17+
namespace o2::tpc
2118
{
2219

2320
template <typename T>
2421
GPUdi() T BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5)
2522
{
26-
T beta = bg / o2::gpu::GPUCommonMath::Sqrt(static_cast<T>(1.) + bg * bg);
27-
28-
T aa = o2::gpu::GPUCommonMath::Pow(beta, kp4);
29-
T bb = o2::gpu::GPUCommonMath::Pow(static_cast<T>(1.) / bg, kp5);
30-
bb = o2::gpu::GPUCommonMath::Log(kp3 + bb);
31-
32-
return (kp2 - aa - bb) * kp1 / aa;
23+
return o2::common::BetheBlochAleph(bg, kp1, kp2, kp3, kp4, kp5);
3324
}
3425

35-
} // namespace tpc
36-
} // namespace o2
26+
} // namespace o2::tpc
3727

3828
#endif

0 commit comments

Comments
 (0)