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 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
DTOccupancyCluster::computeRadius
void computeRadius()
Definition: DTOccupancyCluster.cc:153
DTOccupancyCluster::getHisto
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
Definition: DTOccupancyCluster.cc:109
DTOccupancyCluster::theValidity
bool theValidity
Definition: DTOccupancyCluster.h:81
DTOccupancyCluster::addPoint
bool addPoint(const DTOccupancyPoint &anotherPoint)
Definition: DTOccupancyCluster.cc:65
MessageLogger.h
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
DTOccupancyCluster::theMeanSum
double theMeanSum
Definition: DTOccupancyCluster.h:87
clusterIsLessThan
bool clusterIsLessThan(const DTOccupancyCluster &clusterOne, const DTOccupancyCluster &clusterTwo)
for DTOccupancyCluster sorting
Definition: DTOccupancyCluster.cc:174
DTOccupancyCluster::maxMean
double maxMean() const
max average cell occupancy of the layers in the cluster
Definition: DTOccupancyCluster.cc:105
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
DTOccupancyPoint
Definition: DTOccupancyPoint.h:13
edm
HLT enums.
Definition: AlignableModifier.h:19
DTOccupancyCluster
Definition: DTOccupancyCluster.h:20
DTOccupancyCluster::theMaxRMS
double theMaxRMS
Definition: DTOccupancyCluster.h:86
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DTOccupancyPoint::deltaMean
double deltaMean(const DTOccupancyPoint &anotherPoint) const
Definition: DTOccupancyPoint.cc:35
DTOccupancyCluster::thePoints
std::vector< DTOccupancyPoint > thePoints
Definition: DTOccupancyCluster.h:83
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
DTOccupancyPoint::deltaRMS
double deltaRMS(const DTOccupancyPoint &anotherPoint) const
Definition: DTOccupancyPoint.cc:39
HGVHistoProducerAlgoBlock_cfi.minX
minX
Definition: HGVHistoProducerAlgoBlock_cfi.py:153
DTOccupancyCluster::maxRMS
double maxRMS() const
max RMS of the cell occpuancy distributions of the layers in the cluster
Definition: DTOccupancyCluster.cc:107
DTOccupancyCluster.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DTOccupancyCluster::distance
double distance(const DTOccupancyPoint &point) const
Definition: DTOccupancyCluster.cc:89
DTOccupancyCluster::qualityCriterion
bool qualityCriterion(const DTOccupancyPoint &firstPoint, const DTOccupancyPoint &secondPoint)
Definition: DTOccupancyCluster.cc:125
computeAverageRMS
double computeAverageRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
Definition: DTOccupancyPoint.cc:74
DTOccupancyCluster::theRMSSum
double theRMSSum
Definition: DTOccupancyCluster.h:88
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTOccupancyCluster::getLayerIDs
std::set< DTLayerId > getLayerIDs() const
Definition: DTOccupancyCluster.cc:166
DTOccupancyPoint::mean
double mean() const
average cell occupancy in the layer
Definition: DTOccupancyPoint.cc:27
DTOccupancyCluster::~DTOccupancyCluster
virtual ~DTOccupancyCluster()
Destructor.
Definition: DTOccupancyCluster.cc:58
HGVHistoProducerAlgoBlock_cfi.minY
minY
Definition: HGVHistoProducerAlgoBlock_cfi.py:158
DTOccupancyCluster::DTOccupancyCluster
DTOccupancyCluster(const DTOccupancyPoint &firstPoint, const DTOccupancyPoint &secondPoint)
Constructor.
Definition: DTOccupancyCluster.cc:19
computeMinRMS
double computeMinRMS(const DTOccupancyPoint &onePoint, const DTOccupancyPoint &anotherPoint)
Definition: DTOccupancyPoint.cc:79
DTOccupancyCluster::averageRMS
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
Definition: DTOccupancyCluster.cc:103
DTOccupancyCluster::theMaxMean
double theMaxMean
Definition: DTOccupancyCluster.h:85
DTOccupancyCluster::radius
double radius
Definition: DTOccupancyCluster.h:82
DTOccupancyCluster::isValid
bool isValid() const
Check if the cluster candidate satisfies the quality requirements.
Definition: DTOccupancyCluster.cc:61
std
Definition: JetResolutionObject.h:76
HGVHistoProducerAlgoBlock_cfi.maxY
maxY
Definition: HGVHistoProducerAlgoBlock_cfi.py:159
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
DTOccupancyCluster::nPoints
int nPoints() const
Definition: DTOccupancyCluster.cc:164
point
*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
RecoTauValidation_cfi.fillColor
fillColor
Definition: RecoTauValidation_cfi.py:295
DTOccupancyCluster::averageMean
double averageMean() const
average cell occupancy of the layers in the cluster
Definition: DTOccupancyCluster.cc:101
DTOccupancyPoint::rms
double rms() const
RMS of the distribution of the cell occupancies in the layer.
Definition: DTOccupancyPoint.cc:29
HGVHistoProducerAlgoBlock_cfi.maxX
maxX
Definition: HGVHistoProducerAlgoBlock_cfi.py:154