Skip to content

Commit 23f79db

Browse files
committed
TPC: Decouple BetheBloch from Detector class
Provide function in standalone header. Clients (such as O2Physics) should not have to include the whole TPC detector to have access to this function.
1 parent a385609 commit 23f79db

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

DataFormats/Detectors/TPC/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ o2_target_root_dictionary(
6262
include/DataFormatsTPC/CalibdEdxCorrection.h
6363
include/DataFormatsTPC/CalibdEdxTrackTopologyPol.h
6464
include/DataFormatsTPC/CalibdEdxContainer.h
65-
include/DataFormatsTPC/CalibdEdxTrackTopologySpline.h)
65+
include/DataFormatsTPC/CalibdEdxTrackTopologySpline.h
66+
include/DataFormatsTPC/BetheBlochAleph.h)
6667

6768
o2_add_test(
6869
ClusterNative
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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_TPC_BETHEBLOCH_H_
13+
#define AliceO2_TPC_BETHEBLOCH_H_
14+
15+
#include <cmath>
16+
17+
namespace o2
18+
{
19+
namespace tpc
20+
{
21+
22+
template <typename T>
23+
inline T BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5)
24+
{
25+
T beta = bg / std::sqrt(static_cast<T>(1.) + bg * bg);
26+
27+
T aa = std::pow(beta, kp4);
28+
T bb = std::pow(static_cast<T>(1.) / bg, kp5);
29+
bb = std::log(kp3 + bb);
30+
31+
return (kp2 - aa - bb) * kp1 / aa;
32+
}
33+
34+
} // namespace tpc
35+
} // namespace o2
36+
37+
#endif

Detectors/TPC/simulation/include/TPCSimulation/Detector.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "TPCSimulation/Point.h"
2121
#include "TPCBase/Sector.h"
22+
#include "DataFormatsTPC/BetheBlochAleph.h"
2223

2324
class FairVolume; // lines 10-10
2425

@@ -115,7 +116,10 @@ class Detector : public o2::base::DetImpl<Detector>
115116
/// @param kp* Parameters for the ALICE TPC
116117
/// @return Bethe-Bloch value in MIP units
117118
template <typename T>
118-
static T BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5);
119+
static T BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5)
120+
{
121+
return o2::tpc::BetheBlochAleph(bg, kp1, kp2, kp3, kp4, kp5);
122+
}
119123

120124
/// Copied from AliRoot - should go to someplace else
121125
/// Function to generate random numbers according to Gamma function
@@ -188,18 +192,6 @@ class Detector : public o2::base::DetImpl<Detector>
188192
ClassDefOverride(Detector, 1);
189193
};
190194

191-
template <typename T>
192-
inline T Detector::BetheBlochAleph(T bg, T kp1, T kp2, T kp3, T kp4, T kp5)
193-
{
194-
T beta = bg / std::sqrt(static_cast<T>(1.) + bg * bg);
195-
196-
T aa = std::pow(beta, kp4);
197-
T bb = std::pow(static_cast<T>(1.) / bg, kp5);
198-
bb = std::log(kp3 + bb);
199-
200-
return (kp2 - aa - bb) * kp1 / aa;
201-
}
202-
203195
} // namespace tpc
204196
} // namespace o2
205197

0 commit comments

Comments
 (0)