CbmRoot
Loading...
Searching...
No Matches
HitFactory2D.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer], Alexandru Bercuci */
4
5#pragma once
6
7#include "compat/RTypes.h"
8
9#include <cstdint>
10#include <vector>
11
12#define NBINSCORRX 50
13#define NBINSCORRY 4
14
15using std::vector;
16
17namespace cbm::algo::trd
18{
19
20 // working representation of a hit on which the reconstruction is performed
22
23 public:
24 struct signal {
25 double s;
26 double se;
27 char t;
28 double x;
29 double xe;
30 signal(double _s, double _se, char _t, double _x, double _xe) : s(_s), se(_se), t(_t), x(_x), xe(_xe) {}
31 signal() : s(0), se(0), t(0), x(0), xe(0) {}
32 };
33
34 std::vector<signal> fSignal;
35 int nCols;
36
37 uint64_t vt0 = 0;
38 uint8_t vcM = 0;
39 uint8_t vrM = 0;
40 uint8_t viM = 0;
41 uint16_t vyM = 0;
42
43 HitFactory2D(int ncols) : nCols(ncols), vt0(0), vcM(0), vrM(0), viM(0), vyM(0) {}
44
45 void reset()
46 {
47 fSignal.clear();
48 vt0 = 0;
49 vcM = 0;
50 vrM = 0;
51 viM = 0;
52 vyM = 0;
53 }
54
55 bool HasLeftSgn() const { return TESTBIT(vyM, 3); }
56 bool HasOvf() const { return TESTBIT(vyM, 12); }
57 bool IsBiasX() const { return TESTBIT(vyM, 4); }
58 bool IsBiasXleft() const { return TESTBIT(vyM, 5); }
59 bool IsBiasXmid() const { return TESTBIT(vyM, 6); }
60 bool IsBiasXright() const { return TESTBIT(vyM, 7); }
61 bool IsBiasY() const { return TESTBIT(vyM, 8); }
62 bool IsBiasYleft() const { return TESTBIT(vyM, 9); }
63 bool IsLeftHit() const { return TESTBIT(vyM, 2); }
64 bool IsMaxTilt() const { return TESTBIT(vyM, 0); }
65 bool IsOpenLeft() const { return (viM % 2 && !IsMaxTilt()) || (!(viM % 2) && IsMaxTilt()); }
66 inline bool IsOpenRight() const;
67 bool IsSymmHit() const { return TESTBIT(vyM, 1); }
68 void SetBiasX(bool set = 1) { set ? SETBIT(vyM, 4) : CLRBIT(vyM, 4); }
69 void SetBiasXleft(bool set = 1) { set ? SETBIT(vyM, 5) : CLRBIT(vyM, 5); }
70 void SetBiasXmid(bool set = 1) { set ? SETBIT(vyM, 6) : CLRBIT(vyM, 6); }
71 void SetBiasXright(bool set = 1) { set ? SETBIT(vyM, 7) : CLRBIT(vyM, 7); }
72 void SetBiasY(bool set = 1) { set ? SETBIT(vyM, 8) : CLRBIT(vyM, 8); }
73 void SetBiasYleft(bool set = 1) { set ? SETBIT(vyM, 9) : CLRBIT(vyM, 9); }
74 void SetBiasYmid(bool set = 1) { set ? SETBIT(vyM, 10) : CLRBIT(vyM, 10); }
75 void SetBiasYright(bool set = 1) { set ? SETBIT(vyM, 11) : CLRBIT(vyM, 11); }
76 void SetLeftSgn(bool set = 1) { set ? SETBIT(vyM, 3) : CLRBIT(vyM, 3); }
77 void SetLeftHit(bool set = 1) { set ? SETBIT(vyM, 2) : CLRBIT(vyM, 2); }
78 void SetSymmHit(bool set = 1) { set ? SETBIT(vyM, 1) : CLRBIT(vyM, 1); }
79 void SetMaxTilt(bool set = 1) { set ? SETBIT(vyM, 0) : CLRBIT(vyM, 0); }
80 void SetOvf(bool set = 1) { set ? SETBIT(vyM, 12) : CLRBIT(vyM, 12); }
81 uint16_t GetHitMap() const { return vyM; }
82
83 std::pair<double, double> GetDxDy(const int n0);
84 double GetXoffset(int n0 = 0) const;
85 double GetYoffset(int n0 = 0) const;
86
87 void RecenterXoffset(double& dx);
91 void RecenterYoffset(double& dy);
96 int GetHitClass() const;
100 int GetHitRcClass(int a0) const;
101
102 double GetXcorr(double dx, int typ, int cls = 0) const;
108 double GetYcorr(double dy, int cls = 0) const;
113 std::pair<double, double> CorrectPosition(double dx, double dy, const double xcorr, const double padSizeX,
114 const double padSizeY);
115
116 static float fgCorrXdx;
117 static float fgCorrXval[3][NBINSCORRX];
118 static float fgCorrYval[NBINSCORRY][2];
119 static float fgCorrRcXval[2][NBINSCORRX];
120 static float fgCorrRcXbiasXval[3][NBINSCORRX];
121
122 // Nint function copied from TMath until better option is available
123 template<typename T>
124 inline int Nint(T x) const
125 {
126 int i;
127 if (x >= 0) {
128 i = int(x + 0.5);
129 if (i & 1 && x + 0.5 == T(i)) i--;
130 }
131 else {
132 i = int(x - 0.5);
133 if (i & 1 && x - 0.5 == T(i)) i++;
134 }
135 return i;
136 }
137 };
138
139} // namespace cbm::algo::trd
#define NBINSCORRY
#define NBINSCORRX
Compatibility header for basic ROOT macros.
#define SETBIT(n, i)
Definition RTypes.h:15
#define TESTBIT(n, i)
Definition RTypes.h:17
#define CLRBIT(n, i)
Definition RTypes.h:16
static float fgCorrYval[NBINSCORRY][2]
discretized correction LUT
void RecenterYoffset(double &dy)
Shift graph representation to [-0.5, 0.5].
HitFactory2D(int ncols)
bit map for cluster topology classification
void SetBiasXmid(bool set=1)
std::pair< double, double > GetDxDy(const int n0)
void SetBiasYright(bool set=1)
std::pair< double, double > CorrectPosition(double dx, double dy, const double xcorr, const double padSizeX, const double padSizeY)
Shift graph representation to [-0.5, 0.5].
void SetBiasYleft(bool set=1)
void SetMaxTilt(bool set=1)
static float fgCorrXval[3][NBINSCORRX]
step of the discretized correction LUT
void SetBiasYmid(bool set=1)
void SetSymmHit(bool set=1)
void SetBiasXright(bool set=1)
int Nint(T x) const
discretized correction LUT
double GetYoffset(int n0=0) const
uint16_t vyM
index of maximum signal in the projection
static float fgCorrRcXbiasXval[3][NBINSCORRX]
discretized correction LUT
double GetYcorr(double dy, int cls=0) const
y position correction based on LUT
std::vector< signal > fSignal
void SetLeftSgn(bool set=1)
uint8_t vcM
start time of current hit [clk]
int GetHitRcClass(int a0) const
Hit classification wrt signal bias.
double GetXoffset(int n0=0) const
void SetBiasXleft(bool set=1)
int GetHitClass() const
Hit classification wrt center pad.
double GetXcorr(double dx, int typ, int cls=0) const
void SetLeftHit(bool set=1)
static float fgCorrRcXval[2][NBINSCORRX]
discretized correction params
signal(double _s, double _se, char _t, double _x, double _xe)
working copy of signal relative position errors
char t
working copy of signal errors from cluster
double xe
working copy of signal relative positions
double x
working copy of signal relative timing
double se
working copy of signals from cluster