Skip to content

Commit 1d2e235

Browse files
bovulpesshahor02
authored andcommitted
MFT: do the standalone tracking using the compressed clusters
1 parent 153407a commit 1d2e235

12 files changed

Lines changed: 153 additions & 57 deletions

File tree

Detectors/ITSMFT/MFT/tracking/include/MFTTracking/IOUtils.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
#include <gsl/gsl>
2323

2424
#include "MFTTracking/ROframe.h"
25+
#include "ITSMFTBase/SegmentationAlpide.h"
2526
#include "DataFormatsITSMFT/ROFRecord.h"
27+
#include "DataFormatsITSMFT/CompCluster.h"
28+
#include "ReconstructionDataFormats/BaseCluster.h"
2629

2730
namespace o2
2831
{
@@ -38,17 +41,29 @@ class MCTruthContainer;
3841
namespace itsmft
3942
{
4043
class Cluster;
41-
}
44+
class CompClusterExt;
45+
class TopologyDictionary;
46+
} // namespace itsmft
4247

4348
namespace mft
4449
{
4550

4651
namespace ioutils
4752
{
53+
constexpr float DefClusErrorRow = o2::itsmft::SegmentationAlpide::PitchRow * 0.5;
54+
constexpr float DefClusErrorCol = o2::itsmft::SegmentationAlpide::PitchCol * 0.5;
55+
constexpr float DefClusError2Row = DefClusErrorRow * DefClusErrorRow;
56+
constexpr float DefClusError2Col = DefClusErrorCol * DefClusErrorCol;
57+
4858
Int_t loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, gsl::span<itsmft::Cluster const> const& clusters, const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
59+
60+
int loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& events, gsl::span<const itsmft::CompClusterExt> clusters,
61+
gsl::span<const unsigned char>::iterator& pattIt, const itsmft::TopologyDictionary& dict,
62+
const dataformats::MCTruthContainer<MCCompLabel>* mClsLabels = nullptr);
63+
4964
void loadEventData(ROframe& event, const std::vector<itsmft::Cluster>* clusters,
5065
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
51-
} // namespace IOUtils
66+
} // namespace ioutils
5267
} // namespace mft
5368
} // namespace o2
5469

Detectors/ITSMFT/MFT/tracking/include/MFTTracking/Tracker.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Tracker
3636
{
3737

3838
public:
39-
Tracker() = default;
39+
Tracker(bool useMC);
4040
~Tracker() = default;
4141

4242
Tracker(const Tracker&) = delete;
@@ -84,6 +84,8 @@ class Tracker
8484
o2::dataformats::MCTruthContainer<MCCompLabel> mTrackLabels;
8585

8686
Int_t mMaxCellLevel = 0;
87+
88+
bool mUseMC = false;
8789
};
8890

8991
inline std::vector<TrackMFT>& Tracker::getTracks()

Detectors/ITSMFT/MFT/tracking/src/IOUtils.cxx

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include <utility>
2323

2424
#include "MFTBase/GeometryTGeo.h"
25-
2625
#include "DataFormatsITSMFT/Cluster.h"
26+
#include "DataFormatsITSMFT/CompCluster.h"
27+
#include "DataFormatsITSMFT/TopologyDictionary.h"
2728
#include "MathUtils/Utils.h"
2829
#include "MathUtils/Cartesian2D.h"
2930
#include "SimulationDataFormat/MCCompLabel.h"
@@ -34,37 +35,89 @@ namespace o2
3435
namespace mft
3536
{
3637

37-
Int_t ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, gsl::span<itsmft::Cluster const> const& clusters,
38-
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
38+
int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, gsl::span<itsmft::Cluster const> const& clusters,
39+
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
3940
{
4041
event.clear();
4142
GeometryTGeo* geom = GeometryTGeo::Instance();
4243
geom->fillMatrixCache(utils::bit2Mask(TransformType::T2G));
43-
Int_t clusterId{0};
44+
int clusterId{0};
4445

4546
auto first = rof.getFirstEntry();
4647
auto number = rof.getNEntries();
4748
auto clusters_in_frame = gsl::make_span(&(clusters)[first], number);
4849
for (auto& c : clusters_in_frame) {
49-
Int_t layer = geom->getLayer(c.getSensorID());
50+
int layer = geom->getLayer(c.getSensorID());
5051

5152
/// Rotate to the global frame
5253
auto xyz = c.getXYZGlo(*geom);
5354
auto clsPoint2D = Point2D<Float_t>(xyz.x(), xyz.y());
5455
Float_t rCoord = clsPoint2D.R();
5556
Float_t phiCoord = clsPoint2D.Phi();
5657
o2::utils::BringTo02PiGen(phiCoord);
57-
Int_t rBinIndex = constants::index_table::getRBinIndex(rCoord);
58-
Int_t phiBinIndex = constants::index_table::getPhiBinIndex(phiCoord);
59-
Int_t binIndex = constants::index_table::getBinIndex(rBinIndex, phiBinIndex);
58+
int rBinIndex = constants::index_table::getRBinIndex(rCoord);
59+
int phiBinIndex = constants::index_table::getPhiBinIndex(phiCoord);
60+
int binIndex = constants::index_table::getBinIndex(rBinIndex, phiBinIndex);
6061
event.addClusterToLayer(layer, xyz.x(), xyz.y(), xyz.z(), phiCoord, rCoord, event.getClustersInLayer(layer).size(), binIndex);
61-
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));
62+
if (mcLabels) {
63+
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));
64+
}
6265
event.addClusterExternalIndexToLayer(layer, first + clusterId);
6366
clusterId++;
6467
}
6568
return number;
6669
}
6770

71+
int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, gsl::span<const itsmft::CompClusterExt> clusters, gsl::span<const unsigned char>::iterator& pattIt, const itsmft::TopologyDictionary& dict,
72+
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
73+
{
74+
event.clear();
75+
GeometryTGeo* geom = GeometryTGeo::Instance();
76+
geom->fillMatrixCache(utils::bit2Mask(TransformType::T2L, TransformType::L2G));
77+
int clusterId{0};
78+
auto first = rof.getFirstEntry();
79+
auto clusters_in_frame = rof.getROFData(clusters);
80+
for (auto& c : clusters_in_frame) {
81+
int layer = geom->getLayer(c.getSensorID());
82+
83+
auto pattID = c.getPatternID();
84+
Point3D<float> locXYZ;
85+
float sigmaY2 = ioutils::DefClusError2Row, sigmaZ2 = ioutils::DefClusError2Col, sigmaYZ = 0; //Dummy COG errors (about half pixel size)
86+
if (pattID != itsmft::CompCluster::InvalidPatternID) {
87+
sigmaY2 = dict.getErr2X(pattID);
88+
sigmaZ2 = dict.getErr2Z(pattID);
89+
if (!dict.isGroup(pattID)) {
90+
locXYZ = dict.getClusterCoordinates(c);
91+
} else {
92+
o2::itsmft::ClusterPattern patt(pattIt);
93+
locXYZ = dict.getClusterCoordinates(c, patt);
94+
}
95+
} else {
96+
o2::itsmft::ClusterPattern patt(pattIt);
97+
locXYZ = dict.getClusterCoordinates(c, patt);
98+
}
99+
auto sensorID = c.getSensorID();
100+
// Transformation to the local --> global
101+
auto gloXYZ = geom->getMatrixL2G(sensorID) * locXYZ;
102+
103+
auto clsPoint2D = Point2D<Float_t>(gloXYZ.x(), gloXYZ.y());
104+
Float_t rCoord = clsPoint2D.R();
105+
Float_t phiCoord = clsPoint2D.Phi();
106+
o2::utils::BringTo02PiGen(phiCoord);
107+
int rBinIndex = constants::index_table::getRBinIndex(rCoord);
108+
int phiBinIndex = constants::index_table::getPhiBinIndex(phiCoord);
109+
int binIndex = constants::index_table::getBinIndex(rBinIndex, phiBinIndex);
110+
111+
event.addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), phiCoord, rCoord, event.getClustersInLayer(layer).size(), binIndex);
112+
if (mcLabels) {
113+
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));
114+
}
115+
event.addClusterExternalIndexToLayer(layer, first + clusterId);
116+
clusterId++;
117+
}
118+
return clusters_in_frame.size();
119+
}
120+
68121
void ioutils::loadEventData(ROframe& event, const std::vector<itsmft::Cluster>* clusters,
69122
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels)
70123
{
@@ -75,15 +128,17 @@ void ioutils::loadEventData(ROframe& event, const std::vector<itsmft::Cluster>*
75128
event.clear();
76129
GeometryTGeo* geom = GeometryTGeo::Instance();
77130
geom->fillMatrixCache(utils::bit2Mask(TransformType::T2G));
78-
Int_t clusterId{0};
131+
int clusterId{0};
79132

80133
for (auto& c : *clusters) {
81-
Int_t layer = geom->getLayer(c.getSensorID());
134+
int layer = geom->getLayer(c.getSensorID());
82135

83136
/// Rotate to the global frame
84137
auto xyz = c.getXYZGlo(*geom);
85138
event.addClusterToLayer(layer, xyz.x(), xyz.y(), xyz.z(), event.getClustersInLayer(layer).size());
86-
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(clusterId).begin()));
139+
if (mcLabels) {
140+
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(clusterId).begin()));
141+
}
87142
event.addClusterExternalIndexToLayer(layer, clusterId);
88143
clusterId++;
89144
}

Detectors/ITSMFT/MFT/tracking/src/Tracker.cxx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace o2
2626
namespace mft
2727
{
2828

29+
Tracker::Tracker(bool useMC) : mUseMC{useMC} {}
30+
2931
void Tracker::clustersToTracks(ROframe& event, std::ostream& timeBenchmarkOutputStream)
3032
{
3133
mTracks.clear();
@@ -165,7 +167,7 @@ void Tracker::findTracksLTF(ROframe& event)
165167
event.addTrackLTF();
166168

167169
// add the first seed-point
168-
mcCompLabel = event.getClusterLabels(layer1, cluster1.clusterId);
170+
mcCompLabel = mUseMC ? event.getClusterLabels(layer1, cluster1.clusterId) : MCCompLabel();
169171
newPoint = kTRUE;
170172
event.getCurrentTrackLTF().setPoint(cluster1.xCoordinate, cluster1.yCoordinate, cluster1.zCoordinate, layer1, clsLayer1, mcCompLabel, newPoint);
171173

@@ -206,15 +208,15 @@ void Tracker::findTracksLTF(ROframe& event)
206208
dRmin = dR;
207209

208210
hasDisk[layer / 2] = kTRUE;
209-
mcCompLabel = event.getClusterLabels(layer, cluster.clusterId);
211+
mcCompLabel = mUseMC ? event.getClusterLabels(layer, cluster.clusterId) : MCCompLabel();
210212
event.getCurrentTrackLTF().setPoint(cluster.xCoordinate, cluster.yCoordinate, cluster.zCoordinate, layer, clsLayer, mcCompLabel, newPoint);
211213
} // end clusters bin intermediate layer
212214
} // end intermediate layers
213215
} // end binPhi
214216
} // end binR
215217

216218
// add the second seed-point
217-
mcCompLabel = event.getClusterLabels(layer2, cluster2.clusterId);
219+
mcCompLabel = mUseMC ? event.getClusterLabels(layer2, cluster2.clusterId) : MCCompLabel();
218220
newPoint = kTRUE;
219221
event.getCurrentTrackLTF().setPoint(cluster2.xCoordinate, cluster2.yCoordinate, cluster2.zCoordinate, layer2, clsLayer2, mcCompLabel, newPoint);
220222

@@ -326,7 +328,7 @@ void Tracker::findTracksCA(ROframe& event)
326328
event.addRoad();
327329

328330
// add the 1st/2nd road points
329-
mcCompLabel = event.getClusterLabels(layer1, cluster1.clusterId);
331+
mcCompLabel = mUseMC ? event.getClusterLabels(layer1, cluster1.clusterId) : MCCompLabel();
330332
newPoint = kTRUE;
331333
event.getCurrentRoad().setPoint(cluster1.xCoordinate, cluster1.yCoordinate, cluster1.zCoordinate, layer1, clsLayer1, mcCompLabel, newPoint);
332334

@@ -363,7 +365,7 @@ void Tracker::findTracksCA(ROframe& event)
363365
}
364366

365367
hasDisk[layer / 2] = kTRUE;
366-
mcCompLabel = event.getClusterLabels(layer, cluster.clusterId);
368+
mcCompLabel = mUseMC ? event.getClusterLabels(layer, cluster.clusterId) : MCCompLabel();
367369
newPoint = kTRUE;
368370
event.getCurrentRoad().setPoint(cluster.xCoordinate, cluster.yCoordinate, cluster.zCoordinate, layer, clsLayer, mcCompLabel, newPoint);
369371

@@ -373,7 +375,7 @@ void Tracker::findTracksCA(ROframe& event)
373375
} // end binR
374376

375377
// add the second seed-point
376-
mcCompLabel = event.getClusterLabels(layer2, cluster2.clusterId);
378+
mcCompLabel = mUseMC ? event.getClusterLabels(layer2, cluster2.clusterId) : MCCompLabel();
377379
newPoint = kTRUE;
378380
event.getCurrentRoad().setPoint(cluster2.xCoordinate, cluster2.yCoordinate, cluster2.zCoordinate, layer2, clsLayer2, mcCompLabel, newPoint);
379381

@@ -720,8 +722,8 @@ const Bool_t Tracker::addCellToCurrentTrackCA(const Int_t layer1, const Int_t ce
720722
}
721723
}
722724

723-
MCCompLabel mcCompLabel1 = event.getClusterLabels(layer1, cluster1.clusterId);
724-
MCCompLabel mcCompLabel2 = event.getClusterLabels(layer2, cluster2.clusterId);
725+
MCCompLabel mcCompLabel1 = mUseMC ? event.getClusterLabels(layer1, cluster1.clusterId) : MCCompLabel();
726+
MCCompLabel mcCompLabel2 = mUseMC ? event.getClusterLabels(layer2, cluster2.clusterId) : MCCompLabel();
725727

726728
Bool_t newPoint;
727729

Detectors/ITSMFT/MFT/workflow/include/MFTWorkflow/RecoWorkflow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace mft
2222

2323
namespace reco_workflow
2424
{
25-
framework::WorkflowSpec getWorkflow(bool useMC);
25+
framework::WorkflowSpec getWorkflow(bool useMC, bool upstreamDigits, bool upstreamClusters, bool disableRootOutput);
2626
}
2727

2828
} // namespace mft

Detectors/ITSMFT/MFT/workflow/include/MFTWorkflow/TrackerSpec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Framework/DataProcessorSpec.h"
1919
#include "Framework/Task.h"
2020
#include "DataFormatsParameters/GRPObject.h"
21+
#include "DataFormatsITSMFT/TopologyDictionary.h"
2122

2223
namespace o2
2324
{
@@ -33,8 +34,8 @@ class TrackerDPL : public o2::framework::Task
3334
void run(o2::framework::ProcessingContext& pc) final;
3435

3536
private:
36-
int mState = 0;
3737
bool mUseMC = false;
38+
o2::itsmft::TopologyDictionary mDict;
3839
std::unique_ptr<o2::parameters::GRPObject> mGRP = nullptr;
3940
std::unique_ptr<o2::mft::Tracker> mTracker = nullptr;
4041
};

Detectors/ITSMFT/MFT/workflow/src/ClustererSpec.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ void ClustererDPL::run(ProcessingContext& pc)
136136

137137
// TODO: in principle, after masking "overflow" pixels the MC2ROFRecord maxROF supposed to change, nominally to minROF
138138
// -> consider recalculationg maxROF
139-
LOG(INFO) << "MFTClusterer pushed " << clusCompVec.size() << " clusters, in " << clusROFVec.size() << " RO frames";
139+
LOG(INFO) << "MFTClusterer pushed " << clusCompVec.size() << " compressed clusters, in " << clusROFVec.size() << " RO frames";
140+
LOG(INFO) << "MFTClusterer pushed " << clusVec.size() << " full clusters, in " << clusROFVec.size() << " RO frames";
140141
}
141142

142143
DataProcessorSpec getClustererSpec(bool useMC)
@@ -146,9 +147,9 @@ DataProcessorSpec getClustererSpec(bool useMC)
146147
inputs.emplace_back("ROframes", "MFT", "DigitROF", 0, Lifetime::Timeframe);
147148

148149
std::vector<OutputSpec> outputs;
150+
outputs.emplace_back("MFT", "CLUSTERS", 0, Lifetime::Timeframe);
149151
outputs.emplace_back("MFT", "COMPCLUSTERS", 0, Lifetime::Timeframe);
150152
outputs.emplace_back("MFT", "PATTERNS", 0, Lifetime::Timeframe);
151-
outputs.emplace_back("MFT", "CLUSTERS", 0, Lifetime::Timeframe);
152153
outputs.emplace_back("MFT", "ClusterROF", 0, Lifetime::Timeframe);
153154

154155
if (useMC) {
@@ -166,7 +167,7 @@ DataProcessorSpec getClustererSpec(bool useMC)
166167
Options{
167168
{"mft-dictionary-path", VariantType::String, "", {"Path of the cluster-topology dictionary file"}},
168169
{"grp-file", VariantType::String, "o2sim_grp.root", {"Name of the grp file"}},
169-
{"full-clusters", o2::framework::VariantType::Bool, true, {"Produce full clusters"}}, // RSTODO temporary set to true
170+
{"full-clusters", o2::framework::VariantType::Bool, false, {"Produce full clusters"}}, // RSTODO temporary set to true
170171
{"no-patterns", o2::framework::VariantType::Bool, false, {"Do not save rare cluster patterns"}},
171172
{"nthreads", VariantType::Int, 0, {"Number of clustering threads (<1: rely on openMP default)"}}}};
172173
}

Detectors/ITSMFT/MFT/workflow/src/RecoWorkflow.cxx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,29 @@ namespace mft
2929
namespace reco_workflow
3030
{
3131

32-
framework::WorkflowSpec getWorkflow(bool useMC)
32+
framework::WorkflowSpec getWorkflow(bool useMC, bool upstreamDigits, bool upstreamClusters, bool disableRootOutput)
3333
{
3434
framework::WorkflowSpec specs;
3535

36-
specs.emplace_back(o2::mft::getDigitReaderSpec(useMC));
37-
specs.emplace_back(o2::mft::getClustererSpec(useMC));
38-
specs.emplace_back(o2::mft::getClusterWriterSpec(useMC));
39-
36+
if (!(upstreamDigits || upstreamClusters)) {
37+
specs.emplace_back(o2::mft::getDigitReaderSpec(useMC));
38+
}
39+
if (!upstreamClusters) {
40+
specs.emplace_back(o2::mft::getClustererSpec(useMC));
41+
}
42+
if (!disableRootOutput) {
43+
specs.emplace_back(o2::mft::getClusterWriterSpec(useMC));
44+
}
4045
specs.emplace_back(o2::mft::getTrackerSpec(useMC));
4146
specs.emplace_back(o2::mft::getTrackFitterSpec(useMC));
42-
specs.emplace_back(o2::mft::getTrackWriterSpec(useMC));
47+
if (!disableRootOutput) {
48+
specs.emplace_back(o2::mft::getTrackWriterSpec(useMC));
49+
}
4350

4451
return specs;
4552
}
4653

47-
} // namespace RecoWorkflow
54+
} // namespace reco_workflow
4855

4956
} // namespace mft
5057
} // namespace o2

Detectors/ITSMFT/MFT/workflow/src/TrackWriterSpec.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ DataProcessorSpec getTrackWriterSpec(bool useMC)
5757
"MFTTrackMCTruth",
5858
(useMC ? 1 : 0), // one branch if mc labels enabled
5959
""},
60-
BranchDefinition<std::vector<o2::itsmft::ROFRecord>>{InputSpec{"ROframes", "MFT", "MFTTrackROF", 0},
60+
BranchDefinition<std::vector<o2::itsmft::ROFRecord>>{InputSpec{"ROframes", "MFT", "TrackROF", 0},
6161
"MFTTracksROF",
6262
logger},
63-
BranchDefinition<std::vector<o2::itsmft::MC2ROFRecord>>{InputSpec{"MC2ROframes", "MFT", "MFTTrackMC2ROF", 0},
63+
BranchDefinition<std::vector<o2::itsmft::MC2ROFRecord>>{InputSpec{"MC2ROframes", "MFT", "TrackMC2ROF", 0},
6464
"MFTTracksMC2ROF",
6565
(useMC ? 1 : 0), // one branch if mc labels enabled
6666
""})();

0 commit comments

Comments
 (0)