Project
Loading...
Searching...
No Matches
LQND.h
Go to the documentation of this file.
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
15
16#ifndef O2_TRD_LQND_H
17#define O2_TRD_LQND_H
18
19#include "TGraph.h"
20#include "TRDPID/PIDBase.h"
21#include "DataFormatsTRD/PID.h"
28#include "Framework/Logger.h"
32
33#include <memory>
34#include <vector>
35#include <array>
36#include <string>
37#include <numeric>
38
39namespace o2
40{
41namespace trd
42{
43namespace detail
44{
46template <int nDim>
47class LUT
48{
49 public:
50 LUT() = default;
51 LUT(std::vector<float> p, std::vector<TGraph> l) : mIntervalsP(p), mLUTs(l) {}
52
53 //
54 const TGraph& get(float p, bool isNegative, int iDim = 0) const
55 {
56 auto upper = std::upper_bound(mIntervalsP.begin(), mIntervalsP.end(), p);
57 if (upper == mIntervalsP.end()) {
58 // outside of momentum intervals, should not happen
59 return mLUTs[0];
60 }
61 auto index = std::distance(mIntervalsP.begin(), upper);
62 index += (isNegative) ? 0 : mIntervalsP.size() * nDim;
63 return mLUTs[index + iDim];
64 }
65
66 private:
67 std::vector<float> mIntervalsP;
68 std::vector<TGraph> mLUTs;
69
70 ClassDefNV(LUT, 1);
71};
72} // namespace detail
73
76template <int nDim>
77class LQND : public PIDBase
78{
79 static_assert(nDim == 1 || nDim == 2 || nDim == 3, "Likelihood only for 1/2/3 dimension");
80 using PIDBase::PIDBase;
81
82 public:
83 ~LQND() = default;
84
86 {
87 // retrieve lookup tables (LUTs) from ccdb
88 mLUTs = *(pc.inputs().get<detail::LUT<nDim>*>(Form("lq%ddlut", nDim)));
89 }
90
91 float process(const TrackTRD& trkIn, const o2::globaltracking::RecoContainer& input, bool isTPCTRD) const final
92 {
93 const auto& trkSeed = isTPCTRD ? input.getTPCTracks()[trkIn.getRefGlobalTrackId()].getParamOut() : input.getTPCITSTracks()[trkIn.getRefGlobalTrackId()].getParamOut(); // seeding track
94 auto trk = trkSeed;
95
96 const auto isNegative = std::signbit(trkSeed.getSign()); // positive and negative charged particles are treated differently since ExB effects the charge distributions
97 const auto& trackletsRaw = input.getTRDTracklets();
98 float lei0{1.f}, lei1{1.f}, lei2{1.f}, lpi0{1.f}, lpi1{1.f}, lpi2{1.f}; // likelihood per layer
99 for (int iLayer = 0; iLayer < constants::NLAYER; ++iLayer) {
100 int trkltId = trkIn.getTrackletIndex(iLayer);
101 if (trkltId < 0) { // no tracklet attached
102 continue;
103 }
104 const auto xCalib = input.getTRDCalibratedTracklets()[trkIn.getTrackletIndex(iLayer)].getX();
105 auto bz = o2::base::Propagator::Instance()->getNominalBz();
106 const auto tgl = trk.getTgl();
107 const auto snp = trk.getSnpAt(o2::math_utils::sector2Angle(HelperMethods::getSector(input.getTRDTracklets()[trkIn.getTrackletIndex(iLayer)].getDetector())), xCalib, bz);
108 const auto& trklt = trackletsRaw[trkltId];
109 const auto [q0, q1, q2] = getCharges(trklt, iLayer, trkIn, input, snp, tgl); // correct charges
110 if constexpr (nDim == 1) {
111 auto lut = mLUTs.get(trk.getP(), isNegative);
112 auto ll1{1.f};
113 ll1 = lut.Eval(q0 + q1 + q2);
114 lei0 *= ll1;
115 lpi0 *= (1.f - ll1);
116 } else if (nDim == 2) {
117 auto lut1 = mLUTs.get(trk.getP(), isNegative, 0);
118 auto lut2 = mLUTs.get(trk.getP(), isNegative, 1);
119 auto ll1{1.f};
120 auto ll2{1.f};
121 ll1 = lut1.Eval(q0 + q2);
122 ll2 = lut2.Eval(q1);
123 lei0 *= ll1;
124 lei1 *= ll2;
125 lpi0 *= (1.f - ll1);
126 lpi1 *= (1.f - ll2);
127 } else {
128 auto lut1 = mLUTs.get(trk.getP(), isNegative, 0);
129 auto lut2 = mLUTs.get(trk.getP(), isNegative, 1);
130 auto lut3 = mLUTs.get(trk.getP(), isNegative, 2);
131 auto ll1{1.f};
132 auto ll2{1.f};
133 auto ll3{1.f};
134 ll1 = lut1.Eval(q0);
135 ll2 = lut2.Eval(q1);
136 ll3 = lut3.Eval(q2);
137 lei0 *= ll1;
138 lei1 *= ll2;
139 lei2 *= ll3;
140 lpi0 *= (1.f - ll1);
141 lpi1 *= (1.f - ll2);
142 lpi2 *= (1.f - ll3);
143 }
144 }
145
146 return (lei0 * lei1 * lei2) / (lei0 * lei1 * lei2 + lpi0 * lpi1 * lpi2); // combined likelihood
147 }
148
149 private:
150 detail::LUT<nDim> mLUTs;
151
152 ClassDefNV(LQND, 1);
153};
154
155using LQ1D = LQND<1>;
156using LQ2D = LQND<2>;
157using LQ3D = LQND<3>;
158
159} // namespace trd
160} // namespace o2
161
162#endif
Global TRD definitions and constants.
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
double upper[3]
This file provides the base interface for pid policies.
Result of refitting TPC-ITS matched track.
GPUd() value_type estimateLTFast(o2 static GPUd() float estimateLTIncrement(const o2 PropagatorImpl * Instance(bool uninitialized=false)
Definition Propagator.h:180
float process(const TrackTRD &trkIn, const o2::globaltracking::RecoContainer &input, bool isTPCTRD) const final
Calculate a PID for a given track.
Definition LQND.h:91
void init(o2::framework::ProcessingContext &pc) final
Initialize the policy.
Definition LQND.h:85
~LQND()=default
PIDBase(PIDPolicy policy)
Definition PIDBase.h:52
std::array< float, constants::NCHARGES > getCharges(const Tracklet64 &tracklet, const int layer, const TrackTRD &trk, const o2::globaltracking::RecoContainer &input, float snp, float tgl) const noexcept
Definition PIDBase.cxx:30
Lookup Table class for ccdb upload.
Definition LQND.h:48
const TGraph & get(float p, bool isNegative, int iDim=0) const
Definition LQND.h:54
LUT(std::vector< float > p, std::vector< TGraph > l)
Definition LQND.h:51
float sector2Angle(int sect)
Definition Utils.h:193
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static int getSector(int det)