test
CMS 3D CMS Logo

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