CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoEcal/EgammaCoreTools/src/EcalEtaPhiRegion.cc

Go to the documentation of this file.
00001 #include "RecoEcal/EgammaCoreTools/interface/EcalEtaPhiRegion.h"
00002 
00003 EcalEtaPhiRegion::EcalEtaPhiRegion(double etaLow, double etaHigh, double phiLow, double phiHigh):
00004   etaLow_(etaLow),etaHigh_(etaHigh),phiLow_(phiLow),phiHigh_(phiHigh)
00005 {
00006   // put phi in range -pi to pi
00007   if(phiLow_ > Geom::pi()) phiLow_ -= Geom::twoPi();
00008   if(phiLow_ < -Geom::pi()) phiLow_ += Geom::twoPi();
00009   if(phiHigh_ > Geom::pi()) phiHigh_ -= Geom::twoPi();
00010   if(phiHigh_ < -Geom::pi()) phiHigh_ += Geom::twoPi();
00011 }
00012 
00013 bool EcalEtaPhiRegion::inRegion(const GlobalPoint& position) const {
00014 
00015   double phi = position.phi();
00016   double phihightemp = phiHigh_;
00017 
00018   if(phihightemp<phiLow_) phihightemp += Geom::twoPi();
00019 
00020   // put phi in range -pi to pi
00021   if(phi > Geom::pi()) phi -= Geom::twoPi();
00022   if(phi < -Geom::pi()) phi += Geom::twoPi();
00023   if(phi<phiLow_) phi += Geom::twoPi();
00024 
00025 
00026   return (position.eta() > etaLow_ && position.eta() < etaHigh_ &&
00027           phi > phiLow_ && phi < phihightemp);
00028 
00029 }