 |
OpenMS
3.0.0
|
|
Go to the documentation of this file.
37 #include <OpenMS/config.h>
102 return (min_ <= value) & (value <= max_);
108 return contains(inner_range.
min_) & contains(inner_range.
max_);
149 min_ = std::min(min_, other.
min_);
150 max_ = std::max(max_, other.
max_);
156 min_ = std::min(min_, value);
157 max_ = std::max(max_, value);
165 if (isEmpty())
return;
177 if (min_ == max_) extendLeftRight(min_span / 2);
188 if (isEmpty())
return;
191 min_ = std::max(min_, other.
min_);
192 max_ = std::min(max_, other.
max_);
202 if (isEmpty())
return;
207 if (getSpan() > sandbox.
getSpan())
209 max_ = min_ + sandbox.
getSpan();
211 if (min_ < sandbox.
min_)
213 shift(sandbox.
min_ - min_);
215 else if (max_ > sandbox.
max_)
217 shift(sandbox.
max_ - max_);
236 if (isEmpty())
return;
237 const double dist = max_ - min_;
238 const double extension = dist * (factor - 1) / 2;
247 if (isEmpty())
return;
256 if (isEmpty())
return nan(
"");
257 return min_ + (max_ - min_) / 2.0;
264 if (isEmpty())
return nan(
"");
270 return min_ == rhs.
min_ && max_ == rhs.
max_;
280 if (isEmpty())
return {std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()};
281 else return {min_, max_};
286 double min_ = std::numeric_limits<double>::max();
287 double max_ = std::numeric_limits<double>::lowest();
359 OPENMS_DLLAPI std::ostream&
operator<<(std::ostream& out,
const RangeRT& range);
427 OPENMS_DLLAPI std::ostream&
operator<<(std::ostream& out,
const RangeMZ& range);
494 OPENMS_DLLAPI std::ostream&
operator<<(std::ostream& out,
const RangeIntensity& range);
562 OPENMS_DLLAPI std::ostream&
operator<<(std::ostream& out,
const RangeMobility& range);
587 template<
typename... RangeBases>
599 using T_BASE = std::decay_t<decltype(*base)>;
600 equal &= ((T_BASE&) rhs == (T_BASE&) *
this);
614 template <
typename... RangeBasesOther>
619 using T_BASE = std::decay_t<decltype(*base)>;
622 base->operator=((T_BASE&) rhs);
634 template<
typename... RangeBasesOther>
639 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION ,
"No assignment took place (no dimensions in common!);");
648 template<
typename... RangeBasesOther>
653 using T_BASE = std::decay_t<decltype(*base)>;
656 base->extend((T_BASE&) rhs);
667 template<
typename... RangeBasesOther>
672 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"No assignment took place (no dimensions in common!);");
680 base->scaleBy(factor);
695 base->minSpanIfSingular(min_span);
705 template<
typename... RangeBasesOther>
710 using T_BASE = std::decay_t<decltype(*base)>;
713 const auto& rhs_base = (T_BASE&)rhs;
714 if (!rhs_base.isEmpty()) base->
pushInto(rhs_base);
726 template<
typename... RangeBasesOther>
731 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"No assignment took place (no dimensions in common!);");
740 template<
typename... RangeBasesOther>
745 using T_BASE = std::decay_t<decltype(*base)>;
748 const auto& rhs_base = (T_BASE&)rhs;
749 if (!rhs_base.isEmpty()) base->
clampTo(rhs_base);
761 template<
typename... RangeBasesOther>
766 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"No assignment took place (no dimensions in common!);");
776 using Base = std::decay_t<decltype(*base)>;
777 if (base->DIM == dim)
778 r_base = (Base*)
this;
781 assert((r_base !=
nullptr) &&
"No base class has this MSDim!");
791 using Base = std::decay_t<decltype(*base)>;
792 if (base->DIM == dim)
793 r_base = (Base*)
this;
796 assert((r_base !=
nullptr) &&
"No base class has this MSDim!");
803 constexpr
size_t total{
sizeof...(RangeBases)};
806 count += !base->isEmpty();
823 template<
typename... RangeBasesOther>
826 bool contained =
true;
827 bool has_overlap =
false;
829 using T_BASE = std::decay_t<decltype(*base)>;
833 if (((T_BASE&)rhs).isEmpty())
return;
834 if (base->contains((T_BASE&) rhs))
return;
858 if constexpr (std::is_base_of_v<RangeRT, ThisRangeType>) this->
RangeRT::clear();
861 if constexpr (std::is_base_of_v<RangeMZ, ThisRangeType>) this->
RangeMZ::clear();
874 assert(
false &&
"This should never be reached. Did you forget to implement a new DIM_UNIT?");
889 template<
typename Visitor>
892 (void(visitor(static_cast<RangeBases*>(
this))), ...);
895 template<
typename Visitor>
898 (void(visitor(static_cast<const RangeBases*>(
this))), ...);
902 template<
typename Visitor>
905 (void(visitor(static_cast<const RangeBases*>(
nullptr))), ...);
909 template<
typename... Range>
918 template <
typename ...RangeBases>
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:94
RangeMobility(const double min, const double max)
Definition: RangeManager.h:501
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:477
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:140
std::pair< double, double > getNonEmptyRange() const
Return the current range, or (if empty) a full range (-1e308, 1e308).
Definition: RangeManager.h:277
DIM_UNIT
Definition: CommonEnums.h:45
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:58
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
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
void extendLeftRight(const double by)
Definition: RangeManager.h:163
double getMaxMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:537
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:556
RangeBase & operator=(const RangeBase &rhs)=default
Assignment operator.
double getMaxRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:334
Invalid range exception.
Definition: Exception.h:276
virtual void updateRanges()=0
double getMaxMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:403
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
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:489
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:649
RangeMZ & operator=(const RangeBase &rhs)
Definition: RangeManager.h:372
all dimensions are empty (=cleared)
double getMaxIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:470
void clear()
make the range empty, i.e. isEmpty() will be true
Definition: RangeManager.h:88
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:458
double min_
Definition: RangeManager.h:286
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:771
void pushInto(const RangeBase &sandbox)
Definition: RangeManager.h:200
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:147
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:615
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:588
FAIMS compensation voltage.
void clampTo(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:762
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:422
bool contains(const double value) const
is value within [min, max]?
Definition: RangeManager.h:100
double center() const
Definition: RangeManager.h:254
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:268
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:677
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:880
RangeIntensity(const double min, const double max)
Definition: RangeManager.h:434
some dimensions are empty, some are filled
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:316
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:483
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:786
const ThisRangeType & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:930
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:544
void extend(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:154
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:391
all dimensions are filled
RangeIntensity & operator=(const RangeBase &rhs)
Definition: RangeManager.h:439
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:347
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:134
Definition: RangeManager.h:429
void for_each_base_(Visitor &&visitor) const
.. and a const version
Definition: RangeManager.h:896
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
RangeRT(const double min, const double max)
Definition: RangeManager.h:297
Definition: RangeManager.h:919
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
bool pushIntoUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:706
bool clampToUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:741
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:416
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:727
double getMinRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:328
volt-second per square centimeter (i.e. 1/K_0)
ion mobility milliseconds
void setMin(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:118
double max_
Definition: RangeManager.h:287
RangeMZ(const double min, const double max)
Definition: RangeManager.h:367
Definition: RangeManager.h:496
bool contains(const RangeBase &inner_range) const
is the range inner_range within [min, max]?
Definition: RangeManager.h:106
double getSpan() const
Definition: RangeManager.h:262
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:353
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
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:668
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:519
void setMax(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:126
void clampTo(const RangeBase &other)
Definition: RangeManager.h:186
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:595
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:410
RangeRT & operator=(const RangeBase &rhs)
Definition: RangeManager.h:302
void shift(const double distance)
Definition: RangeManager.h:245
double getMinMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:531
double getMinIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:464
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:322
bool operator!=(const RangeManager &rhs) const
Definition: RangeManager.h:605
HasRangeType
Enum listing state of dimensions (RangeBases)
Definition: RangeManager.h:565
typename RangeManager< RangeBases... >::ThisRangeType ThisRangeType
Definition: RangeManager.h:923
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:452
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:341
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:844
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:525
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:824
Definition: RangeManager.h:361
RangeMobility & operator=(const RangeBase &rhs)
Definition: RangeManager.h:506
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:635
ThisRangeType & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:936
ThisRangeType & clear(const DIM_UNIT range)
Definition: RangeManager.h:853
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:801
MSDim
Dimensions of data acquisition for MS data.
Definition: RangeManager.h:49
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:385
Definition: RangeManager.h:292
RangeBase(const double min, const double max)
Definition: RangeManager.h:66
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:550
double getMinMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:397