Skip to content

Commit

Permalink
O2-4592 - adding TOF dX and dZ to the track QA table with int8 precis…
Browse files Browse the repository at this point in the history
…ion (#13787)

* O2-4592 - adding TOF dX and dZ to the track QA table with relative sigma precision nBins*2

* O2-4592 - typo fix

* O2-4592 - clang-format

* AOD: TrackQA_002

Signed-off-by: Felix Schlepper <[email protected]>

* AOD: Activate TrackQA_002

Signed-off-by: Felix Schlepper <[email protected]>

* O2-4592 - patch fix from Felix (not full fix yet)

* O2-4592 - typ fix - getting TOF source

---------

Signed-off-by: Felix Schlepper <[email protected]>
Co-authored-by: miranov25 <[email protected]>
Co-authored-by: Felix Schlepper <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 560a1e9 commit 4e92d0d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ class AODProducerWorkflowDPL : public Task
int8_t dRefGloSnp{std::numeric_limits<int8_t>::min()};
int8_t dRefGloTgl{std::numeric_limits<int8_t>::min()};
int8_t dRefGloQ2Pt{std::numeric_limits<int8_t>::min()};
int8_t dTofdX{std::numeric_limits<int8_t>::min()};
int8_t dTofdZ{std::numeric_limits<int8_t>::min()};
};

// helper struct for addToFwdTracksTable()
Expand Down
31 changes: 23 additions & 8 deletions Detectors/AOD/src/AODProducerWorkflowSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ void AODProducerWorkflowDPL::addToTracksQATable(TracksQACursorType& tracksQACurs
trackQAInfoHolder.dRefGloZ,
trackQAInfoHolder.dRefGloSnp,
trackQAInfoHolder.dRefGloTgl,
trackQAInfoHolder.dRefGloQ2Pt);
trackQAInfoHolder.dRefGloQ2Pt,
trackQAInfoHolder.dTofdX,
trackQAInfoHolder.dTofdZ);
}

template <typename mftTracksCursorType, typename AmbigMFTTracksCursorType>
Expand Down Expand Up @@ -2567,6 +2569,12 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
trackQAHolder.tpcdcaR = 100. * dcaInfo[0] / sqrt(1. + trackPar.getQ2Pt() * trackPar.getQ2Pt());
trackQAHolder.tpcdcaZ = 100. * dcaInfo[1] / sqrt(1. + trackPar.getQ2Pt() * trackPar.getQ2Pt());
}
// This allows to safely clamp any float to one byte, using the
// minmal/maximum values as under-/overflow borders and rounding to the nearest integer
auto safeInt8Clamp = [](auto value) -> int8_t {
using ValType = decltype(value);
return static_cast<int8_t>(TMath::Nint(std::clamp(value, static_cast<ValType>(std::numeric_limits<int8_t>::min()), static_cast<ValType>(std::numeric_limits<int8_t>::max()))));
};
/// get tracklet byteMask
uint8_t clusterCounters[8] = {0};
{
Expand Down Expand Up @@ -2597,6 +2605,16 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
trackQAHolder.tpcdEdxTot1R = uint8_t(tpcOrig.getdEdx().dEdxTotOROC1 * dEdxNorm);
trackQAHolder.tpcdEdxTot2R = uint8_t(tpcOrig.getdEdx().dEdxTotOROC2 * dEdxNorm);
trackQAHolder.tpcdEdxTot3R = uint8_t(tpcOrig.getdEdx().dEdxTotOROC3 * dEdxNorm);
///
float scaleTOF{0};
auto contributorsGIDA = data.getSingleDetectorRefs(trackIndex);
if (contributorsGIDA[GIndex::Source::TOF].isIndexSet()) { // ITS-TPC-TRD-TOF, ITS-TPC-TOF, TPC-TRD-TOF, TPC-TOF
const auto& tofMatch = data.getTOFMatch(trackIndex);
const float qpt = trackPar.getQ2Pt();
scaleTOF = std::sqrt(o2::aod::track::trackQAScaledTOF[0] * o2::aod::track::trackQAScaledTOF[0] + qpt * qpt * o2::aod::track::trackQAScaledTOF[1] * o2::aod::track::trackQAScaledTOF[1]) / (2. * o2::aod::track::trackQAScaleBins);
trackQAHolder.dTofdX = safeInt8Clamp(tofMatch.getDXatTOF() / scaleTOF);
trackQAHolder.dTofdZ = safeInt8Clamp(tofMatch.getDZatTOF() / scaleTOF);
}

// Add matching information at a reference point (defined by
// o2::aod::track::trackQARefRadius) in the same frame as the global track
Expand All @@ -2622,13 +2640,6 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
return o2::aod::track::trackQAScaleBins / std::sqrt(o2::aod::track::trackQAScaleGloP0[i] * o2::aod::track::trackQAScaleGloP0[i] + (o2::aod::track::trackQAScaleGloP1[i] * x) * (o2::aod::track::trackQAScaleGloP1[i] * x));
};

// This allows to safely clamp any float to one byte, using the
// minmal/maximum values as under-/overflow borders and rounding to the nearest integer
auto safeInt8Clamp = [](auto value) -> int8_t {
using ValType = decltype(value);
return static_cast<int8_t>(TMath::Nint(std::clamp(value, static_cast<ValType>(std::numeric_limits<int8_t>::min()), static_cast<ValType>(std::numeric_limits<int8_t>::max()))));
};

// Calculate deltas for contributors
trackQAHolder.dRefContY = safeInt8Clamp((itsCopy.getY() - tpcCopy.getY()) * scaleCont(0));
trackQAHolder.dRefContZ = safeInt8Clamp((itsCopy.getZ() - tpcCopy.getZ()) * scaleCont(1));
Expand All @@ -2641,6 +2652,7 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
trackQAHolder.dRefGloSnp = safeInt8Clamp(((itsCopy.getSnp() + tpcCopy.getSnp()) * 0.5f - gloCopy.getSnp()) * scaleGlo(2));
trackQAHolder.dRefGloTgl = safeInt8Clamp(((itsCopy.getTgl() + tpcCopy.getTgl()) * 0.5f - gloCopy.getTgl()) * scaleGlo(3));
trackQAHolder.dRefGloQ2Pt = safeInt8Clamp(((itsCopy.getQ2Pt() + tpcCopy.getQ2Pt()) * 0.5f - gloCopy.getQ2Pt()) * scaleGlo(4));
//

if (O2_ENUM_TEST_BIT(mStreamerMask, AODProducerStreamerMask::TrackQA)) {
(*mStreamer) << "trackQA"
Expand Down Expand Up @@ -2684,6 +2696,9 @@ AODProducerWorkflowDPL::TrackQA AODProducerWorkflowDPL::processBarrelTrackQA(int
<< "trackQAHolder.dRefGloSnp=" << trackQAHolder.dRefGloSnp
<< "trackQAHolder.dRefGloTgl=" << trackQAHolder.dRefGloTgl
<< "trackQAHolder.dRefGloQ2Pt=" << trackQAHolder.dRefGloQ2Pt
<< "trackQAHolder.dTofdX=" << trackQAHolder.dTofdX
<< "trackQAHolder.dTofdZ=" << trackQAHolder.dTofdZ
<< "scaleTOF=" << scaleTOF
<< "\n";
}
}
Expand Down
16 changes: 14 additions & 2 deletions Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ DECLARE_SOA_COLUMN(DeltaRefGloParamZ, deltaRefGloParamZ, int8_t); //! No
DECLARE_SOA_COLUMN(DeltaRefGloParamSnp, deltaRefGloParamSnp, int8_t); //! Normalized delta of global track to average contributors matched tracks at reference point in the same frame Snp
DECLARE_SOA_COLUMN(DeltaRefGloParamTgl, deltaRefGloParamTgl, int8_t); //! Normalized delta of global track to average contributors matched tracks at reference point in the same frame Tgl
DECLARE_SOA_COLUMN(DeltaRefGloParamQ2Pt, deltaRefGloParamQ2Pt, int8_t); //! Normalized delta of global track to average contributors matched tracks at reference point in the same frame Q2Pt
DECLARE_SOA_COLUMN(DeltaTOFdX, deltaTOFdX, int8_t); //!
DECLARE_SOA_COLUMN(DeltaTOFdZ, deltaTOFdZ, int8_t); //!

DECLARE_SOA_DYNAMIC_COLUMN(IsDummy, isDummy, //! indicates if the propagation of the contrib. tracks was successful and residuals are available
[](int8_t cY, int8_t cZ, int8_t cSnp, int8_t cTgl, int8_t cQ2Pt, int8_t gY, int8_t gZ, int8_t gSnp, int8_t gTgl, int8_t gQ2Pt) -> bool {
Expand All @@ -709,7 +711,17 @@ DECLARE_SOA_TABLE_VERSIONED(TracksQA_001, "AOD", "TRACKQA", 1, //! trackQA infor
trackqa::IsDummy<trackqa::DeltaRefContParamY, trackqa::DeltaRefContParamZ, trackqa::DeltaRefContParamSnp, trackqa::DeltaRefContParamTgl, trackqa::DeltaRefContParamQ2Pt,
trackqa::DeltaRefGloParamY, trackqa::DeltaRefGloParamZ, trackqa::DeltaRefGloParamSnp, trackqa::DeltaRefGloParamTgl, trackqa::DeltaRefGloParamQ2Pt>);

using TracksQAVersion = TracksQA_001;
DECLARE_SOA_TABLE_VERSIONED(TracksQA_002, "AOD", "TRACKQA", 2, //! trackQA information - version 2 - including contributor residuals of matched tracks at reference radius + TOF delta information
o2::soa::Index<>, trackqa::TrackId, trackqa::TPCTime0, trackqa::TPCDCAR, trackqa::TPCDCAZ, trackqa::TPCClusterByteMask,
trackqa::TPCdEdxMax0R, trackqa::TPCdEdxMax1R, trackqa::TPCdEdxMax2R, trackqa::TPCdEdxMax3R,
trackqa::TPCdEdxTot0R, trackqa::TPCdEdxTot1R, trackqa::TPCdEdxTot2R, trackqa::TPCdEdxTot3R,
trackqa::DeltaRefContParamY, trackqa::DeltaRefContParamZ, trackqa::DeltaRefContParamSnp, trackqa::DeltaRefContParamTgl, trackqa::DeltaRefContParamQ2Pt,
trackqa::DeltaRefGloParamY, trackqa::DeltaRefGloParamZ, trackqa::DeltaRefGloParamSnp, trackqa::DeltaRefGloParamTgl, trackqa::DeltaRefGloParamQ2Pt,
trackqa::DeltaTOFdX, trackqa::DeltaTOFdZ,
trackqa::IsDummy<trackqa::DeltaRefContParamY, trackqa::DeltaRefContParamZ, trackqa::DeltaRefContParamSnp, trackqa::DeltaRefContParamTgl, trackqa::DeltaRefContParamQ2Pt,
trackqa::DeltaRefGloParamY, trackqa::DeltaRefGloParamZ, trackqa::DeltaRefGloParamSnp, trackqa::DeltaRefGloParamTgl, trackqa::DeltaRefGloParamQ2Pt>);

using TracksQAVersion = TracksQA_002;
using TracksQA = TracksQAVersion::iterator;

namespace fwdtrack
Expand Down Expand Up @@ -1651,7 +1663,7 @@ using Tracked3body = Tracked3Bodys::iterator;
namespace origins
{
DECLARE_SOA_COLUMN(DataframeID, dataframeID, uint64_t); //! Data frame ID (what is usually found in directory name in the AO2D.root, i.e. DF_XXX)
} // namespace origin
} // namespace origins

DECLARE_SOA_TABLE(Origins, "AOD", "ORIGIN", //! Table which contains the IDs of all dataframes merged into this dataframe
o2::soa::Index<>, origins::DataframeID);
Expand Down
1 change: 1 addition & 0 deletions Framework/Core/include/Framework/DataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ constexpr std::array<float, 5> trackQAScaleContP0{0.257192, 0.0775375, 0.0042428
constexpr std::array<float, 5> trackQAScaleContP1{0.189371, 0.409071, 0.00694444, 0.00720038, 0.0806902};
constexpr std::array<float, 5> trackQAScaleGloP0{0.130985, 0.0775375, 0.00194703, 0.000405458, 0.0160007};
constexpr std::array<float, 5> trackQAScaleGloP1{0.183731, 0.409071, 0.00621802, 0.00624881, 0.0418957};
constexpr std::array<float, 2> trackQAScaledTOF{1.1, 0.33};
} // namespace o2::aod::track

namespace o2::aod::fwdtrack
Expand Down

0 comments on commit 4e92d0d

Please sign in to comment.