BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
L1HitArea.h
Go to the documentation of this file.
1
#ifndef L1HitArea_H
2
#define L1HitArea_H
3
4
#include "
CbmL1Def.h
"
5
#include "
L1Grid.h
"
6
7
struct
L1Grid
;
8
class
L1Row;
9
class
L1SliceData;
10
11
class
L1HitArea
12
{
13
public
:
14
L1HitArea
(
const
L1Grid
& grid,
float
y,
float
z,
float
dy,
float
dz);
15
16
/**
17
* look up the next hit in the requested area.
18
* Sets h to the coordinates and returns the index for the hit data
19
*/
20
bool
GetNext
(
THitI
&
i
);
21
22
protected
:
23
const
L1Grid
&
fGrid
;
24
25
unsigned
short
fBZmax
;
// maximal Z bin index
26
unsigned
short
fBDY
;
// Y distance of bin indexes
27
unsigned
int
fIndYmin
;
// minimum index for
28
unsigned
short
fIz
;
// current Z bin index (incremented while iterating)
29
THitI
fHitYlst
;
// last possible hit index in current z-line
30
THitI
fIh
;
// hit index iterating inside the bins
31
int
fNy
;
// Number of bins in Y direction
32
};
33
34
inline
L1HitArea::L1HitArea
(
const
L1Grid
& grid,
float
y,
float
z,
float
dy,
float
dz)
35
:
fGrid
(grid)
36
,
fBZmax
(0)
37
,
fBDY
(0)
38
,
fIndYmin
(0)
39
,
fIz
(0)
40
,
fHitYlst
(0)
41
,
fIh
(0)
42
,
fNy
(
fGrid
.Ny())
43
{
44
const
float
minY = y - dy;
45
const
float
maxY = y + dy;
46
const
float
minZ = z - dz;
47
const
float
maxZ = z + dz;
48
unsigned
short
bYmin, bZmin, bYmax;
// boundary bin indexes
49
fGrid
.GetBinBounded(minY, minZ, &bYmin, &bZmin);
50
fGrid
.GetBinBounded(maxY, maxZ, &bYmax, &
fBZmax
);
51
52
fBDY
= (bYmax - bYmin + 1);
// bin index span in y direction
53
54
fIndYmin
= (bZmin *
fNy
+ bYmin);
// same as grid.GetBin(fMinY, fMinZ), i.e. the smallest bin index of interest
55
// fIndYmin + fBDY - 1 then is the largest bin index of interest with the same Z
56
57
fGrid
.GetBinBounds(
fIndYmin
, y, dy, z, dz);
58
59
fIz
= bZmin;
60
61
fIh
=
fGrid
.FirstHitInBin(
fIndYmin
);
62
fHitYlst
=
fGrid
.FirstHitInBin(
fIndYmin
+
fBDY
);
63
64
// const unsigned int hitLst = fGrid.FirstHitInBin( fBZmax * fNy + bZmin + 1 );
65
// cout << fIh << " " << hitLst << endl;
66
// if ( fIh >= hitLst ) fIz = fBZmax + 1; // finish area in one step
67
68
// cout // << fBZmax << " " << fBDY << " " << fIndYmin << " " << fIz << " " << fHitYlst << " " << fIh << endl; //
69
// dbg
70
// << "HitArea created:\n"
71
// << y << " " << z << endl
72
// << "bYmin: " << bYmin << "\n"
73
// << "bZmin: " << bZmin << "\n"
74
// << "bYmax: " << bYmax << "\n"
75
// << "fBZmax: " << fBZmax << "\n"
76
// << "fBDY: " << fBDY << "\n"
77
// << "fIndYmin: " << fIndYmin << "\n"
78
// << "fIz: " << fIz << "\n"
79
// << "fHitYlst: " << fHitYlst << "\n"
80
// << "fIh: " << fIh << "\n"
81
// << "fNy: " << fNy << "\n"
82
// << "Nz " << fGrid.Nz() << std::endl;
83
L1_ASSERT
(
fIndYmin
+
fBDY
<
fGrid
.N() + 1,
fIndYmin
<<
" + "
<<
fBDY
<<
" < "
<<
fGrid
.N());
84
}
85
86
inline
bool
L1HitArea::GetNext
(
THitI
&
i
)
87
{
88
bool
yIndexOutOfRange =
fIh
>=
fHitYlst
;
// current y is not in the area
89
bool
nextZIndexOutOfRange = (
fIz
>=
fBZmax
);
// there isn't any new z-line
90
91
if
(yIndexOutOfRange && nextZIndexOutOfRange) {
// all iterators are over the end
92
return
false
;
93
}
94
95
// at least one entry in the vector has (fIh >= fHitYlst && fIz < fBZmax)
96
bool
needNextZ = yIndexOutOfRange && !nextZIndexOutOfRange;
97
98
// skip as long as fIh is outside of the interesting bin y-index
99
while
(
ISLIKELY
(needNextZ)) {
100
fIz
++;
// get new z-line
101
// get next hit
102
fIndYmin
+=
fNy
;
103
fIh
=
fGrid
.FirstHitInBin(
fIndYmin
);
// get first hit in cell, if z-line is new
104
fHitYlst
=
fGrid
.FirstHitInBin(
fIndYmin
+
fBDY
);
105
106
yIndexOutOfRange =
fIh
>=
fHitYlst
;
107
nextZIndexOutOfRange = (
fIz
>=
fBZmax
);
108
needNextZ = yIndexOutOfRange && !nextZIndexOutOfRange;
109
}
110
111
L1_ASSERT
(
fIh
<
fGrid
.FirstHitInBin(
fGrid
.N()) || yIndexOutOfRange,
112
fIh
<<
" < "
<<
fGrid
.FirstHitInBin(
fGrid
.N() - 1) <<
" || "
<< yIndexOutOfRange);
113
114
i
=
fIh
;
// return
115
fIh
++;
// go to next
116
return
!yIndexOutOfRange;
117
}
118
119
#endif
CbmL1Def.h
ISLIKELY
#define ISLIKELY(x)
Definition
CbmL1Def.h:34
L1_ASSERT
#define L1_ASSERT(v, msg)
Definition
CbmL1Def.h:42
L1Grid.h
THitI
unsigned int THitI
Definition
L1StsHit.h:6
i
int i
Definition
P4_F32vec4.h:22
L1Grid
2-dimensional grid of pointers.
Definition
L1Grid.h:49
L1HitArea::fIndYmin
unsigned int fIndYmin
Definition
L1HitArea.h:27
L1HitArea::GetNext
bool GetNext(THitI &i)
look up the next hit in the requested area.
Definition
L1HitArea.h:86
L1HitArea::fIh
THitI fIh
Definition
L1HitArea.h:30
L1HitArea::fNy
int fNy
Definition
L1HitArea.h:31
L1HitArea::L1HitArea
L1HitArea(const L1Grid &grid, float y, float z, float dy, float dz)
Definition
L1HitArea.h:34
L1HitArea::fBDY
unsigned short fBDY
Definition
L1HitArea.h:26
L1HitArea::fBZmax
unsigned short fBZmax
Definition
L1HitArea.h:25
L1HitArea::fHitYlst
THitI fHitYlst
Definition
L1HitArea.h:29
L1HitArea::fGrid
const L1Grid & fGrid
Definition
L1HitArea.h:23
L1HitArea::fIz
unsigned short fIz
Definition
L1HitArea.h:28
reconstruction
cat
L1Algo
L1HitArea.h
Generated on
for BmnRoot by
1.17.0