00001 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00002 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
00003
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005
00006 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00007 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00008
00009 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00010 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00012 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00013
00014 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, edm::InputTag redEBRecHits, edm::InputTag redEERecHits )
00015 {
00016 getGeometry( es );
00017 getTopology( es );
00018 getEBRecHits( ev, redEBRecHits );
00019 getEERecHits( ev, redEERecHits );
00020 }
00021
00022
00023
00024 EcalClusterLazyTools::~EcalClusterLazyTools()
00025 {
00026 }
00027
00028
00029
00030 void EcalClusterLazyTools::getGeometry( const edm::EventSetup &es )
00031 {
00032 edm::ESHandle<CaloGeometry> pGeometry;
00033 es.get<CaloGeometryRecord>().get(pGeometry);
00034 geometry_ = pGeometry.product();
00035 }
00036
00037
00038
00039 void EcalClusterLazyTools::getTopology( const edm::EventSetup &es )
00040 {
00041 edm::ESHandle<CaloTopology> pTopology;
00042 es.get<CaloTopologyRecord>().get(pTopology);
00043 topology_ = pTopology.product();
00044 }
00045
00046
00047
00048 void EcalClusterLazyTools::getEBRecHits( const edm::Event &ev, edm::InputTag redEBRecHits )
00049 {
00050 edm::Handle< EcalRecHitCollection > pEBRecHits;
00051 ev.getByLabel( redEBRecHits, pEBRecHits );
00052 ebRecHits_ = pEBRecHits.product();
00053 }
00054
00055
00056
00057 void EcalClusterLazyTools::getEERecHits( const edm::Event &ev, edm::InputTag redEERecHits )
00058 {
00059 edm::Handle< EcalRecHitCollection > pEERecHits;
00060 ev.getByLabel( redEERecHits, pEERecHits );
00061 eeRecHits_ = pEERecHits.product();
00062 }
00063
00064
00065
00066 const EcalRecHitCollection * EcalClusterLazyTools::getEcalRecHitCollection( const reco::BasicCluster &cluster )
00067 {
00068 if ( cluster.size() == 0 ) {
00069 throw cms::Exception("InvalidCluster") << "The cluster has no crystals!";
00070 }
00071 DetId id = cluster.getHitsByDetId()[0];
00072 const EcalRecHitCollection *recHits = 0;
00073 if ( id.subdetId() == EcalBarrel ) {
00074 recHits = ebRecHits_;
00075 } else if ( id.subdetId() == EcalEndcap ) {
00076 recHits = eeRecHits_;
00077 } else {
00078 throw cms::Exception("InvalidSubdetector") << "The subdetId() " << id.subdetId() << " does not correspond to EcalBarrel neither EcalEndcap";
00079 }
00080 return recHits;
00081 }
00082
00083
00084
00085 float EcalClusterLazyTools::e1x3( const reco::BasicCluster &cluster )
00086 {
00087 return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
00088 }
00089
00090
00091 float EcalClusterLazyTools::e3x1( const reco::BasicCluster &cluster )
00092 {
00093 return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
00094 }
00095
00096
00097 float EcalClusterLazyTools::e1x5( const reco::BasicCluster &cluster )
00098 {
00099 return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109 float EcalClusterLazyTools::e2x2( const reco::BasicCluster &cluster )
00110 {
00111 return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
00112 }
00113
00114
00115 float EcalClusterLazyTools::e3x2( const reco::BasicCluster &cluster )
00116 {
00117 return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
00118 }
00119
00120
00121 float EcalClusterLazyTools::e3x3( const reco::BasicCluster &cluster )
00122 {
00123 return EcalClusterTools::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
00124 }
00125
00126
00127 float EcalClusterLazyTools::e4x4( const reco::BasicCluster &cluster )
00128 {
00129 return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
00130 }
00131
00132
00133 float EcalClusterLazyTools::e5x5( const reco::BasicCluster &cluster )
00134 {
00135 return EcalClusterTools::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
00136 }
00137
00138
00139 float EcalClusterLazyTools::e2x5Right( const reco::BasicCluster &cluster )
00140 {
00141 return EcalClusterTools::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_ );
00142 }
00143
00144
00145 float EcalClusterLazyTools::e2x5Left( const reco::BasicCluster &cluster )
00146 {
00147 return EcalClusterTools::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
00148 }
00149
00150
00151 float EcalClusterLazyTools::e2x5Top( const reco::BasicCluster &cluster )
00152 {
00153 return EcalClusterTools::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
00154 }
00155
00156
00157 float EcalClusterLazyTools::e2x5Bottom( const reco::BasicCluster &cluster )
00158 {
00159 return EcalClusterTools::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_ );
00160 }
00161
00162
00163 float EcalClusterLazyTools::e2x5Max( const reco::BasicCluster &cluster )
00164 {
00165 return EcalClusterTools::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
00166 }
00167
00168
00169 float EcalClusterLazyTools::eLeft( const reco::BasicCluster &cluster )
00170 {
00171 return EcalClusterTools::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
00172 }
00173
00174
00175 float EcalClusterLazyTools::eRight( const reco::BasicCluster &cluster )
00176 {
00177 return EcalClusterTools::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
00178 }
00179
00180
00181 float EcalClusterLazyTools::eTop( const reco::BasicCluster &cluster )
00182 {
00183 return EcalClusterTools::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
00184 }
00185
00186
00187 float EcalClusterLazyTools::eBottom( const reco::BasicCluster &cluster )
00188 {
00189 return EcalClusterTools::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
00190 }
00191
00192
00193 float EcalClusterLazyTools::eMax( const reco::BasicCluster &cluster )
00194 {
00195 return EcalClusterTools::eMax( cluster, getEcalRecHitCollection(cluster) );
00196 }
00197
00198
00199 float EcalClusterLazyTools::e2nd( const reco::BasicCluster &cluster )
00200 {
00201 return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster) );
00202 }
00203
00204
00205 std::pair<DetId, float> EcalClusterLazyTools::getMaximum( const reco::BasicCluster &cluster )
00206 {
00207 return EcalClusterTools::getMaximum( cluster, getEcalRecHitCollection(cluster) );
00208 }
00209
00210
00211 std::vector<float> EcalClusterLazyTools::energyBasketFractionEta( const reco::BasicCluster &cluster )
00212 {
00213 return EcalClusterTools::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster) );
00214 }
00215
00216
00217 std::vector<float> EcalClusterLazyTools::energyBasketFractionPhi( const reco::BasicCluster &cluster )
00218 {
00219 return EcalClusterTools::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster) );
00220 }
00221
00222
00223 std::vector<float> EcalClusterLazyTools::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
00224 {
00225 return EcalClusterTools::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
00226 }
00227
00228
00229 std::vector<float> EcalClusterLazyTools::covariances(const reco::BasicCluster &cluster, float w0 )
00230 {
00231 return EcalClusterTools::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0 );
00232 }
00233
00234 std::vector<float> EcalClusterLazyTools::localCovariances(const reco::BasicCluster &cluster, float w0 )
00235 {
00236 return EcalClusterTools::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
00237 }
00238 double EcalClusterLazyTools::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
00239 {
00240 return EcalClusterTools::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
00241 }
00242
00243
00244 double EcalClusterLazyTools::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
00245 {
00246 return EcalClusterTools::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
00247 }
00248
00249 std::vector<DetId> EcalClusterLazyTools::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
00250 {
00251 return EcalClusterTools::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
00252 }
00253
00254 float EcalClusterLazyTools::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
00255 {
00256 return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
00257 }