Go to the documentation of this file.00001 #include "EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h"
00002 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00003
00004
00005
00006
00007 SuperClusterHelper::SuperClusterHelper(const reco::GsfElectron * electron, const EcalRecHitCollection * rechits, const CaloTopology * topo, const CaloGeometry* geom) {
00008 theElectron_ = electron;
00009 rechits_ = rechits ;
00010 seedCluster_ = & (*(electron->superCluster()->seed()));
00011 theSuperCluster_ = &(*electron->superCluster());
00012
00013 eSubClusters_ = 0.;
00014
00015 reco::CaloCluster_iterator itscl = theSuperCluster_->clustersBegin();
00016 reco::CaloCluster_iterator itsclE = theSuperCluster_->clustersEnd();
00017 for(; itscl < itsclE ; ++itscl) {
00018 if((*itscl)==electron->superCluster()->seed()) continue;
00019 theBasicClusters_.push_back(&(**itscl));
00020 eSubClusters_ += (*itscl)->energy();
00021 }
00022
00023 sort(theBasicClusters_.begin(), theBasicClusters_.end(), SuperClusterHelper::sortClusters);
00024
00025 theBasicClusters_.insert(theBasicClusters_.begin(), seedCluster_);
00026
00027 nBasicClusters_ = theBasicClusters_.size();
00028
00029
00030 eESClusters_ = 0. ;
00031 itscl = theSuperCluster_->preshowerClustersBegin();
00032 itsclE = theSuperCluster_->preshowerClustersEnd();
00033 for( ; itscl < itsclE ; ++ itscl) {
00034 theESClusters_.push_back(&(**itscl));
00035 eESClusters_ += (*itscl)->energy();
00036 }
00037
00038 sort(theESClusters_.begin(), theESClusters_.end(), SuperClusterHelper::sortClusters);
00039
00040 nESClusters_ = theESClusters_.size();
00041
00042 topology_ = topo;
00043 geometry_ = geom;
00044 barrel_ = electron->isEB();
00045 covComputed_ = false;
00046 localCoordinatesComputed_ = false;
00047 }
00048
00049 SuperClusterHelper::SuperClusterHelper(const pat::Electron * electron, const EcalRecHitCollection * rechits, const CaloTopology * topo, const CaloGeometry * geom) {
00050 theElectron_ = (const reco::GsfElectron*)electron;
00051 rechits_ = rechits ;
00052
00053
00054
00055
00056 theSuperCluster_ = &(*electron->superCluster());
00057 seedCluster_ = & (*(electron->seed()));
00058 const std::vector<reco::CaloCluster>& basicClusters(electron->basicClusters());
00059 nBasicClusters_ = basicClusters.size();
00060 eSubClusters_ = 0. ;
00061
00062 for ( unsigned ib = 0; ib < nBasicClusters_ ; ++ib) {
00063 if(fabs((basicClusters[ib].energy()-seedCluster_->energy())/seedCluster_->energy())<1.e-5 &&
00064 fabs((basicClusters[ib].eta()-seedCluster_->eta())/seedCluster_->eta())<1.e-5 &&
00065 fabs((basicClusters[ib].phi()-seedCluster_->phi())/seedCluster_->phi())<1.e-5
00066 )
00067 continue;
00068 theBasicClusters_.push_back(&basicClusters[ib]);
00069 eSubClusters_ += basicClusters[ib].energy();
00070 }
00071
00072 sort(theBasicClusters_.begin(), theBasicClusters_.end(), SuperClusterHelper::sortClusters);
00073
00074 theBasicClusters_.insert(theBasicClusters_.begin(), seedCluster_);
00075
00076
00077 const std::vector<reco::CaloCluster>& esClusters(electron->preshowerClusters());
00078 nESClusters_ = esClusters.size();
00079 eESClusters_ = 0. ;
00080 for (unsigned ib = 0 ; ib < nESClusters_ ; ++ ib) {
00081 theESClusters_.push_back(&esClusters[ib]);
00082 eESClusters_ += esClusters[ib].energy();
00083 }
00084
00085 sort(theESClusters_.begin(), theESClusters_.end(), SuperClusterHelper::sortClusters);
00086
00087
00088
00089
00090
00091
00092
00093 topology_ = topo;
00094 geometry_ = geom;
00095 barrel_ = electron->isEB();
00096 covComputed_ = false;
00097 localCoordinatesComputed_ = false;
00098 }
00099
00100 void SuperClusterHelper::computeLocalCovariances() {
00101 if (!covComputed_) {
00102 vCov_ = EcalClusterTools::localCovariances(*seedCluster_, rechits_, topology_, 4.7);
00103 covComputed_ = true;
00104
00105 spp_ = 0;
00106 if (!isnan(vCov_[2])) spp_ = sqrt (vCov_[2]);
00107
00108 if (theElectron_->sigmaIetaIeta()*spp_ > 0) {
00109 sep_ = vCov_[1] / (theElectron_->sigmaIetaIeta() * spp_);
00110 } else if (vCov_[1] > 0) {
00111 sep_ = 1.0;
00112 } else {
00113 sep_ = -1.0;
00114 }
00115 }
00116 }
00117
00118 float SuperClusterHelper::spp() {
00119 computeLocalCovariances();
00120 return spp_;
00121 }
00122
00123 float SuperClusterHelper::sep() {
00124 computeLocalCovariances();
00125 return sep_;
00126 }
00127
00128 void SuperClusterHelper::localCoordinates() {
00129 if (localCoordinatesComputed_) return;
00130
00131 if (barrel_) {
00132 local_.localCoordsEB(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_);
00133 } else {
00134 local_.localCoordsEE(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_);
00135 }
00136 localCoordinatesComputed_ = true;
00137 }
00138
00139
00140 float SuperClusterHelper::subClusterEnergy(unsigned i) const {
00141 return (nBasicClusters_ > i) ? theBasicClusters_[i]->energy() : 0.;
00142 }
00143
00144 float SuperClusterHelper::subClusterEta(unsigned i) const {
00145 return (nBasicClusters_ > i) ? theBasicClusters_[i]->eta() : 999.;
00146 }
00147
00148 float SuperClusterHelper::subClusterPhi(unsigned i) const {
00149 return (nBasicClusters_ > i) ? theBasicClusters_[i]->phi() : 999.;
00150 }
00151
00152 float SuperClusterHelper::subClusterEmax(unsigned i) const {
00153 return (nBasicClusters_ > i) ? EcalClusterTools::eMax(*theBasicClusters_[i], rechits_) : 0.;
00154 }
00155
00156 float SuperClusterHelper::subClusterE3x3(unsigned i) const {
00157 return (nBasicClusters_ > i) ? EcalClusterTools::e3x3(*theBasicClusters_[i], rechits_, topology_) : 0.;
00158 }
00159
00160 float SuperClusterHelper::esClusterEnergy(unsigned i) const {
00161 return (nESClusters_ > i) ? theESClusters_[i]->energy() : 0. ;
00162 }
00163
00164 float SuperClusterHelper::esClusterEta(unsigned i) const {
00165 return (nESClusters_ > i) ? theESClusters_[i]->eta() : 999. ;
00166 }
00167
00168 float SuperClusterHelper::esClusterPhi(unsigned i) const {
00169 return (nESClusters_ > i) ? theESClusters_[i]->phi() : 999. ;
00170 }