Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITS3: Re-enable tracking workflow #10768

Merged
merged 10 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Detectors/ITSMFT/ITS/base/src/GeometryTGeo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,7 @@ int GeometryTGeo::extractNumberOfChipsPerModule(int lay, int& nrow) const
double dx = -1, dz = -1;

for (int j = 0; j < nNodes; j++) {
// AliInfo(Form("L%d %d of %d %s %s ->
// %d",lay,j,nNodes,volLd->GetNodes()->At(j)->GetName(),mIsLayerITS3[lay] ? getITS3ChipPattern() : getITSChipPattern(),numberOfChips));
LOGP(debug, "layer={}, node/nodes={}/{}, node name={}, pattern={}, number of chips={}, is ITS3 layer={}", lay, j, nNodes, volLd->GetNodes()->At(j)->GetName(), mIsLayerITS3[lay] ? getITS3ChipPattern() : getITSChipPattern(), numberOfChips, mIsLayerITS3[lay]);
TGeoNodeMatrix* node = (TGeoNodeMatrix*)volLd->GetNodes()->At(j);
if (!strstr(node->GetName(), mIsLayerITS3[lay] ? getITS3ChipPattern() : getITSChipPattern())) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,19 @@ class TimeFrame
std::vector<std::vector<TrackingFrameInfo>> mTrackingFrameInfo;
std::vector<std::vector<int>> mClusterExternalIndices;
std::vector<std::vector<int>> mROframesClusters;
const dataformats::MCTruthContainer<MCCompLabel>* mClusterLabels = nullptr;
std::array<std::vector<int>, 2> mNTrackletsPerCluster; // TODO: remove in favour of mNTrackletsPerROf
std::vector<std::vector<int>> mIndexTables;
std::vector<std::vector<int>> mTrackletsLookupTable;
std::vector<std::vector<unsigned char>> mUsedClusters;
int mNrof = 0;

private:
template <typename... T>
void addClusterToLayer(int layer, T&&... args);
template <typename... T>
void addTrackingFrameInfoToLayer(int layer, T&&... args);
void addClusterExternalIndexToLayer(int layer, const int idx);

private:
float mBz = 5.;
int mBeamPosWeight = 0;
float mBeamPos[2] = {0.f, 0.f};
Expand All @@ -230,7 +231,6 @@ class TimeFrame
std::vector<Vertex> mPrimaryVertices;
std::vector<std::array<float, 2>> mPValphaX; /// PV x and alpha for track propagation
std::vector<std::vector<Cluster>> mUnsortedClusters;
const dataformats::MCTruthContainer<MCCompLabel>* mClusterLabels = nullptr;
std::vector<std::vector<MCCompLabel>> mTrackletLabels;
std::vector<std::vector<MCCompLabel>> mCellLabels;
std::vector<std::vector<Cell>> mCells;
Expand All @@ -248,7 +248,7 @@ class TimeFrame
int mCutVertexMult;

// Vertexer
std::array<std::vector<int>, 2> mNTrackletsPerCluster; // TODO: remove in favour of mNTrackletsPerROf

std::vector<std::vector<int>> mNTrackletsPerROf;
std::vector<std::vector<Line>> mLines;
std::vector<std::vector<ClusterLines>> mTrackletClusters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ClassImp(o2::its3::SegmentationSuperAlpide);

void o2::its3::SegmentationSuperAlpide::print()
{
LOGP(info, "SegmentationSuperAlpide:");
LOGP(info, "Layer {}: Active/Total size {:.2f}/{:.2f} (rows) x {:.2f}/{:.2f}", mLayer, mActiveMatrixSizeRows, mSensorSizeRows, mActiveMatrixSizeCols, mSensorSizeCols);
LOGP(info, "Pixel size: {:.2f} (along {} rows) {:.2f} (along {} columns) microns", mPitchRow * 1e4, mNRows, mPitchCol * 1e4, mNCols);
LOGP(info, "Passive edges: bottom: {:.6f}, top: {:.6f}, left/right: {:.6f} microns", mPassiveEdgeReadOut * 1e4, mPassiveEdgeTop * 1e4, mPassiveEdgeSide * 1e4);
LOGP(debug, "SegmentationSuperAlpide:");
LOGP(debug, "Layer {}: Active/Total size {:.2f}/{:.2f} (rows) x {:.2f}/{:.2f}", mLayer, mActiveMatrixSizeRows, mSensorSizeRows, mActiveMatrixSizeCols, mSensorSizeCols);
LOGP(debug, "Pixel size: {:.2f} (along {} rows) {:.2f} (along {} columns) microns", mPitchRow * 1e4, mNRows, mPitchCol * 1e4, mNCols);
LOGP(debug, "Passive edges: bottom: {:.6f}, top: {:.6f}, left/right: {:.6f} microns", mPassiveEdgeReadOut * 1e4, mPassiveEdgeTop * 1e4, mPassiveEdgeSide * 1e4);
}
9 changes: 2 additions & 7 deletions Detectors/Upgrades/ITS3/macros/test/CheckClustersITS3.C
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,14 @@ void CheckClustersITS3(int nITS3layers = 3, std::string clusfile = "o2clus_it3.r
auto chipID = cluster.getSensorID();
if (pattID == o2::its3::CompCluster::InvalidPatternID || dict.isGroup(pattID)) {
o2::itsmft::ClusterPattern patt(pattIt);
locC = dict.getClusterCoordinates(chipID, cluster, patt, false);
locC = dict.getClusterCoordinates(cluster, patt, false);
} else {
locC = dict.getClusterCoordinates(chipID, cluster);
locC = dict.getClusterCoordinates(cluster);
errX = dict.getErrX(pattID);
errZ = dict.getErrZ(pattID);
npix = dict.getNpixels(pattID);
LOGP(info, "I am invalid and I am on chip {}", chipID);
}
if (chipID / nChipsPerLayer < nITS3layers) {
float xCurved{0.f}, yCurved{0.f};
segs[chipID].flatToCurved(locC.X(), locC.Y(), xCurved, yCurved);
locC.SetXYZ(xCurved, yCurved, locC.Z());
}

// Transformation to the local --> global
auto gloC = gman->getMatrixL2G(chipID)(locC);
Expand Down
2 changes: 2 additions & 0 deletions Detectors/Upgrades/ITS3/reconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ o2_add_library(ITS3Reconstruction
TARGETVARNAME targetName
SOURCES src/Clusterer.cxx
src/TopologyDictionary.cxx
src/IOUtils.cxx
# src/FastMultEst.cxx
PUBLIC_LINK_LIBRARIES O2::ITSMFTBase
O2::ITSMFTReconstruction
O2::ITS3Base
O2::ITStracking
O2::CommonDataFormat
O2::DetectorsRaw
O2::SimulationDataFormat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <gsl/gsl>
#include "SimulationDataFormat/MCTruthContainer.h"

namespace o2
{
namespace its
{
class TimeFrame;
}
namespace itsmft
{
class ROFRecord;
} // namespace itsmft

namespace dataformats
{
class MCCompLabel;
} // namespace dataformats
namespace its3
{
class TopologyDictionary;
class CompClusterExt;

namespace ioutils
{
int loadROFrameDataITS3(its::TimeFrame* tf,
gsl::span<o2::itsmft::ROFRecord> rofs,
gsl::span<const its3::CompClusterExt> clusters,
gsl::span<const unsigned char>::iterator& pattIt,
const its3::TopologyDictionary* dict,
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
}
} // namespace its3
} // namespace o2
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class TopologyDictionary : public itsmft::TopologyDictionary
TopologyDictionary(itsmft::TopologyDictionary top) : itsmft::TopologyDictionary{top} {}

/// Returns the local position of a compact cluster
math_utils::Point3D<float> getClusterCoordinates(int detID, const its3::CompCluster& cl) const;
math_utils::Point3D<float> getClusterCoordinates(const its3::CompClusterExt& cl) const;
/// Returns the local position of a compact cluster
static math_utils::Point3D<float> getClusterCoordinates(int detID, const its3::CompCluster& cl, const itsmft::ClusterPattern& patt, bool isGroup = true);
static math_utils::Point3D<float> getClusterCoordinates(const its3::CompClusterExt& cl, const itsmft::ClusterPattern& patt, bool isGroup = true);
};
} // namespace its3
} // namespace o2
Expand Down
91 changes: 91 additions & 0 deletions Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include <ITS3Reconstruction/IOUtils.h>
#include <ITStracking/IOUtils.h>
#include <ITStracking/TimeFrame.h>
#include <DataFormatsITS3/CompCluster.h>
#include <DataFormatsITSMFT/ROFRecord.h>
#include <ITS3Reconstruction/TopologyDictionary.h>
#include <ITSBase/GeometryTGeo.h>
#include <Framework/Logger.h>

namespace o2
{
namespace its3
{
namespace ioutils
{
int loadROFrameDataITS3(its::TimeFrame* tf,
gsl::span<o2::itsmft::ROFRecord> rofs,
gsl::span<const its3::CompClusterExt> clusters,
gsl::span<const unsigned char>::iterator& pattIt,
const its3::TopologyDictionary* dict,
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
{
its::GeometryTGeo* geom = its::GeometryTGeo::Instance();
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));

tf->mNrof = 0;
for (auto& rof : rofs) {
for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) {
auto& c = clusters[clusterId];

auto sensorID = c.getSensorID();
int layer = layer = geom->getLayer(sensorID);

auto pattID = c.getPatternID();
o2::math_utils::Point3D<float> locXYZ;
float sigmaY2 = o2::its::ioutils::DefClusError2Row, sigmaZ2 = o2::its::ioutils::DefClusError2Col, sigmaYZ = 0; // Dummy COG errors (about half pixel size)
if (pattID != itsmft::CompCluster::InvalidPatternID) {
sigmaY2 = dict->getErr2X(pattID);
sigmaZ2 = dict->getErr2Z(pattID);
if (!dict->isGroup(pattID)) {
locXYZ = dict->getClusterCoordinates(c);
} else {
o2::itsmft::ClusterPattern patt(pattIt);
locXYZ = dict->getClusterCoordinates(c, patt);
}
} else {
o2::itsmft::ClusterPattern patt(pattIt);
locXYZ = dict->getClusterCoordinates(c, patt, false);
}
// Inverse transformation to the local --> tracking
auto trkXYZ = geom->getMatrixT2L(sensorID) ^ locXYZ;
// Transformation to the local --> global
auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;

tf->addTrackingFrameInfoToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), trkXYZ.x(), geom->getSensorRefAlpha(sensorID),
std::array<float, 2>{trkXYZ.y(), trkXYZ.z()},
std::array<float, 3>{sigmaY2, sigmaYZ, sigmaZ2});

/// Rotate to the global frame
tf->addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), tf->getUnsortedClusters()[layer].size());
tf->addClusterExternalIndexToLayer(layer, clusterId);
}
for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) {
tf->mROframesClusters[iL].push_back(tf->getUnsortedClusters()[iL].size());
}
tf->mNrof++;
}

for (auto& v : tf->mNTrackletsPerCluster) {
v.resize(tf->getUnsortedClusters()[1].size());
}

if (mcLabels) {
tf->mClusterLabels = mcLabels;
}
return tf->mNrof;
}
} // namespace ioutils
} // namespace its3
} // namespace o2
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,34 @@
namespace o2::its3
{

math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID, const its3::CompCluster& cl) const
math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(const its3::CompClusterExt& cl) const
{

LOGP(debug, "Getting cluster coordinates from TopologyDictionaryITS3");
static SegmentationSuperAlpide segmentations[6]{SegmentationSuperAlpide(0),
SegmentationSuperAlpide(0),
SegmentationSuperAlpide(1),
SegmentationSuperAlpide(1),
SegmentationSuperAlpide(2),
SegmentationSuperAlpide(2)}; // TODO: fix NLayers
math_utils::Point3D<float> locCl;
if (detID >= 6) { // TODO: fix NLayers
if (cl.getSensorID() >= 6) { // TODO: fix NLayers
o2::itsmft::SegmentationAlpide::detectorToLocalUnchecked(cl.getRow(), cl.getCol(), locCl);
locCl.SetX(locCl.X() + this->getXCOG(cl.getPatternID()));
locCl.SetZ(locCl.Z() + this->getZCOG(cl.getPatternID()));
} else {
segmentations[detID].detectorToLocalUnchecked(cl.getRow(), cl.getCol(), locCl);
segmentations[cl.getSensorID()].detectorToLocalUnchecked(cl.getRow(), cl.getCol(), locCl);
locCl.SetX(locCl.X() + this->getXCOG(cl.getPatternID()));
locCl.SetZ(locCl.Z() + this->getZCOG(cl.getPatternID()));
float xCurved{0.f}, yCurved{0.f};
segmentations[cl.getSensorID()].flatToCurved(locCl.X(), locCl.Y(), xCurved, yCurved);
locCl.SetXYZ(xCurved, yCurved, locCl.Z());
}
locCl.SetX(locCl.X() + this->getXCOG(cl.getPatternID()));
locCl.SetZ(locCl.Z() + this->getZCOG(cl.getPatternID()));
return locCl;
}

math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID, const its3::CompCluster& cl, const itsmft::ClusterPattern& patt, bool isGroup)
math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(const its3::CompClusterExt& cl, const itsmft::ClusterPattern& patt, bool isGroup)
{
LOGP(debug, "Getting cluster coordinates from TopologyDictionaryITS3");
static SegmentationSuperAlpide segmentations[6]{SegmentationSuperAlpide(0),
SegmentationSuperAlpide(0),
SegmentationSuperAlpide(1),
Expand All @@ -56,10 +62,13 @@ math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates(int detID,
refCol -= round(zCOG);
}
math_utils::Point3D<float> locCl;
if (detID >= 6) { // TODO: fix NLayers
if (cl.getSensorID() >= 6) { // TODO: fix NLayers
o2::itsmft::SegmentationAlpide::detectorToLocalUnchecked(refRow + xCOG, refCol + zCOG, locCl);
} else {
segmentations[detID].detectorToLocalUnchecked(refRow + xCOG, refCol + zCOG, locCl);
segmentations[cl.getSensorID()].detectorToLocalUnchecked(refRow + xCOG, refCol + zCOG, locCl);
float xCurved{0.f}, yCurved{0.f};
segmentations[cl.getSensorID()].flatToCurved(locCl.X(), locCl.Y(), xCurved, yCurved);
locCl.SetXYZ(xCurved, yCurved, locCl.Z());
}
return locCl;
}
Expand Down
4 changes: 2 additions & 2 deletions Detectors/Upgrades/ITS3/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ o2_add_library(ITS3Workflow
src/ClusterWriterWorkflow.cxx
src/ClustererSpec.cxx
src/ClusterWriterSpec.cxx
# src/TrackerSpec.cxx
src/TrackerSpec.cxx
# src/CookedTrackerSpec.cxx
# src/TrackWriterSpec.cxx
src/TrackWriterSpec.cxx
# src/TrackReaderSpec.cxx
# src/VertexReaderSpec.cxx
PUBLIC_LINK_LIBRARIES O2::Framework
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file TrackWriterSpec.h

#ifndef O2_ITS3_TRACKWRITER
#define O2_ITS3_TRACKWRITER

#include "Framework/DataProcessorSpec.h"

namespace o2
{
namespace its3
{

/// create a processor spec
/// write ITS tracks to ROOT file
o2::framework::DataProcessorSpec getTrackWriterSpec(bool useMC);

} // namespace its3
} // namespace o2

#endif /* O2_ITS_TRACKWRITER */
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define O2_ITS3_TRACKERDPL

#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsITSMFT/TopologyDictionary.h"
#include "ITS3Reconstruction/TopologyDictionary.h"

#include "Framework/DataProcessorSpec.h"
#include "Framework/Task.h"
Expand Down Expand Up @@ -47,7 +47,7 @@ class TrackerDPL : public framework::Task
void run(framework::ProcessingContext& pc) final;
void endOfStream(framework::EndOfStreamContext& ec) final;
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
void setClusterDictionary(const o2::itsmft::TopologyDictionary* d) { mDict = d; }
void setClusterDictionary(const o2::itsmft::TopologyDictionary* d) { mDict = static_cast<const o2::its3::TopologyDictionary*>(d); }

private:
void updateTimeDependentParams(framework::ProcessingContext& pc);
Expand All @@ -58,7 +58,7 @@ class TrackerDPL : public framework::Task
int mUseTriggers = 0;
std::string mMode = "sync";
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
const o2::itsmft::TopologyDictionary* mDict = nullptr;
const o2::its3::TopologyDictionary* mDict = nullptr;
std::unique_ptr<o2::gpu::GPUReconstruction> mRecChain = nullptr;
std::unique_ptr<o2::gpu::GPUChainITS> mChainITS = nullptr;
std::unique_ptr<its::Tracker> mTracker = nullptr;
Expand Down
Loading