CMS 3D CMS Logo

Multi5x5BremRecoveryClusterAlgo.cc
Go to the documentation of this file.
4 
6  const reco::CaloClusterPtrVector& clustersCollection) {
7  const float etaBorder = 1.479;
8  superclusters_v.clear();
9 
10  // create vectors of references to clusters of a specific origin...
11  reco::CaloClusterPtrVector islandClustersBarrel_v;
12  reco::CaloClusterPtrVector islandClustersEndCap_v;
13 
14  // ...and populate them:
15  for (auto const& cluster_p : clustersCollection) {
16  if (cluster_p->algo() == reco::CaloCluster::multi5x5) {
17  if (fabs(cluster_p->position().eta()) < etaBorder) {
18  islandClustersBarrel_v.push_back(cluster_p);
19  } else {
20  islandClustersEndCap_v.push_back(cluster_p);
21  }
22  }
23  }
24 
25  // make the superclusters from the Barrel clusters - Island
26  makeIslandSuperClusters(islandClustersBarrel_v, eb_rdeta_, eb_rdphi_);
27  // make the superclusters from the EndCap clusters - Island
28  makeIslandSuperClusters(islandClustersEndCap_v, ec_rdeta_, ec_rdphi_);
29 
30  return superclusters_v;
31 }
32 
34 
36  double etaRoad,
37  double phiRoad) {
38  if (clusters_v.empty())
39  return;
40 
41  const auto clustersSize = clusters_v.size();
42  assert(clustersSize > 0);
43 
44  bool usedSeed[clustersSize];
45  for (auto ic = 0U; ic < clustersSize; ++ic)
46  usedSeed[ic] = false;
47 
48  float eta[clustersSize], phi[clustersSize], et[clustersSize];
49  for (auto ic = 0U; ic < clustersSize; ++ic) {
50  eta[ic] = clusters_v[ic]->eta();
51  phi[ic] = clusters_v[ic]->phi();
52  et[ic] = clusters_v[ic]->energy() * sin(clusters_v[ic]->position().theta());
53  }
54 
55  for (auto is = 0U; is < clustersSize; ++is) {
56  // check this seed was not already used
57  if (usedSeed[is])
58  continue;
59  auto const& currentSeed = clusters_v[is];
60 
61  // Does our highest energy cluster have high enough energy?
62  // changed this to continue from break (to be robust against the order of sorting of the seed clusters)
64  continue;
65 
66  // if yes, make it a seed for a new SuperCluster:
67  double energy = (currentSeed)->energy();
68  math::XYZVector position_(
69  (currentSeed)->position().X(), (currentSeed)->position().Y(), (currentSeed)->position().Z());
70  position_ *= energy;
71  usedSeed[is] = true;
72 
73  LogTrace("EcalClusters") << "*****************************";
74  LogTrace("EcalClusters") << "******NEW SUPERCLUSTER*******";
75  LogTrace("EcalClusters") << "Seed R = " << (currentSeed)->position().Rho();
76 
77  reco::CaloClusterPtrVector constituentClusters;
78  constituentClusters.push_back(currentSeed);
79  auto ic = is + 1;
80 
81  while (ic < clustersSize) {
82  auto const& currentCluster = clusters_v[ic];
83 
84  // if dynamic phi road is enabled then compute the phi road for a cluster
85  // of energy of existing clusters + the candidate cluster.
86  if (dynamicPhiRoad_)
87  phiRoad = phiRoadAlgo_->endcapPhiRoad(energy + (currentCluster)->energy());
88 
89  auto dphi = [](float p1, float p2) {
90  auto dp = std::abs(p1 - p2);
91  if (dp > float(M_PI))
92  dp -= float(2 * M_PI);
93  return std::abs(dp);
94  };
95 
96  auto match = [&](int i, int j) {
97  return (dphi(phi[i], phi[j]) < phiRoad) & (std::abs(eta[i] - eta[j]) < etaRoad);
98  };
99 
100  // does the cluster match the phi road for this candidate supercluster
101  if (!usedSeed[ic] && match(is, ic)) {
102  // add basic cluster to supercluster constituents
103  constituentClusters.push_back(currentCluster);
104  energy += (currentCluster)->energy();
105  position_ += (currentCluster)->energy() * math::XYZVector((currentCluster)->position().X(),
106  (currentCluster)->position().Y(),
107  (currentCluster)->position().Z());
108  // remove cluster from vector of available clusters
109  usedSeed[ic] = true;
110  LogTrace("EcalClusters") << "Cluster R = " << (currentCluster)->position().Rho();
111  }
112  ++ic;
113  }
114 
115  position_ /= energy;
116 
117  LogTrace("EcalClusters") << "Final SuperCluster R = " << position_.Rho();
118 
119  reco::SuperCluster newSuperCluster(
120  energy, math::XYZPoint(position_.X(), position_.Y(), position_.Z()), currentSeed, constituentClusters);
121 
122  superclusters_v.push_back(newSuperCluster);
123  LogTrace("EcalClusters") << "created a new supercluster of: ";
124  LogTrace("EcalClusters") << "Energy = " << newSuperCluster.energy();
125  LogTrace("EcalClusters") << "Position in (R, phi, theta) = (" << newSuperCluster.position().Rho() << ", "
126  << newSuperCluster.position().phi() << ", " << newSuperCluster.position().theta() << ")";
127  }
128 
129  clusters_v.clear();
130 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
size_type size() const
Size of the RefVector.
Definition: PtrVectorBase.h:75
void makeIslandSuperClusters(reco::CaloClusterPtrVector &clusters_v, double etaRoad, double phiRoad)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define X(str)
Definition: MuonsGrabber.cc:38
assert(be >=bs)
#define LogTrace(id)
bool empty() const
Is the RefVector empty.
Definition: PtrVectorBase.h:72
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
double energy() const
cluster energy
Definition: CaloCluster.h:149
reco::SuperClusterCollection superclusters_v
double endcapPhiRoad(double energy)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void clear()
Clear the PtrVector.
Definition: PtrVectorBase.h:81
static int position[264][3]
Definition: ReadPGInfo.cc:289
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Geom::Theta< T > theta() const
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &clusters)