00001 #include "RecoEcal/EgammaClusterAlgos/interface/BremRecoveryClusterAlgo.h"
00002
00003 reco::SuperClusterCollection BremRecoveryClusterAlgo::makeSuperClusters(reco::BasicClusterRefVector & clustersCollection)
00004 {
00005 const float etaBorder = 1.479;
00006
00007 superclusters_v.clear();
00008
00009
00010 reco::BasicClusterRefVector islandClustersBarrel_v;
00011 reco::BasicClusterRefVector islandClustersEndCap_v;
00012
00013
00014 reco::basicCluster_iterator it;
00015 for (it = clustersCollection.begin(); it != clustersCollection.end(); it++)
00016 {
00017 reco::BasicClusterRef cluster_p = *it;
00018 if (cluster_p->algo() == reco::island)
00019 {
00020 if (fabs(cluster_p->position().eta()) < etaBorder)
00021 {
00022 islandClustersBarrel_v.push_back(cluster_p);
00023 }
00024 else
00025 {
00026 islandClustersEndCap_v.push_back(cluster_p);
00027 }
00028 }
00029 }
00030
00031
00032 makeIslandSuperClusters(islandClustersBarrel_v, eb_rdeta_, eb_rdphi_);
00033
00034 makeIslandSuperClusters(islandClustersEndCap_v, ec_rdeta_, ec_rdphi_);
00035
00036 return superclusters_v;
00037 }
00038
00039 #include "DataFormats/Math/interface/Vector3D.h"
00040
00041 void BremRecoveryClusterAlgo::makeIslandSuperClusters(reco::BasicClusterRefVector &clusters_v,
00042 double etaRoad, double phiRoad)
00043 {
00044
00045 reco::basicCluster_iterator currentSeed;
00046 for (currentSeed = clusters_v.begin(); !clusters_v.empty(); clusters_v.erase(currentSeed))
00047 {
00048
00049 if ((*currentSeed)->energy() * sin((*currentSeed)->position().theta()) < seedTransverseEnergyThreshold) break;
00050
00051
00052 double energy_ = (*currentSeed)->energy();
00053 math::XYZVector position_((*currentSeed)->position().X(),
00054 (*currentSeed)->position().Y(),
00055 (*currentSeed)->position().Z());
00056 position_ *= energy_;
00057
00058 if (verbosity <= pINFO)
00059 {
00060 std::cout << "*****************************" << std::endl;
00061 std::cout << "******NEW SUPERCLUSTER*******" << std::endl;
00062 std::cout << "Seed R = " << (*currentSeed)->position().Rho() << std::endl;
00063 }
00064
00065
00066 reco::BasicClusterRefVector constituentClusters;
00067 constituentClusters.push_back(*currentSeed);
00068 reco::basicCluster_iterator currentCluster = currentSeed + 1;
00069 while (currentCluster != clusters_v.end())
00070 {
00071 if (match(*currentSeed, *currentCluster, etaRoad, phiRoad))
00072 {
00073 constituentClusters.push_back(*currentCluster);
00074 energy_ += (*currentCluster)->energy();
00075 position_ += (*currentCluster)->energy() * math::XYZVector((*currentCluster)->position().X(),
00076 (*currentCluster)->position().Y(),
00077 (*currentCluster)->position().Z());
00078 if (verbosity <= pINFO)
00079 {
00080 std::cout << "Cluster R = " << (*currentCluster)->position().Rho() << std::endl;
00081 }
00082
00083 clusters_v.erase(currentCluster);
00084 }
00085 else currentCluster++;
00086 }
00087
00088 position_ /= energy_;
00089
00090 if (verbosity <= pINFO)
00091 {
00092 std::cout << "Final SuperCluster R = " << position_.Rho() << std::endl;
00093 }
00094
00095 reco::SuperCluster newSuperCluster(energy_,
00096 math::XYZPoint(position_.X(), position_.Y(), position_.Z()),
00097 (*currentSeed),
00098 constituentClusters);
00099
00100 superclusters_v.push_back(newSuperCluster);
00101
00102 if (verbosity <= pINFO)
00103 {
00104 std::cout << "created a new supercluster of: " << std::endl;
00105 std::cout << "Energy = " << newSuperCluster.energy() << std::endl;
00106 std::cout << "Position in (R, phi, theta) = ("
00107 << newSuperCluster.position().Rho() << ", "
00108 << newSuperCluster.position().phi() << ", "
00109 << newSuperCluster.position().theta() << ")" << std::endl;
00110 }
00111 }
00112 currentSeed = clusters_v.end();
00113 }
00114
00115
00116 bool BremRecoveryClusterAlgo::match(reco::BasicClusterRef seed_p,
00117 reco::BasicClusterRef cluster_p,
00118 double dEtaMax, double dPhiMax)
00119 {
00120 math::XYZPoint clusterPosition = cluster_p->position();
00121 math::XYZPoint seedPosition = seed_p->position();
00122
00123 double dPhi = acos(cos(seedPosition.phi() - clusterPosition.phi()));
00124
00125 double dEta = fabs(seedPosition.eta() - clusterPosition.eta());
00126
00127 if (dEta > dEtaMax) return false;
00128 if (dPhi > dPhiMax) return false;
00129
00130 return true;
00131 }