OpenMS
Loading...
Searching...
No Matches
MzCalibrationTof2MzConverter.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <OpenMS/config.h>
7
8#ifdef WITH_OPENTIMS
9
10#include <OpenMS/OpenMSConfig.h>
11#include <opentims++/tof2mz_converter.h>
12#include <array>
13#include <cstdint>
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace OpenMS
19{
20
58 class OPENMS_DLLAPI MzCalibrationTof2MzConverter : public Tof2MzConverter
59 {
60 public:
62 struct Correction
63 {
64 double low = 0.0;
65 double high = 0.0;
66 int n = 0;
67 std::array<double, 7> coefficients{};
68 };
69
71 struct Calibration
72 {
73 int model_type = 0;
74 double digitizer_timebase = 0.0;
75 double digitizer_delay = 0.0;
76 double t1 = 0.0;
77 double t2 = 0.0;
78 double dc1 = 0.0;
79 double dc2 = 0.0;
80 double c0 = 0.0, c1 = 0.0, c2 = 0.0, c3 = 0.0, c4 = 0.0;
81 Correction correction;
82 };
83
85 struct FrameModel
86 {
87 double timebase = 0.0;
88 double delay = 0.0;
89 double c0 = 0.0;
90 double b = 0.0;
91 double c2 = 0.0;
92 double c3 = 0.0;
93 double c4 = 0.0;
94 Correction correction;
95 };
96
98 static FrameModel makeFrameModel(const Calibration& cal, double frame_t1, double frame_t2);
99
101 explicit MzCalibrationTof2MzConverter(std::vector<FrameModel> frame_models, std::string description = "");
102
103 void convert(uint32_t frame_id, double* mzs, const double* tofs, uint32_t size) override;
104 void convert(uint32_t frame_id, double* mzs, const uint32_t* tofs, uint32_t size) override;
105 void inverse_convert(uint32_t frame_id, uint32_t* tofs, const double* mzs, uint32_t size) override;
106
108 std::string description() override;
109
111 static double tofToMz(const FrameModel& m, double tof_index);
112
114 static uint32_t mzToTof(const FrameModel& m, double mz);
115
116 private:
117 std::vector<FrameModel> frame_models_;
118 std::string description_;
119
121 const FrameModel& getModel(uint32_t frame_id) const;
122 };
123
133 OPENMS_DLLAPI std::unique_ptr<Tof2MzConverter> tryCreateMzCalibrationConverter(
134 const std::string& tims_dir_path);
135
136} // namespace OpenMS
137
138#endif // WITH_OPENTIMS
T convert(const std::string &s)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19