Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FPGATrackSimKeyLayerBinDesc.cxx
Go to the documentation of this file.
1 
2 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 
16 
18 {
19  // Dump the configuration to make sure it propagated through right
20  const std::vector<Gaudi::Details::PropertyBase*> props = this->getProperties();
21  for( Gaudi::Details::PropertyBase* prop : props ) {
22  if (prop->ownerTypeName()==this->type()) {
23  ATH_MSG_DEBUG("Property:\t" << prop->name() << "\t : \t"<< prop->toString());
24  }
25  }
26 
29 
30  return StatusCode::SUCCESS;
31 }
32 
34  const IdxSet &idx,
35  StoredHit &storedhit) const
36 {
37  double r1 = m_keylyrtool.R1();
38  double r2 = m_keylyrtool.R2();
39  double hitr= storedhit.hitptr->getR();
40 
41  bool passesPhi = true;
42  bool passesEta = true;
43 
44  if (stepIsRPhi(step)) {
45  // distance of hit from bin center
46  storedhit.phiShift =
47  phiResidual(step.binCenter(idx), storedhit.hitptr.get());
48 
49  // Get expected curvature shift from bin center
50  auto half_xm_bin_pars = parSetToKeyPars(step.binCenter(idx));
51  half_xm_bin_pars.xm = step.binWidth(4)/2.0; // 4 = xm par
52  double xshift =
53  m_keylyrtool.xExpected(half_xm_bin_pars, storedhit.hitptr.get());
54  double xrange = xshift + r1 * step.binWidth(2) / 2.0
55  + ((r2*step.binWidth(3) - r1*step.binWidth(2)) / (r2 - r1) * (hitr - r1))/2.0;
56 
57  passesPhi = std::abs(storedhit.phiShift) < xrange;
58  }
59 
60  if (stepIsREta(step)) {
61  // distance of hit from bin center
62  storedhit.etaShift = etaResidual(step.binCenter(idx),storedhit.hitptr.get());
63 
64  double width_z_in = step.binWidth(0)/2.0;
65  double width_z_out = step.binWidth(1)/2.0;
66  double zrange = width_z_in + (width_z_out-width_z_in) * (hitr-r1)/(r2-r1);
67 
68  // pad for strip length or imprecise SP.
69  double padding = 0;
70  if (storedhit.hitptr->getDetType() == SiliconTech::strip) {
71  // 2.5 cm, length of short strip, half length of long strip
72  padding = 0.025;
73  }
74 
75  passesEta = std::abs(storedhit.etaShift) < (zrange+padding);
76 
77  }
78 
79  return passesPhi && passesEta;
80 }
81 
82 // figure out if step is r-phi or r-eta plan
84  const FPGATrackSimBinStep &step) const {
85  for (const unsigned &steppar : step.stepPars()) {
86  for (const unsigned &phipar : m_phipars) {
87  if (steppar == phipar)
88  return true;
89  }
90  }
91  return false;
92 }
93 
95  const FPGATrackSimBinStep &step) const {
96  for (const unsigned &steppar : step.stepPars()) {
97  for (const unsigned &etapar : m_etapars) {
98  if (steppar == etapar)
99  return true;
100  }
101  }
102  return false;
103 }
104 
105 //---------------------------------------------------------------------------------------
106 //
107 // Write the relevant LUT tables for firmware
108 //
109 //---------------------------------------------------------------------------------------
111  double r_in = m_keylyrtool.R1();
112  double r_out = m_keylyrtool.R2();
113 
114  ATH_MSG_INFO("Writing constants for step:" << step.stepName() << " isRPhi="<< stepIsRPhi(step) << " isREta="<< stepIsREta(step));
115 
116  // write the keylayer definition
117  if (step.isFirstStep()) {
118  FPGATrackSimBinUtil::StreamManager sm("KeyLayer");
119  sm.writeVar("r_in",r_in);
120  sm.writeVar("r_out",r_out);
121  }
122 
123  if (stepIsRPhi(step)) {
124 
126  int nbins = 0;
127  for (FPGATrackSimBinArray<int>::ConstIterator &bin : step.validBinsLocal()) {
128  if (!bin.data())
129  continue;
130 
131  sm.writeVar("phi_bin", bin.idx());
132 
134  keypars.phi1 = step.binCenter(2,bin.idx()[0]);
135  keypars.phi2 = step.binCenter(3,bin.idx()[1]);
136  keypars.xm = step.binCenter(4, bin.idx()[2]);
137 
138  auto rotated_coords = m_keylyrtool.getRotatedConfig(keypars);
139 
140  sm.writeVar("y", rotated_coords.y);
141  sm.writeVar("x1p", rotated_coords.xy1p.first);
142  sm.writeVar("y1p", rotated_coords.xy1p.second);
143  sm.writeVar("cosb", rotated_coords.rotang.first);
144  sm.writeVar("sinb", rotated_coords.rotang.second);
145 
146  sm.writeVar("x_m", keypars.xm);
147  sm.writeVar("x_factor", 4.0 * keypars.xm / (rotated_coords.y * rotated_coords.y));
148 
149  nbins++;
150  }
151 
152  double w_in = r_in * step.binWidth(2) / 2.0;
153  double w_out = r_out * step.binWidth(3) / 2.0;
154  double w_x = step.binWidth(4) / 2.0;
155  double dw_dr = (w_out - w_in) / (r_out - r_in);
156 
157  sm.writeVar("w_x", 4.0 * w_x / ((r_out - r_in) * (r_out - r_in)));
158  sm.writeVar("w_in", w_in);
159  sm.writeVar("dw_dr", dw_dr);
160 
161  sm.writeVar("nbins", nbins);
162  }
163 
164  if (stepIsREta(step)) {
165 
167 
168  int nbins = 0;
169  for (FPGATrackSimBinArray<int>::ConstIterator &bin : step.validBinsLocal()) {
170  if (!bin.data())
171  continue;
172 
173  // write just this steps idxs
174  sm.writeVar("z_bin", bin.idx());
175 
176  double z_in = step.binCenter(0, bin.idx()[0]);
177  double z_out = step.binCenter(1, bin.idx()[1]);
178  double dz_dr = (z_out - z_in) / (r_out - r_in);
179 
180  sm.writeVar("z_in", z_in);
181  sm.writeVar("dz_dr", dz_dr);
182 
183  nbins++;
184  }
185  sm.writeVar("nbins", nbins);
186 
187  // same for all bins
188  double w_in = step.binWidth(0) / 2.0;
189  double w_out = step.binWidth(1) / 2.0;
190  double dw_dr = (w_out - w_in) / (r_out - r_in);
191  sm.writeVar("w_in", w_in);
192  sm.writeVar("dw_dr", dw_dr);
193 
194  }
195 
196 
197 
198 
199 }
200 
FPGATrackSimKeyLayerTool::setR1
void setR1(const double r1)
Definition: FPGATrackSimKeyLayerTool.h:105
xrange
void xrange(TH1 *h, bool symmetric)
Definition: computils.cxx:516
FPGATrackSimKeyLayerBinDesc::m_etapars
const std::vector< unsigned > m_etapars
Definition: FPGATrackSimKeyLayerBinDesc.h:105
FPGATrackSimBinUtil::StoredHit::hitptr
std::shared_ptr< const FPGATrackSimHit > hitptr
Definition: FPGATrackSimBinUtil.h:103
SiliconTech::strip
@ strip
FPGATrackSimBinStep
Definition: FPGATrackSimBinStep.h:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthMsgStreamMacros.h
FPGATrackSimKeyLayerBinDesc::parSetToKeyPars
FPGATrackSimKeyLayerTool::KeyLyrPars parSetToKeyPars(const ParSet &parset) const
Definition: FPGATrackSimKeyLayerBinDesc.h:96
FPGATrackSimKeyLayerTool.h
Binning Classes for BinTool.
FPGATrackSimKeyLayerTool::R2
double R2() const
Definition: FPGATrackSimKeyLayerTool.h:104
bin
Definition: BinsDiffFromStripMedian.h:43
FPGATrackSimKeyLayerBinDesc::m_rout
Gaudi::Property< double > m_rout
Definition: FPGATrackSimKeyLayerBinDesc.h:89
FPGATrackSimKeyLayerTool::KeyLyrPars::xm
double xm
Definition: FPGATrackSimKeyLayerTool.h:60
FPGATrackSimBinStep.h
Binning Classes for BinStep.
dqutils::padding
std::atomic< int > padding
Definition: MonitoringFile_MoveVertexMonitoring.cxx:20
FPGATrackSimKeyLayerTool::KeyLyrPars::phi2
double phi2
Definition: FPGATrackSimKeyLayerTool.h:59
FPGATrackSimKeyLayerBinDesc::hitInBin
virtual bool hitInBin(const FPGATrackSimBinStep &step, const IdxSet &idx, StoredHit &storedhit) const override
Definition: FPGATrackSimKeyLayerBinDesc.cxx:33
FPGATrackSimKeyLayerBinDesc::m_phipars
const std::vector< unsigned > m_phipars
Definition: FPGATrackSimKeyLayerBinDesc.h:104
FPGATrackSimBinUtil::StreamManager
Definition: FPGATrackSimBinUtil.h:83
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FPGATrackSimKeyLayerBinDesc::m_rin
Gaudi::Property< double > m_rin
Definition: FPGATrackSimKeyLayerBinDesc.h:88
FPGATrackSimBinArray
Definition: FPGATrackSimBinArray.h:41
FPGATrackSimKeyLayerBinDesc::stepIsREta
bool stepIsREta(const FPGATrackSimBinStep &step) const
Definition: FPGATrackSimKeyLayerBinDesc.cxx:94
FPGATrackSimKeyLayerBinDesc::phiResidual
virtual double phiResidual(const ParSet &parset, FPGATrackSimHit const *hit) const override
Definition: FPGATrackSimKeyLayerBinDesc.h:66
FPGATrackSimKeyLayerTool::KeyLyrPars::phi1
double phi1
Definition: FPGATrackSimKeyLayerTool.h:58
FPGATrackSimKeyLayerTool::setR2
void setR2(const double r2)
Definition: FPGATrackSimKeyLayerTool.h:106
FPGATrackSimKeyLayerTool::getRotatedConfig
rotatedConfig getRotatedConfig(const KeyLyrPars &keypars) const
Definition: FPGATrackSimKeyLayerTool.cxx:32
FPGATrackSimBinUtil::StoredHit
Definition: FPGATrackSimBinUtil.h:101
FPGATrackSimKeyLayerTool::R1
double R1() const
Definition: FPGATrackSimKeyLayerTool.h:103
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
zrange
void zrange(double nsigma, double fence, double &zed, double &zedMinus, double &zedPlus, const SG::ReadCondHandleKey< InDet::BeamSpotData > &bs, const EventContext &ctx)
Definition: RoiUpdaterTool.cxx:33
FPGATrackSimKeyLayerTool::xExpected
double xExpected(const KeyLyrPars &keypars, const FPGATrackSimHit *hit) const
Definition: FPGATrackSimKeyLayerTool.cxx:170
FPGATrackSimKeyLayerBinDesc::m_keylyrtool
FPGATrackSimKeyLayerTool m_keylyrtool
Definition: FPGATrackSimKeyLayerBinDesc.h:101
FPGATrackSimKeyLayerBinDesc::stepIsRPhi
bool stepIsRPhi(const FPGATrackSimBinStep &step) const
Definition: FPGATrackSimKeyLayerBinDesc.cxx:83
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
FPGATrackSimKeyLayerBinDesc.h
Binning Classes for BinTool.
LArCellBinning.step
step
Definition: LArCellBinning.py:158
FPGATrackSimKeyLayerBinDesc::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimKeyLayerBinDesc.cxx:17
FPGATrackSimBinUtil::StreamManager::writeVar
void writeVar(const std::string &var, T val)
Definition: FPGATrackSimBinUtil.h:86
FPGATrackSimBinUtil::StoredHit::etaShift
double etaShift
Definition: FPGATrackSimBinUtil.h:105
FPGATrackSimBinUtil::StoredHit::phiShift
double phiShift
Definition: FPGATrackSimBinUtil.h:104
FPGATrackSimBinUtil::IdxSet
Definition: FPGATrackSimBinUtil.h:50
FPGATrackSimTypes.h
FPGATrackSimKeyLayerBinDesc::writeLUTs
virtual void writeLUTs(const FPGATrackSimBinStep &step) const override
Definition: FPGATrackSimKeyLayerBinDesc.cxx:110
FPGATrackSimKeyLayerBinDesc::etaResidual
virtual double etaResidual(const ParSet &parset, FPGATrackSimHit const *hit) const override
Definition: FPGATrackSimKeyLayerBinDesc.h:70
FPGATrackSimKeyLayerTool::KeyLyrPars
Definition: FPGATrackSimKeyLayerTool.h:52