Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FPGATrackSimMappingSvc.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
6 
7 FPGATrackSimMappingSvc::FPGATrackSimMappingSvc(const std::string& name, ISvcLocator*svc) :
8  base_class(name, svc),
9  m_EvtSel("FPGATrackSimEventSelectionSvc", name)
10 {
11 }
12 
13 
15 {
16  if (m_pmap_path.value().empty())
17  ATH_MSG_FATAL("Main plane map definition missing");
18  else if (m_rmap_path.value().empty())
19  ATH_MSG_FATAL("Missing region map path");
20  else if (m_modulelut_path.value().empty())
21  ATH_MSG_FATAL("Module LUT file is missing");
22  else
23  return StatusCode::SUCCESS;
24 
25  return StatusCode::FAILURE;
26 }
27 
28 
30 {
31  if (m_pmap_vector_1st.empty())
32  {
33  ATH_MSG_FATAL("Error using 1st stage plane map no elements of vector made: " << m_pmap_vector_1st);
34  return StatusCode::FAILURE;
35  }
36  if (!m_numberOfPmaps){
37  ATH_MSG_FATAL("Error with declared number of plane maps: " << m_pmap_path);
38  return StatusCode::FAILURE;
39  }
40  if (m_numberOfPmaps != (m_pmap_vector_1st.size())){
41  ATH_MSG_FATAL("Error using number of declared plane maps does not equal number of loaded plane maps: " << m_pmap_path<<"=/="<<m_pmap_vector_1st.size());
42  return StatusCode::FAILURE;
43  }
44  for (size_t a = 0 ; a < m_pmap_vector_1st.size() ;a++)
45  {
46  if(!m_pmap_vector_1st.at(a)){
47  ATH_MSG_FATAL("Error using 1st stage plane map for slice: " << a <<" of "<< m_pmap_vector_1st.size());
48  return StatusCode::FAILURE;
49  }
50  }
51  if (m_pmap_vector_2nd.empty())
52  {
53  ATH_MSG_FATAL("Error using 2nd stage plane map no elements of vector made: " << m_pmap_vector_2nd);
54  return StatusCode::FAILURE;
55  }
56  if (!m_numberOfPmaps){
57  ATH_MSG_FATAL("Error with declared number of plane maps: " << m_pmap_path);
58  return StatusCode::FAILURE;
59  }
60  if (m_numberOfPmaps != (m_pmap_vector_2nd.size())){
61  ATH_MSG_FATAL("Error using number of declared plane maps does not equal number of loaded plane maps: " << m_pmap_path<<"=/="<<m_pmap_vector_2nd.size());
62  return StatusCode::FAILURE;
63  }
64  for (size_t a = 0 ; a < m_pmap_vector_2nd.size() ;a++)
65  {
66  if(!m_pmap_vector_2nd.at(a)){
67  ATH_MSG_FATAL("Error using 1st stage plane map for slice: " << a <<" of "<< m_pmap_vector_2nd.size());
68  return StatusCode::FAILURE;
69  }
70  }
71  if (!m_rmap_1st){
72  ATH_MSG_FATAL("Error creating region map for 1st stage from: " << m_rmap_path);
73  return StatusCode::FAILURE;
74  }
75  if (!m_rmap_2nd){
76  ATH_MSG_FATAL("Error creating region map for 2nd stage from: " << m_rmap_path);
77  return StatusCode::FAILURE;
78  }
79  if (!m_subrmap){
80  ATH_MSG_FATAL("Error creating sub-region map from: " << m_subrmap_path);
81  return StatusCode::FAILURE;
82  }
83  if (!m_subrmap_2nd){
84  ATH_MSG_FATAL("Error creating second stage sub-region map from: " << m_subrmap_path);
85  return StatusCode::FAILURE;
86  }
87  return StatusCode::SUCCESS;
88 }
89 
90 
92  if (m_NNmap_fake != nullptr) {
93  return m_NNmap_fake->getNNMap();
94  }
95  else{
96  return ""; // Handle null case appropriately
97  }
98 }
99 
101  if (m_NNmap_extension_vol != nullptr) {
102  return m_NNmap_extension_vol->getNNMap();
103  }
104  else{
105  return ""; // Handle null case appropriately
106  }
107 }
108 
110  if (m_NNmap_extension_hit != nullptr) {
111  return m_NNmap_extension_hit->getNNMap();
112  }
113  else{
114  return ""; // Handle null case appropriately
115  }
116 }
117 
119  if (m_NNmap_param != nullptr) {
120  return m_NNmap_param->getNNMap();
121  }
122  else{
123  return ""; // Handle null case appropriately
124  }
125 }
126 
127 
128 int FPGATrackSimMappingSvc::countPmapSize(std::ifstream& fileIn)
129 {
130  std::string line;
131 
132  getline(fileIn, line);
133  std::istringstream sline(line);
134  std::string geoKeyCheck;
135  sline >> geoKeyCheck;
136  m_numberOfPmaps = 1;
137  while (getline(fileIn,line)){
138  std::istringstream sline(line);
139  std::string geoKeyCandidate;
140  sline >> geoKeyCandidate;
141  if(geoKeyCheck.compare(geoKeyCandidate)==0){
142  m_numberOfPmaps++;
143  }
144  }
145  return m_numberOfPmaps;
146 }
148 {
149  ATH_CHECK(m_EvtSel.retrieve());
151 
152  if (m_mappingType.value() == "FILE")
153  {
154  const std::string & filepath = PathResolverFindCalibFile(m_pmap_path.value());
155  std::ifstream fin(filepath);
156  if (!fin.is_open())
157  {
158  ATH_MSG_DEBUG("Couldn't open " << filepath);
159  throw ("FPGATrackSimPlaneMap Couldn't open " + filepath);
160  }
161 
163  fin.close();
164  fin.open(filepath);
165  ATH_MSG_DEBUG("Creating the 1st stage plane map");
166  for (size_t i = 0; i<m_numberOfPmaps; i++)
167  {
168  m_pmap_vector_1st.emplace_back(std::make_unique<FPGATrackSimPlaneMap>(fin, m_EvtSel->getRegionID(), 1, m_layerOverrides));
169  }
170 
171  fin.close();
172  fin.open(filepath);
173  ATH_MSG_DEBUG("Creating the 2nd stage plane map");
174  for (size_t i = 0; i<m_numberOfPmaps; i++)
175  {
176  m_pmap_vector_2nd.emplace_back(std::make_unique<FPGATrackSimPlaneMap>(fin, m_EvtSel->getRegionID(), 2, m_layerOverrides));
177  }
178  fin.close();
179 
180  ATH_MSG_DEBUG("Creating the 1st stage region map");
181  m_rmap_1st = std::unique_ptr<FPGATrackSimRegionMap>(new FPGATrackSimRegionMap(m_pmap_vector_1st, PathResolverFindCalibFile(m_rmap_path.value())));
182 
183  ATH_MSG_DEBUG("Creating the 2nd stage region map");
184  m_rmap_2nd = std::unique_ptr<FPGATrackSimRegionMap>(new FPGATrackSimRegionMap(m_pmap_vector_2nd, PathResolverFindCalibFile(m_rmap_path.value())));
185 
186  ATH_MSG_DEBUG("Creating the sub-region map");
187  m_subrmap = std::unique_ptr<FPGATrackSimRegionMap>(new FPGATrackSimRegionMap(m_pmap_vector_1st, PathResolverFindCalibFile(m_subrmap_path.value())));
188 
189  ATH_MSG_DEBUG("Creating the 2nd stage sub-region map");
190  m_subrmap_2nd = std::make_unique<FPGATrackSimRegionMap>(m_pmap_vector_2nd, PathResolverFindCalibFile(m_subrmap_path.value()));
191 
192  ATH_MSG_DEBUG("Setting the Modules LUT for Region Maps");
193  m_rmap_1st->loadModuleIDLUT(PathResolverFindCalibFile(m_modulelut_path.value()));
194  m_rmap_2nd->loadModuleIDLUT(PathResolverFindCalibFile(m_modulelut_path.value()));
195 
196  ATH_MSG_DEBUG("Setting the average radius per logical layer for Region and Subregion Maps");
197  m_rmap_1st->loadRadiiFile(PathResolverFindCalibFile(m_radii_path.value()));
198  m_rmap_2nd->loadRadiiFile(PathResolverFindCalibFile(m_radii_path.value()));
199  m_subrmap->loadRadiiFile(PathResolverFindCalibFile(m_radii_path.value()));
200  m_rmap_2nd->loadRadiiFile(PathResolverFindCalibFile(m_radii_path.value()));
201  m_subrmap_2nd->loadRadiiFile(PathResolverFindCalibFile(m_radii_path.value()));
202 
203  ATH_MSG_DEBUG("Creating NN weighting map");
204  ATH_MSG_INFO("MappingSVc using " << m_NNmap_path_fake.value() << " for fake track estimation");
205  ATH_MSG_INFO("MappingSVc using " << m_NNmap_path_param.value() << " for track parameter estimation");
206  ATH_MSG_INFO("MappingSVc using " << m_NNmap_path_extension_vol.value() << " for track extension");
207  ATH_MSG_INFO("MappingSVc using " << m_NNmap_path_extension_hit.value() << " for track extension");
208 
209  if ( ! m_NNmap_path_fake.empty() ) {
210  m_NNmap_fake = std::make_unique<FPGATrackSimNNMap>(PathResolverFindCalibFile(m_NNmap_path_fake.value()));
211  } else {
212  m_NNmap_fake = nullptr;
213  }
214 
215  if ( ! m_NNmap_path_extension_vol.empty() ) {
216  m_NNmap_extension_vol = std::make_unique<FPGATrackSimNNMap>(PathResolverFindCalibFile(m_NNmap_path_extension_vol.value()));
217  } else {
218  m_NNmap_extension_vol = nullptr;
219  }
220 
221  if ( ! m_NNmap_path_extension_hit.empty() ) {
222  m_NNmap_extension_hit = std::make_unique<FPGATrackSimNNMap>(PathResolverFindCalibFile(m_NNmap_path_extension_hit.value()));
223  } else {
224  m_NNmap_extension_hit = nullptr;
225  }
226 
227  if ( ! m_NNmap_path_param.empty() ) {
228  m_NNmap_param = std::make_unique<FPGATrackSimNNMap>(PathResolverFindCalibFile(m_NNmap_path_param.value()));
229  } else {
230  m_NNmap_param = nullptr;
231  }
232  }
234  return StatusCode::SUCCESS;
235 }
236 
237 
FPGATrackSimMappingSvc::m_NNmap_path_fake
Gaudi::Property< std::string > m_NNmap_path_fake
Definition: FPGATrackSimMappingSvc.h:52
FPGATrackSimMappingSvc::m_rmap_2nd
std::unique_ptr< FPGATrackSimRegionMap > m_rmap_2nd
Definition: FPGATrackSimMappingSvc.h:66
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
checkFileSG.line
line
Definition: checkFileSG.py:75
FPGATrackSimMappingSvc::FPGATrackSimMappingSvc
FPGATrackSimMappingSvc(const std::string &name, ISvcLocator *svc)
Definition: FPGATrackSimMappingSvc.cxx:7
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimMappingSvc::m_NNmap_path_extension_hit
Gaudi::Property< std::string > m_NNmap_path_extension_hit
Definition: FPGATrackSimMappingSvc.h:54
FPGATrackSimMappingSvc::m_NNmap_fake
std::unique_ptr< FPGATrackSimNNMap > m_NNmap_fake
Definition: FPGATrackSimMappingSvc.h:69
FPGATrackSimMappingSvc::m_numberOfPmaps
size_t m_numberOfPmaps
Definition: FPGATrackSimMappingSvc.h:74
FPGATrackSimMappingSvc::m_radii_path
Gaudi::Property< std::string > m_radii_path
Definition: FPGATrackSimMappingSvc.h:56
FPGATrackSimMappingSvc::checkAllocs
StatusCode checkAllocs()
Definition: FPGATrackSimMappingSvc.cxx:29
FPGATrackSimMappingSvc::m_rmap_1st
std::unique_ptr< FPGATrackSimRegionMap > m_rmap_1st
Definition: FPGATrackSimMappingSvc.h:65
FPGATrackSimMappingSvc::m_NNmap_path_extension_vol
Gaudi::Property< std::string > m_NNmap_path_extension_vol
Definition: FPGATrackSimMappingSvc.h:53
FPGATrackSimMappingSvc::getParamNNMapString
virtual std::string getParamNNMapString() const override
Definition: FPGATrackSimMappingSvc.cxx:118
FPGATrackSimMappingSvc::m_layerOverrides
Gaudi::Property< std::vector< int > > m_layerOverrides
Definition: FPGATrackSimMappingSvc.h:57
FPGATrackSimMappingSvc::m_subrmap_2nd
std::unique_ptr< FPGATrackSimRegionMap > m_subrmap_2nd
Definition: FPGATrackSimMappingSvc.h:68
FPGATrackSimMappingSvc::getFakeNNMapString
virtual std::string getFakeNNMapString() const override
Definition: FPGATrackSimMappingSvc.cxx:91
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimMappingSvc::m_pmap_path
Gaudi::Property< std::string > m_pmap_path
Definition: FPGATrackSimMappingSvc.h:50
FPGATrackSimMappingSvc::m_NNmap_extension_hit
std::unique_ptr< FPGATrackSimNNMap > m_NNmap_extension_hit
Definition: FPGATrackSimMappingSvc.h:72
FPGATrackSimMappingSvc::m_EvtSel
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_EvtSel
Definition: FPGATrackSimMappingSvc.h:43
FPGATrackSimMappingSvc::m_modulelut_path
Gaudi::Property< std::string > m_modulelut_path
Definition: FPGATrackSimMappingSvc.h:51
FPGATrackSimMappingSvc::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimMappingSvc.cxx:147
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
FPGATrackSimMappingSvc::getExtensionNNHitMapString
virtual std::string getExtensionNNHitMapString() const override
Definition: FPGATrackSimMappingSvc.cxx:109
FPGATrackSimMappingSvc::m_NNmap_path_param
Gaudi::Property< std::string > m_NNmap_path_param
Definition: FPGATrackSimMappingSvc.h:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
FPGATrackSimMappingSvc::m_pmap_vector_1st
std::vector< std::unique_ptr< FPGATrackSimPlaneMap > > m_pmap_vector_1st
Definition: FPGATrackSimMappingSvc.h:61
PathResolver.h
FPGATrackSimMappingSvc::m_rmap_path
Gaudi::Property< std::string > m_rmap_path
Definition: FPGATrackSimMappingSvc.h:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FPGATrackSimMappingSvc::getExtensionNNVolMapString
virtual std::string getExtensionNNVolMapString() const override
Definition: FPGATrackSimMappingSvc.cxx:100
FPGATrackSimMappingSvc::m_pmap_vector_2nd
std::vector< std::unique_ptr< FPGATrackSimPlaneMap > > m_pmap_vector_2nd
Definition: FPGATrackSimMappingSvc.h:62
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
FPGATrackSimMappingSvc::m_mappingType
Gaudi::Property< std::string > m_mappingType
Definition: FPGATrackSimMappingSvc.h:47
FPGATrackSimMappingSvc::m_subrmap_path
Gaudi::Property< std::string > m_subrmap_path
Definition: FPGATrackSimMappingSvc.h:49
a
TList * a
Definition: liststreamerinfos.cxx:10
FPGATrackSimMappingSvc::m_NNmap_extension_vol
std::unique_ptr< FPGATrackSimNNMap > m_NNmap_extension_vol
Definition: FPGATrackSimMappingSvc.h:71
IFPGATrackSimEventSelectionSvc.h
FPGATrackSimMappingSvc::m_subrmap
std::unique_ptr< FPGATrackSimRegionMap > m_subrmap
Definition: FPGATrackSimMappingSvc.h:67
FPGATrackSimMappingSvc::checkInputs
StatusCode checkInputs()
Definition: FPGATrackSimMappingSvc.cxx:14
compute_lumi.fin
fin
Definition: compute_lumi.py:19
FPGATrackSimRegionMap
Definition: FPGATrackSimRegionMap.h:62
FPGATrackSimMappingSvc.h
FPGATrackSimMappingSvc::m_NNmap_param
std::unique_ptr< FPGATrackSimNNMap > m_NNmap_param
Definition: FPGATrackSimMappingSvc.h:70
FPGATrackSimMappingSvc::countPmapSize
int countPmapSize(std::ifstream &fileIn)
Definition: FPGATrackSimMappingSvc.cxx:128