ATLAS Offline Software
CSCDigitVariables.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 
8 namespace MuonPRDTest {
9  CscDigitVariables::CscDigitVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10  PrdTesterModule(tree, "Digits_CSC", msglvl), m_key{container_name} {}
12 
13  bool CscDigitVariables::fill(const EventContext& ctx) {
14  ATH_MSG_DEBUG("do fillCSCDigitVariables()");
15  const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
16  if (!MuonDetMgr) { return false; }
18  if (!CscDigitContainer.isValid()) {
19  ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
20  return false;
21  }
22 
23  ATH_MSG_DEBUG("retrieved CSC Digit Container with size " << CscDigitContainer->digit_size());
24 
25  if (CscDigitContainer->size() == 0) ATH_MSG_DEBUG(" CSC Digit Container empty ");
26  unsigned int n_digits{0};
27  for (const CscDigitCollection* coll : *CscDigitContainer) {
28  ATH_MSG_DEBUG("processing collection with size " << coll->size());
29  for (unsigned int digitNum = 0; digitNum < coll->size(); digitNum++) {
30  const CscDigit* digit = coll->at(digitNum);
31 
32  Identifier Id = digit->identify();
33  ATH_MSG_DEBUG("CSC Digit Offline id: " << idHelperSvc()->toString(Id));
34 
35  const MuonGM::CscReadoutElement* rdoEl = MuonDetMgr->getCscReadoutElement(Id);
36  if (!rdoEl) {
37  ATH_MSG_ERROR("CSCDigitVariables::fillVariables() - Failed to retrieve CSCReadoutElement for "<<idHelperSvc()->cscIdHelper().print_to_string(Id).c_str());
38  return false;
39  }
40 
41  Amg::Vector3D gpos{0., 0., 0.};
42  Amg::Vector2D lpos(0., 0.);
43 
44  rdoEl->surface(Id).localToGlobal(lpos, gpos, gpos);
47 
48  ++n_digits;
49  }
50  // Local digit position information loss after localToGlobal transformation, fill the local positions in another loop for retrieving the local positions
51  for (unsigned int digitNum = 0; digitNum < coll->size(); digitNum++) {
52  const CscDigit* digit = coll->at(digitNum);
53  Identifier Id = digit->identify();
54  ATH_MSG_DEBUG("CSC Digit Offline id: " << idHelperSvc()->toString(Id));
55 
56  const MuonGM::CscReadoutElement* rdoEl = MuonDetMgr->getCscReadoutElement(Id);
57  if (!rdoEl) return false;
58 
59  Amg::Vector3D glpos{0., 0., 0.};
60  Amg::Vector2D lopos(0., 0.);
61 
62  rdoEl->surface(Id).globalToLocal(glpos, glpos, lopos);
63  m_CSC_dig_localPosX.push_back(lopos.x());
64  m_CSC_dig_localPosX.push_back(lopos.y());
65  }
66  }
67  m_CSC_nDigits = n_digits;
68  ATH_MSG_DEBUG(" finished fillCscDigitVariables()");
69  return true;
70  }
71 }
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
CscDigitContainer
Use IdentifiableContainer with CscDigitCollection.
Definition: CscDigitContainer.h:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonVal::CscIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:52
MuonPRDTest::CscDigitVariables::m_CSC_dig_globalPos
ThreeVectorBranch m_CSC_dig_globalPos
Definition: CSCDigitVariables.h:26
tree
TChain * tree
Definition: tile_monitor.h:30
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
CSCDigitVariables.h
MuonPRDTest::PrdTesterModule::getDetMgr
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
Definition: PrdTesterModule.cxx:16
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
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.
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
MuonPRDTest::CscDigitVariables::m_key
SG::ReadHandleKey< CscDigitContainer > m_key
Definition: CSCDigitVariables.h:22
CscDigitContainer::digit_size
size_type digit_size() const
Definition: CscDigitContainer.cxx:53
MuonPRDTest::CscDigitVariables::m_CSC_dig_localPosX
VectorBranch< float > & m_CSC_dig_localPosX
Definition: CSCDigitVariables.h:24
MuonPRDTest::CscDigitVariables::declare_keys
bool declare_keys() override final
Definition: CSCDigitVariables.cxx:11
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
MuonGM::MuonDetectorManager::getCscReadoutElement
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:225
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CscDigit
Definition: CscDigit.h:17
MuonPRDTest::PrdTesterModule
Definition: PrdTesterModule.h:15
CscReadoutElement.h
MuonPRDTest::CscDigitVariables::CscDigitVariables
CscDigitVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
Definition: CSCDigitVariables.cxx:9
MuonPRDTest::CscDigitVariables::m_CSC_nDigits
ScalarBranch< unsigned int > & m_CSC_nDigits
Definition: CSCDigitVariables.h:23
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
CscDigitCollection
Definition: CscDigitCollection.h:17
MuonPRDTest::CscDigitVariables::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: CSCDigitVariables.cxx:13
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MuonPRDTest
Definition: CSCDigitVariables.h:10
MuonPRDTest::PrdTesterModule::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: PrdTesterModule.cxx:15
MuonPRDTest::CscDigitVariables::m_CSC_dig_id
CscIdentifierBranch m_CSC_dig_id
Definition: CSCDigitVariables.h:27
Trk::PlaneSurface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
Definition: PlaneSurface.cxx:204
Identifier
Definition: IdentifierFieldParser.cxx:14