Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:51

0001 #ifndef rangeIntersection_H
0002 #define rangeIntersection_H
0003 
0004 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
0005 #include <algorithm>
0006 
0007 /** Utility for computing efficiently the intersection of two 
0008  *  one-dimantional intervals.
0009  *
0010  *  Pre-condition and expected template argument Range interface:
0011  *  as for function  rangesIntersect.
0012  *  If the intervals don't intersect an empty interval is returned.
0013  */
0014 
0015 template <class Range>
0016 inline Range rangeIntersection(const Range& a, const Range& b) {
0017   return Range(std::max(a.first, b.first), std::min(a.second, b.second));
0018 }
0019 
0020 template <class Range, class Less>
0021 inline Range rangeIntersection(const Range& a, const Range& b, const Less& less) {
0022   return Range(std::max(a.first, b.first, less), std::min(a.second, b.second, less));
0023 }
0024 
0025 #endif