Skip to content

Commit

Permalink
Merge branch 'AliceO2Group:dev' into new-detector4
Browse files Browse the repository at this point in the history
  • Loading branch information
pkurash authored Sep 9, 2024
2 parents 9c4883c + 44df33b commit 605bf80
Show file tree
Hide file tree
Showing 62 changed files with 1,143 additions and 825 deletions.
14 changes: 7 additions & 7 deletions Common/DCAFitter/include/DCAFitter/DCAFitterN.h
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ GPUd() void DCAFitterN<N, Args...>::calcTrackResiduals()

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline void DCAFitterN<N, Args...>::calcTrackDerivatives()
GPUdi() void DCAFitterN<N, Args...>::calcTrackDerivatives()
{
// calculate track derivatives over X param
for (int i = N; i--;) {
Expand All @@ -763,7 +763,7 @@ GPUd() inline void DCAFitterN<N, Args...>::calcTrackDerivatives()

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline double DCAFitterN<N, Args...>::calcChi2() const
GPUdi() double DCAFitterN<N, Args...>::calcChi2() const
{
// calculate current chi2
double chi2 = 0;
Expand All @@ -777,7 +777,7 @@ GPUd() inline double DCAFitterN<N, Args...>::calcChi2() const

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline double DCAFitterN<N, Args...>::calcChi2NoErr() const
GPUdi() double DCAFitterN<N, Args...>::calcChi2NoErr() const
{
// calculate current chi2 of abs. distance minimization
double chi2 = 0;
Expand Down Expand Up @@ -842,7 +842,7 @@ GPUd() bool DCAFitterN<N, Args...>::propagateTracksToVertex(int icand)

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline o2::track::TrackPar DCAFitterN<N, Args...>::getTrackParamAtPCA(int i, int icand)
GPUdi() o2::track::TrackPar DCAFitterN<N, Args...>::getTrackParamAtPCA(int i, int icand)
{
// propagate tracks param only to current vertex (if not already done)
int ord = mOrder[icand];
Expand All @@ -858,7 +858,7 @@ GPUd() inline o2::track::TrackPar DCAFitterN<N, Args...>::getTrackParamAtPCA(int

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline double DCAFitterN<N, Args...>::getAbsMax(const VecND& v)
GPUdi() double DCAFitterN<N, Args...>::getAbsMax(const VecND& v)
{
double mx = -1;
for (int i = N; i--;) {
Expand Down Expand Up @@ -1075,7 +1075,7 @@ GPUd() o2::track::TrackPar DCAFitterN<N, Args...>::createParentTrackPar(int cand

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline bool DCAFitterN<N, Args...>::propagateParamToX(o2::track::TrackPar& t, float x)
GPUdi() bool DCAFitterN<N, Args...>::propagateParamToX(o2::track::TrackPar& t, float x)
{
bool res = true;
if (mUsePropagator || mMatCorr != o2::base::Propagator::MatCorrType::USEMatCorrNONE) {
Expand All @@ -1091,7 +1091,7 @@ GPUd() inline bool DCAFitterN<N, Args...>::propagateParamToX(o2::track::TrackPar

//___________________________________________________________________
template <int N, typename... Args>
GPUd() inline bool DCAFitterN<N, Args...>::propagateToX(o2::track::TrackParCov& t, float x)
GPUdi() bool DCAFitterN<N, Args...>::propagateToX(o2::track::TrackParCov& t, float x)
{
bool res = true;
if (mUsePropagator || mMatCorr != o2::base::Propagator::MatCorrType::USEMatCorrNONE) {
Expand Down
20 changes: 10 additions & 10 deletions DataFormats/Detectors/TPC/include/DataFormatsTPC/TrackTPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class TrackTPC : public o2::track::TrackParCov
GPUd() void setClusterRef(uint32_t entry, uint16_t ncl) { mClustersReference.set(entry, ncl); }

template <class T>
GPUd() static inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex, const ClusRef& ref)
GPUdi() static void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex, const ClusRef& ref)
{
// data for given tracks starts at clinfo[ ref.getFirstEntry() ],
// 1st ref.getEntries() cluster indices are stored as uint32_t
Expand All @@ -95,31 +95,31 @@ class TrackTPC : public o2::track::TrackParCov
}

template <class T>
GPUd() inline void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex) const
GPUdi() void getClusterReference(T& clinfo, int nCluster,
uint8_t& sectorIndex, uint8_t& rowIndex, uint32_t& clusterIndex) const
{
getClusterReference<T>(clinfo, nCluster, sectorIndex, rowIndex, clusterIndex, mClustersReference);
}

template <class T>
GPUd() static inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex, const ClusRef& ref)
GPUdi() static const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex, const ClusRef& ref)
{
uint32_t clusterIndex;
getClusterReference<T>(clinfo, nCluster, sectorIndex, rowIndex, clusterIndex, ref);
return (clusters.clusters[sectorIndex][rowIndex][clusterIndex]);
}

template <class T>
GPUd() inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex) const
GPUdi() const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters, uint8_t& sectorIndex, uint8_t& rowIndex) const
{
return getCluster<T>(clinfo, nCluster, clusters, sectorIndex, rowIndex, mClustersReference);
}

template <class T>
GPUd() inline const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters) const
GPUdi() const o2::tpc::ClusterNative& getCluster(T& clinfo, int nCluster,
const o2::tpc::ClusterNativeAccess& clusters) const
{
uint8_t sectorIndex, rowIndex;
return (getCluster<T>(clinfo, nCluster, clusters, sectorIndex, rowIndex));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ class TrackParametrization
GPUd() value_t getPt() const;
GPUd() value_t getE2() const;
GPUd() value_t getE() const;
GPUd() static inline value_t getdEdxBB(value_t betagamma) { return BetheBlochSolid(betagamma); }
GPUd() static inline value_t getdEdxBBOpt(value_t betagamma) { return BetheBlochSolidOpt(betagamma); }
GPUd() static inline value_t getBetheBlochSolidDerivativeApprox(value_T dedx, value_T bg) { return BetheBlochSolidDerivative(dedx, bg); }
GPUdi() static value_t getdEdxBB(value_t betagamma) { return BetheBlochSolid(betagamma); }
GPUdi() static value_t getdEdxBBOpt(value_t betagamma) { return BetheBlochSolidOpt(betagamma); }
GPUdi() static value_t getBetheBlochSolidDerivativeApprox(value_T dedx, value_T bg) { return BetheBlochSolidDerivative(dedx, bg); }

GPUd() value_t getTheta() const;
GPUd() value_t getEta() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ GPUd() value_T BetheBlochSolidOpt(value_T bg)

//____________________________________________________
template <typename value_T>
GPUd() value_T inline BetheBlochSolidDerivative(value_T dedx, value_T bg)
GPUdi() value_T BetheBlochSolidDerivative(value_T dedx, value_T bg)
{
//
// This is approximate derivative of the BB over betagamm, NO check for the consistency of the provided dedx and bg is done
Expand Down
6 changes: 6 additions & 0 deletions DataFormats/simulation/include/SimulationDataFormat/MCTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ class MCTrackT
}
}

Double_t GetTgl() const
{
auto pT = GetPt();
return pT > 1e-6 ? mStartVertexMomentumZ / pT : (GetStartVertexMomentumZ() > 0 ? 999. : -999.);
}

Double_t GetTheta() const
{
double mz(mStartVertexMomentumZ);
Expand Down
2 changes: 2 additions & 0 deletions Detectors/Base/include/DetectorsBase/MatLayerCyl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class MatLayerCyl : public o2::gpu::FlatObject
Within = 0,
Above = 1 };

#ifndef GPUCA_GPUCODE
MatLayerCyl();
MatLayerCyl(const MatLayerCyl& src) CON_DELETE;
~MatLayerCyl() CON_DEFAULT;
#endif

#ifndef GPUCA_ALIGPUCODE // this part is unvisible on GPU version
MatLayerCyl(float rMin, float rMax, float zHalfSpan, float dzMin, float drphiMin);
Expand Down
2 changes: 2 additions & 0 deletions Detectors/Base/include/DetectorsBase/MatLayerCylSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class MatLayerCylSet : public o2::gpu::FlatObject
{

public:
#ifndef GPUCA_GPUCODE
MatLayerCylSet() CON_DEFAULT;
~MatLayerCylSet() CON_DEFAULT;
MatLayerCylSet(const MatLayerCylSet& src) CON_DELETE;
#endif

GPUd() const MatLayerCylSetLayout* get() const { return reinterpret_cast<const MatLayerCylSetLayout*>(mFlatBufferPtr); }
GPUd() MatLayerCylSetLayout* get() { return reinterpret_cast<MatLayerCylSetLayout*>(mFlatBufferPtr); }
Expand Down
2 changes: 2 additions & 0 deletions Detectors/Base/src/MatLayerCyl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
using namespace o2::base;
using flatObject = o2::gpu::FlatObject;

#ifndef GPUCA_GPUCODE
//________________________________________________________________________________
MatLayerCyl::MatLayerCyl() : mNZBins(0), mNPhiBins(0), mNPhiSlices(0), mZHalf(0.f), mRMin2(0.f), mRMax2(0.f), mDZ(0.f), mDZInv(0.f), mDPhi(0.f), mDPhiInv(0.f), mPhiBin2Slice(nullptr), mSliceCos(nullptr), mSliceSin(nullptr), mCells(nullptr)
{
}
#endif

#ifndef GPUCA_ALIGPUCODE // this part is unvisible on GPU version
//________________________________________________________________________________
Expand Down
8 changes: 2 additions & 6 deletions Detectors/Base/src/Propagator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -788,16 +788,12 @@ namespace o2::base
{
#if !defined(GPUCA_GPUCODE) || defined(GPUCA_GPUCODE_DEVICE) // FIXME: DR: WORKAROUND to avoid CUDA bug creating host symbols for device code.
template class PropagatorImpl<float>;
template bool GPUdni() PropagatorImpl<float>::propagateToAlphaX<PropagatorImpl<float>::TrackPar_t>(PropagatorImpl<float>::TrackPar_t&, float, float, bool, float, float, int, PropagatorImpl<float>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
template bool GPUdni() PropagatorImpl<float>::propagateToAlphaX<PropagatorImpl<float>::TrackParCov_t>(PropagatorImpl<float>::TrackParCov_t&, float, float, bool, float, float, int, PropagatorImpl<float>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
#endif
#ifndef GPUCA_GPUCODE
template class PropagatorImpl<double>;
#endif
#ifndef __HIPCC__ // TODO: Fixme: must prevent HIP from compiling this, should file bug report
template bool GPUd() PropagatorImpl<float>::propagateToAlphaX<PropagatorImpl<float>::TrackPar_t>(PropagatorImpl<float>::TrackPar_t&, float, float, bool, float, float, int, PropagatorImpl<float>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
template bool GPUd() PropagatorImpl<float>::propagateToAlphaX<PropagatorImpl<float>::TrackParCov_t>(PropagatorImpl<float>::TrackParCov_t&, float, float, bool, float, float, int, PropagatorImpl<float>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
#ifndef GPUCA_GPUCODE_DEVICE
template bool PropagatorImpl<double>::propagateToAlphaX<PropagatorImpl<double>::TrackPar_t>(PropagatorImpl<double>::TrackPar_t&, double, double, bool, double, double, int, PropagatorImpl<double>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
template bool PropagatorImpl<double>::propagateToAlphaX<PropagatorImpl<double>::TrackParCov_t>(PropagatorImpl<double>::TrackParCov_t&, double, double, bool, double, double, int, PropagatorImpl<double>::MatCorrType matCorr, track::TrackLTIntegral*, int) const;
#endif
#endif
} // namespace o2::base
4 changes: 2 additions & 2 deletions Detectors/FIT/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ o2_add_test_root_macro(readFITDCSdata.C
O2::CCDB
LABELS fit)

o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/readFITDCSdata.C)
o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/readFITDeadChannelMap.C)
o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/)
o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/)
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,14 @@ class MatchGlobalFwd
std::vector<o2::mft::TrackMFT> mMFTMatchPlaneParams; ///< MFT track parameters at matching plane
std::vector<o2::track::TrackParCovFwd> mMCHMatchPlaneParams; ///< MCH track parameters at matching plane

std::map<int, std::vector<std::pair<int, int>>> mCandidates; ///< map each MCH track id to vector of best match candidates

const o2::itsmft::TopologyDictionary* mMFTDict{nullptr}; // cluster patterns dictionary
o2::itsmft::ChipMappingMFT mMFTMapping;
bool mMCTruthON = false; ///< Flag availability of MC truth
bool mUseMIDMCHMatch = false; ///< Flag for using MCHMID matches (TrackMCHMID)
int mSaveMode = 0; ///< Output mode [0 = SaveBestMatch; 1 = SaveAllMatches; 2 = SaveTrainingData]
int mSaveMode = 0; ///< Output mode [0 = SaveBestMatch; 1 = SaveAllMatches; 2 = SaveTrainingData; 3 = SaveNCandidates]
int mNCandidates = 5; ///< Numbers of matching candidates to save in savemode=3
MatchingType mMatchingType = MATCHINGUNDEFINED;
TGeoManager* mGeoManager;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace globaltracking

enum SaveMode { kBestMatch = 0,
kSaveAll,
kSaveTrainingData };
kSaveTrainingData,
kSaveNCandidates };

struct GlobalFwdMatchingParam : public o2::conf::ConfigurableParamHelper<GlobalFwdMatchingParam> {

Expand All @@ -41,6 +42,7 @@ struct GlobalFwdMatchingParam : public o2::conf::ConfigurableParamHelper<GlobalF
Int_t saveMode = kBestMatch; ///< Global Forward Tracks save mode
float MFTRadLength = 0.042; ///< MFT thickness in radiation length
float alignResidual = 1.; ///< Alignment residual for cluster position uncertainty
int nCandidates = 5; ///< Number of best matching candidates to save in savemode=3

bool
isMatchUpstream() const
Expand Down
41 changes: 40 additions & 1 deletion Detectors/GlobalTracking/src/MatchGlobalFwd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// or submit itself to any jurisdiction.

#include "GlobalTracking/MatchGlobalFwd.h"
#include <queue>

using namespace o2::globaltracking;

Expand Down Expand Up @@ -66,6 +67,8 @@ void MatchGlobalFwd::init()

mSaveMode = matchingParam.saveMode;
LOG(info) << "Save mode MFTMCH candidates = " << mSaveMode;

mNCandidates = matchingParam.nCandidates;
}

//_________________________________________________________
Expand Down Expand Up @@ -98,6 +101,9 @@ void MatchGlobalFwd::run(const o2::globaltracking::RecoContainer& inp)
case kSaveTrainingData:
doMatching<kSaveTrainingData>();
break;
case kSaveNCandidates:
doMatching<kSaveNCandidates>();
break;
default:
LOG(fatal) << "Invalid MFTMCH save mode";
}
Expand Down Expand Up @@ -132,6 +138,7 @@ void MatchGlobalFwd::clear()
mMatchLabels.clear();
mMFTTrackROFContMapping.clear();
mMatchingInfo.clear();
mCandidates.clear();
}

//_________________________________________________________
Expand Down Expand Up @@ -400,6 +407,25 @@ void MatchGlobalFwd::doMatching()
if (mMCTruthON) {
LOG(info) << " MFT-MCH Matching: nFakes = " << nFakes << " nTrue = " << nTrue;
}
} else if constexpr (saveAllMode == SaveMode::kSaveNCandidates) {
int nFakes = 0, nTrue = 0;
auto& matchAllChi2 = mMatchingFunctionMap["matchALL"];
for (auto MCHId = 0; MCHId < mMCHWork.size(); MCHId++) {
auto& thisMCHTrack = mMCHWork[MCHId];
for (auto& pairCandidate : mCandidates[MCHId]) {
thisMCHTrack.setMFTTrackID(pairCandidate.second);
auto& thisMFTTrack = mMFTWork[pairCandidate.second];
auto chi2 = matchAllChi2(thisMCHTrack, thisMFTTrack); // Matching chi2 is stored independently
thisMCHTrack.setMFTMCHMatchingScore(pairCandidate.first);
thisMCHTrack.setMFTMCHMatchingChi2(chi2);
mMatchedTracks.emplace_back(thisMCHTrack);
mMatchingInfo.emplace_back(thisMCHTrack);
if (mMCTruthON) {
mMatchLabels.push_back(computeLabel(MCHId, pairCandidate.second));
mMatchLabels.back().isFake() ? nFakes++ : nTrue++;
}
}
}
}
}

Expand All @@ -413,6 +439,10 @@ void MatchGlobalFwd::ROFMatch(int MFTROFId, int firstMCHROFId, int lastMCHROFId)
const auto& lastMCHROF = mMCHTrackROFRec[lastMCHROFId];
int nFakes = 0, nTrue = 0;

auto compare = [](const std::pair<int, int>& a, const std::pair<int, int>& b) {
return a.first < b.first;
};

auto firstMFTTrackID = thisMFTROF.getFirstEntry();
auto lastMFTTrackID = firstMFTTrackID + thisMFTROF.getNEntries() - 1;

Expand Down Expand Up @@ -464,12 +494,21 @@ void MatchGlobalFwd::ROFMatch(int MFTROFId, int firstMCHROFId, int lastMCHROFId)
}
}

if constexpr (saveAllMode == SaveMode::kSaveNCandidates) { // In saveAllmode save all pairs to output container
auto score = mMatchFunc(thisMCHTrack, thisMFTTrack);
std::pair<int, int> scoreID = {score, MFTId};
mCandidates[MCHId].push_back(scoreID);
std::sort(mCandidates[MCHId].begin(), mCandidates[MCHId].end(), compare);
if (mCandidates[MCHId].size() > mNCandidates) {
mCandidates[MCHId].pop_back();
}
}

if constexpr (saveAllMode == SaveMode::kSaveTrainingData) { // In save training data mode store track parameters at matching plane
thisMCHTrack.setMFTTrackID(MFTId);
mMatchingInfo.emplace_back(thisMCHTrack);
mMCHMatchPlaneParams.emplace_back(thisMCHTrack);
mMFTMatchPlaneParams.emplace_back(static_cast<o2::mft::TrackMFT>(thisMFTTrack));

if (mMCTruthON) {
mMatchLabels.push_back(matchLabel);
mMatchLabels.back().isFake() ? nFakes++ : nTrue++;
Expand Down
6 changes: 5 additions & 1 deletion Detectors/GlobalTrackingWorkflow/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

# add_compile_options(-O0 -g -fPIC)
add_compile_options(-O0 -g -fPIC)

o2_add_library(GlobalTrackingStudy
SOURCES src/TPCTrackStudy.cxx
Expand All @@ -21,6 +21,8 @@ o2_add_library(GlobalTrackingStudy
src/DumpTracks.cxx
src/V0Ext.cxx
src/TrackInfoExt.cxx
src/TrackMCStudyConfig.cxx
src/TrackMCStudyTypes.cxx
PUBLIC_LINK_LIBRARIES O2::GlobalTracking
O2::GlobalTrackingWorkflowReaders
O2::GlobalTrackingWorkflowHelpers
Expand All @@ -33,6 +35,8 @@ o2_target_root_dictionary(
GlobalTrackingStudy
HEADERS include/GlobalTrackingStudy/V0Ext.h
include/GlobalTrackingStudy/TrackInfoExt.h
include/GlobalTrackingStudy/TrackMCStudyConfig.h
include/GlobalTrackingStudy/TrackMCStudyTypes.h
)

o2_add_executable(study-workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
#ifndef O2_TRACKING_STUDY_H
#define O2_TRACKING_STUDY_H

#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "Framework/Task.h"
#include "Framework/DataProcessorSpec.h"
#include "ReconstructionDataFormats/Track.h"
#include "MathUtils/detail/Bracket.h"
#include "DataFormatsTPC/ClusterNative.h"
#include "Framework/Task.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"

namespace o2::trackstudy
{

/// create a processor spec
o2::framework::DataProcessorSpec getTrackMCStudySpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool checkMatching);
o2::framework::DataProcessorSpec getTrackMCStudySpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus);

} // namespace o2::trackstudy

Expand Down
Loading

0 comments on commit 605bf80

Please sign in to comment.