ProteoWizard
CalibrationParameters.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Darren Kessner <darren@proteowizard.org>
6//
7// Copyright 2006 Louis Warschaw Prostate Cancer Center
8// Cedars Sinai Medical Center, Los Angeles, California 90048
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21//
22
23
24#ifndef _CALIBRATIONPARAMETERS_HPP_
25#define _CALIBRATIONPARAMETERS_HPP_
26
27
29#include <cmath>
30#include <stdexcept>
31#include <iostream>
32
33
34namespace pwiz {
35namespace data {
36
37
38const double thermoA_FT_ = 1.075e8;
39const double thermoB_FT_ = -3.455e8;
40const double thermoA_Orbitrap_ = 4.753e10;
41const double thermoB_Orbitrap_ = 0;
42
43
44#pragma pack(1)
46{
47 double A;
48 double B;
49
52
53 CalibrationParameters(double a=0, double b=0, InstrumentModel im=FT);
54 double mz(double frequency) const;
55 double frequency(double mz) const;
56 bool operator==(const CalibrationParameters& that) const;
57 bool operator!=(const CalibrationParameters& that) const;
58
61};
62#pragma pack()
63
64
65inline std::ostream& operator<<(std::ostream& os, const CalibrationParameters& p)
66{
67 os << "(" << p.A << "," << p.B << ")";
68 return os;
69}
70
71
73: A(a), B(b), instrumentModel(im)
74{}
75
76
77inline double CalibrationParameters::mz(double frequency) const
78{
79 if (frequency == 0) throw std::runtime_error("[CalibrationParameters::mz()] Division by zero.\n");
80 return (instrumentModel==Orbitrap) ?
81 A/(frequency*frequency) :
82 A/frequency + B/(frequency*frequency);
83}
84
85
86inline double CalibrationParameters::frequency(double mz) const
87{
88 if (mz == 0) throw std::runtime_error("[CalibrationParameters::frequency()] Division by zero.\n");
89 return (instrumentModel==Orbitrap) ?
90 sqrt(A/mz) :
91 (A+sqrt(A*A + 4*B*mz))/(2*mz);
92}
93
94
96{
97 return A==that.A && B==that.B && instrumentModel==that.instrumentModel;
98}
99
100
102{
103 return !operator==(that);
104}
105
106
111
112
117
118
119} // namespace data
120} // namespace pwiz
121
122
123#endif // _CALIBRATIONPARAMETERS_HPP_
124
B
Definition Chemistry.hpp:81
#define A
std::ostream & operator<<(std::ostream &os, const Diff< object_type, config_type > &diff)
stream insertion of Diff results
Definition diff_std.hpp:200
const double thermoA_Orbitrap_
const double thermoB_FT_
const double thermoA_FT_
const double thermoB_Orbitrap_
bool operator!=(const CalibrationParameters &that) const
bool operator==(const CalibrationParameters &that) const
static CalibrationParameters thermo_FT()
CalibrationParameters(double a=0, double b=0, InstrumentModel im=FT)
double mz(double frequency) const
static CalibrationParameters thermo_Orbitrap()