00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002
00003 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00004 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.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 #include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h"
00014 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00015 #include "RecoCaloTools/Navigation/interface/EcalPreshowerNavigator.h"
00016
00017 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00018 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00019 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
00020
00021 #include "CommonTools/Utils/interface/StringToEnumValue.h"
00022 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00023 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00024
00025
00026 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits)
00027 {
00028 getGeometry( es );
00029 getTopology( es );
00030 getEBRecHits( ev, redEBRecHits );
00031 getEERecHits( ev, redEERecHits );
00032 getIntercalibConstants( es );
00033 getADCToGeV ( es );
00034 getLaserDbService ( es );
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 }
00060
00061 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config)
00062 {
00063 getGeometry( es );
00064 getTopology( es );
00065 getEBRecHits( ev, redEBRecHits );
00066 getEERecHits( ev, redEERecHits );
00067 getIntercalibConstants( es );
00068 getADCToGeV ( es );
00069 getLaserDbService ( es );
00070
00071
00072
00073
00074 }
00075
00076 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits, const edm::InputTag& redESRecHits)
00077 {
00078 getGeometry( es );
00079 getTopology( es );
00080 getEBRecHits( ev, redEBRecHits );
00081 getEERecHits( ev, redEERecHits );
00082 getESRecHits( ev, redESRecHits );
00083 getIntercalibConstants( es );
00084 getADCToGeV ( es );
00085 getLaserDbService ( es );
00086
00087 }
00088
00089 EcalClusterLazyTools::~EcalClusterLazyTools()
00090 {
00091 }
00092
00093
00094
00095 void EcalClusterLazyTools::getGeometry( const edm::EventSetup &es )
00096 {
00097 edm::ESHandle<CaloGeometry> pGeometry;
00098 es.get<CaloGeometryRecord>().get(pGeometry);
00099 geometry_ = pGeometry.product();
00100 }
00101
00102
00103
00104 void EcalClusterLazyTools::getTopology( const edm::EventSetup &es )
00105 {
00106 edm::ESHandle<CaloTopology> pTopology;
00107 es.get<CaloTopologyRecord>().get(pTopology);
00108 topology_ = pTopology.product();
00109 }
00110
00111
00112
00113 void EcalClusterLazyTools::getEBRecHits( const edm::Event &ev, const edm::InputTag& redEBRecHits )
00114 {
00115 edm::Handle< EcalRecHitCollection > pEBRecHits;
00116 ev.getByLabel( redEBRecHits, pEBRecHits );
00117 ebRecHits_ = pEBRecHits.product();
00118 }
00119
00120
00121
00122 void EcalClusterLazyTools::getEERecHits( const edm::Event &ev, const edm::InputTag& redEERecHits )
00123 {
00124 edm::Handle< EcalRecHitCollection > pEERecHits;
00125 ev.getByLabel( redEERecHits, pEERecHits );
00126 eeRecHits_ = pEERecHits.product();
00127 }
00128
00129
00130
00131 void EcalClusterLazyTools::getESRecHits( const edm::Event &ev, const edm::InputTag& redESRecHits )
00132 {
00133 edm::Handle< EcalRecHitCollection > pESRecHits;
00134 ev.getByLabel( redESRecHits, pESRecHits );
00135 esRecHits_ = pESRecHits.product();
00136
00137
00138 rechits_map_.clear();
00139 if (pESRecHits.isValid()) {
00140 EcalRecHitCollection::const_iterator it;
00141 for (it = pESRecHits->begin(); it != pESRecHits->end(); ++it) {
00142
00143 if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue;
00144
00145 rechits_map_.insert(std::make_pair(it->id(), *it));
00146 }
00147 }
00148
00149 }
00150
00151
00152
00153 void EcalClusterLazyTools::getIntercalibConstants( const edm::EventSetup &es )
00154 {
00155
00156 es.get<EcalIntercalibConstantsRcd>().get(ical);
00157 icalMap = ical->getMap();
00158 }
00159
00160
00161
00162 void EcalClusterLazyTools::getADCToGeV( const edm::EventSetup &es )
00163 {
00164
00165 es.get<EcalADCToGeVConstantRcd>().get(agc);
00166 }
00167
00168
00169
00170 void EcalClusterLazyTools::getLaserDbService ( const edm::EventSetup &es ){
00171
00172 es.get<EcalLaserDbRecord>().get(laser);
00173 }
00174
00175
00176 const EcalRecHitCollection * EcalClusterLazyTools::getEcalRecHitCollection( const reco::BasicCluster &cluster )
00177 {
00178 if ( cluster.size() == 0 ) {
00179 throw cms::Exception("InvalidCluster") << "The cluster has no crystals!";
00180 }
00181 DetId id = (cluster.hitsAndFractions()[0]).first;
00182 const EcalRecHitCollection *recHits = 0;
00183 if ( id.subdetId() == EcalBarrel ) {
00184 recHits = ebRecHits_;
00185 } else if ( id.subdetId() == EcalEndcap ) {
00186 recHits = eeRecHits_;
00187 } else {
00188 throw cms::Exception("InvalidSubdetector") << "The subdetId() " << id.subdetId() << " does not correspond to EcalBarrel neither EcalEndcap";
00189 }
00190 return recHits;
00191 }
00192
00193
00194
00195 float EcalClusterLazyTools::e1x3( const reco::BasicCluster &cluster )
00196 {
00197 return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
00198 }
00199
00200
00201 float EcalClusterLazyTools::e1x3( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00202 {
00203 return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00204 }
00205
00206
00207
00208 float EcalClusterLazyTools::e3x1( const reco::BasicCluster &cluster )
00209 {
00210 return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
00211 }
00212
00213 float EcalClusterLazyTools::e3x1( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00214 {
00215 return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00216 }
00217
00218
00219 float EcalClusterLazyTools::e1x5( const reco::BasicCluster &cluster )
00220 {
00221 return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
00222 }
00223
00224 float EcalClusterLazyTools::e1x5( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00225 {
00226 return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00227 }
00228
00229
00230
00231 float EcalClusterLazyTools::e5x1( const reco::BasicCluster &cluster )
00232 {
00233 return EcalClusterTools::e5x1( cluster, getEcalRecHitCollection(cluster), topology_ );
00234 }
00235
00236 float EcalClusterLazyTools::e5x1( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00237 {
00238 return EcalClusterTools::e5x1( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00239 }
00240
00241
00242 float EcalClusterLazyTools::e2x2( const reco::BasicCluster &cluster )
00243 {
00244 return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
00245 }
00246
00247 float EcalClusterLazyTools::e2x2( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00248 {
00249 return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00250 }
00251
00252
00253 float EcalClusterLazyTools::e3x2( const reco::BasicCluster &cluster )
00254 {
00255 return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
00256 }
00257
00258 float EcalClusterLazyTools::e3x2( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00259 {
00260 return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00261 }
00262
00263
00264 float EcalClusterLazyTools::e3x3( const reco::BasicCluster &cluster )
00265 {
00266 return EcalClusterTools::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
00267 }
00268
00269 float EcalClusterLazyTools::e3x3( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00270 {
00271 return EcalClusterTools::e3x3( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00272 }
00273
00274
00275 float EcalClusterLazyTools::e4x4( const reco::BasicCluster &cluster )
00276 {
00277 return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
00278 }
00279
00280 float EcalClusterLazyTools::e4x4( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00281 {
00282 return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00283 }
00284
00285
00286 float EcalClusterLazyTools::e5x5( const reco::BasicCluster &cluster )
00287 {
00288 return EcalClusterTools::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
00289 }
00290
00291 float EcalClusterLazyTools::e5x5( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00292 {
00293 return EcalClusterTools::e5x5( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00294 }
00295
00296
00297 float EcalClusterLazyTools::e2x5Right( const reco::BasicCluster &cluster )
00298 {
00299 return EcalClusterTools::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_ );
00300 }
00301
00302 float EcalClusterLazyTools::e2x5Right( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00303 {
00304 return EcalClusterTools::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00305 }
00306
00307
00308 float EcalClusterLazyTools::e2x5Left( const reco::BasicCluster &cluster )
00309 {
00310 return EcalClusterTools::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
00311 }
00312
00313 float EcalClusterLazyTools::e2x5Left( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00314 {
00315 return EcalClusterTools::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00316 }
00317
00318
00319 float EcalClusterLazyTools::e2x5Top( const reco::BasicCluster &cluster )
00320 {
00321 return EcalClusterTools::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
00322 }
00323
00324 float EcalClusterLazyTools::e2x5Top( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00325 {
00326 return EcalClusterTools::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00327 }
00328
00329
00330 float EcalClusterLazyTools::e2x5Bottom( const reco::BasicCluster &cluster )
00331 {
00332 return EcalClusterTools::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_ );
00333 }
00334
00335 float EcalClusterLazyTools::e2x5Bottom( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00336 {
00337 return EcalClusterTools::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00338 }
00339
00340
00341 float EcalClusterLazyTools::e2x5Max( const reco::BasicCluster &cluster )
00342 {
00343 return EcalClusterTools::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
00344 }
00345
00346 float EcalClusterLazyTools::e2x5Max( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00347 {
00348 return EcalClusterTools::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00349 }
00350
00351
00352 float EcalClusterLazyTools::eLeft( const reco::BasicCluster &cluster )
00353 {
00354 return EcalClusterTools::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
00355 }
00356
00357 float EcalClusterLazyTools::eLeft( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00358 {
00359 return EcalClusterTools::eLeft( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00360 }
00361
00362
00363 float EcalClusterLazyTools::eRight( const reco::BasicCluster &cluster )
00364 {
00365 return EcalClusterTools::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
00366 }
00367
00368 float EcalClusterLazyTools::eRight( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00369 {
00370 return EcalClusterTools::eRight( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00371 }
00372
00373
00374 float EcalClusterLazyTools::eTop( const reco::BasicCluster &cluster )
00375 {
00376 return EcalClusterTools::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
00377 }
00378
00379 float EcalClusterLazyTools::eTop( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00380 {
00381 return EcalClusterTools::eTop( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00382 }
00383
00384
00385 float EcalClusterLazyTools::eBottom( const reco::BasicCluster &cluster )
00386 {
00387 return EcalClusterTools::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
00388 }
00389
00390 float EcalClusterLazyTools::eBottom( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00391 {
00392 return EcalClusterTools::eBottom( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
00393 }
00394
00395
00396 float EcalClusterLazyTools::eMax( const reco::BasicCluster &cluster )
00397 {
00398 return EcalClusterTools::eMax( cluster, getEcalRecHitCollection(cluster) );
00399 }
00400
00401 float EcalClusterLazyTools::eMax( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00402 {
00403 return EcalClusterTools::eMax( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
00404 }
00405
00406
00407 float EcalClusterLazyTools::e2nd( const reco::BasicCluster &cluster )
00408 {
00409 return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster) );
00410 }
00411
00412 float EcalClusterLazyTools::e2nd( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00413 {
00414 return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
00415 }
00416
00417 std::pair<DetId, float> EcalClusterLazyTools::getMaximum( const reco::BasicCluster &cluster )
00418 {
00419 return EcalClusterTools::getMaximum( cluster, getEcalRecHitCollection(cluster) );
00420 }
00421
00422 std::pair<DetId, float> EcalClusterLazyTools::getMaximum( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00423 {
00424 return EcalClusterTools::getMaximum( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
00425 }
00426
00427
00428 std::vector<float> EcalClusterLazyTools::energyBasketFractionEta( const reco::BasicCluster &cluster )
00429 {
00430 return EcalClusterTools::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster) );
00431 }
00432
00433 std::vector<float> EcalClusterLazyTools::energyBasketFractionEta( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00434 {
00435 return EcalClusterTools::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
00436 }
00437
00438
00439 std::vector<float> EcalClusterLazyTools::energyBasketFractionPhi( const reco::BasicCluster &cluster )
00440 {
00441 return EcalClusterTools::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster) );
00442 }
00443
00444 std::vector<float> EcalClusterLazyTools::energyBasketFractionPhi( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00445 {
00446 return EcalClusterTools::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
00447 }
00448
00449
00450 std::vector<float> EcalClusterLazyTools::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
00451 {
00452 return EcalClusterTools::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
00453 }
00454
00455
00456
00457
00458
00459
00460
00461 std::vector<float> EcalClusterLazyTools::covariances(const reco::BasicCluster &cluster, float w0 )
00462 {
00463 return EcalClusterTools::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0 );
00464 }
00465
00466 std::vector<float> EcalClusterLazyTools::covariances(const reco::BasicCluster &cluster,const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
00467 {
00468 return EcalClusterTools::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, flagsexcl, severitiesexcl, sevLv, w0 );
00469 }
00470
00471 std::vector<float> EcalClusterLazyTools::localCovariances(const reco::BasicCluster &cluster, float w0 )
00472 {
00473 return EcalClusterTools::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
00474 }
00475
00476 std::vector<float> EcalClusterLazyTools::localCovariances(const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
00477 {
00478 return EcalClusterTools::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv, w0 );
00479 }
00480
00481 std::vector<float> EcalClusterLazyTools::scLocalCovariances(const reco::SuperCluster &cluster, float w0 )
00482 {
00483 return EcalClusterTools::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
00484 }
00485
00486 std::vector<float> EcalClusterLazyTools::scLocalCovariances(const reco::SuperCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
00487 {
00488 return EcalClusterTools::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv, w0 );
00489 }
00490
00491 double EcalClusterLazyTools::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
00492 {
00493 return EcalClusterTools::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
00494 }
00495
00496
00497 double EcalClusterLazyTools::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
00498 {
00499 return EcalClusterTools::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
00500 }
00501
00502 std::vector<DetId> EcalClusterLazyTools::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
00503 {
00504 return EcalClusterTools::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
00505 }
00506
00507 float EcalClusterLazyTools::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
00508 {
00509 return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
00510 }
00511
00512 float EcalClusterLazyTools::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax,const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
00513 {
00514 return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax, flagsexcl, severitiesexcl, sevLv );
00515 }
00516
00517
00518
00519 float EcalClusterLazyTools::BasicClusterSeedTime(const reco::BasicCluster &cluster)
00520 {
00521
00522 const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
00523
00524 DetId id = cluster.seed();
00525 EcalRecHitCollection::const_iterator theSeedHit = recHits->find (id);
00526
00527
00528
00529
00530
00531 return (*theSeedHit).time();
00532 }
00533
00534
00535
00536 float EcalClusterLazyTools::BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev)
00537 {
00538
00539 std::vector<std::pair<DetId, float> > clusterComponents = (cluster).hitsAndFractions() ;
00540
00541
00542 const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
00543
00544
00545
00546 float weightedTsum = 0;
00547 float sumOfWeights = 0;
00548
00549 for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterComponents.begin(); detitr != clusterComponents.end(); detitr++ )
00550 {
00551
00552 EcalRecHitCollection::const_iterator oneHit = recHits->find( (detitr -> first) ) ;
00553
00554
00555
00556 float lasercalib = 1.;
00557 lasercalib = laser->getLaserCorrection( detitr->first, ev.time());
00558
00559 EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detitr->first);
00560 EcalIntercalibConstant icalconst = 1.;
00561 if( icalit!=icalMap.end() ) {
00562 icalconst = (*icalit);
00563
00564 } else {
00565 edm::LogError("EcalClusterLazyTools") << "No intercalib const found for xtal " << (detitr->first).rawId() << "bailing out";
00566 assert(0);
00567 }
00568
00569 float adcToGeV = 1.;
00570 if ( (detitr -> first).subdetId() == EcalBarrel ) adcToGeV = float(agc->getEBValue());
00571 else if ( (detitr -> first).subdetId() == EcalEndcap ) adcToGeV = float(agc->getEEValue());
00572 float adc = 2.;
00573 if (icalconst>0 && lasercalib>0 && adcToGeV>0) adc= (*oneHit).energy()/(icalconst*lasercalib*adcToGeV);
00574
00575
00576 if( (detitr -> first).subdetId() == EcalBarrel && adc< (1.1*20) ) continue;
00577 if( (detitr -> first).subdetId() == EcalEndcap && adc< (2.2*20) ) continue;
00578
00579
00580 if(! (*oneHit).isTimeErrorValid()) continue;
00581
00582 float timeError = (*oneHit).timeError();
00583
00584
00585 if (timeError>0.6) timeError = sqrt( timeError*timeError - 0.6*0.6 + 0.15*0.15);
00586 else timeError = sqrt( timeError*timeError + 0.15*0.15);
00587
00588
00589 weightedTsum += (*oneHit).time() / (timeError*timeError);
00590 sumOfWeights += 1. / (timeError*timeError);
00591
00592 }
00593
00594
00595 if ( sumOfWeights ==0 ) return -999;
00596 else return ( weightedTsum / sumOfWeights);
00597
00598 }
00599
00600
00601
00602 float EcalClusterLazyTools::SuperClusterSeedTime(const reco::SuperCluster &cluster){
00603
00604 return BasicClusterSeedTime ( (*cluster.seed()) );
00605
00606 }
00607
00608
00609
00610 float EcalClusterLazyTools::SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev){
00611
00612 return BasicClusterTime ( (*cluster.seed()) , ev);
00613
00614 }
00615
00616
00617
00618 float EcalClusterLazyTools::eseffsirir(const reco::SuperCluster &cluster)
00619 {
00620 if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
00621
00622 const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00623 CaloSubdetectorTopology *topology_p = 0;
00624 if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
00625
00626 std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
00627 std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
00628 float phoESShapeIXIX = getESShape(phoESHitsIXIX);
00629 float phoESShapeIYIY = getESShape(phoESHitsIYIY);
00630
00631 return sqrt(phoESShapeIXIX*phoESShapeIXIX + phoESShapeIYIY*phoESShapeIYIY);
00632 }
00633
00634
00635 float EcalClusterLazyTools::eseffsixix(const reco::SuperCluster &cluster)
00636 {
00637 if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
00638
00639 const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00640 CaloSubdetectorTopology *topology_p = 0;
00641 if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
00642
00643 std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
00644 float phoESShapeIXIX = getESShape(phoESHitsIXIX);
00645
00646 return phoESShapeIXIX;
00647 }
00648
00649
00650 float EcalClusterLazyTools::eseffsiyiy(const reco::SuperCluster &cluster)
00651 {
00652 if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
00653
00654 const CaloSubdetectorGeometry *geometryES = geometry_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00655 CaloSubdetectorTopology *topology_p = 0;
00656 if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
00657
00658 std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
00659 float phoESShapeIYIY = getESShape(phoESHitsIYIY);
00660
00661 return phoESShapeIYIY;
00662 }
00663
00664
00665 std::vector<float> EcalClusterLazyTools::getESHits(double X, double Y, double Z, std::map<DetId, EcalRecHit> rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row, int plane)
00666 {
00667 std::vector<float> esHits;
00668
00669 const GlobalPoint point(X,Y,Z);
00670
00671 const CaloSubdetectorGeometry *geometry_p ;
00672 geometry_p = geometry->getSubdetectorGeometry (DetId::Ecal,EcalPreshower) ;
00673
00674 DetId esId = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, plane);
00675 ESDetId esDetId = (esId == DetId(0)) ? ESDetId(0) : ESDetId(esId);
00676
00677 std::map<DetId, EcalRecHit>::iterator it;
00678 ESDetId next;
00679 ESDetId strip;
00680 strip = esDetId;
00681
00682 EcalPreshowerNavigator theESNav(strip, topology_p);
00683 theESNav.setHome(strip);
00684
00685 if (row == 1) {
00686 if (plane==1 && strip != ESDetId(0)) strip = theESNav.north();
00687 if (plane==2 && strip != ESDetId(0)) strip = theESNav.east();
00688 } else if (row == -1) {
00689 if (plane==1 && strip != ESDetId(0)) strip = theESNav.south();
00690 if (plane==2 && strip != ESDetId(0)) strip = theESNav.west();
00691 }
00692
00693
00694 if (strip == ESDetId(0)) {
00695 for (int i=0; i<31; ++i) esHits.push_back(0);
00696 } else {
00697 it = rechits_map.find(strip);
00698 if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
00699 else esHits.push_back(0);
00700
00701
00702
00703 if (plane==1) {
00704
00705 for (int i=0; i<15; ++i) {
00706 next = theESNav.east();
00707 if (next != ESDetId(0)) {
00708 it = rechits_map.find(next);
00709 if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
00710 else esHits.push_back(0);
00711
00712 } else {
00713 for (int j=i; j<15; j++) esHits.push_back(0);
00714 break;
00715
00716 }
00717 }
00718
00719
00720 theESNav.setHome(strip);
00721 theESNav.home();
00722 for (int i=0; i<15; ++i) {
00723 next = theESNav.west();
00724 if (next != ESDetId(0)) {
00725 it = rechits_map.find(next);
00726 if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
00727 else esHits.push_back(0);
00728
00729 } else {
00730 for (int j=i; j<15; j++) esHits.push_back(0);
00731 break;
00732
00733 }
00734 }
00735 }
00736
00737
00738 if (plane==2) {
00739
00740 for (int i=0; i<15; ++i) {
00741 next = theESNav.north();
00742 if (next != ESDetId(0)) {
00743 it = rechits_map.find(next);
00744 if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
00745 else esHits.push_back(0);
00746
00747 } else {
00748 for (int j=i; j<15; j++) esHits.push_back(0);
00749 break;
00750
00751 }
00752 }
00753
00754
00755 theESNav.setHome(strip);
00756 theESNav.home();
00757 for (int i=0; i<15; ++i) {
00758 next = theESNav.south();
00759 if (next != ESDetId(0)) {
00760 it = rechits_map.find(next);
00761 if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
00762 else esHits.push_back(0);
00763
00764 } else {
00765 for (int j=i; j<15; j++) esHits.push_back(0);
00766 break;
00767
00768 }
00769 }
00770 }
00771 }
00772
00773 return esHits;
00774 }
00775
00776
00777
00778 float EcalClusterLazyTools::getESShape(const std::vector<float>& ESHits0)
00779 {
00780 const int nBIN = 21;
00781 float esRH[nBIN];
00782 for (int idx=0; idx<nBIN; idx++) {
00783 esRH[idx] = 0.;
00784 }
00785
00786 for(int ibin=0; ibin<((nBIN+1)/2); ibin++) {
00787 if (ibin==0) {
00788 esRH[(nBIN-1)/2] = ESHits0[ibin];
00789 } else {
00790 esRH[(nBIN-1)/2+ibin] = ESHits0[ibin];
00791 esRH[(nBIN-1)/2-ibin] = ESHits0[ibin+15];
00792 }
00793 }
00794
00795
00796 double EffWidthSigmaISIS = 0.;
00797 double totalEnergyISIS = 0.;
00798 double EffStatsISIS = 0.;
00799 for (int id_X=0; id_X<21; id_X++) {
00800 totalEnergyISIS += esRH[id_X];
00801 EffStatsISIS += esRH[id_X]*(id_X-10)*(id_X-10);
00802 }
00803 EffWidthSigmaISIS = (totalEnergyISIS>0.) ? sqrt(fabs(EffStatsISIS / totalEnergyISIS)) : 0.;
00804
00805 return EffWidthSigmaISIS;
00806 }