ATLAS Offline Software
FPGATrackSimTrackFitterTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
6 
7 #include "GaudiKernel/MsgStream.h"
8 
9 #include <sstream>
10 #include <iostream>
11 #include <fstream>
12 
15  const std::string& name,
16  const IInterface* parent)
18 {
19 }
20 
21 
22 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
24 {
25  ATH_MSG_DEBUG("FPGATrackSimTrackFitterTool::initialize()");
26 
27  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
28  ATH_CHECK(m_FPGATrackSimBank.retrieve());
29  if (m_useSpacePoints) ATH_CHECK(m_spRoadFilterTool.retrieve(EnableTool{m_spRoadFilterTool}));
30 
31  const FPGATrackSimFitConstantBank* nominalbank;
32  std::vector<const FPGATrackSimFitConstantBank*> bankvec;
33  if(!m_do2ndStage){
34  nominalbank = m_FPGATrackSimBank->FitConstantBank_1st();
35  if (!m_guessHits) {
36  for (unsigned int iplane = 0; iplane < m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers(); iplane++) {
37  const FPGATrackSimFitConstantBank* bank = m_FPGATrackSimBank->FitConstantBank_1st(iplane);
38  bankvec.push_back(bank);
39  }
40  }
41  }
42  else {
43  nominalbank = m_FPGATrackSimBank->FitConstantBank_2nd();
44  if (!m_guessHits) {
45  for (unsigned int iplane = 0; iplane < m_FPGATrackSimMapping->PlaneMap_2nd(0)->getNLogiLayers(); iplane++) {
46  const FPGATrackSimFitConstantBank* bank = m_FPGATrackSimBank->FitConstantBank_2nd(iplane);
47  bankvec.push_back(bank);
48  }
49  }
50  }
51 
52  MsgStream m(msgSvc(), "TrackFitter");
53  m.setLevel(msg().level());
54  m_tfpobj = std::unique_ptr<TrackFitter>(new TrackFitter(nominalbank, bankvec, m_guessHits));
55 
56  if(!m_do2ndStage) {
57  m_tfpobj->setPlaneMap(m_FPGATrackSimMapping->PlaneMap_1st(0));
58  m_tfpobj->setRegionMap(m_FPGATrackSimMapping->RegionMap_1st());
59  } else {
60  m_tfpobj->setPlaneMap(m_FPGATrackSimMapping->PlaneMap_2nd(0));
61  m_tfpobj->setRegionMap(m_FPGATrackSimMapping->RegionMap_2nd());
62  }
63 
64  // set parameter object to TrackFitter
65  m_tfpobj->setChi2DofRecoveryMin(m_chi2dof_recovery_min);
66  m_tfpobj->setChi2DofRecoveryMax(m_chi2dof_recovery_max);
67 
68  m_tfpobj->setDoMajority(m_doMajority);
69 
70  m_tfpobj->setRequireFirst(0);
71  m_tfpobj->setDoSecondStage(m_do2ndStage);
72 
73  m_tfpobj->setNorecoveryNhits(m_noRecoveryNHits);
74 
75  if (!m_guessHits && m_doMissingHitsChecks) ATH_MSG_WARNING("We can't do missing hits check if we don't guess hits");
76  m_tfpobj->setDoMissingHitsCheck(m_doMissingHitsChecks);
77  m_tfpobj->setIdealCoordFitType(static_cast<TrackCorrType>(m_idealCoordFitType.value()));
78  m_tfpobj->setDoDeltaGPhis(m_doDeltaGPhis);
79 
80  return StatusCode::SUCCESS;
81 }
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
84 StatusCode FPGATrackSimTrackFitterTool::getTracks(std::vector<std::shared_ptr<const FPGATrackSimRoad>>& roads, std::vector<FPGATrackSimTrack>& tracks) {
85  // elaborate the next event
86  ATH_CHECK(setRoadSectors(roads));
87  int status = m_tfpobj->fitTracks(roads,tracks);
88  if (status != FITTRACKS_OK) return StatusCode::FAILURE;
89 
90  if (msgLvl(MSG::DEBUG))
91  {
92  ATH_MSG_DEBUG("getTracks() returning " << tracks.size() << " tracks:");
93  for (auto & t : tracks)
94  ATH_MSG_DEBUG("\tchi2 = " << t.getChi2() << " and phi = " << t.getPhi()
95  << " and eta = " << t.getEta() << " and d0 = " << t.getD0()
96  << " and z0 = " << t.getZ0() << "and pt = " << t.getPt());
97  }
98 
99  return StatusCode::SUCCESS;
100 }
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
103 StatusCode FPGATrackSimTrackFitterTool::getMissingHitsCheckTracks(std::vector<FPGATrackSimTrack>& tracks_guessed)
104 {
105  // only call this after we first fit the tracks!
106  tracks_guessed = m_tfpobj->getMissingHitsCheckTracks();
107  return StatusCode::SUCCESS;
108 }
109 
FPGATrackSimTrackingToolBase::m_FPGATrackSimBank
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBank
Definition: FPGATrackSimTrackingToolBase.h:30
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
FPGATrackSimPlaneMap.h
Maps physical layers to logical layers.
FPGATrackSimTrackFitterTool::m_idealCoordFitType
Gaudi::Property< int > m_idealCoordFitType
Definition: FPGATrackSimTrackFitterTool.h:56
xAOD::TrackFitter
TrackFitter
Enums to identify who created this track and which properties does it have.
Definition: TrackingPrimitives.h:39
FPGATrackSimTrackFitterTool::m_guessHits
Gaudi::Property< bool > m_guessHits
Definition: FPGATrackSimTrackFitterTool.h:53
FPGATrackSimTrackFitterTool::m_chi2dof_recovery_max
Gaudi::Property< int > m_chi2dof_recovery_max
Definition: FPGATrackSimTrackFitterTool.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FPGATrackSimTrackFitterTool::m_tfpobj
std::unique_ptr< TrackFitter > m_tfpobj
Definition: FPGATrackSimTrackFitterTool.h:46
FITTRACKS_OK
#define FITTRACKS_OK
Definition: FPGATrackSimTypes.h:15
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
FPGATrackSimTrackingToolBase
Definition: FPGATrackSimTrackingToolBase.h:21
FPGATrackSimRegionMap.h
Maps ITK module indices to FPGATrackSim regions.
FPGATrackSimTrackingToolBase::setRoadSectors
StatusCode setRoadSectors(std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads)
Definition: FPGATrackSimTrackingToolBase.cxx:11
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
FPGATrackSimTrackingToolBase::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimTrackingToolBase.h:29
FPGATrackSimTrackFitterTool::m_chi2dof_recovery_min
Gaudi::Property< int > m_chi2dof_recovery_min
Definition: FPGATrackSimTrackFitterTool.h:48
FPGATrackSimTrackFitterTool::m_doMissingHitsChecks
Gaudi::Property< bool > m_doMissingHitsChecks
Definition: FPGATrackSimTrackFitterTool.h:55
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimTrackFitterTool::initialize
StatusCode initialize() override
Definition: FPGATrackSimTrackFitterTool.cxx:23
FPGATrackSimTrackingToolBase::m_useSpacePoints
Gaudi::Property< bool > m_useSpacePoints
Definition: FPGATrackSimTrackingToolBase.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FPGATrackSimFitConstantBank
Definition: FPGATrackSimFitConstantBank.h:24
FPGATrackSimTrackFitterTool::m_doMajority
Gaudi::Property< int > m_doMajority
Definition: FPGATrackSimTrackFitterTool.h:50
FPGATrackSimTrackFitterTool::m_noRecoveryNHits
Gaudi::Property< int > m_noRecoveryNHits
Definition: FPGATrackSimTrackFitterTool.h:52
FPGATrackSimTrackFitterTool::getMissingHitsCheckTracks
StatusCode getMissingHitsCheckTracks(std::vector< FPGATrackSimTrack > &tracks_guessed)
Definition: FPGATrackSimTrackFitterTool.cxx:103
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
FPGATrackSimTrackFitterTool::FPGATrackSimTrackFitterTool
FPGATrackSimTrackFitterTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimTrackFitterTool.cxx:14
merge.status
status
Definition: merge.py:17
TrackCorrType
TrackCorrType
Definition: FPGATrackSimTypes.h:37
FPGATrackSimTrackingToolBase::m_do2ndStage
Gaudi::Property< bool > m_do2ndStage
Definition: FPGATrackSimTrackingToolBase.h:40
FPGATrackSimTrackingToolBase::m_spRoadFilterTool
ToolHandle< IFPGATrackSimRoadFilterTool > m_spRoadFilterTool
Definition: FPGATrackSimTrackingToolBase.h:32
FPGATrackSimTrackFitterTool.h
FPGATrackSimTrackFitterTool::getTracks
StatusCode getTracks(std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, std::vector< FPGATrackSimTrack > &tracks)
Definition: FPGATrackSimTrackFitterTool.cxx:84
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
FPGATrackSimTrackFitterTool::m_doDeltaGPhis
Gaudi::Property< bool > m_doDeltaGPhis
Definition: FPGATrackSimTrackFitterTool.h:54