ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
FPGATrackSim
FPGATrackSimMaps
src
FPGATrackSimSlicingEngineTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <array>
6
#include <vector>
7
8
#include "
FPGATrackSimMaps/FPGATrackSimSlicingEngineTool.h
"
9
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
10
#include "
FPGATrackSimMaps/FPGATrackSimRegionMap.h
"
11
#include "
FPGATrackSimObjects/FPGATrackSimTowerInputHeader.h
"
12
#include <nlohmann/json.hpp>
13
14
FPGATrackSimSlicingEngineTool::FPGATrackSimSlicingEngineTool
(std::string
const
& algname, std::string
const
& name, IInterface
const
* ifc) :
15
AthAlgTool
(algname,name,ifc) {}
16
17
18
StatusCode
FPGATrackSimSlicingEngineTool::initialize
()
19
{
20
ATH_MSG_INFO
(
"Reading first stage module/layer map in slicing engine: "
<<
m_layerMap
);
21
if
(
m_doSecondStage
)
readLayerMap
();
22
return
StatusCode::SUCCESS;
23
}
24
25
void
FPGATrackSimSlicingEngineTool::readLayerMap
() {
26
// Adapted from FPGATrackSimBinnedHits
27
std::ifstream stream(
m_layerMap
);
28
nlohmann::json data = nlohmann::json::parse(stream);
29
30
std::set<unsigned> modules;
31
32
// Loop over entries in the layer map.
33
for
(
const
auto
&binelem : data) {
34
std::vector<unsigned>
bin
;
35
binelem.at(
"bin"
).get_to(
bin
);
36
auto
& lyrmap = binelem[
"lyrmap"
];
37
ATH_MSG_DEBUG
(
"bin = "
<<
bin
);
38
ATH_MSG_DEBUG
(
"lyrmap = "
<< lyrmap);
39
for
(
auto
&lyrelem : lyrmap) {
40
unsigned
layer;
41
lyrelem.at(
"lyr"
).get_to(layer);
42
lyrelem.at(
"mods"
).get_to(modules);
43
ATH_MSG_DEBUG
(
"layer = "
<< layer);
44
ATH_MSG_DEBUG
(
"mods = "
<< modules);
45
46
// Build a single set containing all module ID hashes used in the layer map.
47
// NOTE: this assumes the pixel module hashes are all unique?
48
m_layerMapModules
.merge(modules);
49
}
50
}
51
52
ATH_MSG_DEBUG
(
"Region Modules: "
<<
m_layerMapModules
);
53
}
54
55
// While this method returns *two* streams, it outputs *three* branches since in the firmware
56
// second stage pixels and strips will probably be split.
57
void
FPGATrackSimSlicingEngineTool::sliceHits
(
const
std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits,
58
std::vector<std::shared_ptr<const FPGATrackSimHit>>& firstHits,
59
std::vector<std::shared_ptr<const FPGATrackSimHit>>& secondHits,
60
std::vector<const FPGATrackSimHit*>& stripHits) {
61
62
const
FPGATrackSimRegionMap
* rmap_1st =
m_FPGATrackSimMapping
->SubRegionMap();
63
const
FPGATrackSimRegionMap
* rmap_2nd =
m_FPGATrackSimMapping
->SubRegionMap_2nd();
64
65
// NOTE: this now assumes that there is ONE "slice" for each of the three configurations (1st pixels,
66
// 2nd pixels, strips). the subregion map is NO LONGER USED.
67
if
(
m_rootOutput
) {
68
FPGATrackSimTowerInputHeader
towerFirstPixel =
FPGATrackSimTowerInputHeader
(0);
69
FPGATrackSimTowerInputHeader
towerSecondPixel =
FPGATrackSimTowerInputHeader
(0);
70
m_slicedFirstPixelHeader
->addTower(towerFirstPixel);
71
m_slicedSecondPixelHeader
->addTower(towerSecondPixel);
72
}
73
74
// We need to process the strips into a header object no matter what.
75
FPGATrackSimTowerInputHeader
towerStrips =
FPGATrackSimTowerInputHeader
(0);
76
m_slicedStripHeader
->addTower(towerStrips);
77
78
// Loop over all of the hits. Test if they pass region boundaries or not.
79
for
(
const
std::shared_ptr<const FPGATrackSimHit>&
hit
: hits) {
80
// If the hit falls within the boundaries of ANY subregion in the first or second stage,
81
// it's to be considered "IN REGION". Technically the second stage *should* be a superset
82
// of the first stage but let's be redundant to be safe here.
83
if
((rmap_1st->
getRegions
(*hit).size() == 0) && (rmap_2nd->
getRegions
(*hit).size() == 0)) {
84
continue
;
85
}
86
87
// Test if the remaining hit is strip or pixel, sort accordingly.
88
// If doSecondStage is false, then all hits are first stage-- so don't worry about the layer map.
89
if
(
hit
->isPixel()) {
90
// In this case, test using the layer map (if we are doing second stage).
91
if
(!
m_doSecondStage
||
m_layerMapModules
.contains(
hit
->getIdentifierHash())) {
92
firstHits.push_back(
hit
);
93
if
(
m_rootOutput
)
m_slicedFirstPixelHeader
->getTower(0)->addHit(*
hit
);
94
}
95
if
(
m_doSecondStage
) {
96
secondHits.push_back(
hit
);
97
if
(
m_rootOutput
)
m_slicedSecondPixelHeader
->getTower(0)->addHit(*
hit
);
98
}
99
}
else
{
100
// Strip hits need to be post-processed in LogicalHitsProcessAlg, so we only put them in a header here.
101
// Unfortunately this has to happen no matter what.
102
// Also populate stripHits vector with pointers to strip hits from the input collection
103
stripHits.push_back(
hit
.get());
104
m_slicedStripHeader
->getTower(0)->addHit(*
hit
);
105
}
106
}
107
108
ATH_MSG_DEBUG
(
"From "
<< hits.size() <<
" total input hits, sent "
<< firstHits.size() <<
" ("
<< secondHits.size() <<
") to first (second) stage in region"
);
109
}
AthMsgStreamMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
FPGATrackSimRegionMap.h
Maps ITK module indices to FPGATrackSim regions.
FPGATrackSimSlicingEngineTool.h
FPGATrackSimTowerInputHeader.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
FPGATrackSimRegionMap
Definition
FPGATrackSimRegionMap.h:62
FPGATrackSimRegionMap::getRegions
std::vector< uint32_t > getRegions(const FPGATrackSimHit &hit) const
Definition
FPGATrackSimRegionMap.cxx:305
FPGATrackSimSlicingEngineTool::m_slicedSecondPixelHeader
FPGATrackSimLogicalEventInputHeader * m_slicedSecondPixelHeader
Definition
FPGATrackSimSlicingEngineTool.h:56
FPGATrackSimSlicingEngineTool::m_layerMapModules
std::set< unsigned > m_layerMapModules
Definition
FPGATrackSimSlicingEngineTool.h:61
FPGATrackSimSlicingEngineTool::m_doSecondStage
Gaudi::Property< bool > m_doSecondStage
Definition
FPGATrackSimSlicingEngineTool.h:51
FPGATrackSimSlicingEngineTool::m_rootOutput
Gaudi::Property< bool > m_rootOutput
Definition
FPGATrackSimSlicingEngineTool.h:49
FPGATrackSimSlicingEngineTool::initialize
virtual StatusCode initialize() override
Definition
FPGATrackSimSlicingEngineTool.cxx:18
FPGATrackSimSlicingEngineTool::m_layerMap
Gaudi::Property< std::string > m_layerMap
Definition
FPGATrackSimSlicingEngineTool.h:50
FPGATrackSimSlicingEngineTool::m_slicedFirstPixelHeader
FPGATrackSimLogicalEventInputHeader * m_slicedFirstPixelHeader
Definition
FPGATrackSimSlicingEngineTool.h:55
FPGATrackSimSlicingEngineTool::m_slicedStripHeader
FPGATrackSimLogicalEventInputHeader * m_slicedStripHeader
Definition
FPGATrackSimSlicingEngineTool.h:57
FPGATrackSimSlicingEngineTool::FPGATrackSimSlicingEngineTool
FPGATrackSimSlicingEngineTool(const std::string &, const std::string &, const IInterface *)
Definition
FPGATrackSimSlicingEngineTool.cxx:14
FPGATrackSimSlicingEngineTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition
FPGATrackSimSlicingEngineTool.h:47
FPGATrackSimSlicingEngineTool::readLayerMap
void readLayerMap()
Definition
FPGATrackSimSlicingEngineTool.cxx:25
FPGATrackSimSlicingEngineTool::sliceHits
void sliceHits(const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits, std::vector< std::shared_ptr< const FPGATrackSimHit > > &firstHits, std::vector< std::shared_ptr< const FPGATrackSimHit > > &secondHits, std::vector< const FPGATrackSimHit * > &stripHits)
Definition
FPGATrackSimSlicingEngineTool.cxx:57
FPGATrackSimTowerInputHeader
Definition
FPGATrackSimTowerInputHeader.h:18
bin
Definition
BinsDiffFromStripMedian.h:43
Generated on
for ATLAS Offline Software by
1.17.0