CMS 3D CMS Logo

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