Skip to content

Commit 269d0e1

Browse files
committed
[PWGEM] PhotonMeson: Add second iteration of non lin for PCM
- Add second iteration of non lin for PCM photons - Make use of new NonLin tables in calibTaskEmc and taskPi0FlowEMC
1 parent 4ec2009 commit 269d0e1

File tree

7 files changed

+409
-203
lines changed

7 files changed

+409
-203
lines changed

PWGEM/PhotonMeson/Core/EMCPhotonCut.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ static constexpr bool HasPrimaries = !std::is_same_v<TPrimaries, std::nullptr_t>
4141
template <typename TSecondaries>
4242
static constexpr bool HasSecondaries = !std::is_same_v<TSecondaries, std::nullptr_t>;
4343

44+
template <typename T>
45+
concept IsNonLinIterator = o2::soa::is_iterator<T> && requires(T t) {
46+
// Check that the *elements* of the container have the required methods:
47+
{ t.corrE() } -> std::same_as<float>;
48+
{ t.corrPt() } -> std::same_as<float>;
49+
};
50+
51+
template <typename T>
52+
concept IsNonLinContainer = o2::soa::is_table<T> && requires(T t) {
53+
// Check that the *elements* of the container have the required methods:
54+
{ t.begin().corrE() } -> std::same_as<float>;
55+
{ t.begin().corrPt() } -> std::same_as<float>;
56+
};
57+
4458
template <typename T>
4559
concept IsTrackIterator = o2::soa::is_iterator<T> && requires(T t) {
4660
// Check that the *elements* of the container have the required methods:
@@ -114,7 +128,7 @@ class EMCPhotonCut : public TNamed
114128

115129
static const char* mCutNames[static_cast<int>(EMCPhotonCuts::kNCuts)];
116130

117-
constexpr auto getClusterId(o2::soa::is_iterator auto const& t) const
131+
static constexpr auto getClusterId(o2::soa::is_iterator auto const& t)
118132
{
119133
if constexpr (requires { t.emEmcClusterId(); }) {
120134
return t.emEmcClusterId();
@@ -384,7 +398,11 @@ class EMCPhotonCut : public TNamed
384398
return cluster.definition() == mDefinition;
385399

386400
case EMCPhotonCuts::kEnergy:
387-
return cluster.e() > mMinE;
401+
if constexpr (IsNonLinIterator<std::decay_t<decltype(cluster)>>) {
402+
return cluster.corrE() > mMinE;
403+
} else {
404+
return cluster.e() > mMinE;
405+
}
388406

389407
case EMCPhotonCuts::kNCell:
390408
return cluster.nCells() >= mMinNCell;
@@ -478,7 +496,11 @@ class EMCPhotonCut : public TNamed
478496
return cluster.definition() == mDefinition;
479497

480498
case EMCPhotonCuts::kEnergy:
481-
return cluster.e() > mMinE;
499+
if constexpr (IsNonLinIterator<Cluster>) {
500+
return cluster.corrE() > mMinE;
501+
} else {
502+
return cluster.e() > mMinE;
503+
}
482504

483505
case EMCPhotonCuts::kNCell:
484506
return cluster.nCells() >= mMinNCell;
@@ -496,7 +518,9 @@ class EMCPhotonCut : public TNamed
496518
auto dPhi = std::fabs(emcmatchedtrack.deltaPhi());
497519
auto trackpt = emcmatchedtrack.trackPt();
498520
auto trackp = emcmatchedtrack.trackP();
499-
bool result = (dEta > GetTrackMatchingEta(trackpt)) || (dPhi > GetTrackMatchingPhi(trackpt)) || (cluster.e() / trackp >= mMinEoverP);
521+
bool result = (dEta > GetTrackMatchingEta(trackpt)) ||
522+
(dPhi > GetTrackMatchingPhi(trackpt)) ||
523+
(cluster.e() / trackp >= mMinEoverP);
500524
if (!result) {
501525
return false;
502526
}
@@ -527,7 +551,8 @@ class EMCPhotonCut : public TNamed
527551
auto dPhi = std::fabs(emcmatchedtrack.deltaPhi());
528552
auto trackpt = emcmatchedtrack.trackPt();
529553
auto trackp = emcmatchedtrack.trackP();
530-
bool result = (dEta > GetSecTrackMatchingEta(trackpt)) || (dPhi > GetSecTrackMatchingPhi(trackpt)) || (cluster.e() / trackp >= mMinEoverP);
554+
bool result = (dEta > GetSecTrackMatchingEta(trackpt)) ||
555+
(dPhi > GetSecTrackMatchingPhi(trackpt));
531556
if (!result) {
532557
return false;
533558
}

PWGEM/PhotonMeson/Core/EMNonLin.cxx

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,38 @@
1515

1616
#include "EMNonLin.h"
1717

18-
#include <cmath>
19-
2018
using namespace o2::pwgem::nonlin;
2119

22-
float EMNonLin::getCorrectionFactor(float inputCalibValue, PhotonType photonType, float cent)
20+
float EMNonLin::getCorrectionFactor(float x, const Context& ctx)
2321
{
24-
float param0 = 0, param1 = 0, param2 = 0, val = 1.f;
25-
switch (photonType) {
26-
case PhotonType::kEMC:
27-
if (cent >= 30 && cent <= 40) {
28-
param0 = -5.33426e-01f;
29-
param1 = 1.40144e-02f;
30-
param2 = -5.24434e-01f;
31-
} else {
32-
param0 = 0.f;
33-
param1 = 0.f;
34-
param2 = 0.f;
35-
}
36-
break;
37-
case PhotonType::kPCM:
38-
if (cent >= 0 && cent <= 100) {
39-
param0 = 10.7203f;
40-
param1 = 0.0383968f;
41-
param2 = 10.6025f;
42-
} else {
43-
param0 = 0.f;
44-
param1 = 0.f;
45-
param2 = 0.f;
46-
}
47-
break;
48-
case PhotonType::kPHOS:
49-
param0 = 0.f;
50-
param1 = 0.f;
51-
param2 = 0.f;
52-
break;
22+
float val = x;
23+
24+
for (int i = 0; i < ctx.nIter; ++i) {
25+
float inv = 1.f / val;
26+
val *= (1.f + ctx.params[i].par0 * inv + ctx.params[i].par1 * inv * inv) / (1.f + ctx.params[i].par2 * inv);
5327
}
5428

55-
val = (1.f + param0 / inputCalibValue + param1 / std::pow(inputCalibValue, 2.f)) / (1.f + param2 / inputCalibValue);
5629
return val;
5730
}
31+
32+
const EMNonLin::NonLinParams* EMNonLin::resolveParams(PhotonType type, float cent)
33+
{
34+
int centBin = static_cast<int>(cent / 10.f);
35+
if (centBin < 0)
36+
centBin = 0;
37+
if (centBin >= CentBins)
38+
centBin = CentBins - 1;
39+
40+
return &kNonLinTable[static_cast<int>(type)][centBin][0];
41+
}
42+
43+
const EMNonLin::NonLinParams* EMNonLin::resolveParamsMC(PhotonType type, float cent)
44+
{
45+
int centBin = static_cast<int>(cent / 10.f);
46+
if (centBin < 0)
47+
centBin = 0;
48+
if (centBin >= CentBins)
49+
centBin = CentBins - 1;
50+
51+
return &kNonLinTableMC[static_cast<int>(type)][centBin][0];
52+
}

0 commit comments

Comments
 (0)