ATLAS Offline Software
MdtCalibDbAlgTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MdtCalibDbAlgTest.h"
6 
7 #include "GaudiKernel/PhysicalConstants.h"
10 #include "GaudiKernel/ITHistSvc.h"
11 #include "TH2D.h"
12 #include "TCanvas.h"
13 
14 using namespace MuonValR4;
15 
16 MdtCalibDbAlgTest::MdtCalibDbAlgTest(const std::string& name, ISvcLocator* pSvcLocator) :
17  AthHistogramAlgorithm(name, pSvcLocator) {}
18 
20  ATH_MSG_VERBOSE("Initializing MdtCalibDbAlgTest");
21  ATH_CHECK(m_MdtKey.initialize());
23  ATH_CHECK(m_calibrationTool.retrieve());
24  ATH_CHECK(m_idHelperSvc.retrieve());
25  ATH_CHECK(m_tree.init(this));
26  ATH_CHECK(book(TH2D("DriftRadiusVsTdc", "DriftRadiusVsTdc", 100, 0., 250., 100, 0., 15.), "MdtCalibDbAlgTest", "MdtCalibDbAlgTest"));
27  ATH_CHECK(book(TH2D("DriftdRdtVsTdc", "DriftdRdtVsTdc", 100, 0., 250., 100, 0., 0.6), "MdtCalibDbAlgTest", "MdtCalibDbAlgTest"));
28  return StatusCode::SUCCESS;
29 }
30 
32  ATH_MSG_VERBOSE("Finalizing MdtCalibDbAlgTest");
34  return StatusCode::SUCCESS;
35 }
36 
38  // ATH_MSG_ALWAYS("Executing MdtCalibDbAlgTest");
39  const EventContext& ctx = Gaudi::Hive::currentContext();
40  SG::ReadHandle mdtContainer{m_MdtKey};
42  ATH_CHECK(mdtContainer.isPresent());
43  ATH_CHECK(geoCtx.isPresent());
44  constexpr double inversePropSpeed = 1. / Gaudi::Units::c_light;
45  for(const xAOD::MdtDriftCircle* mdt : *mdtContainer) {
46  const MuonGMR4::MdtReadoutElement* mdtRE = mdt->readoutElement();
47  const Amg::Vector3D mdtGlobalTubePos = mdtRE->globalTubePos(*geoCtx, mdt->measurementHash());
48  const float tdcAdj = IMdtCalibrationTool::tdcBinSize * mdt->tdc() - inversePropSpeed * (mdtGlobalTubePos.norm() - 0.5 * mdtRE->activeTubeLength(mdt->measurementHash()));
49  m_out_tdcAdj = tdcAdj;
50  m_out_tdc = mdt->tdc();
51  m_out_driftRadius = mdt->driftRadius();
52  const float driftV = m_calibrationTool->getCalibConstants(ctx, mdt->identify())->rtRelation->rt()->driftVelocity(tdcAdj);
53  m_out_driftdRdt = driftV;
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, driftV);
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:19
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
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
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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_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
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
MuonGMR4::MdtReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:22
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
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:16
MdtFullCalibData.h
MuonValR4::MdtCalibDbAlgTest::finalize
virtual StatusCode finalize() override
Definition: MdtCalibDbAlgTest.cxx:31
MuonValR4::MdtCalibDbAlgTest::execute
virtual StatusCode execute() override
Definition: MdtCalibDbAlgTest.cxx:37
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:38