40float MSangle(
float mass,
float p,
float xX0)
42 float beta = p / o2::gpu::CAMath::Hypot(mass, p);
43 return 0.0136f * o2::gpu::CAMath::Sqrt(xX0) * (1.f + 0.038f * o2::gpu::CAMath::Log(xX0)) / (beta * p);
65 mMinR.resize(nLayers, 10000.);
66 mMaxR.resize(nLayers, -1.);
74 mTrackletsIndexROF.resize(2, {0});
79 for (
const auto&
vertex : vertices) {
81 if (!isBeamPositionOverridden) {
82 const int w{
vertex.getNContributors()};
83 mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight +
vertex.getX() *
w) / (mBeamPosWeight +
w);
84 mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight +
vertex.getY() *
w) / (mBeamPosWeight +
w);
98 mVerticesMCRecInfo.insert(mVerticesMCRecInfo.end(), labels.begin(), labels.end());
107 mTotVertPerIteration[iteration] += vertices.size();
112 mVerticesMCRecInfo.insert(mVerticesMCRecInfo.begin() +
mROFramesPV[rofId], labels.begin(), labels.end());
117 std::vector<Vertex> futureVertices;
118 for (
const auto&
vertex : vertices) {
119 if (
vertex.getTimeStamp().getTimeStamp() < rofId) {
122 if (
vertex.getTimeStamp().getTimeStamp() > rofId) {
123 futureVertices.emplace_back(
vertex);
127 mTotVertPerIteration[iteration]++;
128 if (!isBeamPositionOverridden) {
129 const int w{
vertex.getNContributors()};
130 mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight +
vertex.getX() *
w) / (mBeamPosWeight +
w);
131 mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight +
vertex.getY() *
w) / (mBeamPosWeight +
w);
136 if (futureVertices.size()) {
137 for (
auto&
vertex : futureVertices) {
139 mTotVertPerIteration[iteration]++;
153 for (
auto&
c : clusters_in_frame) {
157 auto xyz =
c.getXYZGloRot(*geom);
159 std::array<float, 2>{c.getY(), c.getZ()},
160 std::array<float, 3>{c.getSigmaY2(), c.getSigmaYZ(), c.getSigmaZ2()});
179 return clusters_in_frame.size();
183 gsl::span<const itsmft::CompClusterExt>
clusters,
184 gsl::span<const unsigned char>::iterator& pattIt,
206 mClusterSize.reserve(
clusters.size());
207 for (
auto& rof : rofs) {
208 for (
int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
213 auto pattID =
c.getPatternID();
236 mClusterSize.push_back(255);
238 auto sensorID =
c.getSensorID();
245 std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
246 std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});
271 size_t totalClusters{0};
275 return int(totalClusters);
278void TimeFrame::prepareClusters(
const TrackingParameters& trkParam,
const int maxLayers)
280 std::vector<ClusterHelper> cHelper;
281 std::vector<int> clsPerBin(trkParam.
PhiBins * trkParam.
ZBins, 0);
282 for (
int rof{0}; rof <
mNrof; ++rof) {
286 for (
int iLayer{0}; iLayer < std::min(trkParam.
NLayers, maxLayers); ++iLayer) {
287 std::fill(clsPerBin.begin(), clsPerBin.end(), 0);
289 const int clustersNum{
static_cast<int>(unsortedClusters.size())};
292 cHelper.resize(clustersNum);
294 for (
int iCluster{0}; iCluster < clustersNum; ++iCluster) {
296 const Cluster&
c = unsortedClusters[iCluster];
297 ClusterHelper&
h = cHelper[iCluster];
298 float x =
c.xCoordinate - mBeamPos[0];
299 float y =
c.yCoordinate - mBeamPos[1];
300 const float&
z =
c.zCoordinate;
301 float phi = math_utils::computePhi(
x,
y);
305 mBogusClusters[iLayer]++;
306 }
else if (zBin >= trkParam.
ZBins) {
307 zBin = trkParam.
ZBins - 1;
308 mBogusClusters[iLayer]++;
312 h.r = math_utils::hypot(
x,
y);
313 mMinR[iLayer] = o2::gpu::GPUCommonMath::Min(
h.r, mMinR[iLayer]);
314 mMaxR[iLayer] = o2::gpu::GPUCommonMath::Max(
h.r, mMaxR[iLayer]);
316 h.ind = clsPerBin[bin]++;
318 std::vector<int> lutPerBin(clsPerBin.size());
320 for (
unsigned int iB{1}; iB < lutPerBin.size(); ++iB) {
321 lutPerBin[iB] = lutPerBin[iB - 1] + clsPerBin[iB - 1];
325 for (
int iCluster{0}; iCluster < clustersNum; ++iCluster) {
326 const ClusterHelper&
h = cHelper[iCluster];
328 Cluster&
c = clusters2beSorted[lutPerBin[
h.bin] +
h.ind];
329 c = unsortedClusters[iCluster];
332 c.indexTableBinIndex =
h.bin;
335 for (
unsigned int iB{0}; iB < clsPerBin.size(); ++iB) {
338 for (
auto iB{clsPerBin.size()}; iB < (trkParam.
ZBins * trkParam.
PhiBins + 1); iB++) {
347 if (iteration == 0) {
348 if (maxLayers < trkParam.
NLayers && resetVertices) {
359 mTracksLabel.resize(
mNrof);
360 mLinesLabels.resize(
mNrof);
364 mCellsNeighboursLUT.resize(trkParam.
CellsPerRoad() - 1);
370 mPositionResolution.resize(trkParam.
NLayers);
371 mBogusClusters.resize(trkParam.
NLayers, 0);
374 for (
unsigned int iLayer{0}; iLayer < std::min((
int)
mClusters.size(), maxLayers); ++iLayer) {
383 mLines.resize(
mNrof);
384 mTrackletClusters.resize(
mNrof);
386 for (
int iLayer{0}; iLayer < trkParam.
NLayers; ++iLayer) {
390 tfInfo.covarianceTrackingFrame[0] += trkParam.
SystErrorY2[iLayer];
391 tfInfo.covarianceTrackingFrame[2] += trkParam.
SystErrorZ2[iLayer];
396 mNTrackletsPerROF.resize(2);
397 for (
auto&
v : mNTrackletsPerROF) {
398 v = std::vector<int>(
mNrof + 1, 0);
400 if (iteration == 0 || iteration == 3) {
401 prepareClusters(trkParam, maxLayers);
403 mTotalTracklets = {0, 0};
404 if (maxLayers < trkParam.
NLayers) {
405 for (
size_t iLayer{0}; iLayer < maxLayers; ++iLayer) {
411 mTotVertPerIteration.resize(1 + iteration);
416 mMSangles.resize(trkParam.
NLayers);
417 mPhiCuts.resize(
mClusters.size() - 1, 0.f);
419 float oneOverR{0.001f * 0.3f * std::abs(mBz) / trkParam.
TrackletMinPt};
420 for (
unsigned int iLayer{0}; iLayer <
mClusters.size(); ++iLayer) {
424 const float& r1 = trkParam.
LayerRadii[iLayer];
425 const float& r2 = trkParam.
LayerRadii[iLayer + 1];
426 const float res1 = o2::gpu::CAMath::Hypot(trkParam.
PVres, mPositionResolution[iLayer]);
427 const float res2 = o2::gpu::CAMath::Hypot(trkParam.
PVres, mPositionResolution[iLayer + 1]);
428 const float cosTheta1half = o2::gpu::CAMath::Sqrt(1.f - Sq(0.5f * r1 * oneOverR));
429 const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - Sq(0.5f * r2 * oneOverR));
430 float x = r2 * cosTheta1half - r1 * cosTheta2half;
431 float delta = o2::gpu::CAMath::Sqrt(1. / (1.f - 0.25f * Sq(
x * oneOverR)) * (Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta2half + cosTheta1half) * Sq(res1) + Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta1half + cosTheta2half) * Sq(res2)));
432 mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f *
x * oneOverR) + 2.f * mMSangles[iLayer] + delta,
constants::math::Pi * 0.5f);
436 for (
int iLayer{0}; iLayer < std::min((
int)
mTracklets.size(), maxLayers); ++iLayer) {
439 if (iLayer < (
int)
mCells.size()) {
446 if (iLayer < (
int)
mCells.size() - 1) {
456 unsigned long size{0};
464 size +=
sizeof(
int) * cellsN.size();
471 if (mPValphaX.size()) {
476 mPValphaX.emplace_back(std::array<float, 2>{o2::gpu::CAMath::Hypot(pv.getX(), pv.getY()), math_utils::computePhi(pv.getX(), pv.getY())});
482 for (ushort iLayer = 0; iLayer < 2; ++iLayer) {
483 for (
unsigned int iRof{0}; iRof <
mNrof; ++iRof) {
485 mTotalTracklets[iLayer] += mNTrackletsPerROF[iLayer][iRof];
488 std::exclusive_scan(mNTrackletsPerROF[iLayer].begin(), mNTrackletsPerROF[iLayer].
end(), mNTrackletsPerROF[iLayer].begin(), 0);
495 for (uint32_t iLayer{0}; iLayer <
getTracklets().size(); ++iLayer) {
498 for (uint32_t iTracklet{0}; iTracklet <
getTracklets()[iLayer].size(); ++iTracklet) {
500 int currentId{trk.firstClusterIndex};
501 if (currentId < prev) {
502 std::cout <<
"First Cluster Index not increasing monotonically on L:T:ID:Prev " << iLayer <<
"\t" << iTracklet <<
"\t" << currentId <<
"\t" << prev << std::endl;
503 }
else if (currentId == prev) {
508 if (
count != lut[prev + 1] - lut[prev]) {
509 std::cout <<
"LUT count broken " << iLayer - 1 <<
"\t" << prev <<
"\t" <<
count <<
"\t" << lut[prev + 1] <<
"\t" << lut[prev] << std::endl;
517 if (iTracklet >= (uint32_t)(lut[currentId + 1]) || iTracklet < (uint32_t)(lut[currentId])) {
518 std::cout <<
"LUT broken: " << iLayer - 1 <<
"\t" << currentId <<
"\t" << iTracklet << std::endl;
527 mMinR.resize(nLayers, 10000.);
528 mMaxR.resize(nLayers, -1.);
536 mTrackletsIndexROF.resize(2, {0});
541 std::cout <<
"--------" << std::endl
542 <<
"Tracklet LUT " <<
i << std::endl;
544 std::cout <<
j <<
"\t";
546 std::cout <<
"\n--------" << std::endl
552 std::cout <<
"--------" << std::endl
553 <<
"Cell LUT " <<
i << std::endl;
555 std::cout <<
j <<
"\t";
557 std::cout <<
"\n--------" << std::endl
577 std::cout <<
"Vertices in ROF (nROF = " <<
mNrof <<
", lut size = " <<
mROFramesPV.size() <<
")" << std::endl;
578 for (
unsigned int iR{0}; iR <
mROFramesPV.size(); ++iR) {
581 std::cout <<
"\n\n Vertices:" << std::endl;
585 std::cout <<
"--------" << std::endl;
590 std::cout <<
"--------" << std::endl;
592 std::cout <<
"Layer " << iLayer << std::endl;
594 std::cout <<
value <<
"\t";
596 std::cout << std::endl;
602 std::cout <<
"--------" << std::endl;
604 std::cout <<
"Layer " << iLayer << std::endl;
606 std::cout <<
value <<
"\t";
608 std::cout << std::endl;
614 std::cout <<
"Dumping slice of " << sliceSize <<
" rofs:" << std::endl;
615 for (
int iROF{startROF}; iROF < startROF + sliceSize; ++iROF) {
616 std::cout <<
"ROF " << iROF <<
" dump:" << std::endl;
617 for (
unsigned int iLayer{0}; iLayer <
mClusters.size(); ++iLayer) {
618 std::cout <<
"Layer " << iLayer <<
" has: " <<
getClustersOnLayer(iROF, iLayer).size() <<
" clusters." << std::endl;
620 std::cout <<
"Number of seeding vertices: " <<
getPrimaryVertices(iROF).size() << std::endl;
623 std::cout <<
"\t vertex " << iVertex++ <<
": x=" <<
v.getX() <<
" " <<
" y=" <<
v.getY() <<
" z=" <<
v.getZ() <<
" has " <<
v.getNContributors() <<
" contributors." << std::endl;
Definition of the ITSMFT compact cluster.
Definition of the GeometryTGeo class.
Definition of the SegmentationAlpide class.
Class for time synchronization of RawReader instances.
const Mat3D & getMatrixL2G(int sensID) const
HMPID cluster implementation.
const Mat3D & getMatrixT2L(int lay, int hba, int sta, int det) const
int getLayer(int index) const
Get chip layer, from 0.
float getSensorRefAlpha(int isn) const
static GeometryTGeo * Instance()
void fillMatrixCache(int mask) override
void setTrackingParameters(const T ¶ms)
gsl::span< const Vertex > getPrimaryVertices(int rofId) const
std::vector< std::vector< int > > & getTrackletsLookupTable()
void resizeVectors(int nLayers)
std::vector< std::vector< int > > mCellsLookupTable
std::array< std::vector< int >, 2 > mNTrackletsPerClusterSum
void fillPrimaryVerticesXandAlpha()
std::vector< std::vector< int > > mROFramesClusters
void printTrackletLUTonLayer(int i)
IndexTableUtils mIndexTableUtils
unsigned long getArtefactsMemory()
std::vector< std::vector< TrackingFrameInfo > > mTrackingFrameInfo
void addPrimaryVerticesInROF(const std::vector< Vertex > &vertices, const int rofId, const int iteration)
std::vector< uint8_t > mMultiplicityCutMask
void initialise(const int iteration, const TrackingParameters &trkParam, const int maxLayers=7, bool resetVertices=true)
gsl::span< const Cluster > getUnsortedClustersOnLayer(int rofId, int layerId) const
std::vector< std::vector< unsigned char > > mUsedClusters
void addPrimaryVerticesLabels(std::vector< std::pair< MCCompLabel, float > > &labels)
void addTrackingFrameInfoToLayer(int layer, T &&... args)
std::vector< std::vector< TrackITSExt > > mTracks
std::vector< Vertex > mPrimaryVertices
void computeTrackletsPerROFScans()
std::vector< std::vector< Tracklet > > & getTracklets()
std::vector< std::vector< Cluster > > mUnsortedClusters
const dataformats::MCTruthContainer< MCCompLabel > * mClusterLabels
void checkTrackletLUTs()
Debug and printing.
std::vector< std::vector< int > > mClusterExternalIndices
std::vector< int > mROFramesPV
std::vector< std::vector< int > > mNClustersPerROF
std::vector< std::vector< int > > mCellsNeighbours
int loadROFrameData(const o2::itsmft::ROFRecord &rof, gsl::span< const itsmft::Cluster > clusters, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
std::vector< std::vector< Tracklet > > mTracklets
std::vector< std::vector< Cluster > > mClusters
gsl::span< Cluster > getClustersOnLayer(int rofId, int layerId)
void addPrimaryVerticesLabelsInROF(const std::vector< std::pair< MCCompLabel, float > > &labels, const int rofId)
std::vector< Road< 5 > > mRoads
std::vector< std::vector< int > > mIndexTables
void addClusterExternalIndexToLayer(int layer, const int idx)
void printCellLUTonLayer(int i)
std::vector< std::vector< int > > mTrackletsLookupTable
int getTotalClusters() const
void addPrimaryVertices(const std::vector< Vertex > &vertices)
std::vector< std::vector< CellSeed > > mCells
std::array< std::vector< int >, 2 > mNTrackletsPerCluster
void addClusterToLayer(int layer, T &&... args)
void insertPastVertex(const Vertex &vertex, const int refROFId)
void deepVectorClear(std::vector< T > &vec)
void printSliceInfo(const int, const int)
int getNPixels() const
Returns the number of fired pixels.
static constexpr unsigned short InvalidPatternID
gsl::span< const T > getROFData(const gsl::span< const T > tfdata) const
int getFirstEntry() const
static constexpr float PitchCol
static constexpr float PitchRow
math_utils::Point3D< T > getClusterCoordinates(const CompCluster &cl) const
float getErr2X(int n) const
Returns the error^2 on the x position of the COG for the n_th element.
int getNpixels(int n) const
Returns the number of fired pixels of the n_th element.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
float getErr2Z(int n) const
Returns the error^2 on the z position of the COG for the n_th element.
GLsizei const GLfloat * value
GLenum GLuint GLint GLint layer
GLubyte GLubyte GLubyte GLubyte w
GLdouble GLdouble GLdouble z
constexpr float DefClusError2Col
constexpr float DefClusError2Row
constexpr float DefClusErrorRow
constexpr float DefClusErrorCol
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
int TrackletsPerRoad() const
std::vector< float > LayerRadii
std::vector< float > SystErrorY2
std::vector< float > SystErrorZ2
float TrackletMinPt
Trackleting cuts.
std::vector< float > LayerResolution
std::vector< float > LayerxX0
std::vector< Cluster > clusters
std::vector< Cell > cells