ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetPattRecoTools/TrigInDetPattRecoTools/TrigSeedML_LUT.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGINDETPATTRECOTOOLS_TRIG_SEED_ML_LUT_H
6#define TRIGINDETPATTRECOTOOLS_TRIG_SEED_ML_LUT_H
7
8#include <vector>
9
10typedef struct TrigSeedML_LUT {
11public:
13
14TrigSeedML_LUT(int id, int w, int h, float c[4]) : m_id(id), m_w(w), m_h(h) {
15 for(int i=0;i<4;i++) m_c[i] = c[i];
16 initialize();
17}
18
19TrigSeedML_LUT(const TrigSeedML_LUT& tsl) : m_id(tsl.m_id), m_w(tsl.m_w), m_h(tsl.m_h), m_data(tsl.m_data) {
20 for(int i=0;i<4;i++) m_c[i] = tsl.m_c[i];
21 m_invBinWidthX = m_w/(m_c[1]-m_c[0]);
22 m_invBinWidthY = m_h/(m_c[3]-m_c[2]);
23}
24
26
27 bool check(float fX, float fY) const {
28
29 int i = (fY - m_c[2])*m_invBinWidthY;
30 int j = (fX - m_c[0])*m_invBinWidthX;
31
32 if(i<0 || i>= m_h || j<0 || j>=m_w) return false;
33
34 return (m_data[j+i*m_w] != 0);
35 }
36
37 bool getValidRange(float fX, float& min, float& max) const {
38 min = m_c[2];
39 max = m_c[3];
40 int j = (fX - m_c[0])*m_invBinWidthX;
41 if(j<0 || j>=m_w) return false;
42
43 int idx=j;
44 int i1=0;
45 int i2=0;
46 int i=0;
47 for(;i<m_h;i++, idx+=m_w) {
48 if(m_data[idx] == 0) continue;
49 else {
50 i1 = i;
51 i2 = i1;
52 break;
53 }
54 }
55 for(;i<m_h;i++, idx+=m_w) {
56 if(m_data[idx] != 0) i2++;
57 else break;
58 }
59
60 min = m_c[2] + i1/m_invBinWidthY;
61 max = m_c[2] + i2/m_invBinWidthY;
62 return true;
63 }
64 void initialize() {
65 m_invBinWidthX = m_w/(m_c[1]-m_c[0]);
66 m_invBinWidthY = m_h/(m_c[3]-m_c[2]);
67 m_data.resize(m_h*m_w, 0);
68 }
69
70 void setBin(int r, int c) {
71 m_data[c + r*m_w] = 1;
72 }
73
74 void generate(float offset, float slope, float hwm, float hwp) {
75
76 m_data.resize(m_h*m_w, 0);
77
78 for(int j=0;j<m_w;j++) {
79 float x = m_c[0] + j/m_invBinWidthX;
80
81 float y = offset + x*slope;
82 float yp= y+hwp;
83 float ym= y+hwm;
84
85 if(yp < m_c[2]) yp = m_c[2];
86 if(yp > m_c[3]) yp = m_c[3];
87
88 if(ym < m_c[2]) ym = m_c[2];
89 if(ym > m_c[3]) ym = m_c[3];
90
91 int i1 = int((ym-m_c[2])*m_invBinWidthY);
92 int i2 = int((yp-m_c[2])*m_invBinWidthY);
93
94 for(int i=i1;i<i2;i++) {
95 m_data[j+m_w*i] = 1;
96 }
97
98 }
99 }
100
101 int m_id;
102 int m_w, m_h;
103 float m_c[4];
104 std::vector<unsigned char> m_data;
107
108#endif
struct TrigSeedML_LUT TRIG_SEED_ML_LUT
#define y
#define x
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
Header file for AthHistogramAlgorithm.
int r
Definition globals.cxx:22
bool getValidRange(float fX, float &min, float &max) const
void generate(float offset, float slope, float hwm, float hwp)