1515
1616#include " ITStracking/IOUtils.h"
1717
18+ #include < gsl/span>
19+ #include < vector>
20+ #include < array>
21+ #include < string>
1822#include < iostream>
1923#include < cstdlib>
2024#include < fstream>
2125#include < sstream>
2226#include < tuple>
23- #include < unordered_set>
2427#include < utility>
2528
2629#include " ITSBase/GeometryTGeo.h"
@@ -35,10 +38,7 @@ constexpr int PrimaryVertexLayerId{-1};
3538constexpr int EventLabelsSeparator{-1 };
3639} // namespace
3740
38- namespace o2
39- {
40- namespace its
41- {
41+ using namespace o2 ::its;
4242
4343// / convert compact clusters to 3D spacepoints
4444void ioutils::convertCompactClusters (gsl::span<const itsmft::CompClusterExt> clusters,
@@ -57,8 +57,8 @@ void ioutils::convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clu
5757 }
5858 }
5959
60- for (auto & c : clusters) {
61- float sigmaY2, sigmaZ2, sigmaYZ = 0 ;
60+ for (const auto & c : clusters) {
61+ float sigmaY2{ 0 } , sigmaZ2{ 0 } , sigmaYZ{ 0 } ;
6262 auto locXYZ = extractClusterData (c, pattIt, dict, sigmaY2, sigmaZ2);
6363 auto & cl3d = output.emplace_back (c.getSensorID (), geom->getMatrixT2L (c.getSensorID ()) ^ locXYZ); // local --> tracking
6464 if (applyMisalignment) {
@@ -83,9 +83,9 @@ void ioutils::loadEventData(ROframe& event, gsl::span<const itsmft::CompClusterE
8383 geom->fillMatrixCache (o2::math_utils::bit2Mask (o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G));
8484 int clusterId{0 };
8585
86- for (auto & c : clusters) {
87- int layer = geom->getLayer (c.getSensorID ());
88- float sigmaY2, sigmaZ2, sigmaYZ = 0 ;
86+ for (const auto & c : clusters) {
87+ const int layer = geom->getLayer (c.getSensorID ());
88+ float sigmaY2{ 0 } , sigmaZ2{ 0 } , sigmaYZ{ 0 } ;
8989 auto locXYZ = extractClusterData (c, pattIt, dict, sigmaY2, sigmaZ2);
9090 auto sensorID = c.getSensorID ();
9191 // Inverse transformation to the local --> tracking
@@ -118,9 +118,9 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
118118
119119 auto first = rof.getFirstEntry ();
120120 auto clusters_in_frame = rof.getROFData (clusters);
121- for (auto & c : clusters_in_frame) {
122- int layer = geom->getLayer (c.getSensorID ());
123- float sigmaY2, sigmaZ2, sigmaYZ = 0 ;
121+ for (const auto & c : clusters_in_frame) {
122+ const int layer = geom->getLayer (c.getSensorID ());
123+ float sigmaY2{ 0 } , sigmaZ2{ 0 } , sigmaYZ{ 0 } ;
124124 auto locXYZ = extractClusterData (c, pattIt, dict, sigmaY2, sigmaZ2);
125125 auto sensorID = c.getSensorID ();
126126 // Inverse transformation to the local --> tracking
@@ -141,100 +141,5 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
141141 event.addClusterExternalIndexToLayer (layer, first + clusterId);
142142 clusterId++;
143143 }
144- return clusters_in_frame.size ();
144+ return ( int ) clusters_in_frame.size ();
145145}
146-
147- std::vector<std::unordered_map<int , Label>> ioutils::loadLabels (const int eventsNum, const std::string& fileName)
148- {
149- std::vector<std::unordered_map<int , Label>> labelsMap{};
150- std::unordered_map<int , Label> currentEventLabelsMap{};
151- std::ifstream inputStream{};
152- std::string line{};
153- int monteCarloId{}, pdgCode{}, numberOfClusters{};
154- float transverseMomentum{}, phi{}, pseudorapidity{};
155-
156- labelsMap.reserve (eventsNum);
157-
158- inputStream.open (fileName);
159- std::getline (inputStream, line);
160-
161- while (std::getline (inputStream, line)) {
162-
163- std::istringstream inputStringStream (line);
164-
165- if (inputStringStream >> monteCarloId) {
166-
167- if (monteCarloId == EventLabelsSeparator) {
168-
169- labelsMap.emplace_back (currentEventLabelsMap);
170- currentEventLabelsMap.clear ();
171-
172- } else {
173-
174- if (inputStringStream >> transverseMomentum >> phi >> pseudorapidity >> pdgCode >> numberOfClusters) {
175-
176- if (std::abs (pdgCode) == constants::pdgcodes::PionCode && numberOfClusters == 7 ) {
177-
178- currentEventLabelsMap.emplace (std::piecewise_construct, std::forward_as_tuple (monteCarloId),
179- std::forward_as_tuple (monteCarloId, transverseMomentum, phi,
180- pseudorapidity, pdgCode, numberOfClusters));
181- }
182- }
183- }
184- }
185- }
186-
187- labelsMap.emplace_back (currentEventLabelsMap);
188-
189- return labelsMap;
190- }
191-
192- // void ioutils::writeRoadsReport(std::ofstream& correctRoadsOutputStream, std::ofstream& duplicateRoadsOutputStream,
193- // std::ofstream& fakeRoadsOutputStream, const std::vector<std::vector<Road<5>>>& roads,
194- // const std::unordered_map<int, Label>& labelsMap)
195- // {
196- // const int numVertices{static_cast<int>(roads.size())};
197- // std::unordered_set<int> foundMonteCarloIds{};
198-
199- // correctRoadsOutputStream << EventLabelsSeparator << std::endl;
200- // fakeRoadsOutputStream << EventLabelsSeparator << std::endl;
201-
202- // for (int iVertex{0}; iVertex < numVertices; ++iVertex) {
203-
204- // const std::vector<Road<5>>& currentVertexRoads{roads[iVertex]};
205- // const int numRoads{static_cast<int>(currentVertexRoads.size())};
206-
207- // for (int iRoad{0}; iRoad < numRoads; ++iRoad) {
208-
209- // const Road<5>& currentRoad{currentVertexRoads[iRoad]};
210- // const int currentRoadLabel{currentRoad.getLabel()};
211-
212- // if (!labelsMap.count(currentRoadLabel)) {
213-
214- // continue;
215- // }
216-
217- // const Label& currentLabel{labelsMap.at(currentRoadLabel)};
218-
219- // if (currentRoad.isFakeRoad()) {
220-
221- // fakeRoadsOutputStream << currentLabel << std::endl;
222-
223- // } else {
224-
225- // if (foundMonteCarloIds.count(currentLabel.monteCarloId)) {
226-
227- // duplicateRoadsOutputStream << currentLabel << std::endl;
228-
229- // } else {
230-
231- // correctRoadsOutputStream << currentLabel << std::endl;
232- // foundMonteCarloIds.emplace(currentLabel.monteCarloId);
233- // }
234- // }
235- // }
236- // }
237- // }
238-
239- } // namespace its
240- } // namespace o2
0 commit comments