CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/DTMonitorClient/src/DTOccupancyPoint.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *  See header file for a description of this class.
00004  *
00005  *  $Date: 2008/09/10 03:43:35 $
00006  *  $Revision: 1.4 $
00007  *  \author G. Cerminara - INFN Torino
00008  */
00009 
00010 #include "DTOccupancyPoint.h"
00011 
00012 #include <math.h>
00013 
00014 
00015 
00016 DTOccupancyPoint::DTOccupancyPoint() : theMean(0.),
00017                                        theRMS(0.) {
00018  debug = false; // FIXME: to be removed
00019 
00020 }
00021 
00022 
00023 
00024 DTOccupancyPoint::DTOccupancyPoint(double mean, double rms) : theMean(mean),
00025                                                               theRMS(rms) {
00026  debug = false; // FIXME: to be removed
00027 }
00028 
00029 
00030 DTOccupancyPoint::DTOccupancyPoint(double mean, double rms, DTLayerId layerId) : theMean(mean),
00031                                                                                  theRMS(rms),
00032                                                                                  theLayerId(layerId) {
00033  debug = false; // FIXME: to be removed
00034 }
00035 
00036 
00037 
00038 DTOccupancyPoint::~DTOccupancyPoint(){}
00039 
00040 
00041 
00042 
00043 double DTOccupancyPoint::mean() const {
00044   return theMean;
00045 }
00046 
00047 
00048 
00049 double DTOccupancyPoint::rms() const {
00050   return theRMS;
00051 }
00052 
00053 
00054 
00055 double DTOccupancyPoint::distance(const DTOccupancyPoint& anotherPoint) const {
00056   return sqrt(deltaMean(anotherPoint)*deltaMean(anotherPoint) +
00057               deltaRMS(anotherPoint)* deltaRMS(anotherPoint));
00058 }
00059 
00060 
00061   
00062 double DTOccupancyPoint::deltaMean(const DTOccupancyPoint& anotherPoint) const {
00063   return fabs(mean() - anotherPoint.mean());
00064 }
00065 
00066 
00067 
00068 double DTOccupancyPoint::deltaRMS(const DTOccupancyPoint& anotherPoint) const {
00069   return fabs(rms() - anotherPoint.rms());
00070 }
00071 
00072 
00073 
00074 bool DTOccupancyPoint::operator==(const DTOccupancyPoint& other) const {
00075   // FIXME: should add the layer ID? not clear
00076   if(theMean == other.mean() &&
00077      theRMS == other.rms() &&
00078      theLayerId == other.layerId()) return true;
00079   return false;
00080 }
00081 
00082 
00083 
00084 bool DTOccupancyPoint::operator!=(const DTOccupancyPoint& other) const {
00085   if(theMean != other.mean() ||
00086      theRMS != other.rms() ||
00087      theLayerId != other.layerId()) return true;
00088   return false;
00089 }
00090 
00091 
00092 
00093 bool DTOccupancyPoint::operator<(const DTOccupancyPoint& other) const {
00094   if(distance(DTOccupancyPoint()) == other.distance(DTOccupancyPoint())) {
00095     return false;
00096   }
00097 
00098   if(fabs(distance(DTOccupancyPoint()) - other.distance(DTOccupancyPoint())) < 0.000001) {
00099     if(layerId().rawId() < other.layerId().rawId()) {
00100       return true;
00101     } else {
00102       return false;
00103     }
00104   }
00105 
00106   if(distance(DTOccupancyPoint()) < other.distance(DTOccupancyPoint())) return true;
00107   return false;
00108 }
00109 
00110 
00111 
00112 double computeAverageRMS(const DTOccupancyPoint& onePoint, const DTOccupancyPoint& anotherPoint) {
00113   double ret = (onePoint.rms() + anotherPoint.rms())/2.;
00114   return ret;
00115 }
00116 
00117 
00118 
00119 double computeMinRMS(const DTOccupancyPoint& onePoint, const DTOccupancyPoint& anotherPoint) {
00120   double ret = -1;
00121   if(onePoint.rms() > anotherPoint.rms()) {
00122     ret =  anotherPoint.rms();
00123   } else {
00124     ret = onePoint.rms();
00125   }
00126   return ret;
00127 }
00128 
00129 
00130 
00131 void DTOccupancyPoint::setLayerId(DTLayerId layerId) {
00132   theLayerId = layerId;
00133 }
00134 
00135 
00136 DTLayerId DTOccupancyPoint::layerId() const {
00137   return theLayerId;
00138 }