ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimBinStep.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimBinStep_H
4#define FPGATrackSimBinStep_H
5
25
26
30
31#include "GaudiKernel/StatusCode.h"
32
33#include <cmath>
34#include <string>
35#include <vector>
36#include <array>
37
39
40//--------------------------------------------------------------------------------------------------
41//
42// Class to define the sub steps of the full binning
43//
44//--------------------------------------------------------------------------------------------------
45class FPGATrackSimBinStep : virtual public AthAlgTool {
46public:
47 FPGATrackSimBinStep(const std::string & algname, const std::string & name,
48 const IInterface * ifc) : AthAlgTool(algname, name, ifc) {}
49
50 virtual StatusCode initialize() override;
51 StatusCode setRanges(FPGATrackSimBinStep* prev,const FPGATrackSimBinUtil::ParSet& parMin, const FPGATrackSimBinUtil::ParSet& parMax);
52
53 // property of step
54 const std::vector<unsigned> stepIdx(FPGATrackSimBinUtil::IdxSet idx) const; // index for only the pars used in this step
55 const std::vector<unsigned> stepBins() const; // bin sizes for only the pars used in this step
56 const std::vector<unsigned>& stepPars() const {return m_pars;} // parameters used for this step
57 const std::vector<unsigned> nBins() const {return m_parBins;} // bin sizes for only the pars used in this step
58 const std::string stepName() const {return this->name().substr(this->name().find_last_of(".")+1);}
59 unsigned stepNum() const {return m_stepNum;}
60
61 // Calculation of bin boundaries
62 double binCenter(unsigned par, unsigned bin) const { return m_parMin[par] + m_parStep[par] * (double(bin) + 0.5); }
63 double binLowEdge(unsigned par, unsigned bin) const { return m_parMin[par] + m_parStep[par] * (double(bin)); }
64 double binHighEdge(unsigned par, unsigned bin) const { return m_parMin[par] + m_parStep[par] * (double(bin) + 1.0);}
65 double binWidth(unsigned par) const { return m_parStep[par]; }
68
69 // get bin value for a specific parameter value
70 unsigned binIdx(unsigned par, double val) const {
71 // Guard against both underflow and overflow.
72 if (val < m_parMin[par]) return 0;
73 else if (val > m_parMax[par]) return unsigned(floor((m_parMax[par] - m_parMin[par]) / m_parStep[par])) - 1;
74 else return unsigned(floor((val - m_parMin[par]) / m_parStep[par]));
75 }
76
77 // convert parset (the binning parameters) to a 5-d bin
79
80 // Convert to previous steps idx
82
83 // Check if its the first step
84 bool isFirstStep() const {return m_prev==0;}
85
86 //--------------------------------------------------------------------------------------------------
87 //
88 // Set which bins are valid
89 //
90 //--------------------------------------------------------------------------------------------------
91 // Which bins are consistent with the (pT, eta, pho, d0, z0)
92 // ranges computed from region definition defined in the eventselection
93 // service or set by the layer map
94 void initValidBins();
95 void setValidBin(const std::vector<unsigned>& idx); // also sets SubBins
96 void printValidBin() const; // dump an output to log for x-checks
99
100private:
101 Gaudi::Property<std::vector<unsigned>> m_parBinsConfig{this,"parBins",{},"Vector of number of bins for each parameter (expect 5)"};
102
103 // pars used in this step
104 std::vector<unsigned> m_pars{};
105
106 // Array that has a true/false for if a bin is valid
107 // some bins may not be valid because they correspond to (pT,eta,phi,d0,z0)
108 // that are being targeted for reconstruction
109 FPGATrackSimBinArray<int> m_validBinFull; // this is the full binning
110 FPGATrackSimBinArray<int> m_validBinLocal; // this is for the pars used at this step
111
112 // pointer to FPGATrackSimBinStep of previous step
114 unsigned m_stepNum{}; // number of step
115
116 // the bins for this step
117 FPGATrackSimBinUtil::IdxSet m_parBins; // one means no binning this step
118 FPGATrackSimBinUtil::ParSet m_parStep; // step size of each bin
119
120 // reference to the full range defined in the "tool"
123
125};
126
127#endif // FPGATrackSimBinStep_H
Iterable Multidimensional Array Class for FPGATrackSimBinTool.
Binning Utilities for GenScanTool.
Defines Parameters used for binning.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
double binCenter(unsigned par, unsigned bin) const
const FPGATrackSimBinArray< int > & validBinsLocal() const
const std::vector< unsigned > nBins() const
FPGATrackSimBinStep(const std::string &algname, const std::string &name, const IInterface *ifc)
FPGATrackSimBinArray< int > m_validBinLocal
double binHighEdge(unsigned par, unsigned bin) const
double binWidth(unsigned par) const
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
const std::string stepName() const
virtual StatusCode initialize() override
const std::vector< unsigned > & stepPars() const
FPGATrackSimBinUtil::ParSet m_parStep
double binLowEdge(unsigned par, unsigned bin) const
StatusCode setRanges(FPGATrackSimBinStep *prev, const FPGATrackSimBinUtil::ParSet &parMin, const FPGATrackSimBinUtil::ParSet &parMax)
unsigned stepNum() const
FPGATrackSimBinUtil::IdxSet m_parBins
const std::vector< unsigned > stepIdx(FPGATrackSimBinUtil::IdxSet idx) const
const std::vector< unsigned > stepBins() const
const FPGATrackSimBinArray< int > & validBinsFull() const