CMS 3D CMS Logo

MTDEtaRange.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 ("MTDEtaRange") << "Warning MTDEtaRange:: 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 MTDEtaRange::isInside(float eta, float error) const {
44 
45  if ( (eta+error) > max() || (eta-error) < min() ) return false;
46  return true;
47 }
49 bool MTDEtaRange::isInside(const MTDEtaRange& range) const {
50  if ( min() > range.min() && max() < range.max() ) return true;
51  return false;
52 }
54 bool MTDEtaRange::isCompatible(const MTDEtaRange& 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 MTDEtaRange(max,min);
63 }
66 
67  if ( range.isInside(*this) ) {
68  edm::LogInfo ("MTDEtaRange") << "MTDEtaRange: range is inside!" << std::endl;
69  return *this;
70  }
71  if ( !range.isCompatible(*this) ) {
72  edm::LogInfo ("MTDEtaRange") << "MTDEtaRange: 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 MTDEtaRange(max,min);
79 }
80 
81 
float theMin
Definition: MTDEtaRange.h:34
MTDEtaRange add(const MTDEtaRange &) const
create maximum of ranges
Definition: MTDEtaRange.cc:59
MTDEtaRange & operator=(const MTDEtaRange &)
Assignment operator.
Definition: MTDEtaRange.cc:34
float min() const
Definition: MTDEtaRange.h:24
float theMax
Definition: MTDEtaRange.h:35
float max() const
Definition: MTDEtaRange.h:25
bool isInside(float eta, float error=0.) const
Definition: MTDEtaRange.cc:43
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
MTDEtaRange subtract(const MTDEtaRange &) const
create new range of size this minus range
Definition: MTDEtaRange.cc:65
bool isCompatible(const MTDEtaRange &range) const
true if this overlaps with range
Definition: MTDEtaRange.cc:54