Project
Loading...
Searching...
No Matches
Digit.h
Go to the documentation of this file.
1// Copyright 2020-2022 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// History
18// 10/03/2021 Complete review
19// 05/11/2021 Add and review for the Cluster class
20
21#ifndef DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_
22#define DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_
23
24#include <iosfwd>
25#include <vector>
26#include "DataFormatsHMP/Hit.h" // for hit
27#include "HMPIDBase/Param.h" // for param
28
29namespace o2
30{
31namespace hmpid
32{
35class Digit
36{
37 public:
38 // Coordinates Conversion Functions
39 static inline uint32_t abs(int ch, int pc, int x, int y) { return ch << 24 | pc << 16 | x << 8 | y; }
40 static inline int ddl2C(int ddl) { return ddl >> 1; } // ddl -> chamber
41 static inline int a2C(uint32_t pad) { return (pad & 0xFF000000) >> 24; } // abs pad -> chamber
42 static inline int a2P(uint32_t pad) { return (pad & 0x00FF0000) >> 16; } // abs pad -> pc
43 static inline int a2X(uint32_t pad) { return (pad & 0x0000FF00) >> 8; } // abs pad -> pad X
44 static inline int a2Y(uint32_t pad) { return (pad & 0x000000FF); } // abs pad -> pad Y
45 static inline uint32_t photo2Pad(int ch, int pc, int x, int y) { return abs(ch, pc, x, y); }
46 static uint32_t equipment2Pad(int Equi, int Colu, int Dilo, int Chan);
47 static uint32_t absolute2Pad(int Module, int x, int y);
48 static void pad2Equipment(uint32_t pad, int* Equi, int* Colu, int* Dilo, int* Chan);
49 static void pad2Absolute(uint32_t pad, int* Module, int* x, int* y);
50 static void pad2Photo(uint32_t pad, uint8_t* chamber, uint8_t* photo, uint8_t* x, uint8_t* y);
51 static void absolute2Equipment(int Module, int x, int y, int* Equi, int* Colu, int* Dilo, int* Chan);
52 static void equipment2Absolute(int Equi, int Colu, int Dilo, int Chan, int* Module, int* x, int* y);
53
54 // Trigger time Conversion Functions
55 // static inline uint64_t orbitBcToEventId(uint32_t Orbit, uint16_t BC) { return ((Orbit << 12) | (0x0FFF & BC)); };
56 // static inline uint32_t eventIdToOrbit(uint64_t EventId) { return (EventId >> 12); };
57 // static inline uint16_t EventIdToBc(uint64_t EventId) { return (EventId & 0x0FFF); };
58 // static double OrbitBcToTimeNs(uint32_t Orbit, uint16_t BC);
59 // static uint32_t TimeNsToOrbit(double TimeNs);
60 // static uint16_t TimeNsToBc(double TimeNs);
61 // static void TimeNsToOrbitBc(double TimeNs, uint32_t& Orbit, uint16_t& Bc);
62
63 // Operators definition !
64 friend inline bool operator<(const Digit& l, const Digit& r) { return l.getPadID() < r.getPadID(); };
65 friend inline bool operator==(const Digit& l, const Digit& r) { return l.getPadID() == r.getPadID(); };
66 friend inline bool operator>(const Digit& l, const Digit& r) { return r < l; };
67 friend inline bool operator<=(const Digit& l, const Digit& r) { return !(l > r); };
68 friend inline bool operator>=(const Digit& l, const Digit& r) { return !(l < r); };
69 friend inline bool operator!=(const Digit& l, const Digit& r) { return !(l == r); };
70
71 friend std::ostream& operator<<(std::ostream& os, const Digit& d);
72
73 public:
74 Digit() = default;
75 Digit(int pad, uint16_t charge);
76 Digit(int chamber, int photo, int x, int y, uint16_t charge);
77 Digit(uint16_t charge, int equipment, int column, int dilogic, int channel);
78 Digit(uint16_t charge, int module, int x, int y);
79
80 // Getter & Setters
81 uint16_t getCharge() const { return mQ; }
82 void setCharge(uint16_t Q) { mQ = Q; };
83
84 int getPadID() const { return mCh << 24 | mPh << 16 | mX << 8 | mY; }
85 void setPadID(uint32_t pad)
86 {
87 mCh = pad >> 24;
88 mPh = (pad & 0x00FF0000) >> 16;
89 mX = (pad & 0x0000FF00) >> 8;
90 mY = (pad & 0x000000FF);
91 };
92
93 bool isValid() { return (mCh == 0xFF ? true : false); };
95 {
96 mCh = 0xFF;
97 return;
98 };
99
100 // // convenience wrapper function for conversion to x-y pad coordinates
101 // int getPx() const { return A2X(mPad); }
102 // int getPy() const { return A2Y(mPad); }
103 // int getPhC() const { return A2P(mPad); }
104 // int getCh() const { return A2C(mPad); }
105
106 // Charge management functions
107 static void getPadAndTotalCharge(o2::hmpid::HitType const& hit, int& chamber, int& pc, int& px, int& py, float& totalcharge);
108 static float getFractionalContributionForPad(o2::hmpid::HitType const& hit, int somepad);
109 void addCharge(float q)
110 {
111 mQ += q;
112 if (mQ > 0x0FFF) {
113 mQ = 0x0FFF;
114 }
115 }
116 void subCharge(float q) { mQ -= q; }
117
118 uint16_t getQ() const { return mQ; }
119 uint8_t getCh() const { return mCh; }
120 uint8_t getPh() const { return mPh; }
121 uint8_t getX() const { return mX; }
122 uint8_t getY() const { return mY; }
123
124 public:
125 // Members
126 uint16_t mQ = 0;
127 uint8_t mCh = 0; // 0xFF indicates invalid digit
128 uint8_t mPh = 0;
129 uint8_t mX = 0;
130 uint8_t mY = 0;
131
132 // The Pad Unique Id, code a pad inside one HMPID chamber.
133 // Bit Map : 0000.0000.cccc.pppp.xxxx.xxxx.yyyy.yyyy
134 // cccc := chamber [0..6]
135 // pppp := photo cathode [0..5]
136 // xxxx.xxxx := horizontal displacement [0..79]
137 // yyyy.yyyy := vertical displacement [0..47]
138 // uint32_t mPad = 0; // 0xFFFFFFFF indicates invalid digit
139
140 // Get the Geometric center of the pad
141 static float lorsX(int pad) { return Param::lorsX(a2P(pad), a2X(pad)); } // center of the pad x, [cm]
142 static float lorsY(int pad) { return Param::lorsY(a2P(pad), a2Y(pad)); } // center of the pad y, [cm]
143
144 // determines the total charge created by a hit
145 // might modify the localX, localY coordinates associated to the hit
146 static double qdcTot(double e, double time, int pc, int px, int py, double& localX, double& localY);
147 static double intPartMathiX(double x, int pad);
148 static double intPartMathiY(double y, int pad);
149 static double intMathieson(double localX, double localY, int pad);
150 static double mathiesonX(double x); // Mathieson distribution along wires X
151 static double mathiesonY(double x); // Mathieson distribution perp to wires Y
152
154};
155
156} // namespace hmpid
157} // namespace o2
158
159#endif /* DETECTORS_HMPID_BASE_INCLUDE_HMPIDDATAFORMAT_DIGIT_H_ */
int16_t charge
Definition RawEventData.h:5
int16_t time
Definition RawEventData.h:4
HMPID Digit declaration.
Definition Digit.h:36
void addCharge(float q)
Definition Digit.h:109
static uint32_t absolute2Pad(int Module, int x, int y)
Definition Digit.cxx:198
static int a2C(uint32_t pad)
Definition Digit.h:41
uint8_t mCh
Definition Digit.h:127
static void absolute2Equipment(int Module, int x, int y, int *Equi, int *Colu, int *Dilo, int *Chan)
Definition Digit.cxx:171
static int a2X(uint32_t pad)
Definition Digit.h:43
friend std::ostream & operator<<(std::ostream &os, const Digit &d)
Definition Digit.cxx:97
static double mathiesonY(double x)
Definition Digit.cxx:386
static int a2Y(uint32_t pad)
Definition Digit.h:44
void setPadID(uint32_t pad)
Definition Digit.h:85
uint16_t getQ() const
Definition Digit.h:118
uint8_t getCh() const
Definition Digit.h:119
friend bool operator==(const Digit &l, const Digit &r)
Definition Digit.h:65
uint8_t getX() const
Definition Digit.h:121
uint16_t getCharge() const
Definition Digit.h:81
uint8_t mX
Definition Digit.h:129
static void pad2Absolute(uint32_t pad, int *Module, int *x, int *y)
Definition Digit.cxx:211
static float lorsY(int pad)
Definition Digit.h:142
static int ddl2C(int ddl)
Definition Digit.h:40
static int a2P(uint32_t pad)
Definition Digit.h:42
uint8_t getPh() const
Definition Digit.h:120
static uint32_t photo2Pad(int ch, int pc, int x, int y)
Definition Digit.h:45
uint8_t mPh
Definition Digit.h:128
static double intPartMathiX(double x, int pad)
Definition Digit.cxx:326
static uint32_t equipment2Pad(int Equi, int Colu, int Dilo, int Chan)
Definition Digit.cxx:111
static void pad2Equipment(uint32_t pad, int *Equi, int *Colu, int *Dilo, int *Chan)
Definition Digit.cxx:141
void setInvalid()
Definition Digit.h:94
uint16_t mQ
Definition Digit.h:126
static void pad2Photo(uint32_t pad, uint8_t *chamber, uint8_t *photo, uint8_t *x, uint8_t *y)
Definition Digit.cxx:228
static double qdcTot(double e, double time, int pc, int px, int py, double &localX, double &localY)
Definition Digit.cxx:286
friend bool operator!=(const Digit &l, const Digit &r)
Definition Digit.h:69
friend bool operator<=(const Digit &l, const Digit &r)
Definition Digit.h:67
static float lorsX(int pad)
Definition Digit.h:141
static double intPartMathiY(double y, int pad)
Definition Digit.cxx:344
void setCharge(uint16_t Q)
Definition Digit.h:82
static double mathiesonX(double x)
Definition Digit.cxx:372
uint8_t getY() const
Definition Digit.h:122
static float getFractionalContributionForPad(o2::hmpid::HitType const &hit, int somepad)
Definition Digit.cxx:263
friend bool operator>=(const Digit &l, const Digit &r)
Definition Digit.h:68
uint8_t mY
Definition Digit.h:130
static double intMathieson(double localX, double localY, int pad)
Definition Digit.cxx:363
static void getPadAndTotalCharge(o2::hmpid::HitType const &hit, int &chamber, int &pc, int &px, int &py, float &totalcharge)
Definition Digit.cxx:245
bool isValid()
Definition Digit.h:93
int getPadID() const
Definition Digit.h:84
friend bool operator<(const Digit &l, const Digit &r)
Definition Digit.h:64
static uint32_t abs(int ch, int pc, int x, int y)
Definition Digit.h:39
void subCharge(float q)
Definition Digit.h:116
friend bool operator>(const Digit &l, const Digit &r)
Definition Digit.h:66
ClassDefNV(Digit, 2)
static void equipment2Absolute(int Equi, int Colu, int Dilo, int Chan, int *Module, int *x, int *y)
Definition Digit.cxx:186
static float lorsY(Int_t pc, Int_t pady)
Definition Param.h:88
static float lorsX(Int_t pc, Int_t padx)
Definition Param.h:86
GLint GLenum GLint x
Definition glcorearb.h:403
GLint y
Definition glcorearb.h:270
GLboolean r
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...