ATLAS Offline Software
Loading...
Searching...
No Matches
MuEntryVariables.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
7
9#include "CLHEP/Vector/ThreeVector.h"
11
12namespace MuonPRDTest{
13 MuEntryVariables::MuEntryVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl):
14 PrdTesterModule(tree, "MuEntryVariables", msglvl), m_key{container_name} {}
16
17 bool MuEntryVariables::fill(const EventContext& ctx) {
18 ATH_MSG_DEBUG("do fillNSWMuEntryVariables()");
19 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
20 if (!MuonDetMgr) { return false; }
21 SG::ReadHandle<TrackRecordCollection> trackRecordCollection{m_key, ctx};
22 if (!trackRecordCollection.isValid()) {
23 ATH_MSG_FATAL("Failed to retrieve track collection container " << m_key.fullKey());
24 return false;
25 }
26 m_MuEntry_nParticles = trackRecordCollection->size();
27 for(const auto& it : *trackRecordCollection ) {
28 m_MuEntry_particlePdg_id.push_back(it.GetPDGCode());
29 m_MuEntry_particleBarcode.push_back(it.barcode()); // FIXME barcode-based
30 const Amg::Vector3D threeMom = Amg::Hep3VectorToEigen(it.GetMomentum());
31 m_MuEntry_mom.push_back(threeMom.perp(), threeMom.eta(), threeMom.phi(), it.GetEnergy());
32 m_MuEntry_pos.push_back(Amg::Hep3VectorToEigen(it.GetPosition()));
33 }
34 return true;
35 }
36}
37
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
ScalarBranch< unsigned int > & m_MuEntry_nParticles
SG::ReadHandleKey< TrackRecordCollection > m_key
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...
MuEntryVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
VectorBranch< int > & m_MuEntry_particlePdg_id
VectorBranch< int > & m_MuEntry_particleBarcode
bool declare_keys() override final
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Eigen::Matrix< double, 3, 1 > Vector3D