OpenMS  3.0.0
RangeManager.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/config.h>
40 
41 #include <cmath> // for nan()
42 #include <algorithm> // for min/max
43 #include <cassert>
44 #include <iosfwd> // for std::ostream
45 
46 namespace OpenMS
47 {
49  enum class MSDim
50  {
51  RT,
52  MZ,
53  INT,
54  IM
55  };
56 
58  struct OPENMS_DLLAPI RangeBase
59  {
60  public:
62  RangeBase() = default;
63 
66  RangeBase(const double min, const double max) :
67  min_(min), max_(max)
68  {
69  if (min_ > max_)
70  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Invalid initialization of range");
71  }
73  RangeBase(const RangeBase& rhs) = default;
74 
76  RangeBase(RangeBase&& rhs) noexcept = default;
77 
79  RangeBase& operator=(const RangeBase& rhs) = default;
80 
82  RangeBase& operator=(RangeBase&& rhs) noexcept = default;
83 
85  ~RangeBase() noexcept = default;
86 
88  void clear()
89  {
90  *this = RangeBase(); // overwrite with fresh instance
91  }
92 
94  bool isEmpty() const
95  {
96  return min_ > max_;
97  }
98 
100  bool contains(const double value) const
101  {
102  return (min_ <= value) & (value <= max_);
103  }
104 
106  bool contains(const RangeBase& inner_range) const
107  {
108  return contains(inner_range.min_) & contains(inner_range.max_);
109  }
110 
115 
118  void setMin(const double min)
119  {
120  min_ = min;
121  if (max_ < min)
122  max_ = min;
123  }
124 
126  void setMax(const double max)
127  {
128  max_ = max;
129  if (min_ > max)
130  min_ = max;
131  }
132 
134  double getMin() const
135  {
136  return min_;
137  }
138 
140  double getMax() const
141  {
142  return max_;
143  }
145 
147  void extend(const RangeBase& other)
148  {
149  min_ = std::min(min_, other.min_);
150  max_ = std::max(max_, other.max_);
151  }
152 
154  void extend(const double value)
155  {
156  min_ = std::min(min_, value);
157  max_ = std::max(max_, value);
158  }
159 
163  void extendLeftRight(const double by)
164  {
165  if (isEmpty()) return;
166  min_ -= by;
167  max_ += by;
168  }
169 
175  void minSpanIfSingular(const double min_span)
176  {
177  if (min_ == max_) extendLeftRight(min_span / 2);
178  }
179 
186  void clampTo(const RangeBase& other)
187  {
188  if (isEmpty()) return;
189  if (other.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
190 
191  min_ = std::max(min_, other.min_);
192  max_ = std::min(max_, other.max_);
193  }
194 
200  void pushInto(const RangeBase& sandbox)
201  {
202  if (isEmpty()) return;
203  if (sandbox.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
204 
205  if (!sandbox.contains(*this))
206  {
207  if (getSpan() > sandbox.getSpan())
208  { // make interval fit into sandbox (= ensure full containment)
209  max_ = min_ + sandbox.getSpan();
210  }
211  if (min_ < sandbox.min_)
212  { // need to shift right (positive shift)
213  shift(sandbox.min_ - min_);
214  }
215  else if (max_ > sandbox.max_)
216  { // need to shift left (negative shift)
217  shift(sandbox.max_ - max_);
218  }
219  }
220 
221  }
222 
223 
234  void scaleBy(const double factor)
235  {
236  if (isEmpty()) return;
237  const double dist = max_ - min_;
238  const double extension = dist * (factor - 1) / 2;
239  min_ -= extension;
240  max_ += extension;
241  }
242 
245  void shift(const double distance)
246  {
247  if (isEmpty()) return;
248  min_ += distance;
249  max_ += distance;
250  }
251 
254  double center() const
255  {
256  if (isEmpty()) return nan("");
257  return min_ + (max_ - min_) / 2.0;
258  }
259 
262  double getSpan() const
263  {
264  if (isEmpty()) return nan("");
265  return max_ - min_;
266  }
267 
268  bool operator==(const RangeBase& rhs) const
269  {
270  return min_ == rhs.min_ && max_ == rhs.max_;
271  }
272 
277  std::pair<double, double> getNonEmptyRange() const
278  {
279  // pair with full range
280  if (isEmpty()) return {std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()};
281  else return {min_, max_};
282  }
283 
284  protected:
285  // make members non-accessible to maintain invariant: min <= max (unless uninitialized)
286  double min_ = std::numeric_limits<double>::max();
287  double max_ = std::numeric_limits<double>::lowest();
288  };
289 
290  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeBase& b);
291 
292  struct OPENMS_DLLAPI RangeRT : public RangeBase {
293 
294  const static MSDim DIM = MSDim::RT;
295 
296  RangeRT() = default;
297  RangeRT(const double min, const double max)
298  : RangeBase(min, max)
299  {
300  }
301 
303  {
305  return *this;
306  }
307 
308 
313 
316  void setMinRT(const double min)
317  {
318  setMin(min);
319  }
320 
322  void setMaxRT(const double max)
323  {
324  setMax(max);
325  }
326 
328  double getMinRT() const
329  {
330  return min_;
331  }
332 
334  double getMaxRT() const
335  {
336  return max_;
337  }
339 
341  void extendRT(const double value)
342  {
343  extend(value);
344  }
345 
347  bool containsRT(const double value) const
348  {
349  return RangeBase::contains(value);
350  }
351 
353  bool containsRT(const RangeBase& inner_range) const
354  {
355  return RangeBase::contains(inner_range);
356  }
357  };
358 
359  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeRT& range);
360 
361  struct OPENMS_DLLAPI RangeMZ : public RangeBase
362  {
363 
364  const static MSDim DIM = MSDim::MZ;
365 
366  RangeMZ() = default;
367  RangeMZ(const double min, const double max) :
368  RangeBase(min, max)
369  {
370  }
371 
373  {
375  return *this;
376  }
377 
382 
385  void setMinMZ(const double min)
386  {
387  setMin(min);
388  }
389 
391  void setMaxMZ(const double max)
392  {
393  setMax(max);
394  }
395 
397  double getMinMZ() const
398  {
399  return min_;
400  }
401 
403  double getMaxMZ() const
404  {
405  return max_;
406  }
408 
410  void extendMZ(const double value)
411  {
412  extend(value);
413  }
414 
416  bool containsMZ(const double value) const
417  {
418  return RangeBase::contains(value);
419  }
420 
422  bool containsMZ(const RangeBase& inner_range) const
423  {
424  return RangeBase::contains(inner_range);
425  }
426  };
427  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMZ& range);
428 
429  struct OPENMS_DLLAPI RangeIntensity : public RangeBase {
430 
431  const static MSDim DIM = MSDim::INT;
432 
433  RangeIntensity() = default;
434  RangeIntensity(const double min, const double max) :
435  RangeBase(min, max)
436  {
437  }
438 
440  {
442  return *this;
443  }
444 
449 
452  void setMinIntensity(const double min)
453  {
454  setMin(min);
455  }
456 
458  void setMaxIntensity(const double max)
459  {
460  setMax(max);
461  }
462 
464  double getMinIntensity() const
465  {
466  return min_;
467  }
468 
470  double getMaxIntensity() const
471  {
472  return max_;
473  }
475 
477  void extendIntensity(const double value)
478  {
479  extend(value);
480  }
481 
483  bool containsIntensity(const double value) const
484  {
485  return RangeBase::contains(value);
486  }
487 
489  bool containsIntensity(const RangeBase& inner_range) const
490  {
491  return RangeBase::contains(inner_range);
492  }
493  };
494  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeIntensity& range);
495 
496  struct OPENMS_DLLAPI RangeMobility : public RangeBase
497  {
498  const static MSDim DIM = MSDim::IM;
499 
500  RangeMobility() = default;
501  RangeMobility(const double min, const double max) :
502  RangeBase(min, max)
503  {
504  }
505 
507  {
509  return *this;
510  }
511 
516 
519  void setMinMobility(const double min)
520  {
521  setMin(min);
522  }
523 
525  void setMaxMobility(const double max)
526  {
527  setMax(max);
528  }
529 
531  double getMinMobility() const
532  {
533  return min_;
534  }
535 
537  double getMaxMobility() const
538  {
539  return max_;
540  }
542 
544  void extendMobility(const double value)
545  {
546  extend(value);
547  }
548 
550  bool containsMobility(const double value) const
551  {
552  return RangeBase::contains(value);
553  }
554 
556  bool containsMobility(const RangeBase& inner_range) const
557  {
558  return RangeBase::contains(inner_range);
559  }
560  };
561 
562  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMobility& range);
563 
565  enum class HasRangeType
566  {
567  ALL,
568  SOME,
569  NONE
570  };
571 
587  template<typename... RangeBases>
588  class RangeManager : public RangeBases...
589  {
590  public:
591  using ThisRangeType = RangeManager<RangeBases...>;
592  // rule of 0 -- no need for a virtual d'tor or anything fancy
593  // ...
594 
595  bool operator==(const RangeManager& rhs) const
596  {
597  bool equal = true;
598  for_each_base_([&](auto* base) {
599  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
600  equal &= ((T_BASE&) rhs == (T_BASE&) *this);
601  });
602  return equal;
603  }
604 
605  bool operator!=(const RangeManager& rhs) const
606  {
607  return !operator==(rhs);
608  }
609 
614  template <typename... RangeBasesOther>
616  {
617  bool found = false;
618  for_each_base_([&](auto* base) {
619  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
620  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
621  {
622  base->operator=((T_BASE&) rhs);
623  found = true;
624  }
625  });
626 
627  return found;
628  }
629 
634  template<typename... RangeBasesOther>
636  {
637  if (!assignUnsafe(rhs))
638  {
639  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION , "No assignment took place (no dimensions in common!);");
640  }
641  return *this;
642  }
643 
648  template<typename... RangeBasesOther>
650  {
651  bool found = false;
652  for_each_base_([&](auto* base) {
653  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
654  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
655  {
656  base->extend((T_BASE&) rhs);
657  found = true;
658  }
659  });
660  return found;
661  }
662 
667  template<typename... RangeBasesOther>
669  {
670  if (!extendUnsafe(rhs))
671  {
672  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
673  }
674  }
675 
677  void scaleBy(const double factor)
678  {
679  for_each_base_([&](auto* base) {
680  base->scaleBy(factor);
681  });
682  }
683 
692  void minSpanIfSingular(const double min_span)
693  {
694  for_each_base_([&](auto* base) {
695  base->minSpanIfSingular(min_span);
696  });
697  }
698 
699 
705  template<typename... RangeBasesOther>
707  {
708  bool found = false;
709  for_each_base_([&](auto* base) {
710  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
711  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
712  {
713  const auto& rhs_base = (T_BASE&)rhs;
714  if (!rhs_base.isEmpty()) base->pushInto(rhs_base);
715  found = true;
716  }
717  });
718  return found;
719  }
720 
726  template<typename... RangeBasesOther>
728  {
729  if (!pushIntoUnsafe(sandbox))
730  {
731  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
732  }
733  }
734 
735 
740  template<typename... RangeBasesOther>
742  {
743  bool found = false;
744  for_each_base_([&](auto* base) {
745  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
746  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
747  {
748  const auto& rhs_base = (T_BASE&)rhs;
749  if (!rhs_base.isEmpty()) base->clampTo(rhs_base);
750  found = true;
751  }
752  });
753  return found;
754  }
755 
761  template<typename... RangeBasesOther>
763  {
764  if (!clampToUnsafe(rhs))
765  {
766  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
767  }
768  }
769 
771  const RangeBase& getRangeForDim(MSDim dim) const
772  {
773  RangeBase* r_base = nullptr;
774 
775  static_for_each_base_([&](auto* base) {
776  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
777  if (base->DIM == dim)
778  r_base = (Base*)this;
779  });
780 
781  assert((r_base != nullptr) && "No base class has this MSDim!");
782  return *r_base;
783  }
784 
787  {
788  RangeBase* r_base = nullptr;
789 
790  static_for_each_base_([&](auto* base) {
791  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
792  if (base->DIM == dim)
793  r_base = (Base*) this;
794  });
795 
796  assert((r_base != nullptr) && "No base class has this MSDim!");
797  return *r_base;
798  }
799 
802  {
803  constexpr size_t total{sizeof...(RangeBases)};// total number of bases
804  size_t count{0};
805  for_each_base_([&](auto* base) {
806  count += !base->isEmpty();
807  });
808  switch (count)
809  {
810  case 0:
811  return HasRangeType::NONE;
812  case total:
813  return HasRangeType::ALL;
814  default:
815  return HasRangeType::SOME;
816  }
817  }
818 
823  template<typename... RangeBasesOther>
825  {
826  bool contained = true; // assume rhs is contained, until proven otherwise
827  bool has_overlap = false;
828  for_each_base_([&](auto* base) {
829  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
830  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
831  {
832  has_overlap = true; // at least one dimension overlaps
833  if (((T_BASE&)rhs).isEmpty()) return;
834  if (base->contains((T_BASE&) rhs)) return;
835  contained = false;
836  }
837  });
838  if (!has_overlap) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
839 
840  return contained;
841  }
842 
844  void clearRanges()
845  {
846  for_each_base_([&](auto* base) {
847  base->clear();
848  });
849  }
850 
854  {
855  switch (range)
856  {
857  case DIM_UNIT::RT:
858  if constexpr (std::is_base_of_v<RangeRT, ThisRangeType>) this->RangeRT::clear();
859  break;
860  case DIM_UNIT::MZ:
861  if constexpr (std::is_base_of_v<RangeMZ, ThisRangeType>) this->RangeMZ::clear();
862  break;
863  case DIM_UNIT::INT:
864  if constexpr (std::is_base_of_v<RangeIntensity, ThisRangeType>) this->RangeIntensity::clear();
865  break;
866  // assume all ion mobility ranges are the same and never occur together. If this is violated at some point, then split RangeMobility into subclasses...
867  case DIM_UNIT::IM_MS:
868  case DIM_UNIT::IM_VSSC:
869  case DIM_UNIT::FAIMS_CV:
870  if constexpr (std::is_base_of_v<RangeMobility, ThisRangeType>) this->RangeMobility::clear();
871  break;
872  default:
873  // all cases should be covered above
874  assert(false && "This should never be reached. Did you forget to implement a new DIM_UNIT?");
875  }
876  return *this;
877  }
878 
880  void printRange(std::ostream& out) const
881  {
882  for_each_base_([&](auto* base) {
883  out << *base;
884  });
885  }
886 
887  protected:
889  template<typename Visitor>
890  void for_each_base_(Visitor&& visitor)
891  {
892  (void(visitor(static_cast<RangeBases*>(this))), ...);
893  }
895  template<typename Visitor>
896  void for_each_base_(Visitor&& visitor) const
897  {
898  (void(visitor(static_cast<const RangeBases*>(this))), ...);
899  }
900 
902  template<typename Visitor>
903  static void static_for_each_base_(Visitor&& visitor)
904  {
905  (void(visitor(static_cast<const RangeBases*>(nullptr))), ...);
906  }
907  };
908 
909  template<typename... Range>
910  std::ostream& operator<<(std::ostream& out, const RangeManager<Range...>& me)
911  {
912  me.printRange(out);
913  return out;
914  }
915 
918  template <typename ...RangeBases>
920  : public RangeManager<RangeBases...>
921  {
922  public:
923  using ThisRangeType = typename RangeManager<RangeBases...>::ThisRangeType;
924 
927  virtual void updateRanges() = 0;
928 
930  const ThisRangeType& getRange() const
931  {
932  return (ThisRangeType&)*this;
933  }
934 
937  {
938  return (ThisRangeType&)*this;
939  }
940  };
941 
944 } // namespace OpenMS
OpenMS::RangeBase::isEmpty
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:94
OpenMS::RangeMobility::RangeMobility
RangeMobility(const double min, const double max)
Definition: RangeManager.h:501
OpenMS::RangeIntensity::extendIntensity
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:477
OpenMS::RangeBase::getMax
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:140
OpenMS::RangeBase::getNonEmptyRange
std::pair< double, double > getNonEmptyRange() const
Return the current range, or (if empty) a full range (-1e308, 1e308).
Definition: RangeManager.h:277
OpenMS::DIM_UNIT
DIM_UNIT
Definition: CommonEnums.h:45
OpenMS::DIM_UNIT::INT
intensity
OpenMS::RangeBase
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:58
OpenMS::MSDim::RT
OpenMS::RangeManager::static_for_each_base_
static void static_for_each_base_(Visitor &&visitor)
use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for e...
Definition: RangeManager.h:903
OpenMS::RangeBase::scaleBy
void scaleBy(const double factor)
Scale the range of the dimension by a factor. A factor > 1 increases the range; factor < 1 decreases ...
Definition: RangeManager.h:234
OpenMS::RangeBase::extendLeftRight
void extendLeftRight(const double by)
Definition: RangeManager.h:163
OpenMS::MSDim::INT
OpenMS::RangeMobility::getMaxMobility
double getMaxMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:537
OpenMS::RangeMobility::containsMobility
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:556
OpenMS::RangeBase::operator=
RangeBase & operator=(const RangeBase &rhs)=default
Assignment operator.
OpenMS::RangeRT::getMaxRT
double getMaxRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:334
OpenMS::MSDim::IM
OpenMS::Exception::InvalidRange
Invalid range exception.
Definition: Exception.h:276
OpenMS::RangeManagerContainer::updateRanges
virtual void updateRanges()=0
OpenMS::RangeMZ::getMaxMZ
double getMaxMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:403
OpenMS::RangeBase::minSpanIfSingular
void minSpanIfSingular(const double min_span)
If the current range is a single point, e.g. min==max, then extend the range by min_span / 2 on eithe...
Definition: RangeManager.h:175
OpenMS::RangeIntensity::containsIntensity
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:489
OpenMS::RangeManager::extendUnsafe
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:649
OpenMS::RangeMZ::operator=
RangeMZ & operator=(const RangeBase &rhs)
Definition: RangeManager.h:372
OpenMS::HasRangeType::NONE
all dimensions are empty (=cleared)
OpenMS::RangeIntensity::getMaxIntensity
double getMaxIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:470
OpenMS::RangeBase::clear
void clear()
make the range empty, i.e. isEmpty() will be true
Definition: RangeManager.h:88
OpenMS::RangeIntensity::setMaxIntensity
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:458
OpenMS::RangeBase::min_
double min_
Definition: RangeManager.h:286
OpenMS::RangeManager::getRangeForDim
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:771
OpenMS::RangeBase::pushInto
void pushInto(const RangeBase &sandbox)
Definition: RangeManager.h:200
OpenMS::DIM_UNIT::MZ
m/z
OpenMS::RangeBase::extend
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:147
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::RangeManager::assignUnsafe
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:615
OpenMS::RangeManager
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:588
OpenMS::DIM_UNIT::FAIMS_CV
FAIMS compensation voltage.
OpenMS::RangeManager::clampTo
void clampTo(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:762
OpenMS::RangeMZ::containsMZ
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:422
Exception.h
OpenMS::RangeBase::contains
bool contains(const double value) const
is value within [min, max]?
Definition: RangeManager.h:100
OpenMS::RangeBase::center
double center() const
Definition: RangeManager.h:254
OpenMS::RangeBase::operator==
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:268
OpenMS::RangeManager::scaleBy
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:677
OpenMS::RangeManager::printRange
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:880
OpenMS::RangeIntensity::RangeIntensity
RangeIntensity(const double min, const double max)
Definition: RangeManager.h:434
OpenMS::HasRangeType::SOME
some dimensions are empty, some are filled
OpenMS::RangeRT::setMinRT
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:316
OpenMS::RangeIntensity::containsIntensity
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:483
OpenMS::RangeManager::getRangeForDim
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:786
OpenMS::RangeManagerContainer::getRange
const ThisRangeType & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:930
OpenMS::RangeMobility::extendMobility
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:544
OpenMS::RangeBase::extend
void extend(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:154
OpenMS::RangeMZ::setMaxMZ
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:391
OpenMS::HasRangeType::ALL
all dimensions are filled
CommonEnums.h
OpenMS::RangeIntensity::operator=
RangeIntensity & operator=(const RangeBase &rhs)
Definition: RangeManager.h:439
OpenMS::RangeRT::containsRT
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:347
OpenMS::RangeBase::getMin
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:134
OpenMS::RangeIntensity
Definition: RangeManager.h:429
OpenMS::RangeManager::for_each_base_
void for_each_base_(Visitor &&visitor) const
.. and a const version
Definition: RangeManager.h:896
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::RangeRT::RangeRT
RangeRT(const double min, const double max)
Definition: RangeManager.h:297
OpenMS::RangeManagerContainer
Definition: RangeManager.h:919
OpenMS::RangeManager::for_each_base_
void for_each_base_(Visitor &&visitor)
use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for e...
Definition: RangeManager.h:890
OpenMS::RangeManager::pushIntoUnsafe
bool pushIntoUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:706
OpenMS::RangeManager::clampToUnsafe
bool clampToUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:741
OpenMS::RangeMZ::containsMZ
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:416
OpenMS::RangeManager::pushInto
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:727
OpenMS::RangeRT::getMinRT
double getMinRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:328
OpenMS::DIM_UNIT::IM_VSSC
volt-second per square centimeter (i.e. 1/K_0)
OpenMS::DIM_UNIT::IM_MS
ion mobility milliseconds
OpenMS::RangeBase::setMin
void setMin(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:118
OpenMS::RangeBase::max_
double max_
Definition: RangeManager.h:287
OpenMS::RangeMZ::RangeMZ
RangeMZ(const double min, const double max)
Definition: RangeManager.h:367
OpenMS::RangeMobility
Definition: RangeManager.h:496
OpenMS::RangeBase::contains
bool contains(const RangeBase &inner_range) const
is the range inner_range within [min, max]?
Definition: RangeManager.h:106
OpenMS::RangeBase::getSpan
double getSpan() const
Definition: RangeManager.h:262
OpenMS::RangeRT::containsRT
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:353
OpenMS::RangeManager::minSpanIfSingular
void minSpanIfSingular(const double min_span)
If any dimension is a single point, e.g. min==max, then extend this dimension by min_span / 2 on eith...
Definition: RangeManager.h:692
OpenMS::RangeManager::extend
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:668
OpenMS::RangeMobility::setMinMobility
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:519
OpenMS::RangeBase::setMax
void setMax(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:126
OpenMS::RangeBase::clampTo
void clampTo(const RangeBase &other)
Definition: RangeManager.h:186
OpenMS::RangeManager::operator==
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:595
OpenMS::MSDim::MZ
OpenMS::RangeMZ::extendMZ
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:410
OpenMS::RangeRT::operator=
RangeRT & operator=(const RangeBase &rhs)
Definition: RangeManager.h:302
OpenMS::RangeBase::shift
void shift(const double distance)
Definition: RangeManager.h:245
OpenMS::RangeMobility::getMinMobility
double getMinMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:531
OpenMS::RangeIntensity::getMinIntensity
double getMinIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:464
OpenMS::RangeRT::setMaxRT
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:322
OpenMS::RangeManager::operator!=
bool operator!=(const RangeManager &rhs) const
Definition: RangeManager.h:605
OpenMS::HasRangeType
HasRangeType
Enum listing state of dimensions (RangeBases)
Definition: RangeManager.h:565
OpenMS::RangeManagerContainer::ThisRangeType
typename RangeManager< RangeBases... >::ThisRangeType ThisRangeType
Definition: RangeManager.h:923
OpenMS::RangeIntensity::setMinIntensity
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:452
OpenMS::RangeRT::extendRT
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:341
OpenMS::RangeManager::clearRanges
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:844
OpenMS::RangeMobility::setMaxMobility
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:525
OpenMS::RangeManager::containsAll
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:824
OpenMS::DIM_UNIT::RT
RT in seconds.
OpenMS::RangeMZ
Definition: RangeManager.h:361
OpenMS::RangeMobility::operator=
RangeMobility & operator=(const RangeBase &rhs)
Definition: RangeManager.h:506
OpenMS::RangeManager::assign
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:635
OpenMS::RangeManagerContainer::getRange
ThisRangeType & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:936
OpenMS::RangeManager::clear
ThisRangeType & clear(const DIM_UNIT range)
Definition: RangeManager.h:853
OpenMS::RangeManager::hasRange
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:801
OpenMS::MSDim
MSDim
Dimensions of data acquisition for MS data.
Definition: RangeManager.h:49
OpenMS::RangeMZ::setMinMZ
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:385
OpenMS::RangeRT
Definition: RangeManager.h:292
OpenMS::RangeBase::RangeBase
RangeBase(const double min, const double max)
Definition: RangeManager.h:66
OpenMS::RangeMobility::containsMobility
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:550
OpenMS::RangeMZ::getMinMZ
double getMinMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:397