CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalDepthPreClusterer.cc
Go to the documentation of this file.
3 
4 #include <list>
5 
6 namespace {
8 
9  // initialize original index locations
10  std::vector<size_t> idx(v.size());
11  for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;
12 
13  // sort indices based on comparing values in v
14  std::sort(idx.begin(), idx.end(),
15  [&v](size_t i1, size_t i2) {return (*v[i1]) > (*v[i2]);});
16 
17  return idx;
18  }
19 
20  float dist2(const edm::Ptr<reco::BasicCluster> &a,
22  return reco::deltaR2(*a,*b);
23  }
24 }
25 
26 std::vector<reco::HGCalMultiCluster> HGCalDepthPreClusterer::makePreClusters(const reco::HGCalMultiCluster::ClusterCollection &thecls) const {
27 
28  std::vector<reco::HGCalMultiCluster> thePreClusters;
29  std::vector<size_t> es = sorted_indices(thecls);
30  std::vector<int> vused(es.size(),0);
31  unsigned int used = 0;
32  const float radius2 = radius*radius;
33 
34  for(unsigned int i = 0; i < es.size(); ++i) {
35  if(vused[i]==0) {
37  temp.push_back(thecls[es[i]]);
38  vused[i]=(thecls[es[i]]->z()>0)? 1 : -1;
39  ++used;
40  for(unsigned int j = i+1; j < es.size(); ++j) {
41  if(vused[j]==0) {
42  if( dist2(thecls[es[i]],thecls[es[j]]) < radius2 && int(thecls[es[i]]->z()*vused[i])>0 ) {
43  temp.push_back(thecls[es[j]]);
44  vused[j]=vused[i];
45  ++used;
46  }
47  }
48  }
49  if( temp.size() > minClusters ) {
50  thePreClusters.push_back(temp);
51  auto& back = thePreClusters.back();
52  back.setPosition(clusterTools->getMultiClusterPosition(back));
53  back.setEnergy(clusterTools->getMultiClusterEnergy(back));
54  }
55  }
56  }
57 
58 
59 
60  return thePreClusters;
61 }
62 
63 
64 
int i
Definition: DBlmapReader.cc:9
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:74
std::vector< reco::HGCalMultiCluster > makePreClusters(const reco::HGCalMultiCluster::ClusterCollection &) const
std::unique_ptr< hgcal::ClusterTools > clusterTools
unsigned int size() const
void push_back(const edm::Ptr< reco::BasicCluster > &b)
int j
Definition: DBlmapReader.cc:9
std::vector< size_t > sorted_indices(const std::vector< T > &v)
double b
Definition: hdecay.h:120
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
double a
Definition: hdecay.h:121