ATLAS Offline Software
sTgcMeasViewAlg.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 
7 #include "sTgcMeasViewAlg.h"
8 
9 #include <StoreGate/ReadHandle.h>
10 #include <StoreGate/WriteHandle.h>
12 namespace MuonR4{
13  sTgcMeasViewAlg::sTgcMeasViewAlg(const std::string& name, ISvcLocator* pSvcLocator):
14  AthReentrantAlgorithm{name, pSvcLocator} {}
15 
17  ATH_CHECK(m_readKeyStrip.initialize());
18  ATH_CHECK(m_readKeyWire.initialize());
19  ATH_CHECK(m_readKeyPad.initialize());
20  ATH_CHECK(m_writeKey.initialize());
21  return StatusCode::SUCCESS;
22  }
23  template <class ContainerType>
26  const ContainerType*& contToPush) const {
27  contToPush = nullptr;
28  if (key.empty()) {
29  ATH_MSG_VERBOSE("No key has been parsed for object " << typeid(ContainerType).name());
30  return StatusCode::SUCCESS;
31  }
32  SG::ReadHandle<ContainerType> readHandle{key, ctx};
33  ATH_CHECK(readHandle.isPresent());
34  contToPush = readHandle.cptr();
35  return StatusCode::SUCCESS;
36  }
37 
38 
39  StatusCode sTgcMeasViewAlg::execute(const EventContext& ctx) const {
40  const xAOD::sTgcStripContainer* strips{nullptr};
41  const xAOD::sTgcWireContainer* wires{nullptr};
42  const xAOD::sTgcPadContainer* pads{nullptr};
46 
48  if (strips) {
49  outContainer.insert(outContainer.end(), strips->begin(), strips->end());
50  }
51  if (wires) {
52  outContainer.insert(outContainer.end(),wires->begin(), wires->end());
53  }
54  if (pads){
55  outContainer.insert(outContainer.end(), pads->begin(), pads->end());
56  }
57  std::sort(outContainer.begin(), outContainer.end(),
59  return a->identifier() < b->identifier();
60  });
61 
63  ATH_CHECK(writeHandle.record(std::make_unique<xAOD::sTgcMeasContainer>(*outContainer.asDataVector())));
64  return StatusCode::SUCCESS;
65  }
66 
67 }
MuonR4::sTgcMeasViewAlg::retrieveContainer
StatusCode retrieveContainer(const EventContext &ctx, const SG::ReadHandleKey< ContainerType > &key, const ContainerType *&contToPush) const
Helper method to fetch data from StoreGate.
Definition: sTgcMeasViewAlg.cxx:24
MuonR4::sTgcMeasViewAlg::m_readKeyStrip
SG::ReadHandleKey< xAOD::sTgcStripContainer > m_readKeyStrip
Definition: sTgcMeasViewAlg.h:42
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonR4::sTgcMeasViewAlg::m_writeKey
SG::WriteHandleKey< xAOD::sTgcMeasContainer > m_writeKey
Definition: sTgcMeasViewAlg.h:51
MuonR4::sTgcMeasViewAlg::m_readKeyWire
SG::ReadHandleKey< xAOD::sTgcWireContainer > m_readKeyWire
Definition: sTgcMeasViewAlg.h:45
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey< ContainerType >
MuonR4::sTgcMeasViewAlg::m_readKeyPad
SG::ReadHandleKey< xAOD::sTgcPadContainer > m_readKeyPad
Definition: sTgcMeasViewAlg.h:48
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MuonR4::sTgcMeasViewAlg::initialize
StatusCode initialize() override
Definition: sTgcMeasViewAlg.cxx:16
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
a
TList * a
Definition: liststreamerinfos.cxx:10
MuonR4::sTgcMeasViewAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: sTgcMeasViewAlg.cxx:39
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
ReadHandle.h
Handle class for reading from StoreGate.
MuonR4::sTgcMeasViewAlg::sTgcMeasViewAlg
sTgcMeasViewAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: sTgcMeasViewAlg.cxx:13
sTgcMeasViewAlg.h
xAOD::sTgcMeasurement_v1
Definition: sTgcMeasurement_v1.h:21
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37