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.

21 : maxMean(-1.), maxRMS(-1.) {}

◆ ~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.

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 }

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

◆ buildClusters()

void DTOccupancyClusterBuilder::buildClusters ( )

build the clusters

Definition at line 33 of file DTOccupancyClusterBuilder.cc.

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 }

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

◆ buildNewCluster()

bool DTOccupancyClusterBuilder::buildNewCluster ( )
private

Definition at line 103 of file DTOccupancyClusterBuilder.cc.

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 }

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().

◆ computeDistancesToCluster()

void DTOccupancyClusterBuilder::computeDistancesToCluster ( const DTOccupancyCluster cluster)
private

Definition at line 96 of file DTOccupancyClusterBuilder.cc.

96  {
98  for (set<DTOccupancyPoint>::const_iterator pt = thePoints.begin(); pt != thePoints.end(); ++pt) {
100  }
101 }

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

Referenced by buildNewCluster().

◆ computePointToPointDistances()

void DTOccupancyClusterBuilder::computePointToPointDistances ( )
private

Definition at line 85 of file DTOccupancyClusterBuilder.cc.

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 }

References theDistances, and thePoints.

Referenced by buildNewCluster().

◆ drawClusters()

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

draw a TH2F histograms showing the clusters

Definition at line 54 of file DTOccupancyClusterBuilder.cc.

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 }

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

◆ getBestCluster()

DTOccupancyCluster DTOccupancyClusterBuilder::getBestCluster ( ) const

get the cluster correspondig to "normal" cell occupancy.

Definition at line 156 of file DTOccupancyClusterBuilder.cc.

156 { return theClusters.front(); }

References theClusters.

◆ getInitialPair()

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

Definition at line 81 of file DTOccupancyClusterBuilder.cc.

81  {
82  return theDistances.begin()->second;
83 }

References theDistances.

Referenced by buildNewCluster().

◆ isProblematic()

bool DTOccupancyClusterBuilder::isProblematic ( DTLayerId  layerId) const

Definition at line 158 of file DTOccupancyClusterBuilder.cc.

158  {
159  if (theProblematicLayers.find(layerId) != theProblematicLayers.end()) {
160  return true;
161  }
162  return false;
163 }

References theProblematicLayers.

◆ sortClusters()

void DTOccupancyClusterBuilder::sortClusters ( )
private

Definition at line 141 of file DTOccupancyClusterBuilder.cc.

141  {
142  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest|DTOccupancyClusterBuilder") << " sorting" << endl;
143  sort(theClusters.begin(), theClusters.end(), clusterIsLessThan);
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 }

References clusterIsLessThan(), LogTrace, theClusters, and theProblematicLayers.

Referenced by buildClusters().

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().

svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
clusterIsLessThan
bool clusterIsLessThan(const DTOccupancyCluster &clusterOne, const DTOccupancyCluster &clusterTwo)
for DTOccupancyCluster sorting
Definition: DTOccupancyCluster.cc:174
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
DTOccupancyClusterBuilder::theDistances
std::map< double, std::pair< DTOccupancyPoint, DTOccupancyPoint > > theDistances
Definition: DTOccupancyClusterBuilder.h:55
DTOccupancyCluster
Definition: DTOccupancyCluster.h:20
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
DTOccupancyClusterBuilder::thePoints
std::set< DTOccupancyPoint > thePoints
Definition: DTOccupancyClusterBuilder.h:54
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DTOccupancyClusterBuilder::computePointToPointDistances
void computePointToPointDistances()
Definition: DTOccupancyClusterBuilder.cc:85
DTOccupancyClusterBuilder::maxMean
double maxMean
Definition: DTOccupancyClusterBuilder.h:60
DTOccupancyClusterBuilder::theProblematicLayers
std::set< DTLayerId > theProblematicLayers
Definition: DTOccupancyClusterBuilder.h:58
DTOccupancyCluster::distance
double distance(const DTOccupancyPoint &point) const
Definition: DTOccupancyCluster.cc:89
DTOccupancyClusterBuilder::maxRMS
double maxRMS
Definition: DTOccupancyClusterBuilder.h:61
DTOccupancyClusterBuilder::theDistancesFromTheCluster
std::map< double, DTOccupancyPoint > theDistancesFromTheCluster
Definition: DTOccupancyClusterBuilder.h:56
DTOccupancyClusterBuilder::buildNewCluster
bool buildNewCluster()
Definition: DTOccupancyClusterBuilder.cc:103
DTOccupancyClusterBuilder::sortClusters
void sortClusters()
Definition: DTOccupancyClusterBuilder.cc:141
DTOccupancyClusterBuilder::computeDistancesToCluster
void computeDistancesToCluster(const DTOccupancyCluster &cluster)
Definition: DTOccupancyClusterBuilder.cc:96
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
DTOccupancyClusterBuilder::getInitialPair
std::pair< DTOccupancyPoint, DTOccupancyPoint > getInitialPair()
Definition: DTOccupancyClusterBuilder.cc:81
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
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
DTOccupancyClusterBuilder::theClusters
std::vector< DTOccupancyCluster > theClusters
Definition: DTOccupancyClusterBuilder.h:57