Loading...
Searching...
No Matches
pappso::MzCalibrationModel1 Class Reference

`#include <mzcalibrationmodel1.h>`

Inheritance diagram for pappso::MzCalibrationModel1:

## Public Member Functions

| MzCalibrationModel1 (double T1_frame, double T2_frame, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3, double C4, double T1_ref, double T2_ref, double dC1, double dC2)
virtual | ~MzCalibrationModel1 ()
virtual double | getMzFromTofIndex (quint32 tof_index) override
| get m/z from time of flight raw index
virtual quint32 | getTofIndexFromMz (double mz) override
| get raw TOF index of a given m/z
Public Member Functions inherited from pappso::MzCalibrationInterface
| MzCalibrationInterface (double digitizerTimebase, double digitizerDelay)
virtual | ~MzCalibrationInterface ()
MzCalibrationInterface & | operator= (const MzCalibrationInterface &other)
bool | operator== (const MzCalibrationInterface &other) const
double | getTofFromTofIndex (quint32 tof_index) const
| get time of flight from raw index
double | getTofFromTofIndex (double tof_index) const
| get time of flight from double index

## Additional Inherited Members

Protected Attributes inherited from pappso::MzCalibrationInterface
double | m_digitizerTimebase = 0
double | m_digitizerDelay = 0
std::vector< double > | m_mzCalibrationArr
| MZ calibration parameters.

## Detailed Description

Todo:
  write docs

Definition at line 40 of file mzcalibrationmodel1.h.

## Constructor & Destructor Documentation

## MzCalibrationModel1()

MzCalibrationModel1::MzCalibrationModel1 | ( | double | T1_frame,
|  | double | T2_frame,
|  | double | digitizerTimebase,
|  | double | digitizerDelay,
|  | double | C0,
|  | double | C1,
|  | double | C2,
|  | double | C3,
|  | double | C4,
|  | double | T1_ref,
|  | double | T2_ref,
|  | double | dC1,
|  | double | dC2
| ) |  |

Default constructor

Definition at line 38 of file mzcalibrationmodel1.cpp.

: MzCalibrationInterface(digitizerTimebase, digitizerDelay)
{
double temperature_correction =
dC1 * (T1_ref - T1_frame) + dC2 * (T2_ref - T2_frame);
temperature_correction = (double)1.0 + (temperature_correction / 1.0e6);
// temperature compensation
C1 = C1 * temperature_correction;
C2 = C2 / temperature_correction;
m_mzCalibrationArr.clear();
m_digitizerDelay = digitizerDelay;
m_digitizerTimebase = digitizerTimebase;
m_mzCalibrationArr.push_back(C0);
m_mzCalibrationArr.push_back(std::sqrt(std::pow(10, 12) / C1));
m_mzCalibrationArr.push_back(C2);
m_mzCalibrationArr.push_back(C3);
m_mzCalibrationArr.push_back(C4);
}
pappso::MzCalibrationInterface
Definition mzcalibrationinterface.h:43
pappso::MzCalibrationInterface::m_mzCalibrationArr
std::vector< double > m_mzCalibrationArr
MZ calibration parameters.
Definition mzcalibrationinterface.h:101
pappso::MzCalibrationInterface::m_digitizerTimebase
double m_digitizerTimebase
Definition mzcalibrationinterface.h:96
pappso::MzCalibrationInterface::m_digitizerDelay
double m_digitizerDelay
Definition mzcalibrationinterface.h:97

References pappso::MzCalibrationInterface::m_digitizerDelay, pappso::MzCalibrationInterface::m_digitizerTimebase, and pappso::MzCalibrationInterface::m_mzCalibrationArr.

## ~MzCalibrationModel1()

MzCalibrationModel1::~MzCalibrationModel1 | ( |  | ) |

virtual

Destructor

Definition at line 75 of file mzcalibrationmodel1.cpp.

{
}

## Member Function Documentation

## getMzFromTofIndex()

double MzCalibrationModel1::getMzFromTofIndex | ( | quint32 | tof_index | ) |

override virtual

get m/z from time of flight raw index

Parameters

  tof_index | time of flight

Returns
  m/z value

Implements pappso::MzCalibrationInterface.

Reimplemented in pappso::MzCalibrationModel1Cached.

Definition at line 80 of file mzcalibrationmodel1.cpp.

{
double tof = ((double)tof_index * m_digitizerTimebase) + m_digitizerDelay;
// http://www.alglib.net/equations/polynomial.php
// http://www.alglib.net/translator/man/manual.cpp.html#sub_polynomialsolve
// https://math.stackexchange.com/questions/1291208/number-of-roots-of-a-polynomial-of-non-integer-degree
// https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=2ahUKEwiWhLOFxqrkAhVLxYUKHVqqDFcQFjABegQIAxAB&url=https%3A%2F%2Fkluge.in-chemnitz.de%2Fopensource%2Fspline%2Fexample_alglib.cpp&usg=AOvVaw0guGejJGPmkOVg48_GJYR8
// https://stackoverflow.com/questions/26091323/how-to-plot-a-function-curve-in-r
/*
* beware to put the function on a single line in R:
> eq <- function(m){ 1 + (sqrt((10^12)/670) * sqrt(m)) + (207.775676931964 * m)
+ (59.2526676368822 * (m^1.5)) }
> eq <- function(m){ 313.577620892277 + (sqrt((10^12)/157424.07710945) *
sqrt(m)) + (0.000338743021989553 * m)
+ (0 * (m^1.5)) }
> plot(eq(1:1000), type='l')
> eq2 <- function(m2){ 1 + sqrt((10^12)/670) * m2 + 207.775676931964 * (m2^2)
+ 59.2526676368822 * (m2^3) }
> plot(eq2(1:sqrt(1000)), type='l')
*/
// How to Factor a Trinomial with Fractions as Coefficients
// formula
// a = c0 = 1
// b = sqrt((10^12)/c1), c1 = 670 * m^0.5 (1/2)
// c = c2, c2 = 207.775676931964 * m
// d = c3, c3 = 59.2526676368822 * m^1.5 (3/2)
// double mz = 0;
/* transformation formula given by Bruker 29/8/2019 :
* x = m + dm
*
* time = m_mzCalibrationArr[0]
* + sqrt ((10^12)/m_mzCalibrationArr[1]) * x^0.5
* + m_mzCalibrationArr[2] * x
* + m_mzCalibrationArr[3] * x^1.5
*/
std::vector<double> X;
X.push_back((m_mzCalibrationArr[0] - (double)tof));
X.push_back(m_mzCalibrationArr[1]);
if(m_mzCalibrationArr[2] != 0)
{
X.push_back(m_mzCalibrationArr[2]);
}
if(m_mzCalibrationArr[3] != 0)
{
X.push_back(m_mzCalibrationArr[3]);
// qDebug() << "m_mzCalibrationArr[3]=" << m_mzCalibrationArr[3];
}
else
{
// qDebug() << "m_mzCalibrationArr[3]=" << m_mzCalibrationArr[3];
}
InHousePolynomialSolverResult res = inHousePolynomialSolve(X);
if(res.type == CardanoResultCase::notvalid)
{
throw pappso::PappsoException(
QObject::tr("ERROR in %1 %2 %3"
"inHousePolynomialSolve :\nresult is not valid")
.arg(__FILE__)
.arg(__FUNCTION__)
.arg(__LINE__));
}
return (pow(res.x1, 2) - m_mzCalibrationArr[4]);
}
inHousePolynomialSolve
InHousePolynomialSolverResult inHousePolynomialSolve(const std::vector< double > &polynome)
Definition cardano.cpp:118
CardanoResultCase::notvalid
@ notvalid
pappso::PappsoException
Definition pappsoexception.h:42
pappso::PrecisionUnit::res
@ res
InHousePolynomialSolverResult
Definition cardano.h:47

References inHousePolynomialSolve(), pappso::MzCalibrationInterface::m_digitizerDelay, pappso::MzCalibrationInterface::m_digitizerTimebase, pappso::MzCalibrationInterface::m_mzCalibrationArr, notvalid, and pappso::res.

Referenced by pappso::MzCalibrationModel1Cached::getMzFromTofIndex().

## getTofIndexFromMz()

quint32 MzCalibrationModel1::getTofIndexFromMz | ( | double | mz | ) |

override virtual

get raw TOF index of a given m/z

Parameters

  mz | the mass to transform

Returns
  integer x raw value

Implements pappso::MzCalibrationInterface.

Definition at line 155 of file mzcalibrationmodel1.cpp.

{
// formula
// a = c0 = 1
// b = sqrt((10^12)/c1), c1 = 670 * m^0.5 (1/2)
// c = c2, c2 = 207.775676931964 * m
// d = c3, c3 = 59.2526676368822 * m^1.5 (3/2)
qDebug() << "mz=" << mz;
mz = mz + m_mzCalibrationArr[4]; // mz_corr
double tof = m_mzCalibrationArr[0];
qDebug() << "tof ( m_mzCalibrationArr[0])=" << tof;
// TODO cache value of std::sqrt((std::pow(10, 12) / m_mzCalibrationArr[1]))
tof += m_mzCalibrationArr[1] * std::sqrt(mz);
qDebug() << "tof=" << tof;
tof += m_mzCalibrationArr[2] * mz;
qDebug() << "tof=" << tof;
tof += m_mzCalibrationArr[3] * std::pow(mz, 1.5);
qDebug() << "tof=" << tof;
tof -= m_digitizerDelay;
qDebug() << "tof=" << tof;
tof = tof / m_digitizerTimebase;
qDebug() << "index=" << tof;
return (quint32)std::round(tof);
}
pappso::PrecisionUnit::mz
@ mz

References pappso::MzCalibrationInterface::m_digitizerDelay, pappso::MzCalibrationInterface::m_digitizerTimebase, pappso::MzCalibrationInterface::m_mzCalibrationArr, and pappso::mz.

The documentation for this class was generated from the following files:

- pappsomspp/vendors/tims/mzcalibration/mzcalibrationmodel1.h
- pappsomspp/vendors/tims/mzcalibration/mzcalibrationmodel1.cpp