CMS 3D CMS Logo

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

#include <HGCal3DClustering.h>

Classes

struct  ClusterRef
 

Public Types

typedef std::vector< reco::BasicClusterClusterCollection
 

Public Member Functions

void getEvent (const edm::Event &ev)
 
void getEventSetup (const edm::EventSetup &es)
 
 HGCal3DClustering ()
 
 HGCal3DClustering (const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
 
 HGCal3DClustering (const edm::ParameterSet &conf, edm::ConsumesCollector &sumes, const std::vector< double > &radii_in, uint32_t min_clusters)
 
std::vector< reco::HGCalMultiClustermakeClusters (const reco::HGCalMultiCluster::ClusterCollection &)
 

Private Types

typedef KDTreeNodeInfo< ClusterRefKDNode
 
typedef KDTreeLinkerAlgo< ClusterRefKDTree
 

Private Member Functions

void layerIntersection (std::array< double, 3 > &to, const std::array< double, 3 > &from) const
 
void organizeByLayer (const reco::HGCalMultiCluster::ClusterCollection &)
 
void reset ()
 

Private Attributes

std::unique_ptr< hgcal::ClusterToolsclusterTools
 
std::vector< size_t > es
 
unsigned int maxlayer
 
std::vector< std::array< float, 2 > > maxpos
 
uint32_t minClusters
 
std::vector< std::array< float, 2 > > minpos
 
std::vector< std::vector< KDNode > > points
 
std::vector< double > radii
 
hgcal::RecHitTools rhtools_
 
std::vector< float > zees
 

Detailed Description

Definition at line 17 of file HGCal3DClustering.h.

Member Typedef Documentation

◆ ClusterCollection

Definition at line 51 of file HGCal3DClustering.h.

◆ KDNode

Definition at line 85 of file HGCal3DClustering.h.

◆ KDTree

Definition at line 84 of file HGCal3DClustering.h.

Constructor & Destructor Documentation

◆ HGCal3DClustering() [1/3]

HGCal3DClustering::HGCal3DClustering ( )
inline

Definition at line 19 of file HGCal3DClustering.h.

19 : radii({0., 0., 0.}), minClusters(0), clusterTools(nullptr) {}

◆ HGCal3DClustering() [2/3]

HGCal3DClustering::HGCal3DClustering ( const edm::ParameterSet conf,
edm::ConsumesCollector sumes,
const std::vector< double > &  radii_in,
uint32_t  min_clusters 
)
inline

Definition at line 21 of file HGCal3DClustering.h.

25  : radii(radii_in),
26  minClusters(min_clusters),
27  es(0),
28  clusterTools(std::make_unique<hgcal::ClusterTools>(conf, sumes)) {}

◆ HGCal3DClustering() [3/3]

HGCal3DClustering::HGCal3DClustering ( const edm::ParameterSet conf,
edm::ConsumesCollector sumes 
)
inline

Definition at line 30 of file HGCal3DClustering.h.

31  : HGCal3DClustering(conf,
32  sumes,
33  conf.getParameter<std::vector<double>>("multiclusterRadii"),
34  conf.getParameter<unsigned>("minClusters")) {}

Member Function Documentation

◆ getEvent()

void HGCal3DClustering::getEvent ( const edm::Event ev)
inline

Definition at line 36 of file HGCal3DClustering.h.

36 { clusterTools->getEvent(ev); }

References clusterTools, and ev.

◆ getEventSetup()

void HGCal3DClustering::getEventSetup ( const edm::EventSetup es)
inline

Definition at line 37 of file HGCal3DClustering.h.

37  {
38  clusterTools->getEventSetup(es);
41  points.clear();
42  minpos.clear();
43  maxpos.clear();
44  zees.clear();
45  points.resize(2 * (maxlayer + 1));
46  minpos.resize(2 * (maxlayer + 1), {{0.0f, 0.0f}});
47  maxpos.resize(2 * (maxlayer + 1), {{0.0f, 0.0f}});
48  zees.resize(2 * (maxlayer + 1), 0.);
49  }

References clusterTools, es, hgcal::RecHitTools::getEventSetup(), hgcal::RecHitTools::lastLayerBH(), maxlayer, maxpos, minpos, points, rhtools_, and zees.

◆ layerIntersection()

void HGCal3DClustering::layerIntersection ( std::array< double, 3 > &  to,
const std::array< double, 3 > &  from 
) const
private

Definition at line 119 of file HGCal3DClustering.cc.

119  {
120  if (from[2] != 0) {
121  to[0] = from[0] / from[2] * to[2];
122  to[1] = from[1] / from[2] * to[2];
123  } else {
124  to[0] = 0;
125  to[1] = 0;
126  }
127 }

Referenced by makeClusters().

◆ makeClusters()

std::vector< reco::HGCalMultiCluster > HGCal3DClustering::makeClusters ( const reco::HGCalMultiCluster::ClusterCollection thecls)

Definition at line 48 of file HGCal3DClustering.cc.

49  {
50  reset();
51  organizeByLayer(thecls);
52  std::vector<reco::HGCalMultiCluster> thePreClusters;
53 
54  std::vector<KDTree> hit_kdtree(2 * (maxlayer + 1));
55  for (unsigned int i = 0; i <= 2 * maxlayer + 1; ++i) {
56  KDTreeBox bounds(minpos[i][0], maxpos[i][0], minpos[i][1], maxpos[i][1]);
57  hit_kdtree[i].build(points[i], bounds);
58  }
59  std::vector<int> vused(es.size(), 0);
60  unsigned int used = 0;
61 
62  unsigned int es_size = es.size();
63  for (unsigned int i = 0; i < es_size; ++i) {
64  if (vused[i] == 0) {
66  temp.push_back(thecls[es[i]]);
67  vused[i] = (thecls[es[i]]->z() > 0) ? 1 : -1;
68  ++used;
69  // Starting from cluster es[i] at from[0] - from[1] - from[2]
70  std::array<double, 3> from{{thecls[es[i]]->x(), thecls[es[i]]->y(), thecls[es[i]]->z()}};
71  unsigned int firstlayer = int(thecls[es[i]]->z() > 0) * (maxlayer + 1);
72  unsigned int lastlayer = firstlayer + maxlayer + 1;
73  for (unsigned int j = firstlayer; j < lastlayer; ++j) {
74  if (zees[j] == 0.) {
75  // layer j not yet ever reached?
76  continue;
77  }
78  std::array<double, 3> to{{0., 0., zees[j]}};
79  layerIntersection(to, from);
80  unsigned int layer =
81  j > maxlayer ? (j - (maxlayer + 1)) : j; //maps back from index used for KD trees to actual layer
82  float radius = radii[2];
83  if (layer <= rhtools_.lastLayerEE())
84  radius = radii[0];
85  else if (layer < rhtools_.firstLayerBH())
86  radius = radii[1];
87  float radius2 = radius * radius;
88  KDTreeBox search_box(
89  float(to[0]) - radius, float(to[0]) + radius, float(to[1]) - radius, float(to[1]) + radius);
90  std::vector<ClusterRef> found;
91  // at layer j in box float(to[0])+/-radius - float(to[1])+/-radius
92  hit_kdtree[j].search(search_box, found);
93  // found found.size() clusters within box
94  for (unsigned int k = 0; k < found.size(); k++) {
95  if (vused[found[k].ind] == 0 && distReal2(thecls[es[found[k].ind]], to) < radius2) {
96  temp.push_back(thecls[es[found[k].ind]]);
97  vused[found[k].ind] = vused[i];
98  ++used;
99  }
100  }
101  }
102  if (temp.size() > minClusters) {
103  math::XYZPoint position = clusterTools->getMultiClusterPosition(temp);
104  if (std::abs(position.z()) <= 0.)
105  continue;
106  // only store multiclusters that pass the energy threshold in getMultiClusterPosition
107  // giving them a position inside the HGCal
108  thePreClusters.push_back(temp);
109  auto &back = thePreClusters.back();
110  back.setPosition(position);
111  back.setEnergy(clusterTools->getMultiClusterEnergy(back));
112  }
113  }
114  }
115 
116  return thePreClusters;
117 }

References funct::abs(), clusterTools, es, hgcal::RecHitTools::firstLayerBH(), newFWLiteAna::found, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, hgcal::RecHitTools::lastLayerEE(), layerIntersection(), maxlayer, maxpos, minClusters, minpos, organizeByLayer(), points, position, radii, CosmicsPD_Skims::radius, reset(), rhtools_, groupFilesInBlocks::temp, z, and zees.

◆ organizeByLayer()

void HGCal3DClustering::organizeByLayer ( const reco::HGCalMultiCluster::ClusterCollection thecls)
private

Definition at line 21 of file HGCal3DClustering.cc.

21  {
22  es = sorted_indices(thecls);
23  unsigned int es_size = es.size();
24  for (unsigned int i = 0; i < es_size; ++i) {
25  int layer = rhtools_.getLayerWithOffset(thecls[es[i]]->hitsAndFractions()[0].first);
26  layer += int(thecls[es[i]]->z() > 0) * (maxlayer + 1);
27  float x = thecls[es[i]]->x();
28  float y = thecls[es[i]]->y();
29  float z = thecls[es[i]]->z();
30  points[layer].emplace_back(ClusterRef(i, z), x, y);
31  if (zees[layer] == 0.) {
32  // At least one cluster for layer at z
33  zees[layer] = z;
34  }
35  if (points[layer].empty()) {
36  minpos[layer][0] = x;
37  minpos[layer][1] = y;
38  maxpos[layer][0] = x;
39  maxpos[layer][1] = y;
40  } else {
41  minpos[layer][0] = std::min(x, minpos[layer][0]);
42  minpos[layer][1] = std::min(y, minpos[layer][1]);
43  maxpos[layer][0] = std::max(x, maxpos[layer][0]);
44  maxpos[layer][1] = std::max(y, maxpos[layer][1]);
45  }
46  }
47 }

References relativeConstraints::empty, es, dqmdumpme::first, hgcal::RecHitTools::getLayerWithOffset(), mps_fire::i, createfilelist::int, SiStripPI::max, maxlayer, maxpos, min(), minpos, points, rhtools_, hgcal_clustering::sorted_indices(), x, y, z, and zees.

Referenced by makeClusters().

◆ reset()

void HGCal3DClustering::reset ( void  )
inlineprivate

Definition at line 57 of file HGCal3DClustering.h.

57  {
58  for (auto& it : points) {
59  it.clear();
60  std::vector<KDNode>().swap(it);
61  }
62  std::fill(zees.begin(), zees.end(), 0.);
63  for (unsigned int i = 0; i < minpos.size(); i++) {
64  minpos[i][0] = 0.;
65  minpos[i][1] = 0.;
66  maxpos[i][0] = 0.;
67  maxpos[i][1] = 0.;
68  }
69  }

References ntuplemaker::fill, mps_fire::i, maxpos, minpos, points, and zees.

Referenced by makeClusters().

Member Data Documentation

◆ clusterTools

std::unique_ptr<hgcal::ClusterTools> HGCal3DClustering::clusterTools
private

instance of tools to simplify cluster access.

Definition at line 91 of file HGCal3DClustering.h.

Referenced by getEvent(), getEventSetup(), and makeClusters().

◆ es

std::vector<size_t> HGCal3DClustering::es
private

vector to contain sorted indices of all clusters.

Definition at line 89 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), and organizeByLayer().

◆ maxlayer

unsigned int HGCal3DClustering::maxlayer
private

Definition at line 73 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), and organizeByLayer().

◆ maxpos

std::vector<std::array<float, 2> > HGCal3DClustering::maxpos
private

Definition at line 88 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), organizeByLayer(), and reset().

◆ minClusters

uint32_t HGCal3DClustering::minClusters
private

Definition at line 76 of file HGCal3DClustering.h.

Referenced by makeClusters().

◆ minpos

std::vector<std::array<float, 2> > HGCal3DClustering::minpos
private

Definition at line 87 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), organizeByLayer(), and reset().

◆ points

std::vector<std::vector<KDNode> > HGCal3DClustering::points
private

Definition at line 86 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), organizeByLayer(), and reset().

◆ radii

std::vector<double> HGCal3DClustering::radii
private

Definition at line 75 of file HGCal3DClustering.h.

Referenced by makeClusters().

◆ rhtools_

hgcal::RecHitTools HGCal3DClustering::rhtools_
private

instance of tools to access RecHit information.

Definition at line 92 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), and organizeByLayer().

◆ zees

std::vector<float> HGCal3DClustering::zees
private

vector to contain z position of each layer.

Definition at line 90 of file HGCal3DClustering.h.

Referenced by getEventSetup(), makeClusters(), organizeByLayer(), and reset().

DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:355
HGCal3DClustering::points
std::vector< std::vector< KDNode > > points
Definition: HGCal3DClustering.h:86
hgcal_clustering::sorted_indices
std::vector< size_t > sorted_indices(const std::vector< T > &v)
Definition: HGCalClusteringAlgoBase.h:18
min
T min(T a, T b)
Definition: MathUtil.h:58
HGCal3DClustering::organizeByLayer
void organizeByLayer(const reco::HGCalMultiCluster::ClusterCollection &)
Definition: HGCal3DClustering.cc:21
to
DDAxes::x
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
HGCal3DClustering::minClusters
uint32_t minClusters
Definition: HGCal3DClustering.h:76
dqmdumpme.first
first
Definition: dqmdumpme.py:55
HGCal3DClustering::HGCal3DClustering
HGCal3DClustering()
Definition: HGCal3DClustering.h:19
HGCal3DClustering::zees
std::vector< float > zees
Definition: HGCal3DClustering.h:90
DDAxes::z
HGCal3DClustering::radii
std::vector< double > radii
Definition: HGCal3DClustering.h:75
KDTreeBox
Definition: KDTreeLinkerAlgo.h:14
HGCal3DClustering::minpos
std::vector< std::array< float, 2 > > minpos
Definition: HGCal3DClustering.h:87
dqmdumpme.k
k
Definition: dqmdumpme.py:60
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
HGCal3DClustering::maxpos
std::vector< std::array< float, 2 > > maxpos
Definition: HGCal3DClustering.h:88
hgcal::RecHitTools::lastLayerBH
unsigned int lastLayerBH() const
Definition: RecHitTools.h:66
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HGCal3DClustering::layerIntersection
void layerIntersection(std::array< double, 3 > &to, const std::array< double, 3 > &from) const
Definition: HGCal3DClustering.cc:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
hgcal::RecHitTools::getLayerWithOffset
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:357
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:63
HGCal3DClustering::reset
void reset()
Definition: HGCal3DClustering.h:57
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
HGCal3DClustering::clusterTools
std::unique_ptr< hgcal::ClusterTools > clusterTools
Definition: HGCal3DClustering.h:91
createfilelist.int
int
Definition: createfilelist.py:10
hgcal::RecHitTools::getEventSetup
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:70
reco::HGCalMultiCluster
Definition: HGCalMultiCluster.h:12
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hgcal::RecHitTools::firstLayerBH
unsigned int firstLayerBH() const
Definition: RecHitTools.h:65
HGCal3DClustering::maxlayer
unsigned int maxlayer
Definition: HGCal3DClustering.h:73
HGCal3DClustering::es
std::vector< size_t > es
Definition: HGCal3DClustering.h:89
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
HGCal3DClustering::rhtools_
hgcal::RecHitTools rhtools_
Definition: HGCal3DClustering.h:92
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66