ATLAS Offline Software
MdtCalibDbAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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_createWireSagFunction{this, "CreateWireSagFunctions", false,
84  "If set to true, the wire sag correction functions are initialized for each rt-relation that is loaded."};
85  Gaudi::Property<bool> m_createSlewingFunction{this, "CreateSlewingFunctions", false,
86  "If set to true, the slewing correction functions are initialized for each rt-relation that is loaded."};
87 
89 
90  // if m_TimeSlewingCorrection is set to true then it is assumed that the
91  // time slewing correction is applied. If false not. If this flag does
92  // not match the bit in the creation parameters, the rt-relation and t0
93  // will be corrected.
94  // NOTE: This was a preliminary solution for 17.2. In principle each
95  // MdtDriftCircleOnTrackCreator could decide individually if it wants to
96  // have TS-correction. In the default reco-jobs however, this is
97  // configured by one muonRecFlag, that will be used to set this job-option.
98  Gaudi::Property<bool> m_TimeSlewingCorrection{this, "TimeSlewingCorrection", false};
99  Gaudi::Property<bool> m_UseMLRt{this, "UseMLRt", false, "Enable use of ML-RTs from COOL"};
100 
101  Gaudi::Property<std::vector<float>> m_MeanCorrectionVsR{this, "MeanCorrectionVsR", {}};
102 
103  Gaudi::Property<double> m_TsCorrectionT0{this, "TimeSlewCorrectionT0", 0.};
104 
105  Gaudi::Property<double> m_defaultT0{this, "defaultT0", 40., "default T0 value to be used in absence of DB information"};
106  Gaudi::Property<double> m_t0Shift{this, "T0Shift", 0., "for simulation: common shift of all T0s, in ns"};
107  Gaudi::Property<double> m_t0Spread{this, "T0Spread", 0., "for simulation: sigma for random smeraing of T0s, in ns"};
108 
109  Gaudi::Property<double> m_rtShift{this, "RTShift", 0., "for simulations: maximum RT distortion, in mm"};
110  Gaudi::Property<double> m_rtScale{this, "RTScale", 1., "for simulations: a muliplicitive scale to the drift r"};
111  Gaudi::Property<double> m_prop_beta{this, "PropagationSpeedBeta", 1., "Speed of the signal propagation"};
112 
113  ServiceHandle<IAthRNGSvc> m_AthRNGSvc{this, "AthRNGSvc", "AthRNGSvc"};
114  StringProperty m_randomStream{this, "RandomStream", "MDTCALIBDBALG"};
116 
117  StringProperty m_RTfileName{this, "RT_InputFile", "MuonCondAlg/Muon_RT_default.data",
118  "single input ascii file for default RT to be applied in absence of DB information"}; // temporary!!!
119 
120  static std::unique_ptr<MuonCalib::RtResolutionLookUp> getRtResolutionInterpolation(const std::vector<MuonCalib::SamplePoint>& sample_points);
121 
122  SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyRt{this, "ReadKeyRt", "/MDT/RTBLOB", "DB folder containing the RT calibrations"};
123  SG::ReadCondHandleKey<CondAttrListCollection> m_readKeyTube{this, "ReadKeyTube", "/MDT/T0BLOB", "DB folder containing the tube constants"};
125  "Conditions object containing the calibrations"};
126 
127  SG::ReadCondHandleKey<MdtCondDbData> m_readKeyDCS{this, "ReadKeyDCS", "MdtCondDbData", "Key of the input DCS data"};
128 };
129 
130 #endif
MdtCalibDbAlg::m_create_b_field_function
Gaudi::Property< bool > m_create_b_field_function
Definition: MdtCalibDbAlg.h:80
GeoModel::TransientConstSharedPtr< MdtRtRelation >
MdtCalibDbAlg::m_rtScale
Gaudi::Property< double > m_rtScale
Definition: MdtCalibDbAlg.h:110
MdtCalibDbAlg::m_useNewGeo
Gaudi::Property< bool > m_useNewGeo
Definition: 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:61
MdtCalibDbAlg::m_rtShift
Gaudi::Property< double > m_rtShift
Definition: MdtCalibDbAlg.h:109
json
nlohmann::json json
Definition: HistogramDef.cxx:9
MdtCalibDbAlg::m_defaultT0
Gaudi::Property< double > m_defaultT0
Definition: MdtCalibDbAlg.h:105
MdtCalibDataContainer.h
MdtCalibDbAlg::m_createSlewingFunction
Gaudi::Property< bool > m_createSlewingFunction
Definition: MdtCalibDbAlg.h:85
MdtCalibDbAlg::m_detMgr
const MuonGM::MuonDetectorManager * m_detMgr
Definition: MdtCalibDbAlg.h:66
WriteCondHandleKey.h
MdtCalibDbAlg::m_randomStream
StringProperty m_randomStream
Definition: MdtCalibDbAlg.h:114
MdtCalibDbAlg::loadTube
StatusCode loadTube(const EventContext &ctx, MuonCalib::MdtCalibDataContainer &writeCdo) const
Definition: MdtCalibDbAlg.cxx:774
MdtCalibDbAlg::m_AthRNGSvc
ServiceHandle< IAthRNGSvc > m_AthRNGSvc
Definition: MdtCalibDbAlg.h:113
MdtCalibDbAlg::getRtResolutionInterpolation
static std::unique_ptr< MuonCalib::RtResolutionLookUp > getRtResolutionInterpolation(const std::vector< MuonCalib::SamplePoint > &sample_points)
Definition: MdtCalibDbAlg.cxx:888
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
MdtCalibDbAlg::legacyTubePayloadToJSON
StatusCode legacyTubePayloadToJSON(const coral::AttributeList &attr, nlohmann::json &json) const
Definition: MdtCalibDbAlg.cxx:658
MdtCalibDbAlg::m_TsCorrectionT0
Gaudi::Property< double > m_TsCorrectionT0
Definition: MdtCalibDbAlg.h:103
MdtCalibDbAlg::loadRt
StatusCode loadRt(const EventContext &ctx, MuonCalib::MdtCalibDataContainer &writeCdo) const
Definition: MdtCalibDbAlg.cxx:394
MdtCalibDbAlg::m_TimeSlewingCorrection
Gaudi::Property< bool > m_TimeSlewingCorrection
Definition: MdtCalibDbAlg.h:98
MdtCalibDbAlg::getInnerTubeRadius
std::optional< double > getInnerTubeRadius(const Identifier &id) const
Definition: MdtCalibDbAlg.cxx:282
MdtCalibDbAlg::initializeSagCorrection
void initializeSagCorrection(MuonCalib::MdtCorFuncSet &funcSet) const
Definition: MdtCalibDbAlg.cxx:922
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: MdtCalibDbAlg.h:124
MdtCalibDbAlg::m_prop_beta
Gaudi::Property< double > m_prop_beta
Definition: MdtCalibDbAlg.h:111
MdtCalibDbAlg::m_RTfileName
StringProperty m_RTfileName
Definition: MdtCalibDbAlg.h:117
MdtCalibDbAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtCalibDbAlg.h:63
MuonCalib::MdtCorFuncSet
Class which holds all correction functions for a given region.
Definition: MdtCorFuncSet.h:18
MdtCalibDbAlg::m_UseMLRt
Gaudi::Property< bool > m_UseMLRt
Definition: MdtCalibDbAlg.h:99
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
MdtCalibDbAlg::initialize
virtual StatusCode initialize() override
Definition: MdtCalibDbAlg.cxx:54
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: MdtCalibDbAlg.h:39
MdtCalibDbAlg::m_readKeyDCS
SG::ReadCondHandleKey< MdtCondDbData > m_readKeyDCS
Definition: MdtCalibDbAlg.h:127
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: MdtCalibDbAlg.cxx:301
MdtCalibDbAlg::~MdtCalibDbAlg
virtual ~MdtCalibDbAlg()=default
MdtCalibDbAlg::m_newFormat2020
Gaudi::Property< bool > m_newFormat2020
Definition: MdtCalibDbAlg.h:76
MdtCalibDbAlg::m_createWireSagFunction
Gaudi::Property< bool > m_createWireSagFunction
Definition: MdtCalibDbAlg.h:83
MdtCalibDbAlg::m_t0Spread
Gaudi::Property< double > m_t0Spread
Definition: MdtCalibDbAlg.h:107
ReadCondHandleKey.h
AthReentrantAlgorithm.h
MdtCalibDbAlg::m_r4detMgr
const MuonGMR4::MuonDetectorManager * m_r4detMgr
Definition: MdtCalibDbAlg.h:67
MdtCalibDbAlg::m_readKeyRt
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyRt
Definition: MdtCalibDbAlg.h:122
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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: MdtCalibDbAlg.cxx:98
MuonDetectorManager.h
SG::ReadCondHandleKey< CondAttrListCollection >
MdtCalibDbAlg::m_readKeyTube
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyTube
Definition: MdtCalibDbAlg.h:123
MdtCalibDbAlg::MdtCalibDbAlg
MdtCalibDbAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MdtCalibDbAlg.cxx:51
blobaccess.h
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
MdtCalibDbAlg::m_MeanCorrectionVsR
Gaudi::Property< std::vector< float > > m_MeanCorrectionVsR
Definition: MdtCalibDbAlg.h:101
MdtCalibDbAlg::m_checkTubes
Gaudi::Property< bool > m_checkTubes
only needed to retrieve information on number of tubes etc. (no alignment needed)
Definition: MdtCalibDbAlg.h:74
MdtCalibDbAlg::defaultT0s
StatusCode defaultT0s(MuonCalib::MdtCalibDataContainer &writeCdoTube) const
Definition: MdtCalibDbAlg.cxx:609
MuonCalib::MdtCalibDataContainer
Definition: MdtCalibDataContainer.h:20
MdtCalibDbAlg::m_RNGWrapper
ATHRNG::RNGWrapper * m_RNGWrapper
Definition: MdtCalibDbAlg.h:115
MuonCalib::MdtFullCalibData::RtRelationPtr
GeoModel::TransientConstSharedPtr< MdtRtRelation > RtRelationPtr
Definition: MdtFullCalibData.h:17
MdtCalibDbAlg::m_t0Shift
Gaudi::Property< double > m_t0Shift
Definition: MdtCalibDbAlg.h:106
MdtCalibDbAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MdtCalibDbAlg.cxx:122
MdtCalibDbAlg::defaultRt
StatusCode defaultRt(MuonCalib::MdtCalibDataContainer &writeCdoRt, LoadedRtMap &loadedRts) const
Definition: MdtCalibDbAlg.cxx:149
SG::WriteCondHandleKey< MuonCalib::MdtCalibDataContainer >
SamplePoint.h
MdtCalibDbAlg::m_idToFixedIdTool
ToolHandle< MuonCalib::IIdToFixedIdTool > m_idToFixedIdTool
Definition: MdtCalibDbAlg.h:64
MdtCondDbData.h
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
MdtCalibDbAlg::LoadedRtMap
std::map< Identifier, RtRelationPtr > LoadedRtMap
Definition: MdtCalibDbAlg.h:50
IMuonIdHelperSvc.h
IIdToFixedIdTool.h
MdtCalibDbAlg
MdtCalibDbAlg reads raw condition data and writes derived condition data to the condition store.
Definition: MdtCalibDbAlg.h:33
IAthRNGSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >