Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:05

0001 
0002 /*
0003  *  See header file for a description of this class.
0004  *
0005  *  \author G. Cerminara - INFN Torino
0006  */
0007 
0008 #include "DTOccupancyPoint.h"
0009 
0010 #include <cmath>
0011 
0012 DTOccupancyPoint::DTOccupancyPoint() : theMean(0.), theRMS(0.) {
0013   debug = false;  // FIXME: to be removed
0014 }
0015 
0016 DTOccupancyPoint::DTOccupancyPoint(double mean, double rms) : theMean(mean), theRMS(rms) {
0017   debug = false;  // FIXME: to be removed
0018 }
0019 
0020 DTOccupancyPoint::DTOccupancyPoint(double mean, double rms, DTLayerId layerId)
0021     : theMean(mean), theRMS(rms), theLayerId(layerId) {
0022   debug = false;  // FIXME: to be removed
0023 }
0024 
0025 DTOccupancyPoint::~DTOccupancyPoint() {}
0026 
0027 double DTOccupancyPoint::mean() const { return theMean; }
0028 
0029 double DTOccupancyPoint::rms() const { return theRMS; }
0030 
0031 double DTOccupancyPoint::distance(const DTOccupancyPoint& anotherPoint) const {
0032   return sqrt(deltaMean(anotherPoint) * deltaMean(anotherPoint) + deltaRMS(anotherPoint) * deltaRMS(anotherPoint));
0033 }
0034 
0035 double DTOccupancyPoint::deltaMean(const DTOccupancyPoint& anotherPoint) const {
0036   return fabs(mean() - anotherPoint.mean());
0037 }
0038 
0039 double DTOccupancyPoint::deltaRMS(const DTOccupancyPoint& anotherPoint) const {
0040   return fabs(rms() - anotherPoint.rms());
0041 }
0042 
0043 bool DTOccupancyPoint::operator==(const DTOccupancyPoint& other) const {
0044   // FIXME: should add the layer ID? not clear
0045   if (theMean == other.mean() && theRMS == other.rms() && theLayerId == other.layerId())
0046     return true;
0047   return false;
0048 }
0049 
0050 bool DTOccupancyPoint::operator!=(const DTOccupancyPoint& other) const {
0051   if (theMean != other.mean() || theRMS != other.rms() || theLayerId != other.layerId())
0052     return true;
0053   return false;
0054 }
0055 
0056 bool DTOccupancyPoint::operator<(const DTOccupancyPoint& other) const {
0057   if (distance(DTOccupancyPoint()) == other.distance(DTOccupancyPoint())) {
0058     return false;
0059   }
0060 
0061   if (fabs(distance(DTOccupancyPoint()) - other.distance(DTOccupancyPoint())) < 0.000001) {
0062     if (layerId().rawId() < other.layerId().rawId()) {
0063       return true;
0064     } else {
0065       return false;
0066     }
0067   }
0068 
0069   if (distance(DTOccupancyPoint()) < other.distance(DTOccupancyPoint()))
0070     return true;
0071   return false;
0072 }
0073 
0074 double computeAverageRMS(const DTOccupancyPoint& onePoint, const DTOccupancyPoint& anotherPoint) {
0075   double ret = (onePoint.rms() + anotherPoint.rms()) / 2.;
0076   return ret;
0077 }
0078 
0079 double computeMinRMS(const DTOccupancyPoint& onePoint, const DTOccupancyPoint& anotherPoint) {
0080   double ret = -1;
0081   if (onePoint.rms() > anotherPoint.rms()) {
0082     ret = anotherPoint.rms();
0083   } else {
0084     ret = onePoint.rms();
0085   }
0086   return ret;
0087 }
0088 
0089 void DTOccupancyPoint::setLayerId(DTLayerId layerId) { theLayerId = layerId; }
0090 
0091 DTLayerId DTOccupancyPoint::layerId() const { return theLayerId; }