ATLAS Offline Software
MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #ifndef MDTCALIBDBCOOLSTRTOOL_MDTCALIBDBALG_H
10 #define MDTCALIBDBCOOLSTRTOOL_MDTCALIBDBALG_H
11 
13 
16 #include "CLHEP/Random/RandomEngine.h"
17 #include "CoralBase/Blob.h"
27 
30 #include "nlohmann/json.hpp"
31 #include "zlib.h"
32 
34 public:
35  MdtCalibDbAlg(const std::string& name, ISvcLocator* pSvcLocator);
36  virtual ~MdtCalibDbAlg() = default;
37  virtual StatusCode initialize() override;
38  virtual StatusCode execute(const EventContext& ctx) const override;
39  virtual bool isReEntrant() const override { return false; }
40 
41 private:
42  StatusCode declareDependency(const EventContext& ctx,
44  StatusCode loadRt(const EventContext& ctx, MuonCalib::MdtCalibDataContainer& writeCdo) const;
45  StatusCode loadTube(const EventContext& ctx, MuonCalib::MdtCalibDataContainer& writeCdo) const;
46 
48 
50  using LoadedRtMap = std::map<Identifier, RtRelationPtr>;
51 
53  LoadedRtMap& loadedRts) const;
54 
55  std::optional<double> getInnerTubeRadius(const Identifier& id) const;
56 
61 
62 
63  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
64  ToolHandle<MuonCalib::IIdToFixedIdTool> m_idToFixedIdTool{this, "IdToFixedIdTool", "MuonCalib::IdToFixedIdTool"};
65 
68 
69  Gaudi::Property<bool> m_useNewGeo{this, "UseR4DetMgr", false,
70  "Switch between the legacy and the new geometry"};
71 
73 
74  Gaudi::Property<bool> m_checkTubes{this, "checkTubes", true,"If true the number of tubes must agree between the conditions DB & geometry"};
75  // new conditions format 2020
76  Gaudi::Property<bool> m_newFormat2020{this, "NewFormat2020", false, "Use the new calibration data format "};
77 
78  // like MdtCalibrationDbSvc
79  // for corData in loadRt
80  Gaudi::Property<bool> m_create_b_field_function{this, "CreateBFieldFunctions", false,
81  "If set to true, the B-field correction functions are initialized for each rt-relation that is loaded."};
82 
83  Gaudi::Property<bool> m_createSlewingFunction{this, "CreateSlewingFunctions", false,
84  "If set to true, the slewing correction functions are initialized for each rt-relation that is loaded."};
85 
86 
87  // if m_TimeSlewingCorrection is set to true then it is assumed that the
88  // time slewing correction is applied. If false not. If this flag does
89  // not match the bit in the creation parameters, the rt-relation and t0
90  // will be corrected.
91  // NOTE: This was a preliminary solution for 17.2. In principle each
92  // MdtDriftCircleOnTrackCreator could decide individually if it wants to
93  // have TS-correction. In the default reco-jobs however, this is
94  // configured by one muonRecFlag, that will be used to set this job-option.
95  Gaudi::Property<bool> m_TimeSlewingCorrection{this, "TimeSlewingCorrection", false};
96  Gaudi::Property<bool> m_UseMLRt{this, "UseMLRt", false, "Enable use of ML-RTs from COOL"};
97 
98  Gaudi::Property<std::vector<float>> m_MeanCorrectionVsR{this, "MeanCorrectionVsR", {}};
99 
100  Gaudi::Property<double> m_TsCorrectionT0{this, "TimeSlewCorrectionT0", 0.};
101 
102  Gaudi::Property<double> m_defaultT0{this, "defaultT0", 40., "default T0 value to be used in absence of DB information"};
103  Gaudi::Property<double> m_t0Shift{this, "T0Shift", 0., "for simulation: common shift of all T0s, in ns"};
104  Gaudi::Property<double> m_t0Spread{this, "T0Spread", 0., "for simulation: sigma for random smeraing of T0s, in ns"};
105 
106  Gaudi::Property<double> m_rtShift{this, "RTShift", 0., "for simulations: maximum RT distortion, in mm"};
107  Gaudi::Property<double> m_rtScale{this, "RTScale", 1., "for simulations: a muliplicitive scale to the drift r"};
108  Gaudi::Property<double> m_prop_beta{this, "PropagationSpeedBeta", 1., "Speed of the signal propagation"};
109 
110  ServiceHandle<IAthRNGSvc> m_AthRNGSvc{this, "AthRNGSvc", "AthRNGSvc"};
111  StringProperty m_randomStream{this, "RandomStream", "MDTCALIBDBALG"};
113 
114  StringProperty m_RTfileName{this, "RT_InputFile", "MuonCondAlg/Muon_RT_default.data",
115  "single input ascii file for default RT to be applied in absence of DB information"}; // temporary!!!
116 
117  static std::unique_ptr<MuonCalib::RtResolutionLookUp> getRtResolutionInterpolation(const std::vector<MuonCalib::SamplePoint>& sample_points);
118 
119  SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyRt{this, "ReadKeyRt", "/MDT/RTBLOB", "DB folder containing the RT calibrations"};
120  SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyTube{this, "ReadKeyTube", "/MDT/T0BLOB", "DB folder containing the tube constants"};
122  "Conditions object containing the calibrations"};
123 
124  SG::ReadCondHandleKey<MdtCondDbData> m_readKeyDCS{this, "ReadKeyDCS", "MdtCondDbData", "Key of the input DCS data"};
125 };
126 
127 #endif
MdtCalibDbAlg::m_create_b_field_function
Gaudi::Property< bool > m_create_b_field_function
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:80
GeoModel::TransientConstSharedPtr< MdtRtRelation >
MdtCalibDbAlg::m_rtScale
Gaudi::Property< double > m_rtScale
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:107
MdtCalibDbAlg::m_useNewGeo
Gaudi::Property< bool > m_useNewGeo
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:69
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
MdtCalibDbAlg::m_rtShift
Gaudi::Property< double > m_rtShift
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:106
json
nlohmann::json json
Definition: HistogramDef.cxx:9
MdtCalibDbAlg::m_defaultT0
Gaudi::Property< double > m_defaultT0
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:102
MdtCalibDataContainer.h
MdtCalibDbAlg::m_createSlewingFunction
Gaudi::Property< bool > m_createSlewingFunction
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:83
MdtCalibDbAlg::m_detMgr
const MuonGM::MuonDetectorManager * m_detMgr
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:66
WriteCondHandleKey.h
MdtCalibDbAlg::m_randomStream
StringProperty m_randomStream
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:111
MdtCalibDbAlg::loadTube
StatusCode loadTube(const EventContext &ctx, MuonCalib::MdtCalibDataContainer &writeCdo) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:762
MdtCalibDbAlg::m_AthRNGSvc
ServiceHandle< IAthRNGSvc > m_AthRNGSvc
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:110
MdtCalibDbAlg::getRtResolutionInterpolation
static std::unique_ptr< MuonCalib::RtResolutionLookUp > getRtResolutionInterpolation(const std::vector< MuonCalib::SamplePoint > &sample_points)
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:876
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
MdtCalibDbAlg::legacyTubePayloadToJSON
StatusCode legacyTubePayloadToJSON(const coral::AttributeList &attr, nlohmann::json &json) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:646
MdtCalibDbAlg::m_TsCorrectionT0
Gaudi::Property< double > m_TsCorrectionT0
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:100
MdtCalibDbAlg::loadRt
StatusCode loadRt(const EventContext &ctx, MuonCalib::MdtCalibDataContainer &writeCdo) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:383
MdtCalibDbAlg::m_TimeSlewingCorrection
Gaudi::Property< bool > m_TimeSlewingCorrection
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:95
MdtCalibDbAlg::getInnerTubeRadius
std::optional< double > getInnerTubeRadius(const Identifier &id) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:271
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MdtCalibDbAlg::m_writeKey
SG::WriteCondHandleKey< MuonCalib::MdtCalibDataContainer > m_writeKey
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:121
MdtCalibDbAlg::m_prop_beta
Gaudi::Property< double > m_prop_beta
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:108
MdtCalibDbAlg::m_RTfileName
StringProperty m_RTfileName
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:114
MdtCalibDbAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:63
MdtCalibDbAlg::m_UseMLRt
Gaudi::Property< bool > m_UseMLRt
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:96
MdtCalibDbAlg::initialize
virtual StatusCode initialize() override
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonDetectorManager.h
MdtCalibDbAlg::isReEntrant
virtual bool isReEntrant() const override
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:39
MdtCalibDbAlg::m_readKeyDCS
SG::ReadCondHandleKey< MdtCondDbData > m_readKeyDCS
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:124
RtResolutionLookUp.h
MdtCalibDbAlg::legacyRtPayloadToJSON
StatusCode legacyRtPayloadToJSON(const coral::AttributeList &attr, nlohmann::json &json) const
Parses the legacy payload for the RT functions to a json format.
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:290
MdtCalibDbAlg::~MdtCalibDbAlg
virtual ~MdtCalibDbAlg()=default
MdtCalibDbAlg::m_newFormat2020
Gaudi::Property< bool > m_newFormat2020
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:76
MdtCalibDbAlg::m_t0Spread
Gaudi::Property< double > m_t0Spread
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:104
ReadCondHandleKey.h
AthReentrantAlgorithm.h
MdtCalibDbAlg::m_r4detMgr
const MuonGMR4::MuonDetectorManager * m_r4detMgr
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:67
MdtCalibDbAlg::m_readKeyRt
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyRt
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:119
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
MdtCalibDbAlg::declareDependency
StatusCode declareDependency(const EventContext &ctx, SG::WriteCondHandle< MuonCalib::MdtCalibDataContainer > &writeHandle) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:96
MuonDetectorManager.h
SG::ReadCondHandleKey< CondAttrListCollection >
MdtCalibDbAlg::m_readKeyTube
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyTube
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:120
MdtCalibDbAlg::MdtCalibDbAlg
MdtCalibDbAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:49
blobaccess.h
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MdtCalibDbAlg::m_MeanCorrectionVsR
Gaudi::Property< std::vector< float > > m_MeanCorrectionVsR
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:98
MdtCalibDbAlg::m_checkTubes
Gaudi::Property< bool > m_checkTubes
only needed to retrieve information on number of tubes etc. (no alignment needed)
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:74
MdtCalibDbAlg::defaultT0s
StatusCode defaultT0s(MuonCalib::MdtCalibDataContainer &writeCdoTube) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:597
MuonCalib::MdtCalibDataContainer
Definition: MdtCalibDataContainer.h:20
MdtCalibDbAlg::m_RNGWrapper
ATHRNG::RNGWrapper * m_RNGWrapper
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:112
MuonCalib::MdtFullCalibData::RtRelationPtr
GeoModel::TransientConstSharedPtr< MdtRtRelation > RtRelationPtr
Definition: MdtFullCalibData.h:17
MdtCalibDbAlg::m_t0Shift
Gaudi::Property< double > m_t0Shift
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:103
MdtCalibDbAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:120
MdtCalibDbAlg::defaultRt
StatusCode defaultRt(MuonCalib::MdtCalibDataContainer &writeCdoRt, LoadedRtMap &loadedRts) const
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/src/MdtCalibDbAlg.cxx:147
SG::WriteCondHandleKey< MuonCalib::MdtCalibDataContainer >
SamplePoint.h
MdtCalibDbAlg::m_idToFixedIdTool
ToolHandle< MuonCalib::IIdToFixedIdTool > m_idToFixedIdTool
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:64
MdtCondDbData.h
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
MdtCalibDbAlg::LoadedRtMap
std::map< Identifier, RtRelationPtr > LoadedRtMap
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:50
IMuonIdHelperSvc.h
IIdToFixedIdTool.h
MdtCalibDbAlg
MdtCalibDbAlg reads raw condition data and writes derived condition data to the condition store.
Definition: MuonConditions/MuonCondGeneral/MuonCondAlg/MuonCondAlg/MdtCalibDbAlg.h:33
IAthRNGSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >
Identifier
Definition: IdentifierFieldParser.cxx:14