CMS 3D CMS Logo

HGCalDepthPreClusterer.cc
Go to the documentation of this file.
3 
4 #include <list>
5 
6 namespace {
8  // initialize original index locations
9  std::vector<size_t> idx(v.size());
10  for (size_t i = 0; i != idx.size(); ++i)
11  idx[i] = i;
12 
13  // sort indices based on comparing values in v
14  std::sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return (*v[i1]) > (*v[i2]); });
15 
16  return idx;
17  }
18 
19  float dist2(const edm::Ptr<reco::BasicCluster> &a, const edm::Ptr<reco::BasicCluster> &b) {
20  return reco::deltaR2(*a, *b);
21  }
22 
23  //get distance between cluster and multicluster axis (defined by remaning cluster with highest energy)
24  // N.B. the order of the clusters matters
25  float distAxisCluster2(const edm::Ptr<reco::BasicCluster> &a, const edm::Ptr<reco::BasicCluster> &b) {
26  float tanTheta = tan(2 * atan(exp(-1 * a->eta())));
27  float ax = b->z() * tanTheta * cos(a->phi());
28  float ay = b->z() * tanTheta * sin(a->phi());
29  return (ax - b->x()) * (ax - b->x()) + (ay - b->y()) * (ay - b->y());
30  }
31 } // namespace
32 
33 std::vector<reco::HGCalMultiCluster> HGCalDepthPreClusterer::makePreClusters(
34  const reco::HGCalMultiCluster::ClusterCollection &thecls) const {
35  std::vector<reco::HGCalMultiCluster> thePreClusters;
36  std::vector<size_t> es = sorted_indices(thecls);
37  std::vector<int> vused(es.size(), 0);
38  unsigned int used = 0;
39 
40  for (unsigned int i = 0; i < es.size(); ++i) {
41  if (vused[i] == 0) {
43  temp.push_back(thecls[es[i]]);
44  vused[i] = (thecls[es[i]]->z() > 0) ? 1 : -1;
45  ++used;
46  for (unsigned int j = i + 1; j < es.size(); ++j) {
47  if (vused[j] == 0) {
48  float distanceCheck = 9999.;
49  if (realSpaceCone)
50  distanceCheck = distAxisCluster2(thecls[es[i]], thecls[es[j]]);
51  else
52  distanceCheck = dist2(thecls[es[i]], thecls[es[j]]);
53  DetId detid = thecls[es[j]]->hitsAndFractions()[0].first();
54  unsigned int layer = clusterTools->getLayer(detid);
55  float radius = radii[2];
56  if (layer <= rhtools_.lastLayerEE())
57  radius = radii[0];
58  else if (layer < rhtools_.firstLayerBH())
59  radius = radii[1];
60  float radius2 = radius * radius;
61  if (distanceCheck<radius2 &&int(thecls[es[j]]->z() * vused[i])> 0) {
62  temp.push_back(thecls[es[j]]);
63  vused[j] = vused[i];
64  ++used;
65  }
66  }
67  }
68  if (temp.size() > minClusters) {
69  thePreClusters.push_back(temp);
70  auto &back = thePreClusters.back();
71  back.setPosition(clusterTools->getMultiClusterPosition(back));
72  back.setEnergy(clusterTools->getMultiClusterEnergy(back));
73  }
74  }
75  }
76 
77  return thePreClusters;
78 }
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
mps_fire.i
i
Definition: mps_fire.py:428
hgcal_clustering::sorted_indices
std::vector< size_t > sorted_indices(const std::vector< T > &v)
Definition: HGCalClusteringAlgoBase.h:18
HGCalDepthPreClusterer.h
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
HGCalDepthPreClusterer::realSpaceCone
bool realSpaceCone
Definition: HGCalDepthPreClusterer.h:51
findQualityFiles.v
v
Definition: findQualityFiles.py:179
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
HGCalDepthPreClusterer::clusterTools
std::unique_ptr< hgcal::ClusterTools > clusterTools
Definition: HGCalDepthPreClusterer.h:53
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DetId
Definition: DetId.h:17
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::PtrVector
Definition: PtrVector.h:36
DDAxes::z
HGCalDepthPreClusterer::minClusters
uint32_t minClusters
Definition: HGCalDepthPreClusterer.h:50
b
double b
Definition: hdecay.h:118
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
HGCalDepthPreClusterer::rhtools_
hgcal::RecHitTools rhtools_
Definition: HGCalDepthPreClusterer.h:54
a
double a
Definition: hdecay.h:119
deltaR.h
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
hgcal::RecHitTools::lastLayerEE
unsigned int lastLayerEE(bool nose=false) const
Definition: RecHitTools.h:64
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HGCalDepthPreClusterer::radii
std::vector< float > radii
Definition: HGCalDepthPreClusterer.h:49
edm::Ptr
Definition: AssociationVector.h:31
reco::HGCalMultiCluster
Definition: HGCalMultiCluster.h:12
hgcal::RecHitTools::firstLayerBH
unsigned int firstLayerBH() const
Definition: RecHitTools.h:66
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
HGCalDepthPreClusterer::makePreClusters
std::vector< reco::HGCalMultiCluster > makePreClusters(const reco::HGCalMultiCluster::ClusterCollection &) const
Definition: HGCalDepthPreClusterer.cc:33
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6