Project
Loading...
Searching...
No Matches
PadOriginal.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_PADORIGINAL_H_
18#define O2_MCH_PADORIGINAL_H_
19
20#include <algorithm>
21#include <stdexcept>
22#include <vector>
23
24#include <TMath.h>
25
26namespace o2
27{
28namespace mch
29{
30
33{
34 public:
35 enum padStatus {
36 kZero = 0x0,
37 kUseForFit = 0x1,
38 kCoupled = 0x10,
39 kOver = 0x100,
40 kMustKeep = 0x1000
41 };
42
43 PadOriginal() = delete;
44 PadOriginal(double x, double y, double dx, double dy, double charge,
45 bool isSaturated = false, int plane = -1, int digitIdx = -1, int status = kZero)
46 : mx(x), my(y), mdx(dx), mdy(dy), mCharge(charge), mIsSaturated(isSaturated), mPlane(plane), mDigitIdx(digitIdx), mStatus(status) {}
47 ~PadOriginal() = default;
48
49 PadOriginal(const PadOriginal& cl) = default;
50 PadOriginal& operator=(const PadOriginal& cl) = default;
53
55 void setx(double x) { mx = x; }
57 void sety(double y) { my = y; }
59 double x() const { return mx; }
61 double y() const { return my; }
63 double xy(int ixy) const { return (ixy == 0) ? mx : my; }
64
66 void setdx(double dx) { mdx = dx; }
68 void setdy(double dy) { mdy = dy; }
70 double dx() const { return mdx; }
72 double dy() const { return mdy; }
74 double dxy(int ixy) const { return (ixy == 0) ? mdx : mdy; }
75
77 void setCharge(double charge) { mCharge = charge; }
79 double charge() const { return mCharge; }
80
82 int plane() const { return mPlane; }
83
85 int digitIndex() const { return mDigitIdx; }
87 bool isReal() const { return mDigitIdx >= 0; }
88
90 void setStatus(int status) { mStatus = status; }
92 int status() const { return mStatus; }
93
95 bool isSaturated() const { return mIsSaturated; }
96
97 private:
98 double mx = 0.;
99 double my = 0.;
100 double mdx = 0.;
101 double mdy = 0.;
102 double mCharge = 0.;
103 bool mIsSaturated = false;
104 int mPlane = -1;
105 int mDigitIdx = -1;
106 int mStatus = kZero;
107};
108
109//_________________________________________________________________________________________________
110inline auto findPad(std::vector<PadOriginal>& pads, double x, double y, double minCharge)
111{
114
115 auto match = [x, y, minCharge](const PadOriginal& pad) {
116 return pad.charge() >= minCharge && TMath::Abs(pad.x() - x) < 1.e-3 && TMath::Abs(pad.y() - y) < 1.e-3;
117 };
118
119 auto itPad = std::find_if(pads.begin(), pads.end(), match);
120
121 if (itPad == pads.end()) {
122 throw std::runtime_error("Pad not found");
123 }
124
125 return itPad;
126}
127
128//_____________________________________________________________________________
129inline bool areOverlapping(const PadOriginal& pad1, const PadOriginal& pad2, double precision)
130{
134
135 if (pad1.x() - pad1.dx() > pad2.x() + pad2.dx() - precision ||
136 pad1.x() + pad1.dx() < pad2.x() - pad2.dx() + precision ||
137 pad1.y() - pad1.dy() > pad2.y() + pad2.dy() - precision ||
138 pad1.y() + pad1.dy() < pad2.y() - pad2.dy() + precision) {
139 return false;
140 }
141
142 return true;
143}
144
145} // namespace mch
146} // namespace o2
147
148#endif // O2_MCH_PADORIGINAL_H_
uint32_t pad2
uint32_t pad1
pad for internal use
Definition PadOriginal.h:33
void setx(double x)
set position in x (cm)
Definition PadOriginal.h:55
void setdx(double dx)
set half dimension in x (cm)
Definition PadOriginal.h:66
PadOriginal(PadOriginal &&)=default
double x() const
return position in x (cm)
Definition PadOriginal.h:59
void setdy(double dy)
set half dimension in y (cm)
Definition PadOriginal.h:68
double dy() const
return half dimension in y (cm)
Definition PadOriginal.h:72
void setCharge(double charge)
set the charge
Definition PadOriginal.h:77
@ kUseForFit
should be used for fit
Definition PadOriginal.h:37
@ kOver
processing is over
Definition PadOriginal.h:39
@ kMustKeep
do not kill (for pixels)
Definition PadOriginal.h:40
@ kCoupled
coupled to another cluster of pixels
Definition PadOriginal.h:38
@ kZero
pad "basic" state
Definition PadOriginal.h:36
int digitIndex() const
return the index of the corresponding digit
Definition PadOriginal.h:85
double dxy(int ixy) const
return half dimension in x or y (cm)
Definition PadOriginal.h:74
bool isSaturated() const
return whether this pad is saturated or not
Definition PadOriginal.h:95
bool isReal() const
return whether this is a real pad or a virtual pad
Definition PadOriginal.h:87
int status() const
return the status word
Definition PadOriginal.h:92
double xy(int ixy) const
return position in x or y (cm)
Definition PadOriginal.h:63
int plane() const
return 0 if bending pad, 1 if non-bending pad or -1 if none (e.g. pixel)
Definition PadOriginal.h:82
void sety(double y)
set position in y (cm)
Definition PadOriginal.h:57
PadOriginal & operator=(const PadOriginal &cl)=default
double dx() const
return half dimension in x (cm)
Definition PadOriginal.h:70
double charge() const
return the charge
Definition PadOriginal.h:79
void setStatus(int status)
set the status word
Definition PadOriginal.h:90
PadOriginal & operator=(PadOriginal &&)=default
PadOriginal(double x, double y, double dx, double dy, double charge, bool isSaturated=false, int plane=-1, int digitIdx=-1, int status=kZero)
Definition PadOriginal.h:44
PadOriginal(const PadOriginal &cl)=default
double y() const
return position in y (cm)
Definition PadOriginal.h:61
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
GLint GLenum GLint x
Definition glcorearb.h:403
GLint y
Definition glcorearb.h:270
GLenum GLint GLint * precision
Definition glcorearb.h:1899
bool areOverlapping(const PadOriginal &pad1, const PadOriginal &pad2, double precision)
auto findPad(std::vector< PadOriginal > &pads, double x, double y, double minCharge)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...