Project
Loading...
Searching...
No Matches
ClusterShape.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.
11
14
15#ifndef ALICEO2_ITSMFT_CLUSTERSHAPE_H_
16#define ALICEO2_ITSMFT_CLUSTERSHAPE_H_
17
19// //
20// Class to describe the cluster shape in the ITSU simulation //
21// Author: Davide Pagano //
23
24#include <TObject.h>
25#include <sstream>
26#include <vector>
27#include <algorithm>
28
29namespace o2
30{
31namespace itsmft
32{
33
34class ClusterShape : public TObject
35{
36
37 public:
39 ClusterShape(UInt_t, UInt_t);
40 ClusterShape(UInt_t, UInt_t, const std::vector<UInt_t>&);
41 ~ClusterShape() override;
42
43 // Set the number of rows
44 inline void SetNRows(UInt_t Nrows) { mNrows = Nrows; }
45
46 // Set the number of cols
47 inline void SetNCols(UInt_t Ncols) { mNcols = Ncols; }
48
49 // Add a pixel position to the shape [0, r*c[
50 inline void AddShapeValue(UInt_t pos) { mShape.push_back(pos); }
51
52 // Check whether the shape has the
53 Bool_t IsValidShape();
54
55 // Return an unique ID based on the cluster size and shape
56 Long64_t GetShapeID() const;
57
58 // Get the number of rows of the cluster
59 inline UInt_t GetNRows() const { return mNrows; }
60
61 inline void SetCenter(UInt_t r, UInt_t c)
62 {
63 mCenterR = r;
64 mCenterC = c;
65 }
66
67 // Get the center of rows of the cluster
68 inline UInt_t GetCenterR() const { return mCenterR; }
69
70 // Get the center of cols of the cluster
71 inline UInt_t GetCenterC() const { return mCenterC; }
72
73 // Get the index of the center (0-based)
74 inline UInt_t GetCenterIndex() const
75 {
76 return RowColToIndex(mCenterR, mCenterC);
77 }
78
79 // Get the number of cols of the cluster
80 inline UInt_t GetNCols() const { return mNcols; }
81
82 // Get the number of fired pixels of the cluster
83 inline UInt_t GetNFiredPixels() const { return mShape.size(); }
84
85 // Get the position of the pixel with the specified index
86 inline UInt_t GetValue(UInt_t index) const { return mShape[index]; }
87
88 // Get the shape of the cluster
89 inline void GetShape(std::vector<UInt_t>& v) const { v = mShape; }
90
91 // Check whether the cluster has the specified pixel on
92 Bool_t HasElement(UInt_t) const;
93
94 // Return a string with the positions of the fired pixels in the cluster
95 inline std::string ShapeSting() const
96 {
97 return ShapeSting(mShape);
98 }
99
100 // r and c are 0-based. The returned index is 0-based as well
101 inline UInt_t RowColToIndex(UInt_t r, UInt_t c) const
102 {
103 return r * mNcols + c;
104 }
105
106 // Static function to get a string with the positions of the fired pixels
107 // in the passed shape vector
108 static std::string ShapeSting(const std::vector<UInt_t>& shape)
109 {
110 std::stringstream out;
111 for (UInt_t i = 0; i < shape.size(); ++i) {
112 out << shape[i];
113 if (i < shape.size() - 1) {
114 out << " ";
115 }
116 }
117 return out.str();
118 }
119
120 friend std::ostream& operator<<(std::ostream& out, const ClusterShape& v)
121 {
122 UInt_t index = 0;
123 for (Int_t r = -1; r < (Int_t)v.mNrows; ++r) {
124 for (UInt_t c = 0; c < v.mNcols; ++c) {
125 if (r == -1) {
126 if (c == 0) {
127 out << " ";
128 }
129 out << c;
130 if (c < v.mNcols - 1) {
131 out << " ";
132 }
133 } else {
134 if (c == 0) {
135 out << r << " ";
136 }
137 index = r * v.mNcols + c;
138 if (std::find(begin(v.mShape), end(v.mShape), index) != end(v.mShape)) {
139 out << "X";
140 } else {
141 out << " ";
142 }
143 if (c < v.mNcols - 1) {
144 out << " ";
145 }
146 }
147 }
148 out << std::endl;
149 }
150 return out;
151 }
152
153 private:
154 UInt_t ComputeCenter(UInt_t);
155
156 UInt_t mNrows;
157 UInt_t mNcols;
158 UInt_t mCenterR;
159 UInt_t mCenterC;
160 std::vector<UInt_t> mShape;
161
162 ClassDefOverride(ClusterShape, 1);
163};
164} // namespace itsmft
165} // namespace o2
166#endif
int32_t i
uint16_t pos
Definition RawData.h:3
uint32_t c
Definition RawData.h:2
UInt_t RowColToIndex(UInt_t r, UInt_t c) const
UInt_t GetCenterIndex() const
UInt_t GetNFiredPixels() const
UInt_t GetValue(UInt_t index) const
friend std::ostream & operator<<(std::ostream &out, const ClusterShape &v)
UInt_t GetCenterR() const
void AddShapeValue(UInt_t pos)
UInt_t GetNCols() const
void GetShape(std::vector< UInt_t > &v) const
Bool_t HasElement(UInt_t) const
void SetNCols(UInt_t Ncols)
void SetCenter(UInt_t r, UInt_t c)
UInt_t GetCenterC() const
static std::string ShapeSting(const std::vector< UInt_t > &shape)
Long64_t GetShapeID() const
std::string ShapeSting() const
void SetNRows(UInt_t Nrows)
UInt_t GetNRows() const
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
GLuint index
Definition glcorearb.h:781
GLboolean r
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...