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