CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
HGCalCLUEAlgo Class Reference

#include <HGCalCLUEAlgo.h>

Inheritance diagram for HGCalCLUEAlgo:
HGCalClusteringAlgoBase

Classes

struct  Hexel
 

Public Types

typedef math::XYZPoint Point
 point in the space More...
 
- Public Types inherited from HGCalClusteringAlgoBase
enum  VerbosityLevel { pDEBUG = 0, pWARNING = 1, pINFO = 2, pERROR = 3 }
 

Public Member Functions

void computeThreshold ()
 
std::vector< reco::BasicClustergetClusters (bool) override
 
Density getDensity () override
 
 HGCalCLUEAlgo (const edm::ParameterSet &ps)
 
void makeClusters () override
 
void populate (const HGCRecHitCollection &hits) override
 
void reset () override
 
 ~HGCalCLUEAlgo () override
 
- Public Member Functions inherited from HGCalClusteringAlgoBase
void getEventSetup (const edm::EventSetup &es)
 
 HGCalClusteringAlgoBase (VerbosityLevel v, reco::CaloCluster::AlgoId algo)
 
void setAlgoId (reco::CaloCluster::AlgoId algo)
 
void setVerbosity (VerbosityLevel the_verbosity)
 
virtual ~HGCalClusteringAlgoBase ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &iDesc)
 

Private Types

typedef KDTreeNodeInfoT< Hexel, 2 > KDNode
 
typedef KDTreeLinkerAlgo< Hexel, 2 > KDTree
 

Private Member Functions

double calculateDistanceToHigher (std::vector< KDNode > &) const
 
double calculateLocalDensity (std::vector< KDNode > &, KDTree &, const unsigned int) const
 
math::XYZPoint calculatePosition (const std::vector< KDNode > &) const
 
double distance (const Hexel &pt1, const Hexel &pt2) const
 
double distance2 (const Hexel &pt1, const Hexel &pt2) const
 
int findAndAssignClusters (std::vector< KDNode > &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector< std::vector< KDNode > > &) const
 
void setDensity (const std::vector< KDNode > &nd)
 
std::vector< size_t > sort_by_delta (const std::vector< KDNode > &v) const
 

Private Attributes

std::vector< double > dEdXweights_
 
Density density_
 
bool dependSensor_
 
double ecut_
 
double fcPerEle_
 
std::vector< double > fcPerMip_
 
bool initialized_
 
double kappa_
 
std::vector< std::vector< std::vector< KDNode > > > layerClustersPerLayer_
 
std::vector< std::array< float, 2 > > maxpos_
 
std::vector< std::array< float, 2 > > minpos_
 
double noiseMip_
 
std::vector< double > nonAgedNoises_
 
std::vector< std::vector< KDNode > > points_
 
std::vector< double > positionDeltaRho_c_
 
std::vector< double > thicknessCorrection_
 
std::vector< std::vector< double > > thresholds_
 
std::vector< double > thresholdW0_
 
std::vector< std::vector< double > > v_sigmaNoise_
 
std::vector< double > vecDeltas_
 

Additional Inherited Members

- Static Public Attributes inherited from HGCalClusteringAlgoBase
static const unsigned int lastLayerEE = 28
 
static const unsigned int lastLayerFH = 40
 
static const unsigned int maxlayer = 52
 
- Protected Attributes inherited from HGCalClusteringAlgoBase
reco::CaloCluster::AlgoId algoId_
 
std::vector< reco::BasicClusterclusters_v_
 
hgcal::RecHitTools rhtools_
 
VerbosityLevel verbosity_
 

Detailed Description

Definition at line 31 of file HGCalCLUEAlgo.h.

Member Typedef Documentation

Definition at line 206 of file HGCalCLUEAlgo.h.

Definition at line 205 of file HGCalCLUEAlgo.h.

point in the space

Definition at line 120 of file HGCalCLUEAlgo.h.

Constructor & Destructor Documentation

HGCalCLUEAlgo::HGCalCLUEAlgo ( const edm::ParameterSet ps)
inline

Definition at line 34 of file HGCalCLUEAlgo.h.

References HGCalClusteringAlgoBase::maxlayer, and maxpos_.

36  (HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter<unsigned int>("verbosity",3),
38  thresholdW0_(ps.getParameter<std::vector<double> >("thresholdW0")),
39  positionDeltaRho_c_(ps.getParameter<std::vector<double> >("positionDeltaRho_c")),
40  vecDeltas_(ps.getParameter<std::vector<double> >("deltac")),
41  kappa_(ps.getParameter<double>("kappa")),
42  ecut_(ps.getParameter<double>("ecut")),
43  dependSensor_(ps.getParameter<bool>("dependSensor")),
44  dEdXweights_(ps.getParameter<std::vector<double> >("dEdXweights")),
45  thicknessCorrection_(ps.getParameter<std::vector<double> >("thicknessCorrection")),
46  fcPerMip_(ps.getParameter<std::vector<double> >("fcPerMip")),
47  fcPerEle_(ps.getParameter<double>("fcPerEle")),
48  nonAgedNoises_(ps.getParameter<edm::ParameterSet>("noises").getParameter<std::vector<double> >("values")),
49  noiseMip_(ps.getParameter<edm::ParameterSet>("noiseMip").getParameter<double>("value")),
50  initialized_(false),
51  points_(2*(maxlayer+1)),
52  minpos_(2*(maxlayer+1),{ {0.0f,0.0f} }),
53  maxpos_(2*(maxlayer+1),{ {0.0f,0.0f} }) {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::array< float, 2 > > minpos_
std::vector< double > nonAgedNoises_
std::vector< double > thicknessCorrection_
std::vector< double > thresholdW0_
std::vector< double > fcPerMip_
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo)
std::vector< double > dEdXweights_
std::vector< std::vector< KDNode > > points_
std::vector< double > vecDeltas_
static const unsigned int maxlayer
std::vector< std::array< float, 2 > > maxpos_
std::vector< double > positionDeltaRho_c_
HGCalCLUEAlgo::~HGCalCLUEAlgo ( )
inlineoverride

Definition at line 55 of file HGCalCLUEAlgo.h.

References getClusters(), hfClusterShapes_cfi::hits, makeClusters(), and populate().

55 {}

Member Function Documentation

double HGCalCLUEAlgo::calculateDistanceToHigher ( std::vector< KDNode > &  nd) const
private

Definition at line 240 of file HGCalCLUEAlgo.cc.

References data, mps_fire::i, hgcal_clustering::sorted_indices(), mathSSE::sqrt(), and tmp.

Referenced by distance().

240  {
241  // sort vector of Hexels by decreasing local density
242  std::vector<size_t> &&rs = sorted_indices(nd);
243 
244  double maxdensity = 0.0;
245  int nearestHigher = -1;
246 
247  if (!rs.empty())
248  maxdensity = nd[rs[0]].data.rho;
249  else
250  return maxdensity; // there are no hits
251  double dist2 = 0.;
252  // start by setting delta for the highest density hit to
253  // the most distant hit - this is a convention
254 
255  for (const auto &j : nd) {
256  double tmp = distance2(nd[rs[0]].data, j.data);
257  if (tmp > dist2) dist2 = tmp;
258  }
259  nd[rs[0]].data.delta = std::sqrt(dist2);
260  nd[rs[0]].data.nearestHigher = nearestHigher;
261 
262  // now we save the largest distance as a starting point
263  const double max_dist2 = dist2;
264  const unsigned int nd_size = nd.size();
265 
266  for (unsigned int oi = 1; oi < nd_size; ++oi) { // start from second-highest density
267  dist2 = max_dist2;
268  unsigned int i = rs[oi];
269  // we only need to check up to oi since hits
270  // are ordered by decreasing density
271  // and all points coming BEFORE oi are guaranteed to have higher rho
272  // and the ones AFTER to have lower rho
273  for (unsigned int oj = 0; oj < oi; ++oj) {
274  unsigned int j = rs[oj];
275  double tmp = distance2(nd[i].data, nd[j].data);
276  if (tmp <= dist2) { // this "<=" instead of "<" addresses the (rare) case
277  // when there are only two hits
278  dist2 = tmp;
279  nearestHigher = j;
280  }
281  }
282  nd[i].data.delta = std::sqrt(dist2);
283  nd[i].data.nearestHigher = nearestHigher; // this uses the original unsorted hitlist
284  }
285  return maxdensity;
286 }
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< size_t > sorted_indices(const std::vector< T > &v)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double distance2(const Hexel &pt1, const Hexel &pt2) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double HGCalCLUEAlgo::calculateLocalDensity ( std::vector< KDNode > &  nd,
KDTree lp,
const unsigned int  layer 
) const
private

Definition at line 210 of file HGCalCLUEAlgo.cc.

References data, SoftLeptonByDistance_cfi::distance, runEdmFileComparison::found, mps_fire::i, SiStripPI::max, and KDTreeLinkerAlgo< DATA >::search().

Referenced by distance().

211  {
212  double maxdensity = 0.;
213  float delta_c; // maximum search distance (critical distance) for local
214  // density calculation
215  if (layer <= lastLayerEE)
216  delta_c = vecDeltas_[0];
217  else if (layer <= lastLayerFH)
218  delta_c = vecDeltas_[1];
219  else
220  delta_c = vecDeltas_[2];
221 
222  // for each node calculate local density rho and store it
223  for (unsigned int i = 0; i < nd.size(); ++i) {
224  // speec up search by looking within +/- delta_c window only
225  KDTreeBox search_box(nd[i].dims[0] - delta_c, nd[i].dims[0] + delta_c, nd[i].dims[1] - delta_c,
226  nd[i].dims[1] + delta_c);
227  std::vector<KDNode> found;
228  lp.search(search_box, found);
229  const unsigned int found_size = found.size();
230  for (unsigned int j = 0; j < found_size; j++) {
231  if (distance(nd[i].data, found[j].data) < delta_c) {
232  nd[i].data.rho += (nd[i].data.detid == found[j].data.detid ? 1. : 0.5) * found[j].data.weight;
233  maxdensity = std::max(maxdensity, nd[i].data.rho);
234  }
235  } // end loop found
236  } // end loop nodes
237  return maxdensity;
238 }
static const unsigned int lastLayerEE
static const unsigned int lastLayerFH
std::vector< double > vecDeltas_
double distance(const Hexel &pt1, const Hexel &pt2) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
math::XYZPoint HGCalCLUEAlgo::calculatePosition ( const std::vector< KDNode > &  v) const
private

Definition at line 145 of file HGCalCLUEAlgo.cc.

References data, mps_fire::i, training_settings::idx, cmsBatch::log, and SiStripPI::max.

Referenced by distance().

145  {
146  float total_weight = 0.f;
147  float x = 0.f;
148  float y = 0.f;
149 
150  unsigned int v_size = v.size();
151  unsigned int maxEnergyIndex = 0;
152  float maxEnergyValue = 0;
153 
154  // loop over hits in cluster candidate
155  // determining the maximum energy hit
156  for (unsigned int i = 0; i < v_size; i++) {
157  if (v[i].data.weight > maxEnergyValue) {
158  maxEnergyValue = v[i].data.weight;
159  maxEnergyIndex = i;
160  }
161  }
162 
163  // Si cell or Scintillator. Used to set approach and parameters
164  int thick = rhtools_.getSiThickIndex(v[maxEnergyIndex].data.detid);
165 
166  // for hits within positionDeltaRho_c_ from maximum energy hit
167  // build up weight for energy-weighted position
168  // and save corresponding hits indices
169  std::vector<unsigned int> innerIndices;
170  for (unsigned int i = 0; i < v_size; i++) {
171  if (thick == -1 || distance2(v[i].data, v[maxEnergyIndex].data) < positionDeltaRho_c_[thick]) {
172  innerIndices.push_back(i);
173 
174  float rhEnergy = v[i].data.weight;
175  total_weight += rhEnergy;
176  // just fill x, y for scintillator
177  // for Si it is overwritten later anyway
178  if (thick == -1) {
179  x += v[i].data.x * rhEnergy;
180  y += v[i].data.y * rhEnergy;
181  }
182  }
183  }
184  // just loop on reduced vector of interesting indices
185  // to compute log weighting
186  if (thick != -1 && total_weight != 0.) { // Silicon case
187  float total_weight_log = 0.f;
188  float x_log = 0.f;
189  float y_log = 0.f;
190  for (auto idx : innerIndices) {
191  float rhEnergy = v[idx].data.weight;
192  if (rhEnergy == 0.) continue;
193  float Wi = std::max(thresholdW0_[thick] + std::log(rhEnergy / total_weight), 0.);
194  x_log += v[idx].data.x * Wi;
195  y_log += v[idx].data.y * Wi;
196  total_weight_log += Wi;
197  }
198  total_weight = total_weight_log;
199  x = x_log;
200  y = y_log;
201  }
202 
203  if (total_weight != 0.) {
204  auto inv_tot_weight = 1. / total_weight;
205  return math::XYZPoint(x * inv_tot_weight, y * inv_tot_weight, v[maxEnergyIndex].data.z);
206  }
207  return math::XYZPoint(0, 0, 0);
208 }
std::vector< double > thresholdW0_
int getSiThickIndex(const DetId &) const
Definition: RecHitTools.cc:168
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double distance2(const Hexel &pt1, const Hexel &pt2) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< double > positionDeltaRho_c_
void HGCalCLUEAlgo::computeThreshold ( )

Definition at line 369 of file HGCalCLUEAlgo.cc.

Referenced by reset().

369  {
370  // To support the TDR geometry and also the post-TDR one (v9 onwards), we
371  // need to change the logic of the vectors containing signal to noise and
372  // thresholds. The first 3 indices will keep on addressing the different
373  // thicknesses of the Silicon detectors, while the last one, number 3 (the
374  // fourth) will address the Scintillators. This change will support both
375  // geometries at the same time.
376 
377  if (initialized_) return; // only need to calculate thresholds once
378 
379  initialized_ = true;
380 
381  std::vector<double> dummy;
382  const unsigned maxNumberOfThickIndices = 3;
383  dummy.resize(maxNumberOfThickIndices + 1, 0); // +1 to accomodate for the Scintillators
384  thresholds_.resize(maxlayer, dummy);
385  v_sigmaNoise_.resize(maxlayer, dummy);
386 
387  for (unsigned ilayer = 1; ilayer <= maxlayer; ++ilayer) {
388  for (unsigned ithick = 0; ithick < maxNumberOfThickIndices; ++ithick) {
389  float sigmaNoise = 0.001f * fcPerEle_ * nonAgedNoises_[ithick] * dEdXweights_[ilayer] /
390  (fcPerMip_[ithick] * thicknessCorrection_[ithick]);
391  thresholds_[ilayer - 1][ithick] = sigmaNoise * ecut_;
392  v_sigmaNoise_[ilayer - 1][ithick] = sigmaNoise;
393  }
394  float scintillators_sigmaNoise = 0.001f * noiseMip_ * dEdXweights_[ilayer];
395  thresholds_[ilayer - 1][maxNumberOfThickIndices] = ecut_ * scintillators_sigmaNoise;
396  v_sigmaNoise_[ilayer - 1][maxNumberOfThickIndices] = scintillators_sigmaNoise;
397  }
398 }
std::vector< std::vector< double > > v_sigmaNoise_
std::vector< double > nonAgedNoises_
std::vector< double > thicknessCorrection_
std::vector< double > fcPerMip_
std::vector< double > dEdXweights_
static const unsigned int maxlayer
std::vector< std::vector< double > > thresholds_
double HGCalCLUEAlgo::distance ( const Hexel pt1,
const Hexel pt2 
) const
inlineprivate

Definition at line 231 of file HGCalCLUEAlgo.h.

References calculateDistanceToHigher(), calculateLocalDensity(), calculatePosition(), distance2(), findAndAssignClusters(), setDensity(), and mathSSE::sqrt().

232  { // 2-d distance on the layer (x-y)
233  return std::sqrt(distance2(pt1, pt2));
234  }
T sqrt(T t)
Definition: SSEVec.h:18
double distance2(const Hexel &pt1, const Hexel &pt2) const
double HGCalCLUEAlgo::distance2 ( const Hexel pt1,
const Hexel pt2 
) const
inlineprivate

Definition at line 226 of file HGCalCLUEAlgo.h.

References PVValHelper::dx, PVValHelper::dy, HGCalCLUEAlgo::Hexel::x, and HGCalCLUEAlgo::Hexel::y.

Referenced by distance().

226  { // distance squared
227  const double dx = pt1.x - pt2.x;
228  const double dy = pt1.y - pt2.y;
229  return (dx * dx + dy * dy);
230  } // distance squaredq
static void HGCalCLUEAlgo::fillPSetDescription ( edm::ParameterSetDescription iDesc)
inlinestatic

Definition at line 87 of file HGCalCLUEAlgo.h.

References edm::ParameterSetDescription::add(), and edm::ParameterSetDescription::addUntracked().

87  {
88  iDesc.add<std::vector<double>>("thresholdW0", {
89  2.9,
90  2.9,
91  2.9
92  });
93  iDesc.add<std::vector<double>>("positionDeltaRho_c", {
94  1.3,
95  1.3,
96  1.3
97  });
98  iDesc.add<std::vector<double>>("deltac", {
99  1.3,
100  1.3,
101  5.0,
102  });
103  iDesc.add<bool>("dependSensor", true);
104  iDesc.add<double>("ecut", 3.0);
105  iDesc.add<double>("kappa", 9.0);
106  iDesc.addUntracked<unsigned int>("verbosity", 3);
107  iDesc.add<std::vector<double>>("dEdXweights",{});
108  iDesc.add<std::vector<double>>("thicknessCorrection",{});
109  iDesc.add<std::vector<double>>("fcPerMip",{});
110  iDesc.add<double>("fcPerEle",0.0);
111  edm::ParameterSetDescription descNestedNoises;
112  descNestedNoises.add<std::vector<double> >("values", {});
113  iDesc.add<edm::ParameterSetDescription>("noises", descNestedNoises);
114  edm::ParameterSetDescription descNestedNoiseMIP;
115  descNestedNoiseMIP.add<double>("value", 0 );
116  iDesc.add<edm::ParameterSetDescription>("noiseMip", descNestedNoiseMIP);
117  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int HGCalCLUEAlgo::findAndAssignClusters ( std::vector< KDNode > &  ,
KDTree ,
double  ,
KDTreeBox ,
const unsigned int  ,
std::vector< std::vector< KDNode > > &   
) const
private

Definition at line 287 of file HGCalCLUEAlgo.cc.

References data, mps_fire::i, LogDebug, and hgcal_clustering::sorted_indices().

Referenced by distance().

289  {
290  // this is called once per layer and endcap...
291  // so when filling the cluster temporary vector of Hexels we resize each time
292  // by the number of clusters found. This is always equal to the number of
293  // cluster centers...
294 
295  unsigned int nClustersOnLayer = 0;
296  float delta_c; // critical distance
297  if (layer <= lastLayerEE)
298  delta_c = vecDeltas_[0];
299  else if (layer <= lastLayerFH)
300  delta_c = vecDeltas_[1];
301  else
302  delta_c = vecDeltas_[2];
303 
304  std::vector<size_t> rs = sorted_indices(nd); // indices sorted by decreasing rho
305  std::vector<size_t> ds = sort_by_delta(nd); // sort in decreasing distance to higher
306 
307  const unsigned int nd_size = nd.size();
308  for (unsigned int i = 0; i < nd_size; ++i) {
309  if (nd[ds[i]].data.delta < delta_c) break; // no more cluster centers to be looked at
310  if (dependSensor_) {
311  float rho_c = kappa_ * nd[ds[i]].data.sigmaNoise;
312  if (nd[ds[i]].data.rho < rho_c) continue; // set equal to kappa times noise threshold
313 
314  } else if (nd[ds[i]].data.rho * kappa_ < maxdensity)
315  continue;
316 
317  nd[ds[i]].data.clusterIndex = nClustersOnLayer;
318  if (verbosity_ < pINFO) {
319  LogDebug("HGCalCLUEAlgo")
320  << "Adding new cluster with index " << nClustersOnLayer
321  << "Cluster center is hit " << ds[i] << std::endl;
322  }
323  nClustersOnLayer++;
324  }
325 
326  // at this point nClustersOnLayer is equal to the number of cluster centers -
327  // if it is zero we are done
328  if (nClustersOnLayer == 0) return nClustersOnLayer;
329 
330  // assign remaining points to clusters, using the nearestHigher set from
331  // previous step (always set except
332  // for top density hit that is skipped...)
333  for (unsigned int oi = 1; oi < nd_size; ++oi) {
334  unsigned int i = rs[oi];
335  int ci = nd[i].data.clusterIndex;
336  if (ci == -1 && nd[i].data.delta < 2. * delta_c) {
337  nd[i].data.clusterIndex = nd[nd[i].data.nearestHigher].data.clusterIndex;
338  }
339  }
340 
341  // make room in the temporary cluster vector for the additional clusterIndex
342  // clusters
343  // from this layer
344  if (verbosity_ < pINFO) {
345  LogDebug("HGCalCLUEAlgo")
346  << "resizing cluster vector by " << nClustersOnLayer << std::endl;
347  }
348  clustersOnLayer.resize(nClustersOnLayer);
349 
350  // Fill the cluster vector
351  for (unsigned int i = 0; i < nd_size; ++i) {
352  int ci = nd[i].data.clusterIndex;
353  if (ci != -1) {
354  clustersOnLayer[ci].push_back(nd[i]);
355  if (verbosity_ < pINFO) {
356  LogDebug("HGCalCLUEAlgo")
357  << "Pushing hit " << i << " into cluster with index " << ci << std::endl;
358  }
359  }
360  }
361 
362  // prepare the offset for the next layer if there is one
363  if (verbosity_ < pINFO) {
364  LogDebug("HGCalCLUEAlgo") << "moving cluster offset by " << nClustersOnLayer << std::endl;
365  }
366  return nClustersOnLayer;
367 }
#define LogDebug(id)
static const unsigned int lastLayerEE
static const unsigned int lastLayerFH
std::vector< size_t > sorted_indices(const std::vector< T > &v)
std::vector< size_t > sort_by_delta(const std::vector< KDNode > &v) const
std::vector< double > vecDeltas_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< reco::BasicCluster > HGCalCLUEAlgo::getClusters ( bool  )
overridevirtual

Implements HGCalClusteringAlgoBase.

Definition at line 109 of file HGCalCLUEAlgo.cc.

References AlignmentPI::calculatePosition(), GetRecoTauVFromDQM_MC_cff::cl, data, reco::CaloID::DET_HGCAL_ENDCAP, LogDebug, hgcal_clustering::max_index(), and position.

Referenced by ~HGCalCLUEAlgo().

109  {
111  std::vector<std::pair<DetId, float>> thisCluster;
112  for (const auto &clsOnLayer : layerClustersPerLayer_) {
113  int index = 0;
114  for (const auto &cl : clsOnLayer) {
115  double energy = 0;
116  Point position;
117  // Will save the maximum density hit of the cluster
118  size_t rsmax = max_index(cl);
119  position = calculatePosition(cl); // energy-weighted position
120  for (const auto &it : cl) {
121  energy += it.data.weight;
122  thisCluster.emplace_back(it.data.detid, 1.f);
123  }
124  if (verbosity_ < pINFO) {
125  LogDebug("HGCalCLUEAlgo")
126  << "******** NEW CLUSTER (HGCIA) ********"
127  << "Index " << index
128  << "No. of cells = " << cl.size()
129  << " Energy = " << energy
130  << " Phi = " << position.phi()
131  << " Eta = " << position.eta()
132  << "*****************************" << std::endl;
133  }
134  clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_);
135  if (!clusters_v_.empty()) {
136  clusters_v_.back().setSeed(cl[rsmax].data.detid);
137  }
138  thisCluster.clear();
139  index++;
140  }
141  }
142  return clusters_v_;
143 }
#define LogDebug(id)
std::vector< std::vector< std::vector< KDNode > > > layerClustersPerLayer_
std::vector< reco::BasicCluster > clusters_v_
reco::CaloCluster::AlgoId algoId_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:55
static int position[264][3]
Definition: ReadPGInfo.cc:509
size_t max_index(const std::vector< T > &v)
math::XYZPoint calculatePosition(const std::vector< KDNode > &) const
Density HGCalCLUEAlgo::getDensity ( )
overridevirtual

Implements HGCalClusteringAlgoBase.

Definition at line 408 of file HGCalCLUEAlgo.cc.

Referenced by reset().

408  {
409  return density_;
410 }
Density density_
void HGCalCLUEAlgo::makeClusters ( )
overridevirtual

Implements HGCalClusteringAlgoBase.

Definition at line 82 of file HGCalCLUEAlgo.cc.

References KDTreeLinkerAlgo< DATA >::build(), mps_fire::i, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by ~HGCalCLUEAlgo().

82  {
83  layerClustersPerLayer_.resize(2 * maxlayer + 2);
84  // assign all hits in each layer to a cluster core
85  tbb::this_task_arena::isolate([&] {
86  tbb::parallel_for(size_t(0), size_t(2 * maxlayer + 2), [&](size_t i) {
87  KDTreeBox bounds(minpos_[i][0], maxpos_[i][0], minpos_[i][1], maxpos_[i][1]);
88  KDTree hit_kdtree;
89  hit_kdtree.build(points_[i], bounds);
90 
91  unsigned int actualLayer = i > maxlayer
92  ? (i - (maxlayer + 1))
93  : i; // maps back from index used for KD trees to actual layer
94 
95  double maxdensity = calculateLocalDensity(points_[i], hit_kdtree,
96  actualLayer); // also stores rho (energy
97  // density) for each point (node)
98  // calculate distance to nearest point with higher density storing
99  // distance (delta) and point's index
101  findAndAssignClusters(points_[i], hit_kdtree, maxdensity, bounds, actualLayer,
103  });
104  });
105  //Now that we have the density per point we can store it
106  for(auto const& p: points_) { setDensity(p); }
107 }
std::vector< std::vector< std::vector< KDNode > > > layerClustersPerLayer_
std::vector< std::array< float, 2 > > minpos_
int findAndAssignClusters(std::vector< KDNode > &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector< std::vector< KDNode > > &) const
double calculateDistanceToHigher(std::vector< KDNode > &) const
std::vector< std::vector< KDNode > > points_
double calculateLocalDensity(std::vector< KDNode > &, KDTree &, const unsigned int) const
static const unsigned int maxlayer
std::vector< std::array< float, 2 > > maxpos_
KDTreeLinkerAlgo< Hexel, 2 > KDTree
void setDensity(const std::vector< KDNode > &nd)
void HGCalCLUEAlgo::populate ( const HGCRecHitCollection hits)
overridevirtual

Implements HGCalClusteringAlgoBase.

Definition at line 17 of file HGCalCLUEAlgo.cc.

References CaloRecHit::detid(), CaloRecHit::energy(), mps_fire::i, createfilelist::int, SiStripPI::max, min(), position, and edm::SortedCollection< T, SORT >::size().

Referenced by ~HGCalCLUEAlgo().

17  {
18  // loop over all hits and create the Hexel structure, skip energies below ecut
19 
20  if (dependSensor_) {
21  // for each layer and wafer calculate the thresholds (sigmaNoise and energy)
22  // once
24  }
25 
26  std::vector<bool> firstHit(2 * (maxlayer + 1), true);
27  for (unsigned int i = 0; i < hits.size(); ++i) {
28  const HGCRecHit &hgrh = hits[i];
29  DetId detid = hgrh.detid();
30  unsigned int layer = rhtools_.getLayerWithOffset(detid);
31  float thickness = 0.f;
32  // set sigmaNoise default value 1 to use kappa value directly in case of
33  // sensor-independent thresholds
34  float sigmaNoise = 1.f;
35  if (dependSensor_) {
36  thickness = rhtools_.getSiThickness(detid);
37  int thickness_index = rhtools_.getSiThickIndex(detid);
38  if (thickness_index == -1) thickness_index = 3;
39  double storedThreshold = thresholds_[layer - 1][thickness_index];
40  sigmaNoise = v_sigmaNoise_[layer - 1][thickness_index];
41 
42  if (hgrh.energy() < storedThreshold)
43  continue; // this sets the ZS threshold at ecut times the sigma noise
44  // for the sensor
45  }
46  if (!dependSensor_ && hgrh.energy() < ecut_) continue;
47 
48  // map layers from positive endcap (z) to layer + maxlayer+1 to prevent
49  // mixing up hits from different sides
50  layer += int(rhtools_.zside(detid) > 0) * (maxlayer + 1);
51 
52  // determine whether this is a half-hexagon
53  bool isHalf = rhtools_.isHalfCell(detid);
55 
56  // here's were the KDNode is passed its dims arguments - note that these are
57  // *copied* from the Hexel
58  points_[layer].emplace_back(Hexel(hgrh, detid, isHalf, sigmaNoise, thickness, &rhtools_),
59  position.x(), position.y());
60 
61  // for each layer, store the minimum and maximum x and y coordinates for the
62  // KDTreeBox boundaries
63  if (firstHit[layer]) {
64  minpos_[layer][0] = position.x();
65  minpos_[layer][1] = position.y();
66  maxpos_[layer][0] = position.x();
67  maxpos_[layer][1] = position.y();
68  firstHit[layer] = false;
69  } else {
70  minpos_[layer][0] = std::min((float)position.x(), minpos_[layer][0]);
71  minpos_[layer][1] = std::min((float)position.y(), minpos_[layer][1]);
72  maxpos_[layer][0] = std::max((float)position.x(), maxpos_[layer][0]);
73  maxpos_[layer][1] = std::max((float)position.y(), maxpos_[layer][1]);
74  }
75  } // end loop hits
76 }
constexpr float energy() const
Definition: CaloRecHit.h:31
bool isHalfCell(const DetId &) const
Definition: RecHitTools.cc:327
std::vector< std::array< float, 2 > > minpos_
int zside(const DetId &id) const
Definition: RecHitTools.cc:131
std::vector< std::vector< double > > v_sigmaNoise_
constexpr const DetId & detid() const
Definition: CaloRecHit.h:35
void computeThreshold()
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< std::vector< KDNode > > points_
std::float_t getSiThickness(const DetId &) const
Definition: RecHitTools.cc:145
Definition: DetId.h:18
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:283
int getSiThickIndex(const DetId &) const
Definition: RecHitTools.cc:168
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:112
static const unsigned int maxlayer
std::vector< std::array< float, 2 > > maxpos_
size_type size() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< std::vector< double > > thresholds_
void HGCalCLUEAlgo::reset ( void  )
inlineoverridevirtual

Implements HGCalClusteringAlgoBase.

Definition at line 68 of file HGCalCLUEAlgo.h.

References HGCalClusteringAlgoBase::clusters_v_, computeThreshold(), getDensity(), mps_fire::i, layerClustersPerLayer_, maxpos_, minpos_, points_, and edm::swap().

68  {
69  clusters_v_.clear();
70  layerClustersPerLayer_.clear();
71  for (auto &it : points_) {
72  it.clear();
73  std::vector<KDNode>().swap(it);
74  }
75  for (unsigned int i = 0; i < minpos_.size(); i++) {
76  minpos_[i][0] = 0.;
77  minpos_[i][1] = 0.;
78  maxpos_[i][0] = 0.;
79  maxpos_[i][1] = 0.;
80  }
81  }
std::vector< std::vector< std::vector< KDNode > > > layerClustersPerLayer_
std::vector< std::array< float, 2 > > minpos_
std::vector< reco::BasicCluster > clusters_v_
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
std::vector< std::vector< KDNode > > points_
std::vector< std::array< float, 2 > > maxpos_
void HGCalCLUEAlgo::setDensity ( const std::vector< KDNode > &  nd)
private

Definition at line 400 of file HGCalCLUEAlgo.cc.

References mps_fire::i.

Referenced by distance().

400  {
401 
402  // for each node store the computer local density
403  for (auto &i : nd){
404  density_[ i.data.detid ] = i.data.rho ;
405  }
406 }
Density density_
std::vector<size_t> HGCalCLUEAlgo::sort_by_delta ( const std::vector< KDNode > &  v) const
inlineprivate

Definition at line 210 of file HGCalCLUEAlgo.h.

References begin, end, training_settings::idx, and findQualityFiles::v.

210  {
211  std::vector<size_t> idx(v.size());
212  std::iota(std::begin(idx), std::end(idx), 0);
213  sort(idx.begin(), idx.end(),
214  [&v](size_t i1, size_t i2) { return v[i1].data.delta > v[i2].data.delta; });
215  return idx;
216  }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32

Member Data Documentation

std::vector<double> HGCalCLUEAlgo::dEdXweights_
private

Definition at line 140 of file HGCalCLUEAlgo.h.

Density HGCalCLUEAlgo::density_
private

Definition at line 135 of file HGCalCLUEAlgo.h.

bool HGCalCLUEAlgo::dependSensor_
private

Definition at line 139 of file HGCalCLUEAlgo.h.

double HGCalCLUEAlgo::ecut_
private

Definition at line 132 of file HGCalCLUEAlgo.h.

double HGCalCLUEAlgo::fcPerEle_
private

Definition at line 143 of file HGCalCLUEAlgo.h.

std::vector<double> HGCalCLUEAlgo::fcPerMip_
private

Definition at line 142 of file HGCalCLUEAlgo.h.

bool HGCalCLUEAlgo::initialized_
private

Definition at line 150 of file HGCalCLUEAlgo.h.

double HGCalCLUEAlgo::kappa_
private

Definition at line 129 of file HGCalCLUEAlgo.h.

std::vector<std::vector<std::vector<KDNode> > > HGCalCLUEAlgo::layerClustersPerLayer_
private

Definition at line 208 of file HGCalCLUEAlgo.h.

Referenced by reset().

std::vector<std::array<float, 2> > HGCalCLUEAlgo::maxpos_
private

Definition at line 223 of file HGCalCLUEAlgo.h.

Referenced by HGCalCLUEAlgo(), and reset().

std::vector<std::array<float, 2> > HGCalCLUEAlgo::minpos_
private

Definition at line 222 of file HGCalCLUEAlgo.h.

Referenced by reset().

double HGCalCLUEAlgo::noiseMip_
private

Definition at line 145 of file HGCalCLUEAlgo.h.

std::vector<double> HGCalCLUEAlgo::nonAgedNoises_
private

Definition at line 144 of file HGCalCLUEAlgo.h.

std::vector<std::vector<KDNode> > HGCalCLUEAlgo::points_
private

Definition at line 218 of file HGCalCLUEAlgo.h.

Referenced by reset().

std::vector<double> HGCalCLUEAlgo::positionDeltaRho_c_
private

Definition at line 125 of file HGCalCLUEAlgo.h.

std::vector<double> HGCalCLUEAlgo::thicknessCorrection_
private

Definition at line 141 of file HGCalCLUEAlgo.h.

std::vector<std::vector<double> > HGCalCLUEAlgo::thresholds_
private

Definition at line 146 of file HGCalCLUEAlgo.h.

std::vector<double> HGCalCLUEAlgo::thresholdW0_
private

Definition at line 124 of file HGCalCLUEAlgo.h.

std::vector<std::vector<double> > HGCalCLUEAlgo::v_sigmaNoise_
private

Definition at line 147 of file HGCalCLUEAlgo.h.

std::vector<double> HGCalCLUEAlgo::vecDeltas_
private

Definition at line 128 of file HGCalCLUEAlgo.h.