ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimTrackingToolBase.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
4
5
6FPGATrackSimTrackingToolBase::FPGATrackSimTrackingToolBase(const std::string& type, const std::string& name, const IInterface* parent)
7 : base_class(type, name, parent)
8{
9}
10
11StatusCode FPGATrackSimTrackingToolBase::setRoadSectors(std::vector<FPGATrackSimRoad> & roads)
12{
13 for (auto& road: roads)
14 {
15 if (m_useSectors) {
16 if(! m_do2ndStage)
17 road.setSector(m_FPGATrackSimBank->SectorBank_1st()->findSector(road.getAllHits()));
18 else
19 road.setSector(m_FPGATrackSimBank->SectorBank_2nd()->findSector(road.getAllHits()));
20 }
22 }
23 // Spacepoint road filter tool. Needed when fitting to spacepoints.
25 {
26 std::vector<FPGATrackSimRoad> postfilter_roads;
27 ATH_CHECK(m_spRoadFilterTool->filterRoads(roads, postfilter_roads));
28 roads = std::move(postfilter_roads);
29 }
30 return StatusCode::SUCCESS;
31}
32
33
34
36{
37 // We now look up the binning information in the sector bank.
38 const FPGATrackSimSectorBank* sectorbank = nullptr;
39 if(! m_do2ndStage)
40 sectorbank = m_FPGATrackSimBank->SectorBank_1st();
41 else
42 sectorbank = m_FPGATrackSimBank->SectorBank_2nd();
43
44 // Look up q/pt (or |q/pt|) from the Hough road, convert to MeV.
45 double qoverpt = r.getY()*0.001;
46 if (sectorbank->isAbsQOverPtBinning()) {
47 qoverpt = std::abs(qoverpt);
48 }
49
50 // Retrieve the bin boundaries from the sector bank; map this onto them.
51 const std::vector<double> &qoverpt_bins = sectorbank->getQOverPtBins();
52 auto bounds = std::equal_range(qoverpt_bins.begin(), qoverpt_bins.end(), qoverpt);
53
54 // estimate sectorbin
55 int sectorbin = fpgatracksim::QPT_SECTOR_OFFSET * (bounds.first - qoverpt_bins.begin() - 1);
56 sectorbin = std::clamp(sectorbin, 0, 10 * static_cast<int>(qoverpt_bins.size() - 2));
57 if (m_do2ndStage) sectorbin = 0;
58
60 int subregion = r.getSubRegion();
61 sectorbin += subregion*fpgatracksim::SUBREGION_SECTOR_OFFSET;
62 }
63
64 std::vector<module_t> modules(r.getNLayers(), -1);
65 layer_bitmask_t wc_layers = r.getWCLayers();
66 for (unsigned int il = 0; il < r.getNLayers(); il++) {
67 if (r.getNHits_layer()[il] == 0) {
68
69 // set corresponding bit to 1 in case of wc in the current layer
70 wc_layers |= (0x1 << il);
71
72 std::unique_ptr<FPGATrackSimHit> wcHit = std::make_unique<FPGATrackSimHit>();
73 wcHit->setHitType(HitType::wildcard);
74 wcHit->setLayer(il);
75 if(! m_do2ndStage)
76 wcHit->setDetType(m_FPGATrackSimMapping->PlaneMap_1st(0)->getDetType(il));
77 else
78 wcHit->setDetType(m_FPGATrackSimMapping->PlaneMap_2nd(0)->getDetType(il));
79
80 // Now store wc hit in a "std::vector<std::shared_ptr<const FPGATrackSimHit>>" format.
81 // We can probably avoid initializing an intermediate variable wcHits as we used to do
82 r.setHits(il,{std::move(wcHit)});
83 }
84 else {
85 modules[il]= sectorbin;
86 }
87 }
88 r.setWCLayers(wc_layers);
89
90
91 // If we are using eta patterns. We need to first run the roads through the road filter.
92 // Then the filter will be responsible for setting the actual sector.
93 // As a hack, we can store the sector bin ID in the road for now.
94 // This is fragile! If we want to store a different ID for each layer, it will break.
95
96 // Similarly, we do the same thing for spacepoints. this probably means we can't combine the two.
97 // maybe better to store the module array instead of just a number?
98
99 r.setSectorBin(sectorbin);
101 r.setSector(sectorbank->findSector(modules));
102 }
103}
#define ATH_CHECK
Evaluate an expression and check for errors.
uint32_t layer_bitmask_t
const std::vector< double > & getQOverPtBins() const
sector_t findSector(std::vector< module_t > const &modules) const
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBank
ToolHandle< IFPGATrackSimRoadFilterTool > m_spRoadFilterTool
void matchIdealGeoSector(FPGATrackSimRoad &r)
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
StatusCode setRoadSectors(std::vector< FPGATrackSimRoad > &roads)
FPGATrackSimTrackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
int r
Definition globals.cxx:22
constexpr int QPT_SECTOR_OFFSET
constexpr int SUBREGION_SECTOR_OFFSET