Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
41  SG::ReadHandle inContainer{m_key, ctx};
42  if (!inContainer.isPresent()) {
43  ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
44  return false;
45  }
46 
47  for (const xAOD::MuonSimHit* simHit : *inContainer) {
48  fillHit(ctx, *simHit);
49  }
50  m_idxLookUp.clear();
51  return true;
52  }
54  return fillHit(Gaudi::Hive::currentContext(), hit);
55  }
56  unsigned int SimHitTester::fillHit(const EventContext& ctx,
57  const xAOD::MuonSimHit& simHit) {
58 
59  const auto insertItr = m_idxLookUp.insert(std::make_pair(&simHit, m_idxLookUp.size()));
60  if (!insertItr.second) {
61  return insertItr.first->second;
62  }
63  const ActsGeometryContext& gctx{getGeoCtx(ctx)};
64 
65  const MuonGMR4::MuonDetectorManager* detMgr = getDetMgr();
66 
67  const Identifier id = simHit.identify();
68  ATH_MSG_VERBOSE("Filling information for "<<idHelperSvc()->toString(id));
69 
71 
72  const IdentifierHash trfHash{idHelperSvc()->isMdt(id) ? re->measurementHash(id)
73  : re->layerHash(id)};
74 
75  const Amg::Vector3D locPos{xAOD::toEigen(simHit.localPosition())};
76  const Amg::Vector3D locDir{xAOD::toEigen(simHit.localDirection())};
77 
78  const Amg::Transform3D& locToGlobal{re->localToGlobalTrans(gctx, trfHash)};
79  m_globPos.push_back(locToGlobal*locPos);
80  m_globDir.push_back(Amg::Vector3D(locToGlobal.linear()* locDir));
81  m_locPos.push_back(locPos);
84  m_beta.push_back(simHit.beta());
85  m_pdgId.push_back(simHit.pdgId());
87  m_kinE.push_back(simHit.kineticEnergy());
88  m_mass.push_back(simHit.mass());
89  m_identifier->push_back(id);
90 
91  return insertItr.first->second;
92  }
93 
94 
95 }
MuonValR4::SimHitTester::m_globDir
ThreeVectorBranch m_globDir
Global direction of the traversing particle generating the hit.
Definition: SimHitTester.h:34
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
Kinetic energy of the traversing particle.
Definition: SimHitTester.h:48
xAOD::MuonSimHit_v1::identify
Identifier identify() const
Returns the global ATLAS identifier of the SimHit.
Definition: xAODMuonSimHit_V1.cxx:42
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:67
MuonValR4::SimHitTester::fillHit
unsigned int fillHit(const EventContext &ctx, const xAOD::MuonSimHit &hit)
Definition: SimHitTester.cxx:56
tree
TChain * tree
Definition: tile_monitor.h:30
MuonValR4::SimHitTester::m_energyDep
VectorBranch< float > & m_energyDep
Energy deposited in the volume.
Definition: SimHitTester.h:46
MuonValR4::SimHitTester::m_identifier
std::shared_ptr< MuonIdentifierBranch > m_identifier
Pointer to the Identifier branch.
Definition: SimHitTester.h:52
ActsTrk::DetectorType::Tgc
@ Tgc
Resitive Plate Chambers.
xAOD::MuonSimHit_v1::globalTime
float globalTime() const
Returns the time ellapsed since the collision of the traversing particle.
MuonGMR4::MuonReadoutElement
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:38
MuonValR4::SimHitTester::push_back
unsigned push_back(const xAOD::MuonSimHit &hit)
Definition: SimHitTester.cxx:53
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::MuonSimHit_v1::pdgId
int pdgId() const
Returns the pdgID of the traversing particle.
ActsTrk::DetectorType::sTgc
@ sTgc
Micromegas (NSW)
MuonValR4::SimHitTester::m_mass
VectorBranch< float > & m_mass
Mass of the traversing particle.
Definition: SimHitTester.h:50
MuonValR4::SimHitTester::m_locDir
ThreeVectorBranch m_locDir
Local direction of the traversing particle generating the hit.
Definition: SimHitTester.h:38
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
MuonValR4::SimHitTester::m_idxLookUp
std::unordered_map< const xAOD::MuonSimHit *, unsigned int > m_idxLookUp
look up table of alrady dumped sim hits
Definition: SimHitTester.h:55
xAOD::MuonSimHit_v1::beta
float beta() const
returns beta (fraction of speed of light)
Definition: xAODMuonSimHit_V1.cxx:52
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
xAOD::MuonSimHit_v1::kineticEnergy
float kineticEnergy() const
Returns the kinetic energy of the traversing particle.
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
Velocity of the simHit expressed in terms of beta.
Definition: SimHitTester.h:42
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonValR4::TesterModuleBase::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: TesterModuleBase.cxx:18
xAOD::MuonSimHit_v1::localDirection
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:66
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
Local position of the produced simHit.
Definition: SimHitTester.h:36
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
MuonValR4::SimHitTester::m_globPos
ThreeVectorBranch m_globPos
Global position of the SimHits.
Definition: SimHitTester.h:32
MuonValR4::SimHitTester::m_pdgId
VectorBranch< int > & m_pdgId
PdgId of the particle generating the hit.
Definition: SimHitTester.h:44
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)
xAOD::MuonSimHit_v1::localPosition
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:60
ActsTrk::DetectorType::Rpc
@ Rpc
Monitored Drift Tubes.
xAOD::MuonSimHit_v1::energyDeposit
float energyDeposit() const
Returns the energy deposited by the traversing particle inside the gas volume.
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
Global time when the simHit was produced.
Definition: SimHitTester.h:40
MuonValR4::SimHitTester::m_key
SG::ReadHandleKey< xAOD::MuonSimHitContainer > m_key
Key of the SimHit container in the StoreGate.
Definition: SimHitTester.h:28
xAOD::MuonSimHit_v1::mass
float mass() const
Returns the rest-mass of the traversing particle.
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