Skip to content

Commit 1625739

Browse files
committed
mv downsampling Tsalis to utils
1 parent a29036a commit 1625739

File tree

2 files changed

+36
-62
lines changed

2 files changed

+36
-62
lines changed

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -384,37 +384,7 @@ struct TreeWriterTpcV0 {
384384
}
385385
}
386386

387-
double tsalisCharged(const double pt, const double mass)
388-
{
389-
const double a = 6.81, b = 59.24;
390-
const double c = 0.082, d = 0.151;
391-
const double mt = std::sqrt(mass * mass + pt * pt);
392-
const double n = a + b / sqrtSNN;
393-
const double t = c + d / sqrtSNN;
394-
const double p0 = n * t;
395-
const double result = std::pow((1. + mt / p0), -n);
396-
return result;
397-
};
398-
399-
/// Random downsampling trigger function using Tsalis/Hagedorn spectra fit (sqrt(s) = 62.4 GeV to 13 TeV)
400-
/// as in https://iopscience.iop.org/article/10.1088/2399-6528/aab00f/pdf
401387
TRandom3* fRndm = new TRandom3(0);
402-
bool downsampleTsalisCharged(const double pt, const double factor1Pt, const double mass, const double maxPt)
403-
{
404-
if (factor1Pt < 0.) {
405-
return true;
406-
}
407-
if (pt > maxPt) {
408-
return true;
409-
}
410-
const double prob = tsalisCharged(pt, mass) * pt;
411-
const double probNorm = tsalisCharged(1., mass);
412-
if ((fRndm->Rndm() * ((prob / probNorm) * pt * pt)) > factor1Pt) {
413-
return false;
414-
} else {
415-
return true;
416-
}
417-
};
418388

419389
void init(o2::framework::InitContext&)
420390
{
@@ -479,7 +449,7 @@ struct TreeWriterTpcV0 {
479449
rowTPCTree.reserve(tracks.size());
480450

481451
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const V0Daughter& daughter) {
482-
const bool passDownsamplig = downsampleTsalisCharged(dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, daughter.maxPt4dwnsmplTsalis);
452+
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
483453
const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < FloatEqualityTolerance;
484454
const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > FloatEqualityTolerance;
485455
if (passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) {
@@ -570,7 +540,7 @@ struct TreeWriterTpcV0 {
570540
}
571541

572542
auto fillDaughterTrack = [&](const auto& mother, const TrksType::iterator& dauTrack, const V0Daughter& daughter, const aod::TracksQA& trackQAInstance, const bool existTrkQA) {
573-
const bool passDownsamplig = downsampleTsalisCharged(dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, daughter.maxPt4dwnsmplTsalis);
543+
const bool passDownsamplig = downsampleTsalisCharged(fRndm, dauTrack.pt(), daughter.downsamplingTsalis, daughter.mass, sqrtSNN, daughter.maxPt4dwnsmplTsalis);
574544
const bool passNSigmaTofCut = std::fabs(daughter.tofNSigma) < daughter.nSigmaTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) < FloatEqualityTolerance;
575545
const bool passMatchTofRequirement = !daughter.rejectNoTofDauTrack || std::fabs(daughter.tofNSigma - NSigmaTofUnmatched) > FloatEqualityTolerance;
576546
if (passDownsamplig && passNSigmaTofCut && passMatchTofRequirement) {
@@ -755,34 +725,7 @@ struct TreeWriterTPCTOF {
755725
double nSigmaTpcTpctof;
756726
};
757727

758-
double tsalisCharged(const double pt, const double mass)
759-
{
760-
const double a = 6.81, b = 59.24;
761-
const double c = 0.082, d = 0.151;
762-
double mt = std::sqrt(mass * mass + pt * pt);
763-
double n = a + b / sqrtSNN;
764-
double t = c + d / sqrtSNN;
765-
double p0 = n * t;
766-
double result = std::pow((1. + mt / p0), -n);
767-
return result;
768-
};
769-
770-
/// Random downsampling trigger function using Tsalis/Hagedorn spectra fit (sqrt(s) = 62.4 GeV to 13 TeV)
771-
/// as in https://iopscience.iop.org/article/10.1088/2399-6528/aab00f/pdf
772728
TRandom3* fRndm = new TRandom3(0);
773-
bool downsampleTsalisCharged(const double pt, const float factor1Pt, const double mass)
774-
{
775-
if (factor1Pt < 0.) {
776-
return true;
777-
}
778-
const double prob = tsalisCharged(pt, mass) * pt;
779-
const double probNorm = tsalisCharged(1., mass);
780-
if ((fRndm->Rndm() * ((prob / probNorm) * pt * pt)) > factor1Pt) {
781-
return false;
782-
} else {
783-
return true;
784-
}
785-
};
786729

787730
/// Function to fill trees
788731
template <bool DoCorrectDeDx = false, typename T, typename C>
@@ -963,7 +906,7 @@ struct TreeWriterTPCTOF {
963906
if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) &&
964907
((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) ||
965908
(trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) &&
966-
downsampleTsalisCharged(trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass)) {
909+
downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) {
967910
fillSkimmedTPCTOFTable<IsCorrectedDeDx>(trk, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate);
968911
}
969912
}
@@ -1047,7 +990,7 @@ struct TreeWriterTPCTOF {
1047990
if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) &&
1048991
((trk.tpcInnerParam() <= tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTPCOnly) ||
1049992
(trk.tpcInnerParam() > tofTrack->maxMomTPCOnly && std::fabs(tofTrack->tofNSigma) < tofTrack->nSigmaTofTpctof && std::fabs(tofTrack->tpcNSigma) < tofTrack->nSigmaTpcTpctof)) &&
1050-
downsampleTsalisCharged(trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass)) {
993+
downsampleTsalisCharged(fRndm, trk.pt(), tofTrack->downsamplingTsalis, tofTrack->mass, sqrtSNN)) {
1051994
fillSkimmedTPCTOFTableWithTrkQAGeneric<IsCorrectedDeDx, IsWithdEdx>(trk, trackQA, existTrkQA, collision, tofTrack->tpcNSigma, tofTrack->tofNSigma, tofTrack->itsNSigma, tofTrack->tpcExpSignal, tofTrack->pid, runnumber, tofTrack->dwnSmplFactor, hadronicRate, bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame);
1052995
}
1053996
}

DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_
2121
#define DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_
2222

23+
#include "TRandom3.h"
24+
2325
namespace o2::dpg_tpcskimstablecreator
2426
{
2527
enum {
@@ -39,7 +41,7 @@ enum {
3941

4042
/// Event selection
4143
template <typename CollisionType>
42-
bool isEventSelected(const CollisionType& collision, const int applyEvSel)
44+
inline bool isEventSelected(const CollisionType& collision, const int applyEvSel)
4345
{
4446
if (applyEvSel == EventSelectionRun2) {
4547
if (!collision.sel7()) {
@@ -53,5 +55,34 @@ bool isEventSelected(const CollisionType& collision, const int applyEvSel)
5355
return true;
5456
};
5557

58+
inline double tsalisCharged(const double pt, const double mass, const double sqrtSNN)
59+
{
60+
const double a = 6.81, b = 59.24;
61+
const double c = 0.082, d = 0.151;
62+
const double mt = std::sqrt(mass * mass + pt * pt);
63+
const double n = a + b / sqrtSNN;
64+
const double t = c + d / sqrtSNN;
65+
const double p0 = n * t;
66+
const double result = std::pow((1. + mt / p0), -n);
67+
return result;
68+
};
69+
70+
/// Random downsampling trigger function using Tsalis/Hagedorn spectra fit (sqrt(s) = 62.4 GeV to 13 TeV)
71+
/// as in https://iopscience.iop.org/article/10.1088/2399-6528/aab00f/pdf
72+
inline bool downsampleTsalisCharged(TRandom3* fRndm, const double pt, const double factor1Pt, const double mass, const double sqrtSNN, const double maxPt = 1e9)
73+
{
74+
if (factor1Pt < 0. || pt > maxPt) {
75+
return true;
76+
}
77+
78+
const double prob = tsalisCharged(pt, mass, sqrtSNN) * pt;
79+
const double probNorm = tsalisCharged(1., mass, sqrtSNN);
80+
if ((fRndm->Rndm() * ((prob / probNorm) * pt * pt)) > factor1Pt) {
81+
return false;
82+
} else {
83+
return true;
84+
}
85+
};
86+
5687
} // namespace o2::dpg_tpcskimstablecreator
5788
#endif // DPG_TASKS_TPC_UTILSTPCSKIMSTABLECREATOR_H_

0 commit comments

Comments
 (0)