ATLAS Offline Software
SimHitTester.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 MuonValR4{
9  const std::string& inContainer,
10  const ActsTrk::DetectorType detType,
11  MSG::Level msgLvl):
12  TesterModuleBase{tree, inContainer, msgLvl},
13  m_key{inContainer},
14  m_collName{ActsTrk::to_string(detType)+"SimHits"} {
15  switch (detType) {
17  m_identifier = std::make_shared<MdtIdentifierBranch>(tree, m_collName);
18  break;
20  m_identifier = std::make_shared<RpcIdentifierBranch>(tree, m_collName);
21  break;
23  m_identifier = std::make_shared<TgcIdentifierBranch>(tree, m_collName);
24  break;
26  m_identifier = std::make_shared<sTgcIdentifierBranch>(tree, m_collName);
27  break;
29  m_identifier = std::make_shared<MmIdentifierBranch>(tree, m_collName);
30  break;
31  default:
32  ATH_MSG_WARNING("Unsupported detector type "<<ActsTrk::to_string(detType));
33  };
34 
35  }
38  }
39  bool SimHitTester::fill(const EventContext& ctx){
40  const ActsGeometryContext& gctx{getGeoCtx(ctx)};
41 
42  SG::ReadHandle inContainer{m_key, ctx};
43  if (!inContainer.isPresent()) {
44  ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
45  return false;
46  }
47  const MuonGMR4::MuonDetectorManager* detMgr = getDetMgr();
48 
49  for (const xAOD::MuonSimHit* simHit : *inContainer) {
50  const Identifier id = simHit->identify();
51  ATH_MSG_VERBOSE("Filling information for "<<idHelperSvc()->toString(id));
52 
54 
55  const IdentifierHash trfHash{idHelperSvc()->isMdt(id) ? re->measurementHash(id)
56  : re->layerHash(id)};
57 
58  const Amg::Vector3D locPos{xAOD::toEigen(simHit->localPosition())};
59  const Amg::Vector3D locDir{xAOD::toEigen(simHit->localDirection())};
60 
61  const Amg::Transform3D& locToGlobal{re->localToGlobalTrans(gctx, trfHash)};
62  m_globPos.push_back(locToGlobal*locPos);
63  m_globDir.push_back(Amg::Vector3D(locToGlobal.linear()* locDir));
64  m_locPos.push_back(locPos);
66  m_globTime.push_back(simHit->globalTime());
67  m_beta.push_back(simHit->beta());
68  m_pdgId.push_back(simHit->pdgId());
69  m_energyDep.push_back(simHit->energyDeposit());
70  m_kinE.push_back(simHit->kineticEnergy());
71  m_mass.push_back(simHit->mass());
72  m_identifier->push_back(id);
73  }
74  return true;
75  }
76 
77 }
MuonValR4::SimHitTester::m_globDir
ThreeVectorBranch m_globDir
Definition: SimHitTester.h:27
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonValR4::SimHitTester::m_kinE
VectorBranch< float > & m_kinE
Definition: SimHitTester.h:36
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
ActsTrk::DetectorType
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
Definition: GeometryDefs.h:17
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
tree
TChain * tree
Definition: tile_monitor.h:30
MuonValR4::SimHitTester::m_energyDep
VectorBranch< float > & m_energyDep
Definition: SimHitTester.h:35
MuonValR4::SimHitTester::m_identifier
std::shared_ptr< MuonIdentifierBranch > m_identifier
Definition: SimHitTester.h:38
ActsTrk::DetectorType::Tgc
@ Tgc
Resitive Plate Chambers.
MuonGMR4::MuonReadoutElement
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:38
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ActsTrk::DetectorType::sTgc
@ sTgc
Micromegas (NSW)
MuonValR4::SimHitTester::m_mass
VectorBranch< float > & m_mass
Definition: SimHitTester.h:37
MuonValR4::SimHitTester::m_locDir
ThreeVectorBranch m_locDir
Definition: SimHitTester.h:30
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition: MuonTesterBranch.cxx:53
MuonValR4::SimHitTester::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: SimHitTester.cxx:39
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonValR4::TesterModuleBase::getGeoCtx
const ActsGeometryContext & getGeoCtx(const EventContext &ctx) const
Definition: TesterModuleBase.cxx:22
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
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
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
ActsTrk::DetectorType::Mm
@ Mm
Maybe not needed in the migration.
MuonValR4::SimHitTester::SimHitTester
SimHitTester(MuonTesterTree &tree, const std::string &inContainer, const ActsTrk::DetectorType detType, MSG::Level msgLvl=MSG::Level::INFO)
Definition: SimHitTester.cxx:8
MuonValR4::SimHitTester::m_beta
VectorBranch< float > & m_beta
Definition: SimHitTester.h:33
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonValR4::TesterModuleBase::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: TesterModuleBase.cxx:18
MuonValR4::SimHitTester::declare_keys
bool declare_keys() override final
Definition: SimHitTester.cxx:36
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonValR4::TesterModuleBase
Definition: TesterModuleBase.h:15
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
Muon::IMuonIdHelperSvc::isMdt
virtual bool isMdt(const Identifier &id) const =0
returns whether this is a MDT Identifier or not
ActsTrk::DetectorType::Mdt
@ Mdt
MuonSpectrometer.
MuonValR4::SimHitTester::m_locPos
ThreeVectorBranch m_locPos
Definition: SimHitTester.h:29
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
MuonValR4::SimHitTester::m_globPos
ThreeVectorBranch m_globPos
Definition: SimHitTester.h:26
MuonValR4::SimHitTester::m_pdgId
VectorBranch< int > & m_pdgId
Definition: SimHitTester.h:34
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.copyTCTOutput.locDir
locDir
Definition: copyTCTOutput.py:113
MuonVal::MuonTesterBranch::parent
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
Definition: MuonTesterBranch.cxx:38
SimHitTester.h
MuonValR4::TesterModuleBase::getDetMgr
const MuonGMR4::MuonDetectorManager * getDetMgr() const
Definition: TesterModuleBase.cxx:19
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
ActsTrk::DetectorType::Rpc
@ Rpc
Monitored Drift Tubes.
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
MuonValR4::SimHitTester::m_globTime
VectorBranch< float > & m_globTime
Definition: SimHitTester.h:32
MuonValR4::SimHitTester::m_key
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_key
Definition: SimHitTester.h:23
MuonVal::MuonTesterTree::addBranch
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.
Definition: MuonTesterTree.cxx:61
MuonGMR4::MuonDetectorManager::getReadoutElement
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Returns a generic Muon readout element.
Identifier
Definition: IdentifierFieldParser.cxx:14