CMS 3D CMS Logo

DTOccupancyCluster.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Cerminara - INFN Torino
6  */
7 
8 #include "DTOccupancyCluster.h"
10 
11 #include "TH2F.h"
12 #include "TMath.h"
13 
14 #include <iostream>
15 
16 using namespace std;
17 using namespace edm;
18 
20  : radius(0), theMaxMean(-1.), theMaxRMS(-1.), theMeanSum(0.), theRMSSum(0.) {
21  if (!qualityCriterion(firstPoint, secondPoint)) {
22  theValidity = false;
23  } else {
24  // compute the cluster quantities
25  thePoints.push_back(firstPoint);
26  thePoints.push_back(secondPoint);
27  if (firstPoint.mean() > secondPoint.mean())
28  theMaxMean = firstPoint.mean();
29  else
30  theMaxMean = secondPoint.mean();
31 
32  if (firstPoint.rms() > secondPoint.rms())
33  theMaxRMS = firstPoint.rms();
34  else
35  theMaxRMS = secondPoint.rms();
36  theMeanSum += firstPoint.mean();
37  theRMSSum += firstPoint.rms();
38 
39  theMeanSum += secondPoint.mean();
40  theRMSSum += secondPoint.rms();
41 
42  computeRadius();
43  }
44 }
45 
47  : radius(0),
48  theMaxMean(singlePoint.mean()),
49  theMaxRMS(singlePoint.rms()),
50  theMeanSum(singlePoint.mean()),
51  theRMSSum(singlePoint.rms()) {
52  theValidity = true;
53 
54  // compute the cluster quantities
55  thePoints.push_back(singlePoint);
56 }
57 
59 
60 // Check if the cluster candidate satisfies the quality requirements
61 bool DTOccupancyCluster::isValid() const { return theValidity; }
62 
63 // Add a point to the cluster: returns false if the point does not satisfy the
64 // quality requirement
66  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyCluster")
67  << " Add a point to the cluster: mean: " << anotherPoint.mean() << " rms: " << anotherPoint.rms() << endl;
68  if (qualityCriterion(anotherPoint)) {
69  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyCluster") << " point is valid" << endl;
70  thePoints.push_back(anotherPoint);
71  // Compute the new cluster size
72  computeRadius();
73  // compute the max mean and RMS
74  if (anotherPoint.mean() > theMaxMean) {
75  theMaxMean = anotherPoint.mean();
76  }
77  if (anotherPoint.rms() > theMaxRMS) {
78  theMaxRMS = anotherPoint.rms();
79  }
80  theMeanSum += anotherPoint.mean();
81  theRMSSum += anotherPoint.rms();
82  return true;
83  }
84  return false;
85 }
86 
87 // Compute the distance of a single point from the cluster
88 // (minimum distance with respect to the cluster points)
90  double dist = 99999999;
91  // compute the minimum distance from a point
92  for (vector<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
93  double distance = point.distance(*pt);
94  if (distance < dist) {
95  dist = distance;
96  }
97  }
98  return dist;
99 }
100 
101 double DTOccupancyCluster::averageMean() const { return theMeanSum / (double)thePoints.size(); }
102 
103 double DTOccupancyCluster::averageRMS() const { return theRMSSum / (double)thePoints.size(); }
104 
105 double DTOccupancyCluster::maxMean() const { return theMaxMean; }
106 
107 double DTOccupancyCluster::maxRMS() const { return theMaxRMS; }
108 
110  int nBinsX,
111  double minX,
112  double maxX,
113  int nBinsY,
114  double minY,
115  double maxY,
116  int fillColor) const {
117  TH2F* histo = new TH2F(histoName.c_str(), histoName.c_str(), nBinsX, minX, maxX, nBinsY, minY, maxY);
118  histo->SetFillColor(fillColor);
119  for (vector<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
120  histo->Fill((*pt).mean(), (*pt).rms());
121  }
122  return histo;
123 }
124 
125 bool DTOccupancyCluster::qualityCriterion(const DTOccupancyPoint& firstPoint, const DTOccupancyPoint& secondPoint) {
126  if (firstPoint.deltaMean(secondPoint) < computeAverageRMS(firstPoint, secondPoint) &&
127  firstPoint.deltaRMS(secondPoint) < computeMinRMS(firstPoint, secondPoint)) {
128  theValidity = true;
129 
130  return true;
131  }
132 
133  theValidity = false;
134  return false;
135 }
136 
138  double minrms = 0;
139  if (anotherPoint.rms() < averageRMS())
140  minrms = anotherPoint.rms();
141  else
142  minrms = averageRMS();
143 
144  if (fabs(averageMean() - anotherPoint.mean()) < averageRMS() &&
145  fabs(averageRMS() - anotherPoint.rms()) < 2 * minrms / 3.) {
146  theValidity = true;
147  return true;
148  }
149  theValidity = false;
150  return false;
151 }
152 
154  double radius_squared = 0;
155  for (vector<DTOccupancyPoint>::const_iterator pt_i = thePoints.begin(); pt_i != thePoints.end(); ++pt_i) {
156  for (vector<DTOccupancyPoint>::const_iterator pt_j = thePoints.begin(); pt_j != thePoints.end(); ++pt_j) {
157  radius_squared += TMath::Power(pt_i->distance(*pt_j), 2);
158  }
159  }
160  radius_squared = radius_squared / (2 * TMath::Power(thePoints.size() + 1, 2));
161  radius = sqrt(radius_squared);
162 }
163 
164 int DTOccupancyCluster::nPoints() const { return thePoints.size(); }
165 
166 set<DTLayerId> DTOccupancyCluster::getLayerIDs() const {
167  set<DTLayerId> ret;
168  for (vector<DTOccupancyPoint>::const_iterator point = thePoints.begin(); point != thePoints.end(); ++point) {
169  ret.insert((*point).layerId());
170  }
171  return ret;
172 }
173 
174 bool clusterIsLessThan(const DTOccupancyCluster& clusterOne, const DTOccupancyCluster& clusterTwo) {
175  if (clusterTwo.nPoints() == 1 && clusterOne.nPoints() != 1) {
176  return true;
177  }
178  if (clusterTwo.nPoints() != 1 && clusterOne.nPoints() == 1) {
179  return false;
180  }
181 
182  if (clusterOne.nPoints() > clusterTwo.nPoints()) {
183  return true;
184  } else if (clusterOne.nPoints() < clusterTwo.nPoints()) {
185  return false;
186  } else {
187  if (fabs(clusterOne.averageRMS() - sqrt(clusterOne.averageMean())) <
188  fabs(clusterTwo.averageRMS() - sqrt(clusterTwo.averageMean()))) {
189  return true;
190  }
191  }
192  return false;
193 }
std::set< DTLayerId > getLayerIDs() const
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
double averageMean() const
average cell occupancy of the layers in the cluster
double deltaRMS(const DTOccupancyPoint &anotherPoint) const
ret
prodAgent to be discontinued
DTOccupancyCluster(const DTOccupancyPoint &firstPoint, const DTOccupancyPoint &secondPoint)
Constructor.
bool isValid() const
Check if the cluster candidate satisfies the quality requirements.
double mean() const
average cell occupancy in the layer
double computeAverageRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
#define LogTrace(id)
double computeMinRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
int nPoints() const
of layers belonging to the cluster
std::vector< DTOccupancyPoint > thePoints
T sqrt(T t)
Definition: SSEVec.h:23
bool addPoint(const DTOccupancyPoint &anotherPoint)
double rms() const
RMS of the distribution of the cell occupancies in the layer.
TH2F * getHisto(std::string histoName, int nBinsX, double minX, double maxX, int nBinsY, double minY, double maxY, int fillColor) const
get a TH2F displaying the cluster
double deltaMean(const DTOccupancyPoint &anotherPoint) const
virtual ~DTOccupancyCluster()
Destructor.
HLT enums.
double distance(const DTOccupancyPoint &point) const
double maxMean() const
max average cell occupancy of the layers in the cluster
double maxRMS() const
max RMS of the cell occpuancy distributions of the layers in the cluster
bool clusterIsLessThan(const DTOccupancyCluster &clusterOne, const DTOccupancyCluster &clusterTwo)
for DTOccupancyCluster sorting
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
bool qualityCriterion(const DTOccupancyPoint &firstPoint, const DTOccupancyPoint &secondPoint)