ATLAS Offline Software
MmClusterVariables.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{
8 
10  const std::string& inContainer,
11  MSG::Level msgLvl,
12  const std::string& collName):
13  TesterModuleBase{tree, inContainer + collName, msgLvl},
14  m_key{inContainer},
15  m_collName{collName}{
16  }
18  return declare_dependency(m_key);
19  }
20  bool MmClusterVariables::fill(const EventContext& ctx){
21  const ActsGeometryContext& gctx{getGeoCtx(ctx)};
22 
23  SG::ReadHandle inContainer{m_key, ctx};
24  if (!inContainer.isPresent()) {
25  ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
26  return false;
27  }
29  for (const xAOD::MMCluster* strip : m_dumpedPRDS){
30  dump(gctx, *strip);
31  }
33  for (const xAOD::MMCluster* strip : *inContainer) {
34  const MuonGMR4::MmReadoutElement* re = strip->readoutElement();
35  const Identifier id{re->measurementId(strip->measurementHash())};
36  if ((m_applyFilter && !m_filteredChamb.count(idHelperSvc()->chamberId(id))) ||
37  m_idOutIdxMap.find(id) != m_idOutIdxMap.end()){
38  ATH_MSG_VERBOSE("Skip "<<idHelperSvc()->toString(id));
39  continue;
40  }
41  dump(gctx, *strip);
42  }
43 
44  m_filteredChamb.clear();
45  m_idOutIdxMap.clear();
46  m_dumpedPRDS.clear();
47  return true;
48  }
50  m_applyFilter = true;
51  }
53  m_applyFilter = true;
54  m_filteredChamb.insert(idHelperSvc()->chamberId(chamberId));
55  }
56  unsigned int MmClusterVariables::push_back(const xAOD::MMCluster& strip){
57  m_applyFilter = true;
58  const MuonGMR4::MmReadoutElement* re = strip.readoutElement();
59  const Identifier id{re->measurementId(strip.measurementHash())};
60 
61  const auto insert_itr = m_idOutIdxMap.insert(std::make_pair(id, m_idOutIdxMap.size()));
62  if (insert_itr.second) {
63  m_dumpedPRDS.push_back(&strip);
64  }
65  return insert_itr.first->second;
66  }
68  const xAOD::MMCluster& strip) {
69  const MuonGMR4::MmReadoutElement* re = strip.readoutElement();
70  const Identifier id{re->measurementId(strip.layerHash())};
71 
72 
73  ATH_MSG_VERBOSE("Filling information for "<<idHelperSvc()->toString(id));
74 
75  m_id.push_back(id);
77  locPos = strip.localPosition<1>()[0] * Amg::Vector3D::UnitX();
78 
79  const Amg::Vector3D globPos{re->localToGlobalTrans(gctx, strip.layerHash()) *locPos};
80  m_globPos.push_back(globPos);
81  m_locPos.push_back(strip.localPosition<1>()[0]);
82  m_locCov.push_back(strip.localCovariance<1>()(0,0));
83  m_charge.push_back(strip.charge());
84  m_time.push_back(strip.time());
85  m_author.push_back(static_cast<char>(strip.author()));
86  }
87 
88 }
MuonValR4::MmClusterVariables::m_locCov
VectorBranch< float > & m_locCov
local covariance of the measurement
Definition: MmClusterVariables.h:59
MuonGMR4::MmReadoutElement
Definition: MmReadoutElement.h:19
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::MMCluster_v1
Definition: MMCluster_v1.h:20
MuonValR4::MmClusterVariables::declare_keys
bool declare_keys() override final
Definition: MmClusterVariables.cxx:17
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonValR4::MmClusterVariables::m_applyFilter
bool m_applyFilter
Apply a filter to dump the prds.
Definition: MmClusterVariables.h:73
tree
TChain * tree
Definition: tile_monitor.h:30
MuonValR4::MmClusterVariables::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: MmClusterVariables.cxx:20
MuonValR4::MmClusterVariables::dumpAllHitsInChamber
void dumpAllHitsInChamber(const Identifier &chamberId)
All hits from this particular chamber identifier are dumped to the output including the ones from the...
Definition: MmClusterVariables.cxx:52
MuonVal::MmIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:93
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonValR4::MmClusterVariables::dump
void dump(const ActsGeometryContext &gctx, const xAOD::MMCluster &dc)
Definition: MmClusterVariables.cxx:67
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition: MuonTesterBranch.cxx:53
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
MuonValR4::MmClusterVariables::m_idOutIdxMap
std::unordered_map< Identifier, unsigned int > m_idOutIdxMap
Map of Identifiers to the position index inside the vector.
Definition: MmClusterVariables.h:69
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
MuonValR4::MmClusterVariables::m_locPos
VectorBranch< float > & m_locPos
Local strip position of the measurement
Definition: MmClusterVariables.h:57
MuonValR4::TesterModuleBase::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: TesterModuleBase.cxx:18
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonValR4::TesterModuleBase
Definition: TesterModuleBase.h:15
MuonValR4::MmClusterVariables::m_globPos
ThreeVectorBranch m_globPos
Position of the Mdt drift circle in the global frame.
Definition: MmClusterVariables.h:55
MmClusterVariables.h
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
MuonValR4::MmClusterVariables::enableSeededDump
void enableSeededDump()
Activates the seeded dump of the branch.
Definition: MmClusterVariables.cxx:49
MuonValR4::MmClusterVariables::m_charge
VectorBranch< uint32_t > & m_charge
cluster charge
Definition: MmClusterVariables.h:63
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonValR4::MmClusterVariables::push_back
unsigned int push_back(const xAOD::MMCluster &cluster)
Push back the drift circle measurement to the output.
Definition: MmClusterVariables.cxx:56
MuonValR4::MmClusterVariables::m_dumpedPRDS
std::vector< const xAOD::MMCluster * > m_dumpedPRDS
Vector of PRDs parsed via the external mechanism. These measurements are parsed first.
Definition: MmClusterVariables.h:71
re
const boost::regex re(r_e)
MuonValR4::MmClusterVariables::MmClusterVariables
MmClusterVariables(MuonTesterTree &tree, const std::string &inContainer, MSG::Level msgLvl=MSG::Level::INFO, const std::string &collName="MmPrd")
Definition: MmClusterVariables.cxx:9
MuonValR4::MmClusterVariables::m_author
VectorBranch< uint8_t > & m_author
cluster author
Definition: MmClusterVariables.h:65
MuonValR4::MmClusterVariables::m_time
VectorBranch< uint16_t > & m_time
cluster time
Definition: MmClusterVariables.h:61
ReadHandle.h
Handle class for reading from StoreGate.
MuonValR4::MmClusterVariables::m_id
MmIdentifierBranch m_id
Identifier of the Mdt.
Definition: MmClusterVariables.h:53
MuonValR4::MmClusterVariables::m_key
SG::ReadHandleKey< xAOD::MMClusterContainer > m_key
Definition: MmClusterVariables.h:49
MuonValR4::MmClusterVariables::m_filteredChamb
std::unordered_set< Identifier > m_filteredChamb
Set of chambers to be dumped.
Definition: MmClusterVariables.h:67
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Identifier
Definition: IdentifierFieldParser.cxx:14