ATLAS Offline Software
RIO_OnTrackCreator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // RIO_OnTrackCreator.cxx
7 // AlgTool for adapting a RIO to a track candidate. It
8 // automatically selects the corresponding subdet correction.
10 // (c) ATLAS Detector software
12 // 2004 - now: Wolfgang Liebig <http://consult.cern.ch/xwho/people/54608>
14 
15 // --- the base class
19 // --- Gaudi stuff
20 #include "GaudiKernel/TypeNameString.h"
22 #include "Identifier/Identifier.h"
23 
27  const std::string& n,
28  const IInterface* p)
29  : AthAlgTool(t,n,p){}
30 
31 // destructor
33 
34 // initialise
36 {
37  if (AlgTool::initialize().isFailure()) return StatusCode::FAILURE;
38 
39  if (m_mode == "all") {
40  m_enumMode = Mode::all;
41  } else if (m_mode == "indet") {
42  m_enumMode = Mode::indet;
43  } else if (m_mode == "muon") {
44  m_enumMode = Mode::muon;
45  } else {
46  m_enumMode = Mode::invalid;
47  }
48 
49  if (m_enumMode == Mode::invalid) {
50  ATH_MSG_FATAL("Mode is set to unknown value " << m_mode);
51  return StatusCode::FAILURE;
52  }
53 
54  ATH_MSG_INFO("Mode is set to :" <<m_mode);
55 
56  // Get the correction tool to create Pixel/SCT/TRT RIO_onTrack
57  if (m_enumMode == Mode::all || m_enumMode == Mode::indet) {
58  if (!m_pixClusCor.empty()) {
59  ATH_CHECK(m_pixClusCor.retrieve());
60  } else {
61  m_doPixel = false;
62  }
63 
64  if (!m_sctClusCor.empty()) {
65  ATH_CHECK(m_sctClusCor.retrieve());
66  } else {
67  m_doSCT = false;
68  }
69 
70  if (!m_trt_Cor.empty()) {
71  ATH_CHECK(m_trt_Cor.retrieve());
72  } else {
73  m_doTRT = false;
74  }
75  } else {
76  m_trt_Cor.disable();
77  m_pixClusCor.disable();
78  m_sctClusCor.disable();
79  }
80 
81  if (m_enumMode == Mode::all || m_enumMode == Mode::muon) {
82  ATH_CHECK(m_muonDriftCircleCor.retrieve());
83  ATH_CHECK(m_muonClusterCor.retrieve());
84  } else {
85  m_muonClusterCor.disable();
86  m_muonDriftCircleCor.disable();
87  }
88 
89  // Set up ATLAS ID helper to be able to identify the RIO's det-subsystem.
90  ATH_CHECK(detStore()->retrieve(m_idHelper, "AtlasID"));
91 
92  return StatusCode::SUCCESS;
93 }
94 
95 // The sub-detector brancher algorithm
98  const TrackParameters& trk,
99  const EventContext& ctx) const
100 {
101 
102  Identifier id;
103  id = rio.identify();
104 
105  // --- print RIO
106  ATH_MSG_VERBOSE ("RIO ID prints as "<<m_idHelper->print_to_string(id));
107  ATH_MSG_VERBOSE ("RIO.locP = ("<<rio.localPosition().x()<<","<<rio.localPosition().y()<<")");
108 
109  if (m_doPixel && m_idHelper->is_pixel(id)) {
110  if (m_enumMode == Mode::muon) {
112  "No tool to correct the current Pixel hit! return nullptr");
113  return nullptr;
114  }
115  return m_pixClusCor->correct(rio, trk, ctx);
116  }
117 
118  if (m_doSCT && m_idHelper->is_sct(id)) {
119  if (m_enumMode == Mode::muon) {
121  "No tool to correct the current SCT hit! - Giving back nullptr.");
122  return nullptr;
123  }
124  return m_sctClusCor->correct(rio, trk, ctx);
125  }
126 
127  if (m_doTRT && m_idHelper->is_trt(id)) {
128  if (m_enumMode == Mode::muon) {
130  "No tool to correct a TRT DriftCircle! - Giving back nullptr.");
131  return nullptr;
132  }
133  return m_trt_Cor->correct(rio, trk, ctx);
134  }
135 
136  if (m_idHelper->is_mdt(id)) {
137  if (m_enumMode == Mode::indet) {
139  "No tool to correct a MDT DriftCircle! - Giving back nullptr.");
140  return nullptr;
141  }
142  return m_muonDriftCircleCor->correct(rio, trk, ctx);
143  }
144 
145  if ((m_idHelper->is_csc(id)) || (m_idHelper->is_rpc(id)) ||
146  (m_idHelper->is_tgc(id)) || (m_idHelper->is_mm(id)) ||
147  (m_idHelper->is_stgc(id))) {
148  if (m_enumMode == Mode::indet) {
149  ATH_MSG_WARNING("No tool to correct a CSC/RPC/TGC/MM/sTGC hit! - Giving back nullptr.");
150  return nullptr;
151  }
152  return m_muonClusterCor->correct(rio, trk, ctx);
153  }
154 
155  ATH_MSG_WARNING("idHelper could not identify sub-detector for: "
156  << m_idHelper->print_to_string(id)
157  << ". Return nil RIO_OnTrack");
158  return nullptr;
159 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
initialize
void initialize()
Definition: run_EoverP.cxx:894
Trk::RIO_OnTrackCreator::RIO_OnTrackCreator
RIO_OnTrackCreator(const std::string &, const std::string &, const IInterface *)
standard AlgTool constructor
Definition: RIO_OnTrackCreator.cxx:26
RIO_OnTrackCreator.h
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
PrepRawData.h
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk::RIO_OnTrackCreator::initialize
virtual StatusCode initialize() override
get specific ROT tools and the AtlasIdHelper
Definition: RIO_OnTrackCreator.cxx:35
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
RIO_OnTrack.h
Trk::RIO_OnTrackCreator::~RIO_OnTrackCreator
virtual ~RIO_OnTrackCreator()
virtual destructor
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
Trk::RIO_OnTrackCreator::correct
RIO_OnTrack * correct(const PrepRawData &, const TrackParameters &, const EventContext &ctx) const override
the master method for going from RIO to ROT.
Definition: RIO_OnTrackCreator.cxx:97
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14