ATLAS Offline Software
MDTSDOVariables.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <StoreGate/ReadHandle.h>
7 namespace MuonPRDTest {
8  MdtSDOVariables::MdtSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
9  PrdTesterModule(tree, "SDO_MDT", msglvl), m_sdo_key{container_name} {}
10 
11  bool MdtSDOVariables::fill(const EventContext& ctx) {
12  const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
13  if (!MuonDetMgr) { return false; }
14  ATH_MSG_DEBUG(" do fillMdtSDOVariables()");
15  ATH_MSG_VERBOSE("MuonDetectorManager from Conditions Store accessed" << MuonDetMgr);
16 
17  ATH_MSG_DEBUG("Retrieve MDT SDO container with name = " << m_sdo_key.fullKey());
18 
20  if (!mdtSdoContainer.isValid()) {
21  ATH_MSG_FATAL("Failed to retrieve SDO container " << m_sdo_key.fullKey());
22  return false;
23  }
24 
25  for (const auto& coll : *mdtSdoContainer) {
26  const Identifier id = coll.first;
27  const MuonSimData& mdt_sdo = coll.second;
29  // Get information on the SDO
30  ATH_MSG_DEBUG("MDT SDO: " << idHelperSvc()->toString(id));
31  ATH_MSG_DEBUG("Get the truth deposits from the SDO.");
32  std::vector<MuonSimData::Deposit> deposits;
33  mdt_sdo.deposits(deposits);
34 
37  m_mdt_sdo_word.push_back(mdt_sdo.word());
38 
39  // use the information of the first deposit
40  int barcode = deposits[0].first.barcode();
41  double MuonMCdata_firstentry = deposits[0].second.firstEntry();
42  double MuonMCdata_secondentry = deposits[0].second.secondEntry();
43 
44  ATH_MSG_DEBUG("MDT SDO barcode=" << barcode);
45  ATH_MSG_DEBUG("MDT SDO localPosX=" << std::setw(9) << std::setprecision(2) << MuonMCdata_firstentry
46  << ", localPosY=" << std::setw(9) << std::setprecision(2) << MuonMCdata_secondentry);
47 
49  m_mdt_sdo_localPosX.push_back(MuonMCdata_firstentry);
50  m_mdt_sdo_localPosY.push_back(MuonMCdata_secondentry);
51  }
52  m_mdt_nsdo = mdtSdoContainer.cptr()->size();
53  ATH_MSG_DEBUG("Processed " << m_mdt_nsdo << " MDT SDOs");
54  return true;
55  }
56 
58 } // namespace MuonPRDTest
MuonSimData::word
int word() const
Definition: MuonSimData.h:89
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonVal::MdtIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:24
MDTSDOVariables.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
tree
TChain * tree
Definition: tile_monitor.h:30
MuonPRDTest::PrdTesterModule::getDetMgr
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
Definition: PrdTesterModule.cxx:16
MuonPRDTest::MdtSDOVariables::MdtSDOVariables
MdtSDOVariables(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
Definition: MDTSDOVariables.cxx:8
MuonPRDTest::MdtSDOVariables::m_mdt_nsdo
ScalarBranch< unsigned int > & m_mdt_nsdo
Definition: MDTSDOVariables.h:23
MuonPRDTest::MdtSDOVariables::declare_keys
bool declare_keys() override final
Definition: MDTSDOVariables.cxx:57
MuonPRDTest::MdtSDOVariables::m_sdo_key
SG::ReadHandleKey< MuonSimDataCollection > m_sdo_key
Definition: MDTSDOVariables.h:22
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
MuonSimData::deposits
void deposits(std::vector< Deposit > &deposits) const
Definition: MuonSimData.h:99
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_globalPos
ThreeVectorBranch m_mdt_sdo_globalPos
Definition: MDTSDOVariables.h:27
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_barcode
VectorBranch< int > & m_mdt_sdo_barcode
Definition: MDTSDOVariables.h:26
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
MuonPRDTest::PrdTesterModule
Definition: PrdTesterModule.h:15
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_id
MdtIdentifierBranch m_mdt_sdo_id
Definition: MDTSDOVariables.h:24
MuonPRDTest::MdtSDOVariables::fill
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
Definition: MDTSDOVariables.cxx:11
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_word
VectorBranch< int > & m_mdt_sdo_word
Definition: MDTSDOVariables.h:25
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_localPosY
VectorBranch< float > & m_mdt_sdo_localPosY
Definition: MDTSDOVariables.h:30
MuonSimData
Definition: MuonSimData.h:62
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_globalTime
VectorBranch< float > & m_mdt_sdo_globalTime
Definition: MDTSDOVariables.h:28
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MuonPRDTest::MdtSDOVariables::m_mdt_sdo_localPosX
VectorBranch< float > & m_mdt_sdo_localPosX
Definition: MDTSDOVariables.h:29
MuonPRDTest
Definition: CSCDigitVariables.h:10
MuonPRDTest::PrdTesterModule::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: PrdTesterModule.cxx:15
ReadHandle.h
Handle class for reading from StoreGate.
MuonSimData::globalPosition
const Amg::Vector3D globalPosition() const
Definition: MuonSimData.h:113
MuonSimData::getTime
float getTime() const
Definition: MuonSimData.h:124
Identifier
Definition: IdentifierFieldParser.cxx:14