Go to the documentation of this file.00001 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterPUCleaningTools.h"
00002
00003 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00004 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00005 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00006 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00007
00008 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00009
00010 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
00011
00012 #include "RecoEcal/EgammaCoreTools/interface/SuperClusterShapeAlgo.h"
00013
00014 EcalClusterPUCleaningTools::EcalClusterPUCleaningTools( const edm::Event &ev, const edm::EventSetup &es, edm::InputTag redEBRecHits, edm::InputTag redEERecHits )
00015 {
00016 getGeometry( es );
00017 getEBRecHits( ev, redEBRecHits );
00018 getEERecHits( ev, redEERecHits );
00019 }
00020
00021
00022
00023 EcalClusterPUCleaningTools::~EcalClusterPUCleaningTools()
00024 {
00025 }
00026
00027
00028 void EcalClusterPUCleaningTools::getGeometry( const edm::EventSetup &es )
00029 {
00030 edm::ESHandle<CaloGeometry> pGeometry;
00031 es.get<CaloGeometryRecord>().get(pGeometry);
00032 geometry_ = pGeometry.product();
00033 }
00034
00035 void EcalClusterPUCleaningTools::getEBRecHits( const edm::Event &ev, edm::InputTag redEBRecHits )
00036 {
00037 edm::Handle< EcalRecHitCollection > pEBRecHits;
00038 ev.getByLabel( redEBRecHits, pEBRecHits );
00039 ebRecHits_ = pEBRecHits.product();
00040 }
00041
00042
00043
00044 void EcalClusterPUCleaningTools::getEERecHits( const edm::Event &ev, edm::InputTag redEERecHits )
00045 {
00046 edm::Handle< EcalRecHitCollection > pEERecHits;
00047 ev.getByLabel( redEERecHits, pEERecHits );
00048 eeRecHits_ = pEERecHits.product();
00049 }
00050
00051
00052 reco::SuperCluster EcalClusterPUCleaningTools::CleanedSuperCluster(float xi, const reco::SuperCluster &scluster, const edm::Event &ev ){
00053
00054
00055
00056
00057 reco::CaloClusterPtr seed = scluster.seed();
00058
00059 float seedBCEnergy = (scluster.seed())->energy();
00060 float eSeed = 0.35;
00061 int numBcRemoved = 0;
00062
00063 double ClusterE = 0;
00064
00065 double posX=0;
00066 double posY=0;
00067 double posZ=0;
00068
00069 reco::CaloClusterPtrVector thissc;
00070
00071
00072 for(reco::CaloCluster_iterator bcIt = scluster.clustersBegin(); bcIt!=scluster.clustersEnd(); bcIt++)
00073 {
00074
00075
00076 if( (*bcIt)->energy() > sqrt( eSeed*eSeed + xi*xi*seedBCEnergy*seedBCEnergy/cosh((*bcIt)->eta())/cosh((*bcIt)->eta()) ) )
00077 {
00078 ;
00079 }
00080 else{
00081 numBcRemoved++;
00082 continue;
00083 }
00084
00085
00086 thissc.push_back( (*bcIt) );
00087
00088 ClusterE += (*bcIt)->energy();
00089 posX += (*bcIt)->energy() * (*bcIt)->position().X();
00090 posY += (*bcIt)->energy() * (*bcIt)->position().Y();
00091 posZ += (*bcIt)->energy() * (*bcIt)->position().Z();
00092
00093 }
00094
00095 posX /= ClusterE;
00096 posY /= ClusterE;
00097 posZ /= ClusterE;
00098
00099
00100 double Epreshower=scluster.preshowerEnergy();
00101 double phiWidth=0.;
00102 double etaWidth=0.;
00103 reco::SuperCluster suCltmp(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
00104
00105
00106
00107 const CaloSubdetectorGeometry *geometry_p=0;
00108 if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalBarrel){
00109 geometry_p = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
00110 SuperClusterShapeAlgo SCShape( ebRecHits_ , geometry_p);
00111 SCShape.Calculate_Covariances( suCltmp );
00112 phiWidth= SCShape.phiWidth();
00113 etaWidth= SCShape.etaWidth();
00114 }
00115 else if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalEndcap){
00116 geometry_p = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
00117 SuperClusterShapeAlgo SCShape( eeRecHits_ , geometry_p);
00118 SCShape.Calculate_Covariances( suCltmp );
00119 phiWidth= SCShape.phiWidth();
00120 etaWidth= SCShape.etaWidth();
00121 }
00122 else {
00123 std::cout << "The seed crystal of this SC is neither in EB nor in EE. This is a problem. Bailing out " << std::endl;
00124 assert(-1);
00125 }
00126
00127
00128 return reco::SuperCluster(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
00129
00130 }