CMS 3D CMS Logo

MuonEtaRange.cc
Go to the documentation of this file.
1 
14 #include<iostream>
15 
16 
18  theMin(0), theMax(0) {}
19 
21  if ( max < min ) {
22  edm::LogWarning ("MuonEtaRange") << "Warning MuonEtaRange:: max < min!! correcting" <<std::endl;
23  float tmp(min);
24  min = max;
25  max = tmp;
26  }
27  theMax = max;
28  theMin = min;
29 }
30 
32  theMin(range.theMin), theMax(range.theMax) {}
35 
36  if ( this != &range ) {
37  theMin = range.theMin;
38  theMax = range.theMax;
39  }
40  return *this;
41 }
42 
43 bool MuonEtaRange::isInside(float eta, float error) const {
44 
45  if ( (eta+error) > max() || (eta-error) < min() ) return false;
46  return true;
47 }
49 bool MuonEtaRange::isInside(const MuonEtaRange& range) const {
50  if ( min() > range.min() && max() < range.max() ) return true;
51  return false;
52 }
54 bool MuonEtaRange::isCompatible(const MuonEtaRange& range) const {
55  if ( range.min() > max() || range.max() < min() ) return false;
56  return true;
57 }
60  float max = ( theMax > range.theMax ) ? theMax : range.theMax;
61  float min = ( theMin < range.theMin ) ? theMin : range.theMin;
62  return MuonEtaRange(max,min);
63 }
66 
67  if ( range.isInside(*this) ) {
68  edm::LogInfo ("MuonEtaRange") << "MuonEtaRange: range is inside!" << std::endl;
69  return *this;
70  }
71  if ( !range.isCompatible(*this) ) {
72  edm::LogInfo ("MuonEtaRange") << "MuonEtaRange: no overlap between ranges" << std::endl;
73  return *this;
74  }
75 
76  float max = isInside(range.theMin) ? range.theMin : theMax;
77  float min = isInside(range.theMax) ? range.theMax : theMin;
78  return MuonEtaRange(max,min);
79 }
80 
81 
MuonEtaRange add(const MuonEtaRange &) const
create maximum of ranges
Definition: MuonEtaRange.cc:59
float min() const
Definition: MuonEtaRange.h:24
bool isInside(float eta, float error=0.) const
Definition: MuonEtaRange.cc:43
MuonEtaRange & operator=(const MuonEtaRange &)
Assignment operator.
Definition: MuonEtaRange.cc:34
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
bool isCompatible(const MuonEtaRange &range) const
true if this overlaps with range
Definition: MuonEtaRange.cc:54
MuonEtaRange subtract(const MuonEtaRange &) const
create new range of size this minus range
Definition: MuonEtaRange.cc:65
float max() const
Definition: MuonEtaRange.h:25