Project
Loading...
Searching...
No Matches
IOUtils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
15
16#ifndef TRACKINGITSU_INCLUDE_EVENTLOADER_H_
17#define TRACKINGITSU_INCLUDE_EVENTLOADER_H_
18
19#include <iosfwd>
20#include <string>
21#include <unordered_map>
22#include <vector>
23
26#include "ITStracking/ROframe.h"
27#include "ITStracking/Label.h"
28#include "ITStracking/Road.h"
35
36namespace o2
37{
38
39class MCCompLabel;
40
41namespace dataformats
42{
43template <typename T>
45}
46
47namespace its
48{
49
50namespace ioutils
51{
56
57void loadEventData(ROframe& events, gsl::span<const itsmft::CompClusterExt> clusters,
58 gsl::span<const unsigned char>::iterator& pattIt, const itsmft::TopologyDictionary* dict,
59 const dataformats::MCTruthContainer<MCCompLabel>* clsLabels = nullptr);
60int 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
64void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
65 gsl::span<const unsigned char>::iterator& pattIt,
66 std::vector<o2::BaseCluster<float>>& output,
67 const itsmft::TopologyDictionary* dict);
68
69inline static const o2::itsmft::ChipMappingITS& getChipMappingITS()
70{
71 static const o2::itsmft::ChipMappingITS MP;
72 return MP;
73}
74
75std::vector<std::unordered_map<int, Label>> loadLabels(const int, const std::string&);
76void writeRoadsReport(std::ofstream&, std::ofstream&, std::ofstream&, const std::vector<std::vector<Road<5>>>&,
77 const std::unordered_map<int, Label>&);
78
79template <class iterator, typename T>
81{
82 auto pattID = c.getPatternID();
84 sig2z = ioutils::DefClusError2Col; // Dummy COG errors (about half pixel size)
86 sig2y = dict->getErr2X(pattID);
87 sig2z = dict->getErr2Z(pattID);
88 if (!dict->isGroup(pattID)) {
89 return dict->getClusterCoordinates<T>(c);
90 } else {
92 return dict->getClusterCoordinates<T>(c, patt);
93 }
94 } else {
96 return dict->getClusterCoordinates<T>(c, patt, false);
97 }
98}
99
100// same method returning coordinates as an array (suitable for the TGeoMatrix)
101template <class iterator, typename T>
102std::array<T, 3> extractClusterDataA(const itsmft::CompClusterExt& c, iterator& iter, const itsmft::TopologyDictionary* dict, T& sig2y, T& sig2z)
103{
104 auto pattID = c.getPatternID();
106 sig2z = ioutils::DefClusError2Col; // Dummy COG errors (about half pixel size)
108 sig2y = dict->getErr2X(pattID);
109 sig2z = dict->getErr2Z(pattID);
110 if (!dict->isGroup(pattID)) {
111 return dict->getClusterCoordinatesA<T>(c);
112 } else {
114 return dict->getClusterCoordinatesA<T>(c, patt);
115 }
116 } else {
118 return dict->getClusterCoordinatesA<T>(c, patt, false);
119 }
120}
121
122} // namespace ioutils
123} // namespace its
124} // namespace o2
125
126#endif /* TRACKINGITSU_INCLUDE_EVENTLOADER_H_ */
Definition of the ITSMFT compact cluster.
Definition of the ClusterTopology class.
Definition of the ITSMFT ROFrame (trigger) record.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint32_t c
Definition RawData.h:2
Definition of the SegmentationAlpide class.
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
static constexpr float PitchCol
static constexpr float PitchRow
std::array< T, 3 > getClusterCoordinatesA(const CompCluster &cl) const
Returns the local position of a compact cluster.
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.
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.
std::array< T, 3 > extractClusterDataA(const itsmft::CompClusterExt &c, iterator &iter, const itsmft::TopologyDictionary *dict, T &sig2y, T &sig2z)
Definition IOUtils.h:102
void convertCompactClusters(gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, std::vector< o2::BaseCluster< float > > &output, const itsmft::TopologyDictionary *dict)
convert compact clusters to 3D spacepoints
Definition IOUtils.cxx:49
void writeRoadsReport(std::ofstream &, std::ofstream &, std::ofstream &, const std::vector< std::vector< Road< 5 > > > &, const std::unordered_map< int, Label > &)
o2::math_utils::Point3D< T > extractClusterData(const itsmft::CompClusterExt &c, iterator &iter, const itsmft::TopologyDictionary *dict, T &sig2y, T &sig2z)
Definition IOUtils.h:80
constexpr float DefClusErrorCol
Definition IOUtils.h:53
void loadEventData(ROframe &events, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const itsmft::TopologyDictionary *dict, const dataformats::MCTruthContainer< MCCompLabel > *clsLabels=nullptr)
Definition IOUtils.cxx:78
constexpr float DefClusErrorRow
Definition IOUtils.h:52
constexpr float DefClusError2Col
Definition IOUtils.h:55
constexpr float DefClusError2Row
Definition IOUtils.h:54
int loadROFrameData(const o2::itsmft::ROFRecord &rof, ROframe &events, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const itsmft::TopologyDictionary *dict, const dataformats::MCTruthContainer< MCCompLabel > *mClsLabels=nullptr)
Definition IOUtils.cxx:116
std::vector< std::unordered_map< int, Label > > loadLabels(const int, const std::string &)
Definition IOUtils.cxx:152
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< Cluster > clusters