CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoMuon/Navigation/src/MuonEtaRange.cc

Go to the documentation of this file.
00001 
00014 #include "RecoMuon/Navigation/interface/MuonEtaRange.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include<iostream>
00017 
00018 
00019 MuonEtaRange::MuonEtaRange() : 
00020    theMin(0), theMax(0) {}
00021    
00022 MuonEtaRange::MuonEtaRange(float max, float min) {
00023  if ( max < min ) {
00024    edm::LogWarning ("MuonEtaRange") << "Warning MuonEtaRange:: max < min!! correcting" <<std::endl;
00025    float tmp(min);
00026    min = max;
00027    max = tmp;
00028  }
00029  theMax = max;
00030  theMin = min;
00031 }
00032 
00033 MuonEtaRange::MuonEtaRange(const MuonEtaRange& range) :
00034     theMin(range.theMin), theMax(range.theMax) {}
00036 MuonEtaRange& MuonEtaRange::operator=(const MuonEtaRange& range) {
00037 
00038   if ( this != &range ) {
00039     theMin = range.theMin;
00040     theMax = range.theMax;
00041   }
00042   return *this;
00043 }
00044 
00045 bool MuonEtaRange::isInside(float eta, float error) const {
00046 
00047   if ( (eta+error) > max() || (eta-error) < min() ) return false;
00048   return true;
00049 }
00051 bool MuonEtaRange::isInside(const MuonEtaRange& range) const {
00052   if ( min() > range.min() && max() < range.max() ) return true;
00053   return false;
00054 }
00056 bool MuonEtaRange::isCompatible(const MuonEtaRange& range) const {
00057   if ( range.min() > max() || range.max() < min() ) return false; 
00058   return true;
00059 }
00061 MuonEtaRange MuonEtaRange::add(const MuonEtaRange& range) const {
00062   float max = ( theMax > range.theMax ) ? theMax : range.theMax;
00063   float min = ( theMin < range.theMin ) ? theMin : range.theMin;
00064   return MuonEtaRange(max,min);
00065 }
00067 MuonEtaRange MuonEtaRange::subtract(const MuonEtaRange& range) const {
00068 
00069   if ( range.isInside(*this) ) {
00070     edm::LogInfo ("MuonEtaRange") << "MuonEtaRange: range is inside!" << std::endl;
00071     return *this;
00072   }
00073   if ( !range.isCompatible(*this) ) {
00074     edm::LogInfo ("MuonEtaRange") << "MuonEtaRange: no overlap between ranges" << std::endl;
00075     return *this;
00076   }
00077 
00078   float max = isInside(range.theMin) ? range.theMin : theMax;
00079   float min = isInside(range.theMax) ? range.theMax : theMin;
00080   return MuonEtaRange(max,min);
00081 }
00082 
00083