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
3435namespace 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+
68121void 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 }
0 commit comments