CMS 3D CMS Logo

HiBremRecoveryClusterAlgo.cc
Go to the documentation of this file.
4 
6  reco::CaloClusterPtrVector &clustersCollection) {
7  const float etaBorder = 1.479;
8 
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  reco::CaloClusterPtr cluster_p = *it;
18  if (cluster_p->algo() == reco::CaloCluster::island) {
19  if (verbosity <= pINFO) {
20  std::cout << "Basic Cluster: (eta,phi,energy) = " << cluster_p->position().eta() << " "
21  << cluster_p->position().phi() << " " << cluster_p->energy() << std::endl;
22  }
23 
24  // if the basic cluster pass the energy threshold -> fill it into the list
25  if (fabs(cluster_p->position().eta()) < etaBorder) {
26  if (cluster_p->energy() > BarrelBremEnergyThreshold)
27  islandClustersBarrel_v.push_back(cluster_p);
28  } else {
29  if (cluster_p->energy() > EndcapBremEnergyThreshold)
30  islandClustersEndCap_v.push_back(cluster_p);
31  }
32  }
33  }
34 
35  // make the superclusters from the Barrel clusters - Island
36  makeIslandSuperClusters(islandClustersBarrel_v, eb_rdeta_, eb_rdphi_);
37 
38  // make the superclusters from the EndCap clusters - Island
39  makeIslandSuperClusters(islandClustersEndCap_v, ec_rdeta_, ec_rdphi_);
40 
41  return superclusters_v;
42 }
43 
45  double etaRoad,
46  double phiRoad) {
47  // Vector of usedSeedEnergy, use the seed energy to check if this cluster is used.
48  std::vector<double> usedSeedEnergy;
49  usedSeedEnergy.clear();
50 
51  // Main brem recovery loop
52  for (reco::CaloCluster_iterator currentSeed = clusters_v.begin(); currentSeed != clusters_v.end(); ++currentSeed) {
53  if (verbosity <= pINFO) {
54  std::cout << "Current Cluster: " << (*currentSeed)->energy() << " "
55  << (std::find(usedSeedEnergy.begin(), usedSeedEnergy.end(), (*currentSeed)->energy()) !=
56  usedSeedEnergy.end())
57  << std::endl;
58  }
59 
60  // check this seed was not already used
61  if (std::find(usedSeedEnergy.begin(), usedSeedEnergy.end(), (*currentSeed)->energy()) != usedSeedEnergy.end())
62  continue;
63 
64  // Does our highest energy cluster have high enough energy? If not, continue instead of break to be robust
65  if ((*currentSeed)->energy() * sin((*currentSeed)->position().theta()) < seedTransverseEnergyThreshold)
66  continue;
67 
68  // if yes, make it a seed for a new SuperCluster, the position of the SC is calculated by energy weighted sum:
69  double energy_ = (*currentSeed)->energy();
70  math::XYZVector position_(
71  (*currentSeed)->position().X(), (*currentSeed)->position().Y(), (*currentSeed)->position().Z());
72  position_ *= energy_;
73  usedSeedEnergy.push_back((*currentSeed)->energy());
74 
75  // Printout if verbose
76  if (verbosity <= pINFO) {
77  std::cout << "*****************************" << std::endl;
78  std::cout << "******NEW SUPERCLUSTER*******" << std::endl;
79  std::cout << "Seed R = " << (*currentSeed)->position().Rho() << std::endl;
80  std::cout << "Seed Et = " << (*currentSeed)->energy() * sin((*currentSeed)->position().theta()) << std::endl;
81  }
82 
83  // and add the matching clusters:
84  reco::CaloClusterPtrVector constituentClusters;
85  constituentClusters.push_back(*currentSeed);
86  reco::CaloCluster_iterator currentCluster = currentSeed + 1;
87 
88  // loop over the clusters
89  while (currentCluster != clusters_v.end()) {
90  // Print out the basic clusters
91  if (verbosity <= pINFO) {
92  std::cout << "->Cluster: " << (*currentCluster)->energy() << " Used = "
93  << (std::find(usedSeedEnergy.begin(), usedSeedEnergy.end(), (*currentCluster)->energy()) !=
94  usedSeedEnergy.end())
95  << " Matched = " << match(*currentSeed, *currentCluster, etaRoad, phiRoad) << std::endl;
96  }
97 
98  // if it's in the search window, and unused
99  if (match(*currentSeed, *currentCluster, etaRoad, phiRoad) &&
100  (std::find(usedSeedEnergy.begin(), usedSeedEnergy.end(), (*currentCluster)->energy()) ==
101  usedSeedEnergy.end())) {
102  // Add basic cluster
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  // Add the cluster to the used list
109  usedSeedEnergy.push_back((*currentCluster)->energy());
110 
111  if (verbosity <= pINFO) {
112  std::cout << "Cluster R = " << (*currentCluster)->position().Rho() << std::endl;
113  }
114  }
115  ++currentCluster;
116  }
117 
118  // Calculate the final position
119  position_ /= energy_;
120 
121  if (verbosity <= pINFO) {
122  std::cout << "Final SuperCluster R = " << position_.Rho() << std::endl;
123  }
124 
125  // Add the supercluster to the new collection
126  reco::SuperCluster newSuperCluster(
127  energy_, math::XYZPoint(position_.X(), position_.Y(), position_.Z()), (*currentSeed), constituentClusters);
128 
129  superclusters_v.push_back(newSuperCluster);
130 
131  if (verbosity <= pINFO) {
132  std::cout << "created a new supercluster of: " << std::endl;
133  std::cout << "Energy = " << newSuperCluster.energy() << std::endl;
134  std::cout << "Position in (R, phi, theta, eta) = (" << newSuperCluster.position().Rho() << ", "
135  << newSuperCluster.position().phi() << ", " << newSuperCluster.position().theta() << ", "
136  << newSuperCluster.position().eta() << ")" << std::endl;
137  }
138  }
139  clusters_v.clear();
140  usedSeedEnergy.clear();
141 }
142 
144  reco::CaloClusterPtr cluster_p,
145  double dEtaMax,
146  double dPhiMax) {
147  math::XYZPoint clusterPosition = cluster_p->position();
148  math::XYZPoint seedPosition = seed_p->position();
149 
150  double dPhi = acos(cos(seedPosition.phi() - clusterPosition.phi()));
151 
152  double dEta = fabs(seedPosition.eta() - clusterPosition.eta());
153  if (verbosity <= pINFO) {
154  std::cout << "seed phi: " << seedPosition.phi() << " cluster phi: " << clusterPosition.phi() << " dphi = " << dPhi
155  << " dphiMax = " << dPhiMax << std::endl;
156  std::cout << "seed eta: " << seedPosition.eta() << " cluster eta: " << clusterPosition.eta() << " deta = " << dEta
157  << " detaMax = " << dEtaMax << std::endl;
158  }
159  if (dEta > dEtaMax)
160  return false;
161  if (dPhi > dPhiMax)
162  return false;
163 
164  return true;
165 }
bool match(reco::CaloClusterPtr seed_p, reco::CaloClusterPtr cluster_p, double etaRoad, double phiRoad)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:152
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator end() const
Definition: PtrVector.h:149
reco::SuperClusterCollection makeSuperClusters(reco::CaloClusterPtrVector &clusters)
reco::SuperClusterCollection superclusters_v
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const_iterator begin() const
Definition: PtrVector.h:147
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
void makeIslandSuperClusters(reco::CaloClusterPtrVector &clusters_v, double etaRoad, double phiRoad)