CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TopQuarkAnalysis/TopHitFit/src/EtaDepResElement.cc

Go to the documentation of this file.
00001 //
00002 //     $Id: EtaDepResElement.cc,v 1.1 2011/05/26 09:46:59 mseidel Exp $
00003 //
00004 //
00005 // File   : src/EtaDepResolution.cc
00006 // Author : Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
00007 // Purpose: Hold on to an element eta-dependent resolution.
00008 //
00009 
00027 #include <sstream>
00028 #include <stdexcept>
00029 #include "TopQuarkAnalysis/TopHitFit/interface/EtaDepResElement.h"
00030 
00031 namespace hitfit {
00032 
00033 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
00034                                    const Vector_Resolution& res):
00035     _Vector_Resolution(res)
00036 {
00037 
00038     SetEta(eta1,eta2);
00039 
00040 }
00041 
00042 
00043 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
00044                                    std::string res):
00045     _Vector_Resolution(res)
00046 {
00047 
00048     SetEta(eta1,eta2);
00049 
00050 }
00051 
00052 
00053 EtaDepResElement::EtaDepResElement(double eta1,double eta2,
00054                                    const Resolution& p_res,
00055                                    const Resolution& eta_res,
00056                                    const Resolution& phi_res,
00057                                    bool use_et):
00058     _Vector_Resolution(p_res,eta_res,phi_res,use_et)
00059 {
00060 
00061     SetEta(eta1,eta2);
00062 
00063 }
00064 
00065 
00066 EtaDepResElement::~EtaDepResElement()
00067 {
00068 }
00069 
00070 
00071 void
00072 EtaDepResElement::SetEta(double eta1,double eta2)
00073 {
00074 
00075     if (fabs(eta1 - eta2) < (1.0/double(InverseEtaPrecision))) {
00076         throw
00077             std::runtime_error("EtaDepResElement::equal EtaMin and EtaMax");
00078     }
00079 
00080     if (eta1 < eta2) {
00081         _EtaMin = eta1 ;
00082         _EtaMax = eta2 ;
00083     } else {
00084         _EtaMin = eta2 ;
00085         _EtaMax = eta1 ;
00086     }
00087 
00088 }
00089 
00103 bool operator < (const EtaDepResElement& a, const EtaDepResElement& b)
00104 {
00105 
00106     if (a.IsOverlap(b)) { return false;}
00107     return !(a._EtaMax > b._EtaMin);
00108 
00109 }
00110 
00111 
00112 const double
00113 EtaDepResElement::EtaMin() const
00114 {
00115 
00116     return _EtaMin;
00117 
00118 }
00119 
00120 
00121 const double
00122 EtaDepResElement::EtaMax() const
00123 {
00124 
00125     return _EtaMax;
00126 
00127 }
00128 
00129 
00130 bool
00131 EtaDepResElement::IsOverlap(const EtaDepResElement& e) const
00132 {
00133 
00134     return (IsInInterval(e._EtaMin) || IsInInterval(e._EtaMax));
00135 
00136 }
00137 
00138 
00139 bool
00140 EtaDepResElement::IsNotOverlap(const EtaDepResElement& e) const
00141 {
00142 
00143     return !(IsOverlap(e));
00144 
00145 }
00146 
00147 
00148 bool
00149 EtaDepResElement::IsInInterval(const double& eta) const
00150 {
00151 
00152     return ((_EtaMin < eta) && (eta < _EtaMax));
00153 
00154 }
00155 
00156 
00157 bool
00158 EtaDepResElement::IsOnEdge(const double& eta) const
00159 {
00160 
00161     bool nearEtaMin = fabs(eta - _EtaMin) < (1.0/double(InverseEtaPrecision));
00162     bool nearEtaMax = fabs(eta - _EtaMax) < (1.0/double(InverseEtaPrecision));
00163     return nearEtaMin || nearEtaMax ;
00164 
00165 }
00166 
00167 
00168 bool
00169 EtaDepResElement::IsOnEdge(const EtaDepResElement& e) const
00170 {
00171 
00172     return (e.IsOnEdge(_EtaMin) || e.IsOnEdge(_EtaMax));
00173 
00174 }
00175 
00176 
00177 const Vector_Resolution
00178 EtaDepResElement::GetResolution() const
00179 {
00180 
00181     return _Vector_Resolution;
00182 
00183 }
00184 
00185 
00186 std::ostream& operator<< (std::ostream& s, const EtaDepResElement& e)
00187 {
00188 
00189     s << "(" << e._EtaMin << " to " << e._EtaMax << ")" << " / " << e.GetResolution ();
00190     return s ;
00191 
00192 }
00193 
00194 } // namespace hitfit