ATLAS Offline Software
sTGCSDOVariables.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 namespace MuonPRDTest {
9  sTgcSDOVariables::sTgcSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10  PrdTesterModule(tree, "SDO_sTGC", false, msglvl), m_key{container_name} {}
11 
13 
14  bool sTgcSDOVariables::fill(const EventContext& ctx) {
15  ATH_MSG_DEBUG("do fill sTgcSDOVariables()");
16  SG::ReadHandle<MuonSimDataCollection> stgcSdoContainer{m_key, ctx};
17  if (!stgcSdoContainer.isValid()) {
18  ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
19  return false;
20  }
21  const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
22  if (!MuonDetMgr) { return false; }
23  unsigned int n_sdo{0};
24  for (const auto& coll : *stgcSdoContainer) {
25  const Identifier& id = coll.first;
26  const MuonSimData& stgc_sdo = coll.second;
27 
29  m_NSWsTGC_sdo_word.push_back(stgc_sdo.word());
30 
31  ATH_MSG_DEBUG("sTGC SDO: " << idHelperSvc()->toString(id));
32 
33  ATH_MSG_DEBUG("Get the truth deposits from the SDO.");
34  std::vector<MuonSimData::Deposit> deposits;
35  stgc_sdo.deposits(deposits);
36 
37  const Amg::Vector3D hit_gpos = stgc_sdo.globalPosition();
39 
40  // use the information of the first deposit
41  int barcode = deposits[0].first.barcode();
42  double MuonMCdata_firstentry = deposits[0].second.firstEntry();
43  double MuonMCdata_secondentry = deposits[0].second.secondEntry();
44 
45  ATH_MSG_DEBUG("sTGC SDO barcode=" << barcode);
46  ATH_MSG_DEBUG("sTGC SDO energy=" << std::setw(9) << std::setprecision(2) << MuonMCdata_firstentry
47  << ", tof=" << std::setw(9) << std::setprecision(2) << MuonMCdata_secondentry);
48 
50  m_NSWsTGC_sdo_E.push_back(MuonMCdata_firstentry);
51  m_NSWsTGC_sdo_tof.push_back(MuonMCdata_secondentry);
52 
53  // Retrieve the detector element and local SDO coordinates
54  const MuonGM::sTgcReadoutElement* rdoEl = MuonDetMgr->getsTgcReadoutElement(id);
55  if (!rdoEl) {
56  ATH_MSG_ERROR("sTGCSDOVariables::fillVariables() - Failed to retrieve sTgcReadoutElement for " << idHelperSvc()->toString(id));
57  return false;
58  }
59 
61  Amg::Vector2D loc_pos(0., 0.);
62  rdoEl->surface(id).globalToLocal(stgc_sdo.globalPosition(), Amg::Vector3D(0., 0., 0.), loc_pos);
63  ATH_MSG_DEBUG("sTGC SDO local position X=" << std::setw(9) << std::setprecision(2) << loc_pos[0]
64  << ", local position Y=" << std::setw(9) << std::setprecision(2) << loc_pos[1]);
65  m_NSWsTGC_sdo_localPosX.push_back( loc_pos[0] );
66  m_NSWsTGC_sdo_localPosY.push_back( loc_pos[1] );
67 
68  ++n_sdo;
69  }
70  m_NSWsTGC_nsdo = n_sdo;
71 
72  ATH_MSG_DEBUG("Processed " << n_sdo << " sTGC SDOs");
73  return true;
74  }
75 }
Trk::PlaneSurface::globalToLocal
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
Definition: PlaneSurface.cxx:213
MuonSimData::word
int word() const
Definition: MuonSimData.h:89
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_localPosY
VectorBranch< float > & m_NSWsTGC_sdo_localPosY
Definition: sTGCSDOVariables.h:35
MuonPRDTest::sTgcSDOVariables::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: sTGCSDOVariables.cxx:14
sTgcReadoutElement.h
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_tof
VectorBranch< float > & m_NSWsTGC_sdo_tof
Definition: sTGCSDOVariables.h:33
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonPRDTest::sTgcSDOVariables::sTgcSDOVariables
sTgcSDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
Definition: sTGCSDOVariables.cxx:9
tree
TChain * tree
Definition: tile_monitor.h:30
MuonPRDTest::PrdTesterModule::getDetMgr
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
Definition: PrdTesterModule.cxx:15
MuonVal::sTgcIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:79
sTGCSDOVariables.h
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonPRDTest::sTgcSDOVariables::declare_keys
bool declare_keys() override final
Definition: sTGCSDOVariables.cxx:12
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_globaltime
VectorBranch< float > & m_NSWsTGC_sdo_globaltime
Definition: sTGCSDOVariables.h:29
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_nsdo
ScalarBranch< unsigned int > & m_NSWsTGC_nsdo
Definition: sTGCSDOVariables.h:25
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_word
VectorBranch< int > & m_NSWsTGC_sdo_word
Definition: sTGCSDOVariables.h:27
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
MuonGM::sTgcReadoutElement
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:28
MuonPRDTest::PrdTesterModule
Definition: PrdTesterModule.h:15
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_localPosX
VectorBranch< float > & m_NSWsTGC_sdo_localPosX
Definition: sTGCSDOVariables.h:34
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_id
sTgcIdentifierBranch m_NSWsTGC_sdo_id
Definition: sTGCSDOVariables.h:26
MuonSimData
Definition: MuonSimData.h:62
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_E
VectorBranch< float > & m_NSWsTGC_sdo_E
Definition: sTGCSDOVariables.h:32
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_sdo_barcode
VectorBranch< int > & m_NSWsTGC_sdo_barcode
Definition: sTGCSDOVariables.h:28
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
MuonPRDTest
Definition: CSCDigitVariables.h:10
MuonPRDTest::PrdTesterModule::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: PrdTesterModule.cxx:14
MuonPRDTest::sTgcSDOVariables::m_key
SG::ReadHandleKey< MuonSimDataCollection > m_key
Definition: sTGCSDOVariables.h:23
MuonGM::MuonDetectorManager::getsTgcReadoutElement
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:259
MuonPRDTest::sTgcSDOVariables::m_NSWsTGC_dig_globalPos
ThreeVectorBranch m_NSWsTGC_dig_globalPos
Definition: sTGCSDOVariables.h:31
MuonSimData::globalPosition
const Amg::Vector3D globalPosition() const
Definition: MuonSimData.h:113
MuonSimData::getTime
float getTime() const
Definition: MuonSimData.h:124