ATLAS Offline Software
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 
6 FPGATrackSimTrackingToolBase::FPGATrackSimTrackingToolBase(const std::string& type, const std::string& name, const IInterface* parent)
7  : base_class(type, name, parent)
8 {
9 }
10 
11 StatusCode 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.
25  if (m_useSpacePoints)
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 
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>();
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 }
FPGATrackSimTrackingToolBase.h
fpgatracksim::SUBREGION_SECTOR_OFFSET
constexpr int SUBREGION_SECTOR_OFFSET
Definition: FPGATrackSimConstants.h:24
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
beamspotman.r
def r
Definition: beamspotman.py:676
FPGATrackSimTrackingToolBase::m_FPGATrackSimBank
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBank
Definition: FPGATrackSimTrackingToolBase.h:30
FPGATrackSimTrackingToolBase::m_doRegionalMapping
Gaudi::Property< bool > m_doRegionalMapping
Definition: FPGATrackSimTrackingToolBase.h:34
FPGATrackSimTrackingToolBase::FPGATrackSimTrackingToolBase
FPGATrackSimTrackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FPGATrackSimTrackingToolBase.cxx:6
FPGATrackSimSectorBank::getQOverPtBins
const std::vector< double > & getQOverPtBins() const
Definition: FPGATrackSimSectorBank.h:52
HitType::wildcard
@ wildcard
FPGATrackSimTrackingToolBase::matchIdealGeoSector
void matchIdealGeoSector(FPGATrackSimRoad &r)
Definition: FPGATrackSimTrackingToolBase.cxx:36
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimTrackingToolBase::setRoadSectors
StatusCode setRoadSectors(std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads)
Definition: FPGATrackSimTrackingToolBase.cxx:11
FPGATrackSimSectorBank::findSector
sector_t findSector(std::vector< module_t > const &modules) const
Definition: FPGATrackSimSectorBank.cxx:121
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FPGATrackSimTrackingToolBase::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimTrackingToolBase.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimSectorBank
Definition: FPGATrackSimSectorBank.h:32
FPGATrackSimTrackingToolBase::m_useSpacePoints
Gaudi::Property< bool > m_useSpacePoints
Definition: FPGATrackSimTrackingToolBase.h:36
fpgatracksim::QPT_SECTOR_OFFSET
constexpr int QPT_SECTOR_OFFSET
Definition: FPGATrackSimConstants.h:23
FPGATrackSimTrackingToolBase::m_idealGeoRoads
Gaudi::Property< bool > m_idealGeoRoads
Definition: FPGATrackSimTrackingToolBase.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FPGATrackSimTrackingToolBase::m_useSectors
Gaudi::Property< bool > m_useSectors
Definition: FPGATrackSimTrackingToolBase.h:37
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
FPGATrackSimRoad::setSector
void setSector(sector_t sector)
Definition: FPGATrackSimRoad.h:59
layer_bitmask_t
uint32_t layer_bitmask_t
Definition: FPGATrackSimTypes.h:22
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FPGATrackSimSectorBank::isAbsQOverPtBinning
bool isAbsQOverPtBinning() const
Definition: FPGATrackSimSectorBank.h:54
FPGATrackSimTrackingToolBase::m_doEtaPatternConsts
Gaudi::Property< bool > m_doEtaPatternConsts
Definition: FPGATrackSimTrackingToolBase.h:35
FPGATrackSimRoad::getAllHits
const std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit > > > & getAllHits() const
Definition: FPGATrackSimRoad.h:100
FPGATrackSimTrackingToolBase::m_do2ndStage
Gaudi::Property< bool > m_do2ndStage
Definition: FPGATrackSimTrackingToolBase.h:40
FPGATrackSimTrackingToolBase::m_spRoadFilterTool
ToolHandle< IFPGATrackSimRoadFilterTool > m_spRoadFilterTool
Definition: FPGATrackSimTrackingToolBase.h:32
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:30
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54