CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTOccupancyClusterBuilder Class Reference

#include <DTOccupancyClusterBuilder.h>

Public Member Functions

void addPoint (const DTOccupancyPoint &point)
 Add an occupancy point for a given layer. More...
 
void buildClusters ()
 build the clusters More...
 
void drawClusters (std::string canvasName)
 draw a TH2F histograms showing the clusters More...
 
 DTOccupancyClusterBuilder ()
 Constructor. More...
 
DTOccupancyCluster getBestCluster () const
 get the cluster correspondig to "normal" cell occupancy. More...
 
bool isProblematic (DTLayerId layerId) const
 
virtual ~DTOccupancyClusterBuilder ()
 Destructor. More...
 

Private Member Functions

bool buildNewCluster ()
 
void computeDistancesToCluster (const DTOccupancyCluster &cluster)
 
void computePointToPointDistances ()
 
std::pair< DTOccupancyPoint, DTOccupancyPointgetInitialPair ()
 
void sortClusters ()
 

Private Attributes

double maxMean
 
double maxRMS
 
std::vector< DTOccupancyClustertheClusters
 
std::map< double, std::pair< DTOccupancyPoint, DTOccupancyPoint > > theDistances
 
std::map< double, DTOccupancyPointtheDistancesFromTheCluster
 
std::set< DTOccupancyPointthePoints
 
std::set< DTLayerIdtheProblematicLayers
 

Detailed Description

Build clusters of layer occupancies (DTOccupancyCluster) to spot problematic layers. It's used by DTOccupancyTest.

Author
G. Cerminara - INFN Torino

Definition at line 19 of file DTOccupancyClusterBuilder.h.

Constructor & Destructor Documentation

◆ DTOccupancyClusterBuilder()

DTOccupancyClusterBuilder::DTOccupancyClusterBuilder ( )

Constructor.

Definition at line 21 of file DTOccupancyClusterBuilder.cc.

◆ ~DTOccupancyClusterBuilder()

DTOccupancyClusterBuilder::~DTOccupancyClusterBuilder ( )
virtual

Destructor.

Definition at line 23 of file DTOccupancyClusterBuilder.cc.

23 {}

Member Function Documentation

◆ addPoint()

void DTOccupancyClusterBuilder::addPoint ( const DTOccupancyPoint point)

Add an occupancy point for a given layer.

Definition at line 25 of file DTOccupancyClusterBuilder.cc.

References point, DiDispStaMuonMonitor_cfi::pt, theDistances, and thePoints.

25  {
26  // loop over points already stored
27  for (set<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
28  theDistances[(*pt).distance(point)] = make_pair(*pt, point);
29  }
30  thePoints.insert(point);
31 }
std::map< double, std::pair< DTOccupancyPoint, DTOccupancyPoint > > theDistances
std::set< DTOccupancyPoint > thePoints
*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

◆ buildClusters()

void DTOccupancyClusterBuilder::buildClusters ( )

build the clusters

Definition at line 33 of file DTOccupancyClusterBuilder.cc.

References buildNewCluster(), LogTrace, DTOccupancyCluster::maxMean(), maxMean, DTOccupancyCluster::maxRMS(), maxRMS, DiDispStaMuonMonitor_cfi::pt, sortClusters(), theClusters, and thePoints.

33  {
34  while (buildNewCluster()) {
35  if (thePoints.size() <= 1)
36  break;
37  }
38 
39  // build single point clusters with the remaining points
40  for (set<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
41  DTOccupancyCluster clusterCandidate(*pt);
42  theClusters.push_back(clusterCandidate);
43  // store the range for building the histograms later
44  if (clusterCandidate.maxMean() > maxMean)
45  maxMean = clusterCandidate.maxMean();
46  if (clusterCandidate.maxRMS() > maxRMS)
47  maxRMS = clusterCandidate.maxRMS();
48  }
49  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
50  << " # of valid clusters: " << theClusters.size() << endl;
51  sortClusters();
52 }
#define LogTrace(id)
std::set< DTOccupancyPoint > thePoints
std::vector< DTOccupancyCluster > theClusters

◆ buildNewCluster()

bool DTOccupancyClusterBuilder::buildNewCluster ( )
private

Definition at line 103 of file DTOccupancyClusterBuilder.cc.

References DTOccupancyCluster::addPoint(), DTOccupancyCluster::averageMean(), DTOccupancyCluster::averageRMS(), computeDistancesToCluster(), computePointToPointDistances(), getInitialPair(), DTOccupancyCluster::isValid(), LogTrace, DTOccupancyCluster::maxMean(), maxMean, DTOccupancyCluster::maxRMS(), maxRMS, DTOccupancyCluster::nPoints(), theClusters, theDistancesFromTheCluster, and thePoints.

Referenced by buildClusters().

103  {
104  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
105  << "--------- New Cluster Candidate ----------------------" << endl;
106  pair<DTOccupancyPoint, DTOccupancyPoint> initialPair = getInitialPair();
107  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
108  << " Initial Pair: " << endl
109  << " point1: mean " << initialPair.first.mean() << " rms " << initialPair.first.rms() << endl
110  << " point2: mean " << initialPair.second.mean() << " rms " << initialPair.second.rms() << endl;
111  DTOccupancyCluster clusterCandidate(initialPair.first, initialPair.second);
112  if (clusterCandidate.isValid()) {
113  // remove already used pair
114  thePoints.erase(initialPair.first);
115  thePoints.erase(initialPair.second);
116  if (!thePoints.empty()) {
117  computeDistancesToCluster(clusterCandidate);
118  while (clusterCandidate.addPoint(theDistancesFromTheCluster.begin()->second)) {
119  thePoints.erase(theDistancesFromTheCluster.begin()->second);
120  if (thePoints.empty())
121  break;
122  computeDistancesToCluster(clusterCandidate);
123  }
124  }
125  } else {
126  return false;
127  }
128  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
129  << " # of layers: " << clusterCandidate.nPoints() << " avrg. mean: " << clusterCandidate.averageMean()
130  << " avrg. rms: " << clusterCandidate.averageRMS() << endl;
131  theClusters.push_back(clusterCandidate);
132  // store the range for building the histograms later
133  if (clusterCandidate.maxMean() > maxMean)
134  maxMean = clusterCandidate.maxMean();
135  if (clusterCandidate.maxRMS() > maxRMS)
136  maxRMS = clusterCandidate.maxRMS();
138  return true;
139 }
std::map< double, DTOccupancyPoint > theDistancesFromTheCluster
#define LogTrace(id)
std::set< DTOccupancyPoint > thePoints
void computeDistancesToCluster(const DTOccupancyCluster &cluster)
std::pair< DTOccupancyPoint, DTOccupancyPoint > getInitialPair()
std::vector< DTOccupancyCluster > theClusters

◆ computeDistancesToCluster()

void DTOccupancyClusterBuilder::computeDistancesToCluster ( const DTOccupancyCluster cluster)
private

Definition at line 96 of file DTOccupancyClusterBuilder.cc.

References DTOccupancyCluster::distance(), DiDispStaMuonMonitor_cfi::pt, theDistancesFromTheCluster, and thePoints.

Referenced by buildNewCluster().

96  {
98  for (set<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
100  }
101 }
std::map< double, DTOccupancyPoint > theDistancesFromTheCluster
std::set< DTOccupancyPoint > thePoints
double distance(const DTOccupancyPoint &point) const

◆ computePointToPointDistances()

void DTOccupancyClusterBuilder::computePointToPointDistances ( )
private

Definition at line 85 of file DTOccupancyClusterBuilder.cc.

References theDistances, and thePoints.

Referenced by buildNewCluster().

85  {
86  theDistances.clear();
87  for (set<DTOccupancyPoint>::const_iterator pt_i = thePoints.begin(); pt_i != thePoints.end(); ++pt_i) { // i loopo
88  for (set<DTOccupancyPoint>::const_iterator pt_j = thePoints.begin(); pt_j != thePoints.end(); ++pt_j) { // j loop
89  if (*pt_i != *pt_j) {
90  theDistances[pt_i->distance(*pt_j)] = make_pair(*pt_i, *pt_j);
91  }
92  }
93  }
94 }
std::map< double, std::pair< DTOccupancyPoint, DTOccupancyPoint > > theDistances
std::set< DTOccupancyPoint > thePoints

◆ drawClusters()

void DTOccupancyClusterBuilder::drawClusters ( std::string  canvasName)

draw a TH2F histograms showing the clusters

Definition at line 54 of file DTOccupancyClusterBuilder.cc.

References svgfig::canvas(), timingPdfMaker::histo, HltBtagPostValidation_cff::histoName, maxMean, maxRMS, cms::cuda::stream, and theClusters.

54  {
55  int nBinsX = 100;
56  int nBinsY = 100;
57  int colorMap[12] = {632, 600, 800, 400, 820, 416, 432, 880, 616, 860, 900, 920};
58 
59  TCanvas* canvas = new TCanvas(canvasName.c_str(), canvasName.c_str());
60  canvas->cd();
61  for (vector<DTOccupancyCluster>::const_iterator cluster = theClusters.begin(); cluster != theClusters.end();
62  ++cluster) {
63  stringstream stream;
64  stream << canvasName << "_" << cluster - theClusters.begin();
65  string histoName = stream.str();
66  TH2F* histo = (*cluster).getHisto(histoName,
67  nBinsX,
68  0,
69  maxMean + 3 * maxMean / 100.,
70  nBinsY,
71  0,
72  maxRMS + 3 * maxRMS / 100.,
73  colorMap[cluster - theClusters.begin()]);
74  if (cluster == theClusters.begin())
75  histo->Draw("box");
76  else
77  histo->Draw("box,same");
78  }
79 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::vector< DTOccupancyCluster > theClusters
def canvas(sub, attr)
Definition: svgfig.py:482

◆ getBestCluster()

DTOccupancyCluster DTOccupancyClusterBuilder::getBestCluster ( ) const

get the cluster correspondig to "normal" cell occupancy.

Definition at line 156 of file DTOccupancyClusterBuilder.cc.

References theClusters.

156 { return theClusters.front(); }
std::vector< DTOccupancyCluster > theClusters

◆ getInitialPair()

std::pair< DTOccupancyPoint, DTOccupancyPoint > DTOccupancyClusterBuilder::getInitialPair ( )
private

Definition at line 81 of file DTOccupancyClusterBuilder.cc.

References theDistances.

Referenced by buildNewCluster().

81  {
82  return theDistances.begin()->second;
83 }
std::map< double, std::pair< DTOccupancyPoint, DTOccupancyPoint > > theDistances

◆ isProblematic()

bool DTOccupancyClusterBuilder::isProblematic ( DTLayerId  layerId) const

Definition at line 158 of file DTOccupancyClusterBuilder.cc.

References theProblematicLayers.

158  {
159  if (theProblematicLayers.find(layerId) != theProblematicLayers.end()) {
160  return true;
161  }
162  return false;
163 }
std::set< DTLayerId > theProblematicLayers

◆ sortClusters()

void DTOccupancyClusterBuilder::sortClusters ( )
private

Definition at line 141 of file DTOccupancyClusterBuilder.cc.

References clusterIsLessThan(), LogTrace, jetUpdater_cfi::sort, theClusters, and theProblematicLayers.

Referenced by buildClusters().

141  {
142  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder") << " sorting" << endl;
144  // we save the detid of the clusters which are not the best one
145  for (vector<DTOccupancyCluster>::const_iterator cluster = ++(theClusters.begin()); cluster != theClusters.end();
146  ++cluster) { // loop over clusters skipping the first
147  set<DTLayerId> clusterLayers = (*cluster).getLayerIDs();
148  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
149  << " # layers in the cluster: " << clusterLayers.size() << endl;
150  theProblematicLayers.insert(clusterLayers.begin(), clusterLayers.end());
151  }
152  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder")
153  << " # of problematic layers: " << theProblematicLayers.size() << endl;
154 }
std::set< DTLayerId > theProblematicLayers
#define LogTrace(id)
std::vector< DTOccupancyCluster > theClusters
bool clusterIsLessThan(const DTOccupancyCluster &clusterOne, const DTOccupancyCluster &clusterTwo)
for DTOccupancyCluster sorting

Member Data Documentation

◆ maxMean

double DTOccupancyClusterBuilder::maxMean
private

Definition at line 60 of file DTOccupancyClusterBuilder.h.

Referenced by buildClusters(), buildNewCluster(), and drawClusters().

◆ maxRMS

double DTOccupancyClusterBuilder::maxRMS
private

Definition at line 61 of file DTOccupancyClusterBuilder.h.

Referenced by buildClusters(), buildNewCluster(), and drawClusters().

◆ theClusters

std::vector<DTOccupancyCluster> DTOccupancyClusterBuilder::theClusters
private

◆ theDistances

std::map<double, std::pair<DTOccupancyPoint, DTOccupancyPoint> > DTOccupancyClusterBuilder::theDistances
private

◆ theDistancesFromTheCluster

std::map<double, DTOccupancyPoint> DTOccupancyClusterBuilder::theDistancesFromTheCluster
private

Definition at line 56 of file DTOccupancyClusterBuilder.h.

Referenced by buildNewCluster(), and computeDistancesToCluster().

◆ thePoints

std::set<DTOccupancyPoint> DTOccupancyClusterBuilder::thePoints
private

◆ theProblematicLayers

std::set<DTLayerId> DTOccupancyClusterBuilder::theProblematicLayers
private

Definition at line 58 of file DTOccupancyClusterBuilder.h.

Referenced by isProblematic(), and sortClusters().