Project
Loading...
Searching...
No Matches
PadsPEM.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
16
17#ifndef O2_MCH_PADSPEM_H_
18#define O2_MCH_PADSPEM_H_
19
20#include <vector>
21
23
24namespace o2
25{
26namespace mch
27{
28// Neigbours
29static const int MaxNeighbors =
30 25 + 13; // 5*5 neigbours + the center pad itself + separator (-1)
31 // 5x5 neighbours + 50 %
32template <class T>
33inline static T getNeighborListOf(T neigh, PadIdx_t i)
34{
35 return &neigh[MaxNeighbors * i];
36};
37
38inline static PadIdx_t* getTheFirtsNeighborOf(PadIdx_t* neigh, PadIdx_t i)
39{
40 return &neigh[MaxNeighbors * i];
41};
42inline static PadIdx_t getTheFirstNeighborOf(PadIdx_t* neigh, PadIdx_t i)
43{
44 return neigh[MaxNeighbors * i];
45};
46
47class Pads
48{
49 public:
50 enum class PadMode {
53 };
54 static constexpr double epsilonGeometry =
55 1.0e-04; // Uncertainty on pad location (in cm)
56 // Representation mode (see padMode)
57 // PadMode mode;
59
60 // Utilities
61 static void printNeighbors(const PadIdx_t* neigh, int N);
62 static void printPads(const char* title, const Pads& pads);
63 static inline int getNbrOfPads(const Pads* pads)
64 {
65 return (pads == nullptr) ? 0 : pads->nPads;
66 };
67
68 // Allocation constructor
69 Pads(int N, int chId, PadMode mode = PadMode::xydxdyMode);
70 // Build a new set of pads with different coordinates
71 // xydxdy mode or xyInfSup
72 Pads(const Pads& pads, PadMode mode_);
73 // Pad object with over allocated pads
74 Pads(const Pads* pads, int size);
75 // Build a pads set from those selected by "mask"
76 // Used to extract sub-clusters
77 Pads(const Pads& pads, const Groups_t* mask);
78 // Concatenate the 2 pads sets
79 Pads(const Pads* pads0, const Pads* pads1, PadMode mode);
80 // Main constructor
81 Pads(const double* x_, const double* y_, const double* dx_, const double* dy_,
82 const double* q_, const short* cathode, const Mask_t* saturate_,
83 short cathID, int chId, PadIdx_t* mapCathPadIdxToPadIdx, int nAllPads);
84 Pads(const double* x_, const double* y_, const double* dx_,
85 const double* dy_, const double* q_, const short* cathode,
86 const Mask_t* saturate_, int chId, int nAllPads);
87 // Take the ownership of coordinates (x, y, dx, dy)
88 Pads(double* x_, double* y_, double* dx_, double* dy_, int chId, int nPads_);
89 inline int getNbrOfPads() const { return nPads; };
90 inline int getNbrOfObsPads() const { return nObsPads; };
91 inline const double* getX() const { return x; };
92 inline const double* getY() const { return y; };
93 inline const double* getDX() const { return dx; };
94 inline const double* getDY() const { return dy; };
95 inline const double* getXInf() const { return x; };
96 inline const double* getYInf() const { return y; };
97 inline const double* getXSup() const { return dx; };
98 inline const double* getYSup() const { return dy; };
99 inline const double* getCharges() const { return q; };
100 inline const Mask_t* getSaturates() const { return saturate; };
101 inline const Mask_t* getCathodes() const { return cath; };
102 inline double getTotalCharge() const { return totalCharge; };
103 double updateTotalCharge();
104 // Mean of the 2 cathodes total Charge
105 double getMeanTotalCharge();
106 inline int getChamberId() const { return chamberId; };
107 void setCharges(double c);
108 void setCharges(double* q_, int n);
109 void setCathodes(Mask_t cath_);
110 void setSaturate(Mask_t val);
111 // Select/keep pads in the list index
112 Pads* selectPads(int* index, int k);
113 // Remove pads whos charge is less than qCut
114 int removePads(double qCut);
115 // pad coordinates transformations
116 // xydxyMode <-> xyInfSupMode
117 void padBoundsToCenter(const Pads& pads);
118 void padCenterToBounds(const Pads& pads);
119 void padBoundsToCenter();
120 void padCenterToBounds();
121 // Charges normalization
122 void normalizeCharges();
123 // Split each pads in 4 smaller pads with the same sizes
124 Pads* refineAll();
125 // refine only at the local max
126 void refineLocalMax(Pads& localMax, std::vector<PadIdx_t>& localMaxIdx);
127 // refine only at the local max
128 void refineLocalMaxAndUpdateCij(const Pads& pads,
129 std::vector<PadIdx_t>& localMaxIdx, double Cij[]);
130 // Add zero-charged pads to the neighboring of the pads (cathode cluster)
132 // Getting/Building Neighbors
133 // Should be a const PadIdx_t*
135 // Building K-Neighbors
136 PadIdx_t* buildKFirstsNeighbors(int kernelSize);
137 // Extract local maximima
138 Pads* extractLocalMax(std::vector<PadIdx_t>& localMaxIdx, double dxMinPadSize, double dyMinPadSize);
139 Pads* extractLocalMaxOnCoarsePads(std::vector<PadIdx_t>& localMaxIdx);
140
141 Pads* extractLocalMaxOnCoarsePads_Remanent(std::vector<PadIdx_t>& localMaxIdx, double dxMinPadSize, double dyMinPadSize);
142 // Extract local maximima, with of without a neighboring
143 // Obsolete
145 // Groups
146 int addIsolatedPadInGroups(Mask_t* cathToGrp, Mask_t* grpToGrp, int nGroups);
147 //
148 // inv void print(const char* title);
149 ~Pads();
150
151 private:
152 // Mode xydxdy
153 double* x = nullptr;
154 double* y = nullptr;
155 double* dx = nullptr;
156 double* dy = nullptr;
157 // Mode xyInfSupMode
158 // xInf = x, xSup = dx
159 // yInf = y, ySup = dx
160 Mask_t* cath = nullptr;
161 Mask_t* saturate = nullptr;
162 double* q = nullptr;
163 double totalCharge = 0;
164 int nPads = 0;
165 // n Observable/ measurable pads
166 // Used to speed-up the fitting
167 int nObsPads = 0;
168 int chamberId = -1;
169 PadIdx_t* neighbors = nullptr;
170 //
171 // Memory allocation/deallocation
172 void allocate();
173 void allocate(int size);
174 void release();
175 void copyPads(const Pads* srcPads, int srcIdx, int destIdx, int N, Mask_t cathValue);
176 // Utilities
177 void removePad(int index);
178 PadIdx_t* buildFirstNeighbors(double* X, double* Y, double* DX, double* DY,
179 int N);
180 // Assess or not if xyCheck is a remanent local Max (can be removed)
181 bool assessRemanent(double xyCheck, double* xy, double precision, int N);
182 void setToZero();
183};
184
185} // namespace mch
186} // namespace o2
187
188#endif // ALICEO2_MCH_PADSPEM_H_
Clustering and fifting parameters.
int32_t i
uint32_t c
Definition RawData.h:2
const double * getX() const
Definition PadsPEM.h:91
double getMeanTotalCharge()
Definition PadsPEM.cxx:764
static void printNeighbors(const PadIdx_t *neigh, int N)
Definition PadsPEM.cxx:2237
const Mask_t * getCathodes() const
Definition PadsPEM.h:101
const double * getXSup() const
Definition PadsPEM.h:97
int getChamberId() const
Definition PadsPEM.h:106
void refineLocalMaxAndUpdateCij(const Pads &pads, std::vector< PadIdx_t > &localMaxIdx, double Cij[])
Definition PadsPEM.cxx:965
@ xydxdyMode
x, y, dx, dy pad coordinates
@ xyInfSupMode
xInf=x, xSup=dx, yInf=y, ySup=dy pad coordinates
void setCathodes(Mask_t cath_)
Definition PadsPEM.cxx:790
Pads * extractLocalMax(std::vector< PadIdx_t > &localMaxIdx, double dxMinPadSize, double dyMinPadSize)
Definition PadsPEM.cxx:1742
static int getNbrOfPads(const Pads *pads)
Definition PadsPEM.h:63
void setSaturate(Mask_t val)
Definition PadsPEM.cxx:792
Pads * refineAll()
Definition PadsPEM.cxx:1170
const double * getDY() const
Definition PadsPEM.h:94
void setCharges(double c)
Definition PadsPEM.cxx:778
int addIsolatedPadInGroups(Mask_t *cathToGrp, Mask_t *grpToGrp, int nGroups)
Definition PadsPEM.cxx:847
const double * getCharges() const
Definition PadsPEM.h:99
int getNbrOfPads() const
Definition PadsPEM.h:89
Pads * selectPads(int *index, int k)
Definition PadsPEM.cxx:658
Pads * extractLocalMaxOnCoarsePads(std::vector< PadIdx_t > &localMaxIdx)
Definition PadsPEM.cxx:1235
void refineLocalMax(Pads &localMax, std::vector< PadIdx_t > &localMaxIdx)
Definition PadsPEM.cxx:1081
const double * getYInf() const
Definition PadsPEM.h:96
const double * getY() const
Definition PadsPEM.h:92
int getNbrOfObsPads() const
Definition PadsPEM.h:90
Pads * addBoundaryPads()
Definition PadsPEM.cxx:193
Pads * extractLocalMaxOnCoarsePads_Remanent(std::vector< PadIdx_t > &localMaxIdx, double dxMinPadSize, double dyMinPadSize)
Definition PadsPEM.cxx:1449
const double * getXInf() const
Definition PadsPEM.h:95
void normalizeCharges()
Definition PadsPEM.cxx:830
void padCenterToBounds()
Definition PadsPEM.cxx:69
PadIdx_t * getFirstNeighbors()
Definition PadsPEM.cxx:838
const Mask_t * getSaturates() const
Definition PadsPEM.h:100
PadIdx_t * buildKFirstsNeighbors(int kernelSize)
Definition PadsPEM.cxx:139
double getTotalCharge() const
Definition PadsPEM.h:102
void padBoundsToCenter()
Definition PadsPEM.cxx:89
Pads * clipOnLocalMax(bool extractLocalMax)
Definition PadsPEM.cxx:2070
double updateTotalCharge()
Definition PadsPEM.cxx:758
static constexpr double epsilonGeometry
Definition PadsPEM.h:54
int removePads(double qCut)
Definition PadsPEM.cxx:805
const double * getYSup() const
Definition PadsPEM.h:98
static void printPads(const char *title, const Pads &pads)
Definition PadsPEM.cxx:2251
const double * getDX() const
Definition PadsPEM.h:93
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum mode
Definition glcorearb.h:266
GLsizeiptr size
Definition glcorearb.h:659
GLuint index
Definition glcorearb.h:781
GLuint GLfloat * val
Definition glcorearb.h:1582
GLint GLuint mask
Definition glcorearb.h:291
GLenum GLint GLint * precision
Definition glcorearb.h:1899
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...