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.
3 
5 {
6 
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 (reco::CaloCluster_iterator it = clustersCollection.begin(); it != clustersCollection.end(); it++)
16  {
17  reco::CaloClusterPtr cluster_p = *it;
18  if (cluster_p->algo() == reco::CaloCluster::multi5x5)
19  {
20  if (fabs(cluster_p->position().eta()) < etaBorder)
21  {
22  islandClustersBarrel_v.push_back(cluster_p);
23  }
24  else
25  {
26  islandClustersEndCap_v.push_back(cluster_p);
27  }
28  }
29  }
30 
31  // make the superclusters from the Barrel clusters - Island
32  makeIslandSuperClusters(islandClustersBarrel_v, eb_rdeta_, eb_rdphi_);
33  // make the superclusters from the EndCap clusters - Island
34  makeIslandSuperClusters(islandClustersEndCap_v, ec_rdeta_, ec_rdphi_);
35 
36  return superclusters_v;
37 }
38 
40 
42  double etaRoad, double phiRoad)
43 {
44 
45  std::vector<DetId> usedSeedDetIds;
46  usedSeedDetIds.clear();
47 
48  for (reco::CaloCluster_iterator currentSeed = clusters_v.begin(); currentSeed != clusters_v.end(); ++currentSeed)
49  {
50 
51  // check this seed was not already used
52  if (std::find(usedSeedDetIds.begin(), usedSeedDetIds.end(), (*currentSeed)->seed())
53  != usedSeedDetIds.end()) continue;
54 
55  // Does our highest energy cluster have high enough energy?
56  // changed this to continue from break (to be robust against the order of sorting of the seed clusters)
57  if ((*currentSeed)->energy() * sin((*currentSeed)->position().theta()) < seedTransverseEnergyThreshold) continue;
58 
59  // if yes, make it a seed for a new SuperCluster:
60  double energy = (*currentSeed)->energy();
61  math::XYZVector position_((*currentSeed)->position().X(),
62  (*currentSeed)->position().Y(),
63  (*currentSeed)->position().Z());
64  position_ *= energy;
65  usedSeedDetIds.push_back((*currentSeed)->seed());
66 
67  if (verbosity <= pINFO)
68  {
69  std::cout << "*****************************" << std::endl;
70  std::cout << "******NEW SUPERCLUSTER*******" << std::endl;
71  std::cout << "Seed R = " << (*currentSeed)->position().Rho() << std::endl;
72  }
73 
74  // and add the matching clusters:
75  reco::CaloClusterPtrVector constituentClusters;
76  constituentClusters.push_back(*currentSeed);
77  reco::CaloCluster_iterator currentCluster = currentSeed + 1;
78 
79  while (currentCluster != clusters_v.end())
80  {
81 
82  // if dynamic phi road is enabled then compute the phi road for a cluster
83  // of energy of existing clusters + the candidate cluster.
84  if (dynamicPhiRoad_)
85  phiRoad = phiRoadAlgo_->endcapPhiRoad(energy + (*currentCluster)->energy());
86 
87  // does the cluster match the phi road for this candidate supercluster
88  if (match(*currentSeed, *currentCluster, etaRoad, phiRoad) &&
89  std::find(usedSeedDetIds.begin(), usedSeedDetIds.end(), (*currentCluster)->seed()) == usedSeedDetIds.end())
90  {
91 
92  // add basic cluster to supercluster constituents
93  constituentClusters.push_back(*currentCluster);
94  energy += (*currentCluster)->energy();
95  position_ += (*currentCluster)->energy() * math::XYZVector((*currentCluster)->position().X(),
96  (*currentCluster)->position().Y(),
97  (*currentCluster)->position().Z());
98 
99  // remove cluster from vector of available clusters
100  usedSeedDetIds.push_back((*currentCluster)->seed());
101 
102  if (verbosity <= pINFO)
103  std::cout << "Cluster R = " << (*currentCluster)->position().Rho() << std::endl;
104  }
105  ++currentCluster;
106 
107  }
108 
109  position_ /= energy;
110 
111  if (verbosity <= pINFO)
112  std::cout << "Final SuperCluster R = " << position_.Rho() << std::endl;
113 
114  reco::SuperCluster newSuperCluster(energy,
115  math::XYZPoint(position_.X(), position_.Y(), position_.Z()),
116  (*currentSeed),
117  constituentClusters);
118 
119  superclusters_v.push_back(newSuperCluster);
120 
121  if (verbosity <= pINFO)
122  {
123  std::cout << "created a new supercluster of: " << std::endl;
124  std::cout << "Energy = " << newSuperCluster.energy() << std::endl;
125  std::cout << "Position in (R, phi, theta) = ("
126  << newSuperCluster.position().Rho() << ", "
127  << newSuperCluster.position().phi() << ", "
128  << newSuperCluster.position().theta() << ")" << std::endl;
129  }
130 
131  }
132 
133  clusters_v.clear();
134 
135 }
136 
137 
139  reco::CaloClusterPtr cluster_p,
140  double dEtaMax, double dPhiMax)
141 {
142  math::XYZPoint clusterPosition = cluster_p->position();
143  math::XYZPoint seedPosition = seed_p->position();
144 
145  double dPhi = acos(cos(seedPosition.phi() - clusterPosition.phi()));
146 
147  double dEta = fabs(seedPosition.eta() - clusterPosition.eta());
148 
149  if (dEta > dEtaMax) return false;
150  if (dPhi > dPhiMax) return false;
151 
152  return true;
153 }
void makeIslandSuperClusters(reco::CaloClusterPtrVector &clusters_v, double etaRoad, double phiRoad)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:137
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::SuperClusterCollection makeSuperClusters(reco::CaloClusterPtrVector &clusters)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const_iterator begin() const
Definition: PtrVector.h:126
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const_iterator end() const
Definition: PtrVector.h:131
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:13
void clear()
Clear the PtrVector.
Definition: PtrVectorBase.h:79
tuple cout
Definition: gather_cfg.py:41
bool match(reco::CaloClusterPtr seed_p, reco::CaloClusterPtr cluster_p, double etaRoad, double phiRoad)