ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimBinStep.cxx
Go to the documentation of this file.
1
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
10
13#include <GaudiKernel/StatusCode.h>
15
18
20{
21 // Dump the configuration to make sure it propagated through right
22 const std::vector<Gaudi::Details::PropertyBase*> props = this->getProperties();
23 for( Gaudi::Details::PropertyBase* prop : props ) {
24 if (prop->ownerTypeName()==this->type()) {
25 ATH_MSG_DEBUG("Property:\t" << prop->name() << "\t : \t" << prop->toString());
26 }
27 }
28
29 return StatusCode::SUCCESS;
30}
31
33 const ParSet &parMin,
34 const ParSet &parMax) {
35
36 m_prev = prev;
37 if (prev) {
38 m_stepNum = prev->m_stepNum+1;
39 } else {
40 m_stepNum = 0;
41 }
42 m_parMin = parMin;
43 m_parMax = parMax;
44 m_parBins = std::vector<unsigned>(m_parBinsConfig);
45 for (unsigned par = 0; par < FPGATrackSimTrackPars::NPARS; par++) {
46 if (m_parBins[par] <= 0) {
47 ATH_MSG_FATAL("Every dimension must be at least one bin");
48 return StatusCode::FAILURE;
49 }
50 m_parStep[par] = (m_parMax[par] - m_parMin[par]) / m_parBins[par];
51 if (m_parBins[par] <= 0)
52 {
53 ATH_MSG_FATAL("Every dimension must be at least one bin (set #bins=1 for not binning in that parameter)");
54 }
55 if (prev) {
56 if (m_parBins[par] < prev->m_parBins[par]) {
57 ATH_MSG_FATAL("Number of bins can only increase with each step");
58 return StatusCode::FAILURE;
59 }
60 if (m_parBins[par] % prev->m_parBins[par] !=0) {
61 ATH_MSG_FATAL("Number of bins must be integer multiple of bins in previous step");
62 return StatusCode::FAILURE;
63 }
64 if (m_parBins[par] != prev->m_parBins[par]) {
65 // This step involves this parameter
66 m_pars.push_back(par);
67 }
68 } else {
69 if (m_parBins[par] != 1) {
70 // This step involves this parameter
71 m_pars.push_back(par);
72 }
73 }
74 }
75
76 ATH_MSG_DEBUG("Parameters = " << m_pars);
77
78 return StatusCode::SUCCESS;
79}
80
82{
83 ParSet parset;
84 for (unsigned i = 0; i < FPGATrackSimTrackPars::NPARS; i++)
85 {
86 parset[i] = binLowEdge(i, idx[i]);
87 }
88 return parset;
89}
90
92{
93 ParSet parset;
94 for (unsigned i = 0; i < FPGATrackSimTrackPars::NPARS; i++)
95 {
96 parset[i] = binCenter(i, idx[i]);
97 }
98 return parset;
99}
100
102{
103 IdxSet retv;
104 for (unsigned i = 0; i < FPGATrackSimTrackPars::NPARS; i++)
105 {
106 retv[i] = binIdx(i, pars[i]);
107 }
108 return retv;
109}
110
111
112
113// Convert to previous steps idx
115 IdxSet retv{};
116 if (m_prev) {
117 for (unsigned par =0; par < FPGATrackSimTrackPars::NPARS; par++) {
118 retv[par] = int(cur[par]*((const FPGATrackSimBinStep*)m_prev)->m_parBins[par]/m_parBins[par]);
119 }
120 } else {
121 ATH_MSG_FATAL("convertToPrev called, but no previous");
122 }
123 return retv;
124}
125
126
127const std::vector<unsigned> FPGATrackSimBinStep::stepIdx(IdxSet idx) const {
129
130const std::vector<unsigned> FPGATrackSimBinStep::stepBins() const {
132
133void FPGATrackSimBinStep::setValidBin(const std::vector<unsigned>& idx) {
134 m_validBinFull[idx] = true;
135 m_validBinLocal[stepIdx(idx)] = true;
136 if (m_prev) m_prev->setValidBin(convertToPrev(idx));
137}
138
140 m_validBinFull.setsize(m_parBins, false);
141 m_validBinLocal.setsize(stepIdx(m_parBins), false);
142}
143
145 // count valid bins
146 int validBinsFull = 0;
147
149 if (bin.data())
151 }
152 ATH_MSG_INFO("Step" << name() << "Valid Bins Full: " << validBinsFull);
153
154 // count valid bins local
155 int validBinsLocal = 0;
157 if (bin.data())
159 }
160 ATH_MSG_INFO("Step" << name() << "Valid Bins Local: " << validBinsLocal);
161
162}
163
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Binning Classes for BinStep.
Defines Parameters used for binning.
double binCenter(unsigned par, unsigned bin) const
const FPGATrackSimBinArray< int > & validBinsLocal() const
FPGATrackSimBinStep(const std::string &algname, const std::string &name, const IInterface *ifc)
FPGATrackSimBinArray< int > m_validBinLocal
Gaudi::Property< std::vector< unsigned > > m_parBinsConfig
unsigned binIdx(unsigned par, double val) const
FPGATrackSimBinUtil::ParSet m_parMin
FPGATrackSimBinArray< int > m_validBinFull
FPGATrackSimBinUtil::IdxSet convertToPrev(const FPGATrackSimBinUtil::IdxSet &cur) const
FPGATrackSimBinStep * m_prev
std::vector< unsigned > m_pars
void setValidBin(const std::vector< unsigned > &idx)
FPGATrackSimBinUtil::ParSet m_parMax
virtual StatusCode initialize() override
FPGATrackSimBinUtil::ParSet m_parStep
double binLowEdge(unsigned par, unsigned bin) const
StatusCode setRanges(FPGATrackSimBinStep *prev, const FPGATrackSimBinUtil::ParSet &parMin, const FPGATrackSimBinUtil::ParSet &parMax)
FPGATrackSimBinUtil::IdxSet m_parBins
const std::vector< unsigned > stepIdx(FPGATrackSimBinUtil::IdxSet idx) const
const std::vector< unsigned > stepBins() const
const FPGATrackSimBinArray< int > & validBinsFull() const
std::vector< unsigned > subVec(const std::vector< unsigned > &elems, const IdxSet &invec)