ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
FPGATrackSim
FPGATrackSimBinning
FPGATrackSimBinning
FPGATrackSimBinUtil.h
Go to the documentation of this file.
1
// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
#ifndef FPGATrackSimBinUtil_H
4
#define FPGATrackSimBinUtil_H
5
14
15
#include "
FPGATrackSimObjects/FPGATrackSimHit.h
"
16
#include "
FPGATrackSimObjects/FPGATrackSimTrackPars.h
"
17
#include "
FPGATrackSimObjects/FPGATrackSimConstants.h
"
18
#include <array>
19
#include <fstream>
20
#include <map>
21
#include <string>
22
#include <vector>
23
#include <limits>
24
#include <memory>
25
26
namespace
FPGATrackSimBinUtil
{
27
28
//--------------------------------------------------------------------------------------------------
29
//
30
// These just makes ParSet and IdxSet types that have 5 double or unsigned int
31
// for the 5-track parameters. The point of the structs is that they are fixed
32
// to the right length and can be converted back and forth to std::vector
33
// through cast operators and constructors
34
//
35
//--------------------------------------------------------------------------------------------------
36
struct
ParSet
:
public
std::array<double, FPGATrackSimTrackPars::NPARS> {
37
using
array<double,
FPGATrackSimTrackPars::NPARS
>::array;
38
ParSet
(
const
std::vector<double> &val);
39
operator
const
std::vector<double>()
const
;
40
};
41
struct
IdxSet
:
public
std::array<unsigned, FPGATrackSimTrackPars::NPARS> {
42
using
array<unsigned,
FPGATrackSimTrackPars::NPARS
>::array;
43
IdxSet
(
const
std::vector<unsigned> &val);
44
operator
const
std::vector<unsigned>()
const
;
45
};
46
47
// invalid bin value, there is no way a true bin could be there
48
const
IdxSet
invalidBin
{std::initializer_list<unsigned>({std::numeric_limits<unsigned>::max(),std::numeric_limits<unsigned>::max(),
49
std::numeric_limits<unsigned>::max(),std::numeric_limits<unsigned>::max(),std::numeric_limits<unsigned>::max()})};
50
51
52
// Generic Utility for splitting in vector (e.g. idx or #bins 5-d vectors)
53
// into subvectors (e.g. idx for just the scan parameters). Technically, for
54
// a list of parameter indices (elems) gives the subvector of the invec with
55
// just those indices
56
std::vector<unsigned>
subVec
(
const
std::vector<unsigned> &elems,
57
const
IdxSet
&invec);
58
59
// Opposite of above subVec, this sets the subvector
60
void
setIdxSubVec
(
IdxSet
&idx,
const
std::vector<unsigned> &subvecelems,
61
const
std::vector<unsigned> &subvecidx);
62
63
// Makes are set of parameters corresponding to the corners specified by
64
// scanpars of the bin specified by idx e.g. if scan pars is (pT,d0) then the
65
// set is (low pT,low d0), (low pT, high d0), (high pT,low d0), (high pT, high
66
// d0)
67
std::vector<IdxSet>
makeVariationSet
(
const
std::vector<unsigned> &scanpars,
68
const
IdxSet
&idx);
69
70
// this is needed by the stream manager below for outputing std::vector<unsigned>
71
std::ostream &
operator<<
(std::ostream &os,
const
std::vector<unsigned> &idx);
72
73
// Class for writing const files formatted for firmware
74
struct
StreamManager
{
75
StreamManager
(
const
std::string &setname) :
m_setname
(setname) {}
76
~StreamManager
();
77
template
<
typename
T>
void
writeVar
(
const
std::string &var, T val) {
78
auto
emplace_result =
m_map
.try_emplace(
79
var,
m_setname
+
"_"
+ var +
"_const.txt"
, std::ios_base::out);
80
if
(!emplace_result.second) {
81
emplace_result.first->second <<
",\n"
;
82
}
83
emplace_result.first->second << val;
84
}
85
86
private
:
87
std::string
m_setname
;
88
std::map<std::string, std::fstream>
m_map
;
89
};
90
91
// Stores hit plus the phi/etashift from the nominal bin center
92
struct
StoredHit
{
93
StoredHit
(
const
std::shared_ptr<const FPGATrackSimHit>&
hit
) :
hitptr
(
hit
),
phiShift
(0),
etaShift
(0),
layer
(-1) {}
94
std::shared_ptr<const FPGATrackSimHit>
hitptr
;
95
double
phiShift
= 0;
// shift in r-phi plane as quantified by BinDesc
96
double
etaShift
= 0;
// shift in r-z plane as quantified by BinDesc
97
unsigned
layer
= 0;
98
double
rzrad
()
const
;
99
static
const
unsigned
invalidLayer
= std::numeric_limits<unsigned>::max();
100
};
101
std::ostream &
operator<<
(std::ostream &os,
const
StoredHit
&
hit
);
102
103
104
//-------------------------------------------------------------------------------------------------------
105
//
106
// Geometry Helpers -- does basic helix calculations
107
//
108
//-------------------------------------------------------------------------------------------------------
109
class
GeomHelpers
110
{
111
public
:
112
// This is the constant needed to relate hit phi to track phi due to curvature
113
static
constexpr
double
CurvatureConstant
=
fpgatracksim::A
;
114
115
// standard eta to theta calculation
116
static
double
ThetaFromEta
(
double
eta
);
117
118
// standard theta to eta calculation
119
static
double
EtaFromTheta
(
double
theta
);
120
121
// find the expected z position from the radius and track parameters
122
static
double
zFromPars
(
double
r
,
const
FPGATrackSimTrackPars
&pars);
123
124
// find the expected z position from the radius and track parameters
125
static
double
phiFromPars
(
double
r
,
const
FPGATrackSimTrackPars
&pars);
126
127
// find the track phi that would be consistent with the other track parameters and the hit (r,phi)
128
static
double
parsToTrkPhi
(
const
FPGATrackSimTrackPars
&pars,
FPGATrackSimHit
const
*
hit
);
129
130
// find the difference between the hit and trk phi as a function of r and track pars
131
static
double
dPhiHitTrkFromPars
(
double
r
,
const
FPGATrackSimTrackPars
&pars);
132
133
// for padding
134
static
double
dZdEta
(
double
eta
);
135
static
double
dPhidQOverPt
(
double
hitr);
136
137
};
138
139
140
};
// namespace FPGATrackSimBinUtil
141
142
#endif
// FPGATrackSimBinUtil_H
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
FPGATrackSimConstants.h
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
FPGATrackSimBinUtil::GeomHelpers
Definition
FPGATrackSimBinUtil.h:110
FPGATrackSimBinUtil::GeomHelpers::parsToTrkPhi
static double parsToTrkPhi(const FPGATrackSimTrackPars &pars, FPGATrackSimHit const *hit)
Definition
FPGATrackSimBinUtil.cxx:171
FPGATrackSimBinUtil::GeomHelpers::dPhiHitTrkFromPars
static double dPhiHitTrkFromPars(double r, const FPGATrackSimTrackPars &pars)
Definition
FPGATrackSimBinUtil.cxx:162
FPGATrackSimBinUtil::GeomHelpers::phiFromPars
static double phiFromPars(double r, const FPGATrackSimTrackPars &pars)
Definition
FPGATrackSimBinUtil.cxx:166
FPGATrackSimBinUtil::GeomHelpers::ThetaFromEta
static double ThetaFromEta(double eta)
Definition
FPGATrackSimBinUtil.cxx:138
FPGATrackSimBinUtil::GeomHelpers::CurvatureConstant
static constexpr double CurvatureConstant
Definition
FPGATrackSimBinUtil.h:113
FPGATrackSimBinUtil::GeomHelpers::zFromPars
static double zFromPars(double r, const FPGATrackSimTrackPars &pars)
Definition
FPGATrackSimBinUtil.cxx:151
FPGATrackSimBinUtil::GeomHelpers::dPhidQOverPt
static double dPhidQOverPt(double hitr)
Definition
FPGATrackSimBinUtil.cxx:185
FPGATrackSimBinUtil::GeomHelpers::dZdEta
static double dZdEta(double eta)
Definition
FPGATrackSimBinUtil.cxx:179
FPGATrackSimBinUtil::GeomHelpers::EtaFromTheta
static double EtaFromTheta(double theta)
Definition
FPGATrackSimBinUtil.cxx:143
FPGATrackSimHit
Definition
FPGATrackSimHit.h:42
FPGATrackSimTrackPars
Definition
FPGATrackSimTrackPars.h:22
FPGATrackSimTrackPars::NPARS
@ NPARS
Definition
FPGATrackSimTrackPars.h:49
r
int r
Definition
globals.cxx:22
FPGATrackSimBinUtil
Definition
FPGATrackSimBinUtil.h:26
FPGATrackSimBinUtil::makeVariationSet
std::vector< IdxSet > makeVariationSet(const std::vector< unsigned > &scanpars, const IdxSet &idx)
Definition
FPGATrackSimBinUtil.cxx:93
FPGATrackSimBinUtil::subVec
std::vector< unsigned > subVec(const std::vector< unsigned > &elems, const IdxSet &invec)
Definition
FPGATrackSimBinUtil.cxx:61
FPGATrackSimBinUtil::operator<<
std::ostream & operator<<(std::ostream &os, const std::vector< unsigned > &idx)
Definition
FPGATrackSimBinUtil.cxx:120
FPGATrackSimBinUtil::setIdxSubVec
void setIdxSubVec(IdxSet &idx, const std::vector< unsigned > &subvecelems, const std::vector< unsigned > &subvecidx)
Definition
FPGATrackSimBinUtil.cxx:70
FPGATrackSimBinUtil::invalidBin
const IdxSet invalidBin
Definition
FPGATrackSimBinUtil.h:48
fpgatracksim::A
static constexpr double A
Definition
FPGATrackSimConstants.h:28
FPGATrackSimBinUtil::IdxSet
Definition
FPGATrackSimBinUtil.h:41
FPGATrackSimBinUtil::IdxSet::IdxSet
IdxSet(const std::vector< unsigned > &val)
Definition
FPGATrackSimBinUtil.cxx:30
FPGATrackSimBinUtil::ParSet::ParSet
ParSet(const std::vector< double > &val)
Definition
FPGATrackSimBinUtil.cxx:19
FPGATrackSimBinUtil::StoredHit
Definition
FPGATrackSimBinUtil.h:92
FPGATrackSimBinUtil::StoredHit::StoredHit
StoredHit(const std::shared_ptr< const FPGATrackSimHit > &hit)
Definition
FPGATrackSimBinUtil.h:93
FPGATrackSimBinUtil::StoredHit::layer
unsigned layer
Definition
FPGATrackSimBinUtil.h:97
FPGATrackSimBinUtil::StoredHit::rzrad
double rzrad() const
Definition
FPGATrackSimBinUtil.cxx:53
FPGATrackSimBinUtil::StoredHit::phiShift
double phiShift
Definition
FPGATrackSimBinUtil.h:95
FPGATrackSimBinUtil::StoredHit::invalidLayer
static const unsigned invalidLayer
Definition
FPGATrackSimBinUtil.h:99
FPGATrackSimBinUtil::StoredHit::hitptr
std::shared_ptr< const FPGATrackSimHit > hitptr
Definition
FPGATrackSimBinUtil.h:94
FPGATrackSimBinUtil::StoredHit::etaShift
double etaShift
Definition
FPGATrackSimBinUtil.h:96
FPGATrackSimBinUtil::StreamManager::StreamManager
StreamManager(const std::string &setname)
Definition
FPGATrackSimBinUtil.h:75
FPGATrackSimBinUtil::StreamManager::~StreamManager
~StreamManager()
Definition
FPGATrackSimBinUtil.cxx:113
FPGATrackSimBinUtil::StreamManager::m_map
std::map< std::string, std::fstream > m_map
Definition
FPGATrackSimBinUtil.h:88
FPGATrackSimBinUtil::StreamManager::writeVar
void writeVar(const std::string &var, T val)
Definition
FPGATrackSimBinUtil.h:77
FPGATrackSimBinUtil::StreamManager::m_setname
std::string m_setname
Definition
FPGATrackSimBinUtil.h:87
IdxSet
Definition
FPGATrackSimBinUtil.h:41
Generated on
for ATLAS Offline Software by
1.17.0