Skip to content

Commit a0f47ea

Browse files
authored
[PWGLF] Add TOF mass calculation, minor fixes (#15419)
1 parent a4049f6 commit a0f47ea

File tree

1 file changed

+68
-19
lines changed

1 file changed

+68
-19
lines changed

PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include "MetadataHelper.h"
1717

1818
#include "PWGLF/DataModel/LFHypernucleiKfTables.h"
19+
#include "PWGLF/DataModel/LFNucleiTables.h"
20+
#include "PWGLF/DataModel/LFPIDTOFGenericTables.h"
21+
#include "PWGLF/DataModel/LFParticleIdentification.h"
22+
#include "PWGLF/Utils/pidTOFGeneric.h"
1923

2024
#include "Common/Core/RecoDecay.h"
2125
#include "Common/Core/trackUtilities.h"
@@ -65,7 +69,7 @@ using namespace o2::framework::expressions;
6569

6670
using CollisionsFull = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As>;
6771
using CollisionsFullMC = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::EvSels, aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As>;
68-
using TracksFull = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksCovIU, aod::pidTOFmass, aod::pidTPCFullPr, aod::pidTPCFullPi>;
72+
using TracksFull = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksCovIU, aod::TOFSignal, o2::aod::EvTimeTOFFT0ForTrack, aod::pidTPCFullPr, aod::pidTPCFullPi>;
6973

7074
o2::common::core::MetadataHelper metadataInfo; // Metadata helper
7175
//----------------------------------------------------------------------------------------------------------------
@@ -146,17 +150,17 @@ enum HYPNUCDEFS { kEnabled,
146150
kDsigns,
147151
kUseV0for };
148152
static const std::vector<std::string> hypNucDefsLb{"Enabled", "PDGCode", "d1", "d2", "d3", "d4", "daughterSigns", "useV0for"};
149-
static const std::string hypNucDefs[nHyperNuclei][nHypNucDefs]{
150-
{"0", "3122", "proton", "pion", "none", "none", "+-", ""},
151-
{"0", "1010010030", "helion", "pion", "none", "none", "+-", ""},
152-
{"0", "1010010030", "deuteron", "proton", "pion", "none", "++-", ""},
153-
{"0", "1010010040", "alpha", "pion", "none", "none", "+-", ""},
154-
{"0", "1010010040", "triton", "proton", "pion", "none", "++-", ""},
155-
{"0", "1010020040", "helion", "proton", "pion", "none", "++-", ""},
156-
{"0", "1010020050", "alpha", "proton", "pion", "none", "++-", ""},
157-
{"0", "1010020050", "helion", "deuteron", "pion", "none", "++-", ""},
158-
{"0", "0", "none", "none", "none", "none", "", ""},
159-
{"0", "0", "none", "none", "none", "none", "", ""}}; // NOLINT: runtime/string
153+
const std::string hypNucDefs[nHyperNuclei][nHypNucDefs]{// NOLINT: runtime/string
154+
{"0", "3122", "proton", "pion", "none", "none", "+-", ""},
155+
{"0", "1010010030", "helion", "pion", "none", "none", "+-", ""},
156+
{"0", "1010010030", "deuteron", "proton", "pion", "none", "++-", ""},
157+
{"0", "1010010040", "alpha", "pion", "none", "none", "+-", ""},
158+
{"0", "1010010040", "triton", "proton", "pion", "none", "++-", ""},
159+
{"0", "1010020040", "helion", "proton", "pion", "none", "++-", ""},
160+
{"0", "1010020050", "alpha", "proton", "pion", "none", "++-", ""},
161+
{"0", "1010020050", "helion", "deuteron", "pion", "none", "++-", ""},
162+
{"0", "0", "none", "none", "none", "none", "", ""},
163+
{"0", "0", "none", "none", "none", "none", "", ""}};
160164

161165
const int nSelPrim = 8;
162166
enum PRESELECTIONSPRIMARIES { kMinMass,
@@ -263,7 +267,6 @@ struct DaughterKf {
263267
dcaToPv = daughterKfp.GetDistanceFromVertex(&vtx[0]);
264268
dcaToPvZ = std::sqrt(dcaToPv * dcaToPv - dcaToPvXY * dcaToPvXY);
265269
}
266-
267270
bool isTrack() { return daughterTrackId >= 0; }
268271
};
269272
int DaughterKf::uniqueId = 0;
@@ -429,6 +432,30 @@ struct IndexPairs {
429432
}
430433
}; // struct IndexPairs
431434

435+
struct IndexPairsVec {
436+
std::vector<std::vector<std::pair<int64_t, int>>> pairs;
437+
IndexPairsVec()
438+
{
439+
pairs.resize(nDaughterParticles);
440+
}
441+
void add(int i, int64_t a, int b) { pairs.at(i).push_back({a, b}); }
442+
void clear()
443+
{
444+
for (size_t i = 0; i < nDaughterParticles; i++)
445+
pairs.at(i).clear();
446+
}
447+
bool getIndex(int i, int64_t a, int& b)
448+
{
449+
for (const auto& pair : pairs.at(i)) {
450+
if (pair.first == a) {
451+
b = pair.second;
452+
return true;
453+
}
454+
}
455+
return false;
456+
}
457+
}; // struct IndexPairsVec
458+
432459
struct McCollInfo {
433460
bool hasRecoColl;
434461
bool passedEvSel;
@@ -526,7 +553,8 @@ struct HypKfRecoTask {
526553
std::vector<HyperNucleus> singleHyperNuclei, cascadeHyperNuclei;
527554
std::vector<float> primVtx, cents;
528555
std::vector<McCollInfo> mcCollInfos;
529-
IndexPairs trackIndices, mcPartIndices;
556+
IndexPairsVec trackIndices;
557+
IndexPairs mcPartIndices;
530558
KFPVertex kfPrimVtx;
531559
bool collHasCandidate, collHasMcTrueCandidate, collPassedEvSel, activeCascade, isMC;
532560
int64_t mcCollTableIndex;
@@ -610,8 +638,12 @@ struct HypKfRecoTask {
610638
const float itsNsigma = getITSnSigma(track, daughterParticles.at(i));
611639
if (daughterParticles.at(i).trkSettings[kMaxITSnSigma] >= 0 && std::abs(itsNsigma) > daughterParticles.at(i).trkSettings[kMaxITSnSigma])
612640
continue;
641+
float tpcNsigmaNlp = NoVal;
642+
if (daughterParticles.at(i).name == "alpha") {
643+
tpcNsigmaNlp = getTPCnSigma(track, daughterParticles.at(i - 1));
644+
}
613645
filldedx(track, i);
614-
foundDaughterKfs.at(i).push_back(DaughterKf(i, track.globalIndex(), track.sign(), primVtx, 0, 0, 0));
646+
foundDaughterKfs.at(i).push_back(DaughterKf(i, track.globalIndex(), track.sign(), primVtx, tpcNsigma, tpcNsigmaNlp, itsNsigma));
615647
}
616648
} // track loop
617649
}
@@ -865,14 +897,14 @@ struct HypKfRecoTask {
865897
continue;
866898
const auto& daughterTrackId = daughter->daughterTrackId;
867899
int trackTableId;
868-
if (!trackIndices.getIndex(daughterTrackId, trackTableId)) {
900+
if (!trackIndices.getIndex(daughter->species, daughterTrackId, trackTableId)) {
869901
const auto& track = tracks.rawIteratorAt(daughterTrackId);
870902
outputTrackTable(
871903
daughter->species * track.sign(), track.pt(), track.eta(), track.phi(), daughter->dcaToPvXY, daughter->dcaToPvZ, track.tpcNClsFound(), track.tpcChi2NCl(),
872904
track.itsClusterSizes(), track.itsChi2NCl(), getRigidity(track), track.tpcSignal(), daughter->tpcNsigma, daughter->tpcNsigmaNHP, daughter->tpcNsigmaNLP,
873-
track.mass(), track.isPVContributor());
905+
getMass2(track), track.isPVContributor());
874906
trackTableId = outputTrackTable.lastIndex();
875-
trackIndices.add(daughterTrackId, trackTableId);
907+
trackIndices.add(daughter->species, daughterTrackId, trackTableId);
876908
}
877909
vecDaugtherTracks.push_back(trackTableId);
878910
}
@@ -1162,7 +1194,7 @@ struct HypKfRecoTask {
11621194
return false;
11631195
if (getMeanItsClsSize(track) > particle.trkSettings[kMaxITSmeanClsSize])
11641196
return false;
1165-
if (particle.trkSettings[kTOFrequiredabove] >= 0 && getRigidity(track) > particle.trkSettings[kTOFrequiredabove] && (track.mass() < particle.trkSettings[kMinTOFmass] || track.mass() > particle.trkSettings[kMaxTOFmass]))
1197+
if (particle.trkSettings[kTOFrequiredabove] >= 0 && getRigidity(track) > particle.trkSettings[kTOFrequiredabove] && (getMass2(track) < particle.trkSettings[kMinTOFmass] || getMass2(track) > particle.trkSettings[kMaxTOFmass]))
11661198
return false;
11671199
return true;
11681200
}
@@ -1331,6 +1363,23 @@ struct HypKfRecoTask {
13311363
return -1;
13321364
}
13331365
//----------------------------------------------------------------------------------------------------------------
1366+
template <class T>
1367+
float getMass2(const T& track)
1368+
{
1369+
const float p = track.p();
1370+
const float& tofStartTime = track.evTimeForTrack();
1371+
const float& tofTime = track.tofSignal();
1372+
constexpr float CInCmPs = 2.99792458e-2f;
1373+
const float& length = track.length();
1374+
const float time = tofTime - tofStartTime;
1375+
if (time > 0.f && length > 0.f) {
1376+
const float beta = length / (CInCmPs * time);
1377+
const float gamma = 1.f / std::sqrt(1.f - beta * beta);
1378+
const float mass = p / std::sqrt(gamma * gamma - 1.f);
1379+
return mass * mass;
1380+
}
1381+
return -1.f;
1382+
}
13341383
//----------------------------------------------------------------------------------------------------------------
13351384
};
13361385
//----------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)