ATLAS Offline Software
MdtCalibDbAlgTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MdtCalibDbAlgTest.h"
6 
7 #include "GaudiKernel/PhysicalConstants.h"
9 #include "GaudiKernel/ITHistSvc.h"
10 #include "TH2D.h"
11 #include "TCanvas.h"
12 
13 using namespace MuonValR4;
14 
15 MdtCalibDbAlgTest::MdtCalibDbAlgTest(const std::string& name, ISvcLocator* pSvcLocator) :
16  AthHistogramAlgorithm(name, pSvcLocator) {}
17 
19  ATH_MSG_ALWAYS("Initializing MdtCalibDbAlgTest");
20  ATH_CHECK(m_MdtKey.initialize());
22  ATH_CHECK(m_calibrationTool.retrieve());
23  ATH_CHECK(m_idHelperSvc.retrieve());
24  ATH_CHECK(m_tree.init(this));
25  ATH_CHECK(book(TH2D("DriftRadiusVsTdc", "DriftRadiusVsTdc", 100, 0., 250., 100, 0., 15.), "MdtCalibDbAlgTest", "MdtCalibDbAlgTest"));
26  ATH_CHECK(book(TH2D("DriftdRdtVsTdc", "DriftdRdtVsTdc", 100, 0., 250., 100, 0., 0.6), "MdtCalibDbAlgTest", "MdtCalibDbAlgTest"));
27  return StatusCode::SUCCESS;
28 }
29 
31  ATH_MSG_ALWAYS("Finalizing MdtCalibDbAlgTest");
33  return StatusCode::SUCCESS;
34 }
35 
37  // ATH_MSG_ALWAYS("Executing MdtCalibDbAlgTest");
38  const EventContext& ctx = Gaudi::Hive::currentContext();
41  ATH_CHECK(mdtHandle.isPresent());
42  ATH_CHECK(geoCtxHandle.isPresent());
43  const xAOD::MdtDriftCircleContainer* mdtContainer = mdtHandle.get();
44  const ActsGeometryContext* geoCtx = geoCtxHandle.get();
45  constexpr double inversePropSpeed = 1. / Gaudi::Units::c_light;
46  for(const xAOD::MdtDriftCircle* mdt : *mdtContainer) {
47  const MuonGMR4::MdtReadoutElement* mdtRE = mdt->readoutElement();
48  const Amg::Vector3D& mdtGlobalTubePos = mdtRE->globalTubePos(*geoCtx, mdt->measurementHash());
49  const float tdcAdj = IMdtCalibrationTool::tdcBinSize * (mdt->tdc() - inversePropSpeed * (mdtGlobalTubePos.norm() - 0.5 * mdtRE->activeTubeLength(mdt->measurementHash())));
50  m_out_tdcAdj = tdcAdj;
51  m_out_tdc = mdt->tdc();
52  m_out_driftRadius = mdt->driftRadius();
53  m_out_driftdRdt = m_calibrationTool->getdRdtFromRt(ctx, mdtRE->identify(), tdcAdj);
54  m_out_identifier = mdt->identify();
55  m_out_globalPos = mdtGlobalTubePos.norm();
56  m_out_globalPosX = mdtGlobalTubePos.x();
57  m_out_globalPosY = mdtGlobalTubePos.y();
58  m_out_globalPosZ = mdtGlobalTubePos.z();
59  m_out_tubeLength = mdtRE->activeTubeLength(mdt->measurementHash());
60  hist("DriftRadiusVsTdc")->Fill(tdcAdj, mdt->driftRadius());
61  hist("DriftdRdtVsTdc")->Fill(tdcAdj, m_calibrationTool->getdRdtFromRt(ctx, mdtRE->identify(), tdcAdj));
62  m_tree.fill(ctx);
63  }
64 
65  return StatusCode::SUCCESS;
66 }
MuonValR4::MdtCalibDbAlgTest::m_out_driftdRdt
MuonVal::ScalarBranch< float > & m_out_driftdRdt
Definition: MdtCalibDbAlgTest.h:46
MuonValR4::MdtCalibDbAlgTest::m_out_tubeLength
MuonVal::ScalarBranch< float > & m_out_tubeLength
Definition: MdtCalibDbAlgTest.h:52
MuonVal::MuonTesterTree::init
StatusCode init(OWNER *instance)
Initialize method.
MuonValR4::MdtCalibDbAlgTest::m_out_identifier
MuonVal::ScalarBranch< Identifier > & m_out_identifier
Definition: MdtCalibDbAlgTest.h:47
AthHistogramming::book
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition: AthHistogramming.h:303
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonValR4::MdtCalibDbAlgTest::initialize
virtual StatusCode initialize() override
Definition: MdtCalibDbAlgTest.cxx:18
MuonGMR4::MdtReadoutElement::activeTubeLength
double activeTubeLength(const IdentifierHash &hash) const
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MdtReadoutElement.cxx:173
MuonValR4::MdtCalibDbAlgTest::m_out_tdcAdj
MuonVal::ScalarBranch< float > & m_out_tdcAdj
Definition: MdtCalibDbAlgTest.h:43
MuonValR4::MdtCalibDbAlgTest::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Definition: MdtCalibDbAlgTest.h:38
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
MuonValR4::MdtCalibDbAlgTest::m_out_globalPos
MuonVal::ScalarBranch< float > & m_out_globalPos
Definition: MdtCalibDbAlgTest.h:48
MuonValR4::MdtCalibDbAlgTest::m_MdtKey
SG::ReadHandleKey< xAOD::MdtDriftCircleContainer > m_MdtKey
Definition: MdtCalibDbAlgTest.h:36
MuonValR4::MdtCalibDbAlgTest::m_out_globalPosZ
MuonVal::ScalarBranch< float > & m_out_globalPosZ
Definition: MdtCalibDbAlgTest.h:51
MdtCalibDbAlgTest.h
MuonValR4::MdtCalibDbAlgTest::m_out_tdc
MuonVal::ScalarBranch< float > & m_out_tdc
Definition: MdtCalibDbAlgTest.h:44
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_ALWAYS
#define ATH_MSG_ALWAYS(x)
Definition: AthMsgStreamMacros.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
MuonValR4::MdtCalibDbAlgTest::m_out_globalPosY
MuonVal::ScalarBranch< float > & m_out_globalPosY
Definition: MdtCalibDbAlgTest.h:50
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: MdtCalibDbAlgTest.h:24
MuonGMR4::MdtReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonValR4::MdtCalibDbAlgTest::m_calibrationTool
ToolHandle< IMdtCalibrationTool > m_calibrationTool
pointer to MdtCalibSvc
Definition: MdtCalibDbAlgTest.h:40
MuonValR4::MdtCalibDbAlgTest::m_tree
MuonVal::MuonTesterTree m_tree
Definition: MdtCalibDbAlgTest.h:41
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
MuonGMR4::MuonReadoutElement::identify
Identifier identify() const override final
Return the athena identifier.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonValR4::MdtCalibDbAlgTest::m_out_driftRadius
MuonVal::ScalarBranch< float > & m_out_driftRadius
Definition: MdtCalibDbAlgTest.h:45
MuonValR4::MdtCalibDbAlgTest::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtCalibDbAlgTest.h:41
MdtReadoutElement.h
MuonValR4::MdtCalibDbAlgTest::MdtCalibDbAlgTest
MdtCalibDbAlgTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MdtCalibDbAlgTest.cxx:15
MuonValR4::MdtCalibDbAlgTest::finalize
virtual StatusCode finalize() override
Definition: MdtCalibDbAlgTest.cxx:30
MuonValR4::MdtCalibDbAlgTest::execute
virtual StatusCode execute() override
Definition: MdtCalibDbAlgTest.cxx:36
MuonVal::MuonTesterTree::fill
bool fill(const EventContext &ctx)
Fills the tree per call.
Definition: MuonTesterTree.cxx:89
MuonVal::MuonTesterTree::write
StatusCode write()
Finally write the TTree objects.
Definition: MuonTesterTree.cxx:178
MuonGMR4::MdtReadoutElement::globalTubePos
Amg::Vector3D globalTubePos(const ActsGeometryContext &ctx, const Identifier &measId) const
Returns the global position of the tube center.
AthHistogramming::hist
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Definition: AthHistogramming.cxx:198
MuonValR4::MdtCalibDbAlgTest::m_out_globalPosX
MuonVal::ScalarBranch< float > & m_out_globalPosX
Definition: MdtCalibDbAlgTest.h:49
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
IMdtCalibrationTool::tdcBinSize
static constexpr double tdcBinSize
Conversion to go from tdc counts -> drift Time.
Definition: IMdtCalibrationTool.h:34