test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
19 
21  const DTOccupancyPoint& secondPoint) : radius(0),
22  theMaxMean(-1.),
23  theMaxRMS(-1.),
24  theMeanSum(0.),
25  theRMSSum(0.) {
26  if(!qualityCriterion(firstPoint,secondPoint)) {
27  theValidity = false;
28  } else {
29  // compute the cluster quantities
30  thePoints.push_back(firstPoint);
31  thePoints.push_back(secondPoint);
32  if(firstPoint.mean() > secondPoint.mean()) theMaxMean = firstPoint.mean();
33  else theMaxMean = secondPoint.mean();
34 
35  if(firstPoint.rms() > secondPoint.rms()) theMaxRMS = firstPoint.rms();
36  else theMaxRMS = secondPoint.rms();
37  theMeanSum += firstPoint.mean();
38  theRMSSum += firstPoint.rms();
39 
40  theMeanSum += secondPoint.mean();
41  theRMSSum += secondPoint.rms();
42 
43 
44  computeRadius();
45  }
46 }
47 
48 
49 
51  theMaxMean(singlePoint.mean()),
52  theMaxRMS(singlePoint.rms()),
53  theMeanSum(singlePoint.mean()),
54  theRMSSum(singlePoint.rms()) {
55  theValidity = true;
56 
57  // compute the cluster quantities
58  thePoints.push_back(singlePoint);
59 }
60 
62 
63  // Check if the cluster candidate satisfies the quality requirements
65  return theValidity;
66 }
67 
68 // Add a point to the cluster: returns false if the point does not satisfy the
69 // quality requirement
71  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyCluster")
72  << " Add a point to the cluster: mean: " << anotherPoint.mean()
73  << " rms: " << anotherPoint.rms() << endl;
74  if(qualityCriterion(anotherPoint)) {
75  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyCluster") << " point is valid" << endl;
76  thePoints.push_back(anotherPoint);
77  // Compute the new cluster size
78  computeRadius();
79  // compute the max mean and RMS
80  if(anotherPoint.mean() > theMaxMean) {
81  theMaxMean = anotherPoint.mean();
82  }
83  if(anotherPoint.rms() > theMaxRMS) {
84  theMaxRMS = anotherPoint.rms();
85  }
86  theMeanSum += anotherPoint.mean();
87  theRMSSum += anotherPoint.rms();
88  return true;
89  }
90  return false;
91 }
92 
93 
94 
95 // Compute the distance of a single point from the cluster
96 // (minimum distance with respect to the cluster points)
98  double dist = 99999999;
99  // compute the minimum distance from a point
100  for(vector<DTOccupancyPoint>::const_iterator pt = thePoints.begin();
101  pt != thePoints.end(); ++pt) {
102  double distance = point.distance(*pt);
103  if(distance < dist) {
104  dist = distance;
105  }
106  }
107  return dist;
108 }
109 
110 
111 
113  return theMeanSum/(double)thePoints.size();
114 }
115 
116 
117 
119  return theRMSSum/(double)thePoints.size();
120 }
121 
122 
123 
125  return theMaxMean;
126 }
127 
128 
129 
131  return theMaxRMS;
132 }
133 
134 
135 
136 TH2F * DTOccupancyCluster::getHisto(std::string histoName, int nBinsX, double minX, double maxX,
137  int nBinsY, double minY, double maxY, int fillColor) const {
138  TH2F *histo = new TH2F(histoName.c_str(),histoName.c_str(),
139  nBinsX, minX, maxX, nBinsY, minY, maxY);
140  histo->SetFillColor(fillColor);
141  for(vector<DTOccupancyPoint>::const_iterator pt = thePoints.begin();
142  pt != thePoints.end(); ++pt) {
143  histo->Fill((*pt).mean(), (*pt).rms());
144  }
145  return histo;
146 }
147 
148 
149 
151  const DTOccupancyPoint& secondPoint) {
152 
153  if(firstPoint.deltaMean(secondPoint) < computeAverageRMS(firstPoint, secondPoint) &&
154  firstPoint.deltaRMS(secondPoint) < computeMinRMS(firstPoint, secondPoint)) {
155  theValidity = true;
156 
157  return true;
158  }
159 
160  theValidity = false;
161  return false;
162 }
163 
165 
166  double minrms = 0;
167  if(anotherPoint.rms() < averageRMS()) minrms = anotherPoint.rms();
168  else minrms = averageRMS();
169 
170  if(fabs(averageMean() - anotherPoint.mean()) < averageRMS() &&
171  fabs(averageRMS() - anotherPoint.rms()) < 2*minrms/3.) {
172  theValidity = true;
173  return true;
174  }
175  theValidity = false;
176  return false;
177 }
178 
180  double radius_squared = 0;
181  for(vector<DTOccupancyPoint>::const_iterator pt_i = thePoints.begin();
182  pt_i != thePoints.end(); ++pt_i) {
183  for(vector<DTOccupancyPoint>::const_iterator pt_j = thePoints.begin();
184  pt_j != thePoints.end(); ++pt_j) {
185  radius_squared += TMath::Power(pt_i->distance(*pt_j),2);
186  }
187  }
188  radius_squared = radius_squared/(2*TMath::Power(thePoints.size()+1,2));
189  radius = sqrt(radius_squared);
190 }
191 
192 
193 
195  return thePoints.size();
196 }
197 
198 
199 set<DTLayerId> DTOccupancyCluster::getLayerIDs() const {
200  set<DTLayerId> ret;
201  for(vector<DTOccupancyPoint>::const_iterator point = thePoints.begin();
202  point != thePoints.end(); ++point) {
203  ret.insert((*point).layerId());
204  }
205  return ret;
206 }
207 
208 
209 bool clusterIsLessThan(const DTOccupancyCluster& clusterOne, const DTOccupancyCluster& clusterTwo) {
210  if(clusterTwo.nPoints() == 1 && clusterOne.nPoints() != 1) {
211  return true;
212  }
213  if(clusterTwo.nPoints() != 1 && clusterOne.nPoints() == 1) {
214  return false;
215  }
216 
217  if(clusterOne.nPoints() > clusterTwo.nPoints()) {
218  return true;
219  } else if(clusterOne.nPoints() < clusterTwo.nPoints()) {
220  return false;
221  } else {
222  if(fabs(clusterOne.averageRMS() - sqrt(clusterOne.averageMean())) <
223  fabs(clusterTwo.averageRMS() - sqrt(clusterTwo.averageMean()))) {
224  return true;
225  }
226  }
227  return false;
228 
229 }
230 
231 
bool isValid() const
Check if the cluster candidate satisfies the quality requirements.
tuple ret
prodAgent to be discontinued
double mean() const
average cell occupancy in the layer
DTOccupancyCluster(const DTOccupancyPoint &firstPoint, const DTOccupancyPoint &secondPoint)
Constructor.
double deltaMean(const DTOccupancyPoint &anotherPoint) const
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 computeAverageRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
double maxMean() const
max average cell occupancy of the layers in the cluster
double deltaRMS(const DTOccupancyPoint &anotherPoint) const
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
double rms() const
RMS of the distribution of the cell occupancies in the layer.
double computeMinRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
double maxRMS() const
max RMS of the cell occpuancy distributions of the layers in the cluster
std::vector< DTOccupancyPoint > thePoints
T sqrt(T t)
Definition: SSEVec.h:18
bool addPoint(const DTOccupancyPoint &anotherPoint)
#define LogTrace(id)
double averageMean() const
average cell occupancy of the layers in the cluster
int nPoints() const
of layers belonging to the cluster
virtual ~DTOccupancyCluster()
Destructor.
double distance(const DTOccupancyPoint &anotherPoint) const
distance from another point in the 2D plane
std::set< DTLayerId > getLayerIDs() const
bool clusterIsLessThan(const DTOccupancyCluster &clusterOne, const DTOccupancyCluster &clusterTwo)
for DTOccupancyCluster sorting
double distance(const DTOccupancyPoint &point) const
*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)