ATLAS Offline Software
MuonStationNtupleHelperTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 
10 #include "TTree.h"
11 
12 //================ Constructor =================================================
13 
15  const std::string& n,
16  const IInterface* p )
17  :
18  AthAlgTool(t,n,p),
19  m_mdtSectorIx(nullptr),
20  m_mdtStationIx(nullptr),
21  m_rpcSectorIx(nullptr),
22  m_rpcStationIx(nullptr),
23  m_rpcMeasuresPhi(nullptr),
24  m_tgcStationIx(nullptr),
25  m_tgcMeasuresPhi(nullptr)
26 {
27  declareInterface<Trk::IValidationNtupleHelperTool>(this);
28 }
29 
30 //================ Initialisation =================================================
31 
33 {
34  ATH_CHECK(m_idHelperSvc.retrieve());
35 
36  m_mdtSectorIx = new std::vector<int>();
37  m_mdtStationIx = new std::vector<int>();
38  m_rpcSectorIx = new std::vector<int>();
39  m_rpcStationIx = new std::vector<int>();
40  m_rpcMeasuresPhi = new std::vector<int>();
41  m_tgcStationIx = new std::vector<int>();
42  m_tgcMeasuresPhi = new std::vector<int>();
43 
44  ATH_MSG_INFO ("initialize() successful in " << name());
45  return StatusCode::SUCCESS;
46 }
47 
48 //================ Finalisation =================================================
49 
51 {
52  delete m_mdtSectorIx; m_mdtSectorIx=nullptr;
53  delete m_mdtStationIx; m_mdtStationIx=nullptr;
54  delete m_rpcSectorIx; m_rpcSectorIx=nullptr;
55  delete m_rpcStationIx; m_rpcStationIx=nullptr;
56  delete m_rpcMeasuresPhi; m_rpcMeasuresPhi=nullptr;
57  delete m_tgcStationIx; m_tgcStationIx=nullptr;
58  delete m_tgcMeasuresPhi; m_tgcMeasuresPhi=nullptr;
59  return StatusCode::SUCCESS;
60 }
61 
66  TTree* tree,
67  const int& detectorType) {
68 
69  // add items to the ntuple
70  if (detectorType==Trk::TrackState::MDT) {
71 
72  tree->Branch("MdtSectorIndex", &m_mdtSectorIx);
73  tree->Branch("MdtStationIndex", &m_mdtStationIx);
74  }
75  if (detectorType==Trk::TrackState::RPC) {
76  tree->Branch("RpcSectorIndex", &m_rpcSectorIx);
77  tree->Branch("RpcStationIndex", &m_rpcStationIx);
78  tree->Branch("RpcMeasuresPhi", &m_rpcMeasuresPhi);
79  }
80  if (detectorType==Trk::TrackState::TGC) {
81  // TGC sectors are not defined, will cause warning if tried to compute from helper
82  tree->Branch("TgcStationIndex", &m_tgcStationIx);
83  tree->Branch("TgcMeasuresPhi", &m_tgcMeasuresPhi);
84  }
85 
86  ATH_MSG_VERBOSE ("added items to ntuple.");
87  return StatusCode::SUCCESS;
88 }
89 
94  const Trk::MeasurementBase* hit,
95  const Trk::TrackParameters* ,
96  const int& detectorType,
97  const bool& /*isOutlier*/) {
98 
99  // todo is this actually called for outliers?
100 
101  // identify the detector type:
103  using namespace Muon::MuonStationIndex;
104  const int stIdx = toInt(m_idHelperSvc->stationIndex(id));
105  if (detectorType==Trk::TrackState::MDT) {
106  m_mdtSectorIx->push_back(m_idHelperSvc->sector(id));
107  m_mdtStationIx->push_back(stIdx);
108  }
109  if (detectorType==Trk::TrackState::RPC) {
110  m_rpcSectorIx->push_back(m_idHelperSvc->sector(id));
111  m_rpcStationIx->push_back(stIdx);
112  m_rpcMeasuresPhi->push_back(m_idHelperSvc->measuresPhi(id));
113  }
114  if (detectorType==Trk::TrackState::TGC) {
115  m_tgcStationIx->push_back(stIdx);
116  m_tgcMeasuresPhi->push_back(m_idHelperSvc->measuresPhi(id));
117  }
118 
119  return StatusCode::SUCCESS;
120 }
121 
123  const int& detectorType ) {
124  if (detectorType==Trk::TrackState::MDT) {
125  m_mdtSectorIx->clear();
126  m_mdtStationIx->clear();
127  }
128  if (detectorType==Trk::TrackState::RPC) {
129  m_rpcSectorIx->clear();
130  m_rpcStationIx->clear();
131  m_rpcMeasuresPhi->clear();
132  }
133  if (detectorType==Trk::TrackState::TGC) {
134  m_tgcStationIx->clear();
135  m_tgcMeasuresPhi->clear();
136  }
137  return StatusCode::SUCCESS;
138 }
139 
142  const int&) {
143  // we do nothing with holes
144  return StatusCode::SUCCESS;
145 }
146 
Trk::TrackState::RPC
@ RPC
Definition: TrackStateDefs.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Muon::MuonStationIndex
Definition: MuonStationIndex.h:13
TrackStateDefs.h
Trk::TrackState::MDT
@ MDT
Definition: TrackStateDefs.h:31
tree
TChain * tree
Definition: tile_monitor.h:30
Trk::TrackState::TGC
@ TGC
Definition: TrackStateDefs.h:34
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
IdentifierExtractor.h
Muon::MuonStationNtupleHelperTool::MuonStationNtupleHelperTool
MuonStationNtupleHelperTool(const std::string &, const std::string &, const IInterface *)
Definition: MuonStationNtupleHelperTool.cxx:14
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
beamspotman.n
n
Definition: beamspotman.py:729
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Muon::MuonStationNtupleHelperTool::addNtupleItems
virtual StatusCode addNtupleItems(TTree *tree, const int &detectorType)
add items to the ntuple and configure the helper tool: should be called once (per detector type) by t...
Definition: MuonStationNtupleHelperTool.cxx:65
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
Muon::MuonStationNtupleHelperTool::fillMeasurementData
virtual StatusCode fillMeasurementData(const Trk::MeasurementBase *, const Trk::TrackParameters *, const int &detectorType, const bool &isOutlier)
fill hit position data
Definition: MuonStationNtupleHelperTool.cxx:93
Muon::MuonStationNtupleHelperTool::resetVariables
virtual StatusCode resetVariables(const int &detectorType)
reset ntuple variables
Definition: MuonStationNtupleHelperTool.cxx:122
Muon::MuonStationNtupleHelperTool::initialize
virtual StatusCode initialize()
standard Athena-Algorithm method
Definition: MuonStationNtupleHelperTool.cxx:32
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::IdentifierExtractor::extract
static void extract(std::vector< Identifier > &ids, const std::vector< const MeasurementBase * > &measurements)
Definition: IdentifierExtractor.cxx:13
Muon::MuonStationNtupleHelperTool::fillHoleData
virtual StatusCode fillHoleData(const Trk::TrackStateOnSurface &, const int &)
fill special data about holes on track (here: do nothing)
Definition: MuonStationNtupleHelperTool.cxx:140
MuonStationNtupleHelperTool.h
Muon::MuonStationNtupleHelperTool::finalize
virtual StatusCode finalize()
standard Athena-Algorithm method
Definition: MuonStationNtupleHelperTool.cxx:50
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonStationIndex::toInt
constexpr int toInt(const EnumType enumVal)
Definition: MuonStationIndex.h:61
Identifier
Definition: IdentifierFieldParser.cxx:14