File indexing completed on 2024-04-06 12:27:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "RecoMuon/Navigation/interface/MuonEtaRange.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include <iostream>
0015
0016 MuonEtaRange::MuonEtaRange() : theMin(0), theMax(0) {}
0017
0018 MuonEtaRange::MuonEtaRange(float max, float min) {
0019 if (max < min) {
0020 edm::LogWarning("MuonEtaRange") << "Warning MuonEtaRange:: max < min!! correcting" << std::endl;
0021 float tmp(min);
0022 min = max;
0023 max = tmp;
0024 }
0025 theMax = max;
0026 theMin = min;
0027 }
0028
0029 MuonEtaRange::MuonEtaRange(const MuonEtaRange& range) : theMin(range.theMin), theMax(range.theMax) {}
0030
0031 MuonEtaRange& MuonEtaRange::operator=(const MuonEtaRange& range) {
0032 if (this != &range) {
0033 theMin = range.theMin;
0034 theMax = range.theMax;
0035 }
0036 return *this;
0037 }
0038
0039 bool MuonEtaRange::isInside(float eta, float error) const {
0040 if ((eta + error) > max() || (eta - error) < min())
0041 return false;
0042 return true;
0043 }
0044
0045 bool MuonEtaRange::isInside(const MuonEtaRange& range) const {
0046 if (min() > range.min() && max() < range.max())
0047 return true;
0048 return false;
0049 }
0050
0051 bool MuonEtaRange::isCompatible(const MuonEtaRange& range) const {
0052 if (range.min() > max() || range.max() < min())
0053 return false;
0054 return true;
0055 }
0056
0057 MuonEtaRange MuonEtaRange::add(const MuonEtaRange& range) const {
0058 float max = (theMax > range.theMax) ? theMax : range.theMax;
0059 float min = (theMin < range.theMin) ? theMin : range.theMin;
0060 return MuonEtaRange(max, min);
0061 }
0062
0063 MuonEtaRange MuonEtaRange::subtract(const MuonEtaRange& range) const {
0064 if (range.isInside(*this)) {
0065 edm::LogInfo("MuonEtaRange") << "MuonEtaRange: range is inside!" << std::endl;
0066 return *this;
0067 }
0068 if (!range.isCompatible(*this)) {
0069 edm::LogInfo("MuonEtaRange") << "MuonEtaRange: no overlap between ranges" << std::endl;
0070 return *this;
0071 }
0072
0073 float max = isInside(range.theMin) ? range.theMin : theMax;
0074 float min = isInside(range.theMax) ? range.theMax : theMin;
0075 return MuonEtaRange(max, min);
0076 }