From 0353c6cb1a549325292c89f82d680a05a9a775a3 Mon Sep 17 00:00:00 2001 From: Matteo Date: Sun, 16 Feb 2014 00:37:41 +0100 Subject: [PATCH 1/6] updates --- .../interface/EcalClusterLazyTools.h | 338 +++++++++--------- .../src/EcalClusterLazyTools.cc | 139 ++----- .../test/testEcalClusterLazyTools.cc | 195 +++++----- .../interface/EgammaHLTClusterShapeProducer.h | 6 +- .../interface/EgammaHLTR9IDProducer.h | 6 +- .../interface/EgammaHLTR9Producer.h | 4 +- .../src/EgammaHLTClusterShapeProducer.cc | 7 +- .../src/EgammaHLTR9IDProducer.cc | 7 +- .../src/EgammaHLTR9Producer.cc | 8 +- 9 files changed, 322 insertions(+), 388 deletions(-) diff --git a/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h b/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h index bf76be85d2f89..8b1c831e05bff 100644 --- a/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h +++ b/RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h @@ -31,177 +31,175 @@ class CaloGeometry; class CaloSubdetectorTopology; class EcalClusterLazyTools { - public: - EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config ); - EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits); - EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits, const edm::InputTag& redESRecHits); - - ~EcalClusterLazyTools(); - - // various energies in the matrix nxn surrounding the maximum energy crystal of the input cluster - //NOTE (29/10/08): we now use an eta/phi coordinate system rather than phi/eta - //to minmise possible screwups, for now e5x1 isnt defined all the majority of people who call it actually want e1x5 and - //it is thought it is better that their code doesnt compile rather than pick up the wrong function - //therefore in this version and later e1x5 = e5x1 in the old version - //so 1x5 is 1 crystal in eta and 5 crystals in phi - //note e3x2 does not have a definate eta/phi geometry, it takes the maximum 3x2 block containing the - //seed regardless of whether that 3 in eta or phi - float e1x3( const reco::BasicCluster &cluster ); - float e1x3( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e3x1( const reco::BasicCluster &cluster ); - float e3x1( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e1x5( const reco::BasicCluster &cluster ); - float e1x5( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e5x1( const reco::BasicCluster &cluster ); - float e5x1( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e2x2( const reco::BasicCluster &cluster ); - float e2x2( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e3x2( const reco::BasicCluster &cluster ); - float e3x2( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e3x3( const reco::BasicCluster &cluster ); - float e3x3( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e4x4( const reco::BasicCluster &cluster ); - float e4x4( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float e5x5( const reco::BasicCluster &cluster ); - float e5x5( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // energy in the 2x5 strip right of the max crystal (does not contain max crystal) - // 2 crystals wide in eta, 5 wide in phi. - float e2x5Right( const reco::BasicCluster &cluster ); - float e2x5Right( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // energy in the 2x5 strip left of the max crystal (does not contain max crystal) - float e2x5Left( const reco::BasicCluster &cluster ); - float e2x5Left( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // energy in the 5x2 strip above the max crystal (does not contain max crystal) - // 5 crystals wide in eta, 2 wide in phi. - float e2x5Top( const reco::BasicCluster &cluster ); - float e2x5Top( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - // energy in the 5x2 strip below the max crystal (does not contain max crystal) - float e2x5Bottom( const reco::BasicCluster &cluster ); - float e2x5Bottom( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // energy in a 2x5 strip containing the seed (max) crystal. - // 2 crystals wide in eta, 5 wide in phi. - // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center) - float e2x5Max( const reco::BasicCluster &cluster ); - float e2x5Max( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal - float eLeft( const reco::BasicCluster &cluster ); - float eLeft( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float eRight( const reco::BasicCluster &cluster ); - float eRight( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float eTop( const reco::BasicCluster &cluster ); - float eTop( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - float eBottom( const reco::BasicCluster &cluster ); - float eBottom( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // the energy of the most energetic crystal in the cluster - float eMax( const reco::BasicCluster &cluster ); - float eMax( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - // the energy of the second most energetic crystal in the cluster - float e2nd( const reco::BasicCluster &cluster ); - float e2nd( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - // get the DetId and the energy of the maximum energy crystal of the input cluster - std::pair getMaximum( const reco::BasicCluster &cluster ); - std::pair getMaximum( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - std::vector energyBasketFractionEta( const reco::BasicCluster &cluster ); - std::vector energyBasketFractionEta( const reco::BasicCluster &cluster,const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - std::vector energyBasketFractionPhi( const reco::BasicCluster &cluster ); - std::vector energyBasketFractionPhi( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat - std::vector lat( const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7 ); - std::vector lat( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, bool logW = true, float w0 = 4.7 ); - - // return a vector v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi - std::vector covariances(const reco::BasicCluster &cluster, float w0 = 4.7 ); - std::vector covariances(const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7 ); - - // return a vector v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi - //this function calculates differences in eta/phi in units of crystals not global eta/phi - //this is gives better performance in the crack regions of the calorimeter but gives otherwise identical results to covariances function - //this is only defined for the barrel, it returns covariances when the cluster is in the endcap - //Warning: covIEtaIEta has been studied by egamma, but so far covIPhiIPhi hasnt been studied extensively so there could be a bug in - // the covIPhiIEta or covIPhiIPhi calculations. I dont think there is but as it hasnt been heavily used, there might be one - std::vector localCovariances(const reco::BasicCluster &cluster, float w0 = 4.7); - std::vector localCovariances(const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7); - - std::vector scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7); - std::vector scLocalCovariances(const reco::SuperCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7); - - double zernike20( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 ); - double zernike42( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 ); - - // get the detId's of a matrix centered in the maximum energy crystal = (0,0) - // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals - std::vector matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax ); - // get the energy deposited in a matrix centered in the maximum energy crystal = (0,0) - // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals - float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax ); - float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); - - // get time of basic cluster seed crystal - float BasicClusterSeedTime(const reco::BasicCluster &cluster); - // error-weighted average of time from constituents of basic cluster - float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev); - // get BasicClusterSeedTime of the seed basic cluser of the supercluster - float SuperClusterSeedTime(const reco::SuperCluster &cluster); - // get BasicClusterTime of the seed basic cluser of the supercluster - float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev); - - // mapping for preshower rechits - std::map rechits_map_; - // get Preshower hit array - std::vector getESHits(double X, double Y, double Z, const std::map& rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1); - // get Preshower hit shape - float getESShape(const std::vector& ESHits0); - // get Preshower effective sigmaRR - float eseffsirir( const reco::SuperCluster &cluster ); - float eseffsixix( const reco::SuperCluster &cluster ); - float eseffsiyiy( const reco::SuperCluster &cluster ); - -// std::vector flagsexcl_; + public: + EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, edm::EDGetTokenT token1, edm::EDGetTokenT token2); + ~EcalClusterLazyTools(); + + // various energies in the matrix nxn surrounding the maximum energy crystal of the input cluster + //NOTE (29/10/08): we now use an eta/phi coordinate system rather than phi/eta + //to minmise possible screwups, for now e5x1 isnt defined all the majority of people who call it actually want e1x5 and + //it is thought it is better that their code doesnt compile rather than pick up the wrong function + //therefore in this version and later e1x5 = e5x1 in the old version + //so 1x5 is 1 crystal in eta and 5 crystals in phi + //note e3x2 does not have a definate eta/phi geometry, it takes the maximum 3x2 block containing the + //seed regardless of whether that 3 in eta or phi + float e1x3( const reco::BasicCluster &cluster ); + float e1x3( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e3x1( const reco::BasicCluster &cluster ); + float e3x1( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e1x5( const reco::BasicCluster &cluster ); + float e1x5( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e5x1( const reco::BasicCluster &cluster ); + float e5x1( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e2x2( const reco::BasicCluster &cluster ); + float e2x2( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e3x2( const reco::BasicCluster &cluster ); + float e3x2( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e3x3( const reco::BasicCluster &cluster ); + float e3x3( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e4x4( const reco::BasicCluster &cluster ); + float e4x4( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float e5x5( const reco::BasicCluster &cluster ); + float e5x5( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // energy in the 2x5 strip right of the max crystal (does not contain max crystal) + // 2 crystals wide in eta, 5 wide in phi. + float e2x5Right( const reco::BasicCluster &cluster ); + float e2x5Right( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // energy in the 2x5 strip left of the max crystal (does not contain max crystal) + float e2x5Left( const reco::BasicCluster &cluster ); + float e2x5Left( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // energy in the 5x2 strip above the max crystal (does not contain max crystal) + // 5 crystals wide in eta, 2 wide in phi. + float e2x5Top( const reco::BasicCluster &cluster ); + float e2x5Top( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + // energy in the 5x2 strip below the max crystal (does not contain max crystal) + float e2x5Bottom( const reco::BasicCluster &cluster ); + float e2x5Bottom( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // energy in a 2x5 strip containing the seed (max) crystal. + // 2 crystals wide in eta, 5 wide in phi. + // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center) + float e2x5Max( const reco::BasicCluster &cluster ); + float e2x5Max( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal + float eLeft( const reco::BasicCluster &cluster ); + float eLeft( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float eRight( const reco::BasicCluster &cluster ); + float eRight( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float eTop( const reco::BasicCluster &cluster ); + float eTop( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + float eBottom( const reco::BasicCluster &cluster ); + float eBottom( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // the energy of the most energetic crystal in the cluster + float eMax( const reco::BasicCluster &cluster ); + float eMax( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + // the energy of the second most energetic crystal in the cluster + float e2nd( const reco::BasicCluster &cluster ); + float e2nd( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + // get the DetId and the energy of the maximum energy crystal of the input cluster + std::pair getMaximum( const reco::BasicCluster &cluster ); + std::pair getMaximum( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + std::vector energyBasketFractionEta( const reco::BasicCluster &cluster ); + std::vector energyBasketFractionEta( const reco::BasicCluster &cluster,const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + std::vector energyBasketFractionPhi( const reco::BasicCluster &cluster ); + std::vector energyBasketFractionPhi( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat + std::vector lat( const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7 ); + std::vector lat( const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, bool logW = true, float w0 = 4.7 ); + + // return a vector v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi + std::vector covariances(const reco::BasicCluster &cluster, float w0 = 4.7 ); + std::vector covariances(const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7 ); + + // return a vector v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi + //this function calculates differences in eta/phi in units of crystals not global eta/phi + //this is gives better performance in the crack regions of the calorimeter but gives otherwise identical results to covariances function + //this is only defined for the barrel, it returns covariances when the cluster is in the endcap + //Warning: covIEtaIEta has been studied by egamma, but so far covIPhiIPhi hasnt been studied extensively so there could be a bug in + // the covIPhiIEta or covIPhiIPhi calculations. I dont think there is but as it hasnt been heavily used, there might be one + std::vector localCovariances(const reco::BasicCluster &cluster, float w0 = 4.7); + std::vector localCovariances(const reco::BasicCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7); + + std::vector scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7); + std::vector scLocalCovariances(const reco::SuperCluster &cluster, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 = 4.7); + + double zernike20( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 ); + double zernike42( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 ); + + // get the detId's of a matrix centered in the maximum energy crystal = (0,0) + // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals + std::vector matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax ); + // get the energy deposited in a matrix centered in the maximum energy crystal = (0,0) + // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals + float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax ); + float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax, const std::vector& flagsexcl, const std::vector& severitiesexcl, const EcalSeverityLevelAlgo *sevLv ); + + // get time of basic cluster seed crystal + float BasicClusterSeedTime(const reco::BasicCluster &cluster); + // error-weighted average of time from constituents of basic cluster + float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev); + // get BasicClusterSeedTime of the seed basic cluser of the supercluster + float SuperClusterSeedTime(const reco::SuperCluster &cluster); + // get BasicClusterTime of the seed basic cluser of the supercluster + float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev); + + // mapping for preshower rechits + std::map rechits_map_; + // get Preshower hit array + std::vector getESHits(double X, double Y, double Z, const std::map& rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1); + // get Preshower hit shape + float getESShape(const std::vector& ESHits0); + // get Preshower effective sigmaRR + float eseffsirir( const reco::SuperCluster &cluster ); + float eseffsixix( const reco::SuperCluster &cluster ); + float eseffsiyiy( const reco::SuperCluster &cluster ); + + // std::vector flagsexcl_; //std::vector severitiesexcl_; - // const EcalSeverityLevelAlgo *sevLv; - - private: - void getGeometry( const edm::EventSetup &es ); - void getTopology( const edm::EventSetup &es ); - void getEBRecHits( const edm::Event &ev, const edm::InputTag& redEBRecHits ); - void getEERecHits( const edm::Event &ev, const edm::InputTag& redEERecHits ); - void getESRecHits( const edm::Event &ev, const edm::InputTag& redESRecHits ); - const EcalRecHitCollection * getEcalRecHitCollection( const reco::BasicCluster &cluster ); - - const CaloGeometry *geometry_; - const CaloTopology *topology_; - const EcalRecHitCollection *ebRecHits_; - const EcalRecHitCollection *eeRecHits_; - const EcalRecHitCollection *esRecHits_; - - //const EcalIntercalibConstantMap& icalMap; - edm::ESHandle ical; - EcalIntercalibConstantMap icalMap; - edm::ESHandle agc; - edm::ESHandle laser; - void getIntercalibConstants( const edm::EventSetup &es ); - void getADCToGeV ( const edm::EventSetup &es ); - void getLaserDbService ( const edm::EventSetup &es ); - -// std::vector flagsexcl_; -// std::vector severitiesexcl_; - + // const EcalSeverityLevelAlgo *sevLv; + + private: + void getGeometry( const edm::EventSetup &es ); + void getTopology( const edm::EventSetup &es ); + void getEBRecHits( const edm::Event &ev ); + void getEERecHits( const edm::Event &ev ); + void getESRecHits( const edm::Event &ev ); + const EcalRecHitCollection * getEcalRecHitCollection( const reco::BasicCluster &cluster ); + + const CaloGeometry *geometry_; + const CaloTopology *topology_; + const EcalRecHitCollection *ebRecHits_; + const EcalRecHitCollection *eeRecHits_; + const EcalRecHitCollection *esRecHits_; + + edm::EDGetTokenT ebRHToken_, eeRHToken_, esRHToken_; + + //const EcalIntercalibConstantMap& icalMap; + edm::ESHandle ical; + EcalIntercalibConstantMap icalMap; + edm::ESHandle agc; + edm::ESHandle laser; + void getIntercalibConstants( const edm::EventSetup &es ); + void getADCToGeV ( const edm::EventSetup &es ); + void getLaserDbService ( const edm::EventSetup &es ); + + // std::vector flagsexcl_; + // std::vector severitiesexcl_; }; #endif diff --git a/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc b/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc index 6550e2ce53c2b..e88b0bf16385f 100644 --- a/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc +++ b/RecoEcal/EgammaCoreTools/src/EcalClusterLazyTools.cc @@ -22,130 +22,63 @@ #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h" -//EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config ) -EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits) -{ - getGeometry( es ); - getTopology( es ); - getEBRecHits( ev, redEBRecHits ); - getEERecHits( ev, redEERecHits ); - getIntercalibConstants( es ); - getADCToGeV ( es ); - getLaserDbService ( es ); - - //AA - //Flags and Severities to be excluded from photon calculations -/* - const std::vector flagnames = - config.getParameter >("RecHitFlagToBeExcluded"); - - flagsexcl_= - StringToEnumValue(flagnames); - - const std::vector severitynames = - config.getParameter >("RecHitSeverityToBeExcluded"); - - severitiesexcl_= - StringToEnumValue(severitynames); - //AA - - //AA -*/ - //Get the severity level object -// edm::ESHandle sevLv; -// es.get().get(sevLv); - // - -} - -EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config) -{ - getGeometry( es ); - getTopology( es ); - getEBRecHits( ev, redEBRecHits ); - getEERecHits( ev, redEERecHits ); - getIntercalibConstants( es ); - getADCToGeV ( es ); - getLaserDbService ( es ); - -// edm::ESHandle sevLv; -// es.get().get(sevLv); +EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, edm::EDGetTokenT token1, edm::EDGetTokenT token2) { -} - -EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits, const edm::InputTag& redESRecHits) -{ - getGeometry( es ); - getTopology( es ); - getEBRecHits( ev, redEBRecHits ); - getEERecHits( ev, redEERecHits ); - getESRecHits( ev, redESRecHits ); - getIntercalibConstants( es ); - getADCToGeV ( es ); - getLaserDbService ( es ); + ebRHToken_ = token1; + eeRHToken_ = token2; + getGeometry( es ); + getTopology( es ); + getEBRecHits( ev ); + getEERecHits( ev ); + getIntercalibConstants( es ); + getADCToGeV ( es ); + getLaserDbService ( es ); } EcalClusterLazyTools::~EcalClusterLazyTools() -{ -} - - +{} -void EcalClusterLazyTools::getGeometry( const edm::EventSetup &es ) -{ +void EcalClusterLazyTools::getGeometry( const edm::EventSetup &es ) { edm::ESHandle pGeometry; es.get().get(pGeometry); geometry_ = pGeometry.product(); } - - -void EcalClusterLazyTools::getTopology( const edm::EventSetup &es ) -{ +void EcalClusterLazyTools::getTopology( const edm::EventSetup &es ) { edm::ESHandle pTopology; es.get().get(pTopology); topology_ = pTopology.product(); } - - -void EcalClusterLazyTools::getEBRecHits( const edm::Event &ev, const edm::InputTag& redEBRecHits ) -{ - edm::Handle< EcalRecHitCollection > pEBRecHits; - ev.getByLabel( redEBRecHits, pEBRecHits ); - ebRecHits_ = pEBRecHits.product(); +void EcalClusterLazyTools::getEBRecHits( const edm::Event &ev ) { + edm::Handle< EcalRecHitCollection > pEBRecHits; + ev.getByToken( ebRHToken_, pEBRecHits ); + ebRecHits_ = pEBRecHits.product(); } - - -void EcalClusterLazyTools::getEERecHits( const edm::Event &ev, const edm::InputTag& redEERecHits ) -{ - edm::Handle< EcalRecHitCollection > pEERecHits; - ev.getByLabel( redEERecHits, pEERecHits ); - eeRecHits_ = pEERecHits.product(); +void EcalClusterLazyTools::getEERecHits( const edm::Event &ev ) { + edm::Handle< EcalRecHitCollection > pEERecHits; + ev.getByToken( eeRHToken_, pEERecHits ); + eeRecHits_ = pEERecHits.product(); } +void EcalClusterLazyTools::getESRecHits( const edm::Event &ev ) { - -void EcalClusterLazyTools::getESRecHits( const edm::Event &ev, const edm::InputTag& redESRecHits ) -{ - edm::Handle< EcalRecHitCollection > pESRecHits; - ev.getByLabel( redESRecHits, pESRecHits ); - esRecHits_ = pESRecHits.product(); - - // make the map of rechits - rechits_map_.clear(); - if (pESRecHits.isValid()) { - EcalRecHitCollection::const_iterator it; - for (it = pESRecHits->begin(); it != pESRecHits->end(); ++it) { - // remove bad ES rechits - if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue; - //Make the map of DetID, EcalRecHit pairs - rechits_map_.insert(std::make_pair(it->id(), *it)); - } - } - + edm::Handle< EcalRecHitCollection > pESRecHits; + ev.getByToken( esRHToken_, pESRecHits ); + esRecHits_ = pESRecHits.product(); + // make the map of rechits + rechits_map_.clear(); + if (pESRecHits.isValid()) { + EcalRecHitCollection::const_iterator it; + for (it = pESRecHits->begin(); it != pESRecHits->end(); ++it) { + // remove bad ES rechits + if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue; + //Make the map of DetID, EcalRecHit pairs + rechits_map_.insert(std::make_pair(it->id(), *it)); + } + } } diff --git a/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc b/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc index d5dea6a0e8122..9c9046a5b3983 100644 --- a/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc +++ b/RecoEcal/EgammaCoreTools/test/testEcalClusterLazyTools.cc @@ -48,120 +48,119 @@ Description: class testEcalClusterLazyTools : public edm::EDAnalyzer { - public: - explicit testEcalClusterLazyTools(const edm::ParameterSet&); - ~testEcalClusterLazyTools(); - - edm::InputTag barrelClusterCollection_; - edm::InputTag endcapClusterCollection_; - edm::InputTag reducedBarrelRecHitCollection_; - edm::InputTag reducedEndcapRecHitCollection_; - - private: - virtual void analyze(const edm::Event&, const edm::EventSetup&); - +public: + explicit testEcalClusterLazyTools(const edm::ParameterSet&); + ~testEcalClusterLazyTools(); + + edm::EDGetTokenT barrelClusterToken_; + edm::EDGetTokenT endcapClusterToken_; + edm::EDGetTokenT reducedBarrelRecHitToken_; + edm::EDGetTokenT reducedEndcapRecHitToken_; + +private: + virtual void analyze(const edm::Event&, const edm::EventSetup&); + }; testEcalClusterLazyTools::testEcalClusterLazyTools(const edm::ParameterSet& ps) { - barrelClusterCollection_ = ps.getParameter("barrelClusterCollection"); - endcapClusterCollection_ = ps.getParameter("endcapClusterCollection"); - reducedBarrelRecHitCollection_ = ps.getParameter("reducedBarrelRecHitCollection"); - reducedEndcapRecHitCollection_ = ps.getParameter("reducedEndcapRecHitCollection"); + barrelClusterToken_ = consumes(ps.getParameter("barrelClusterCollection")); + endcapClusterToken_ = consumes(ps.getParameter("endcapClusterCollection")); + reducedBarrelRecHitToken_ = consumes(ps.getParameter("reducedBarrelRecHitCollection")); + reducedEndcapRecHitToken_ = consumes(ps.getParameter("reducedEndcapRecHitCollection")); } testEcalClusterLazyTools::~testEcalClusterLazyTools() -{ -} +{} void testEcalClusterLazyTools::analyze(const edm::Event& ev, const edm::EventSetup& es) { - edm::Handle< reco::BasicClusterCollection > pEBClusters; - ev.getByLabel( barrelClusterCollection_, pEBClusters ); - const reco::BasicClusterCollection *ebClusters = pEBClusters.product(); - - edm::Handle< reco::BasicClusterCollection > pEEClusters; - ev.getByLabel( endcapClusterCollection_, pEEClusters ); - const reco::BasicClusterCollection *eeClusters = pEEClusters.product(); - - EcalClusterLazyTools lazyTools( ev, es, reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_ ); - - std::cout << "========== BARREL ==========" << std::endl; - for (reco::BasicClusterCollection::const_iterator it = ebClusters->begin(); it != ebClusters->end(); ++it ) { - std::cout << "----- new cluster -----" << std::endl; - std::cout << "----------------- size: " << (*it).size() << " energy: " << (*it).energy() << std::endl; - - std::cout << "e1x3..................... " << lazyTools.e1x3( *it ) << std::endl; - std::cout << "e3x1..................... " << lazyTools.e3x1( *it ) << std::endl; - std::cout << "e1x5..................... " << lazyTools.e1x5( *it ) << std::endl; - //std::cout << "e5x1..................... " << lazyTools.e5x1( *it ) << std::endl; - std::cout << "e2x2..................... " << lazyTools.e2x2( *it ) << std::endl; - std::cout << "e3x3..................... " << lazyTools.e5x5( *it ) << std::endl; - std::cout << "e4x4..................... " << lazyTools.e4x4( *it ) << std::endl; - std::cout << "e5x5..................... " << lazyTools.e3x3( *it ) << std::endl; - std::cout << "e2x5Right................ " << lazyTools.e2x5Right( *it ) << std::endl; - std::cout << "e2x5Left................. " << lazyTools.e2x5Left( *it ) << std::endl; - std::cout << "e2x5Top.................. " << lazyTools.e2x5Top( *it ) << std::endl; - std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom( *it ) << std::endl; - std::cout << "e2x5Max.................. " << lazyTools.e2x5Max( *it ) << std::endl; - std::cout << "eMax..................... " << lazyTools.eMax( *it ) << std::endl; - std::cout << "e2nd..................... " << lazyTools.e2nd( *it ) << std::endl; - std::vector vEta = lazyTools.energyBasketFractionEta( *it ); - std::cout << "energyBasketFractionEta.."; - for (size_t i = 0; i < vEta.size(); ++i ) { - std::cout << " " << vEta[i]; - } - std::cout << std::endl; - std::vector vPhi = lazyTools.energyBasketFractionPhi( *it ); - std::cout << "energyBasketFractionPhi.."; - for (size_t i = 0; i < vPhi.size(); ++i ) { - std::cout << " " << vPhi[i]; - } - std::cout << std::endl; - std::vector vLat = lazyTools.lat( *it ); - std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl; - std::vector vCov = lazyTools.covariances( *it ); - std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl; - std::vector vLocCov = lazyTools.localCovariances( *it ); - std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl; - std::cout << "zernike20................ " << lazyTools.zernike20( *it ) << std::endl; - std::cout << "zernike42................ " << lazyTools.zernike42( *it ) << std::endl; - } - - std::cout << "========== ENDCAPS ==========" << std::endl; - for (reco::BasicClusterCollection::const_iterator it = eeClusters->begin(); it != eeClusters->end(); ++it ) { - std::cout << "----- new cluster -----" << std::endl; - std::cout << "----------------- size: " << (*it).size() << " energy: " << (*it).energy() << std::endl; - - std::cout << "e1x3..................... " << lazyTools.e1x3( *it ) << std::endl; - std::cout << "e3x1..................... " << lazyTools.e3x1( *it ) << std::endl; - std::cout << "e1x5..................... " << lazyTools.e1x5( *it ) << std::endl; - //std::cout << "e5x1..................... " << lazyTools.e5x1( *it ) << std::endl; - std::cout << "e2x2..................... " << lazyTools.e2x2( *it ) << std::endl; - std::cout << "e3x3..................... " << lazyTools.e5x5( *it ) << std::endl; - std::cout << "e4x4..................... " << lazyTools.e4x4( *it ) << std::endl; - std::cout << "e5x5..................... " << lazyTools.e3x3( *it ) << std::endl; - std::cout << "e2x5Right................ " << lazyTools.e2x5Right( *it ) << std::endl; - std::cout << "e2x5Left................. " << lazyTools.e2x5Left( *it ) << std::endl; - std::cout << "e2x5Top.................. " << lazyTools.e2x5Top( *it ) << std::endl; - std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom( *it ) << std::endl; - std::cout << "eMax..................... " << lazyTools.eMax( *it ) << std::endl; - std::cout << "e2nd..................... " << lazyTools.e2nd( *it ) << std::endl; - std::vector vLat = lazyTools.lat( *it ); - std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl; - std::vector vCov = lazyTools.covariances( *it ); - std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl; - std::vector vLocCov = lazyTools.localCovariances( *it ); - std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl; - std::cout << "zernike20................ " << lazyTools.zernike20( *it ) << std::endl; - std::cout << "zernike42................ " << lazyTools.zernike42( *it ) << std::endl; - } + edm::Handle< reco::BasicClusterCollection > pEBClusters; + ev.getByToken( barrelClusterToken_, pEBClusters ); + const reco::BasicClusterCollection *ebClusters = pEBClusters.product(); + + edm::Handle< reco::BasicClusterCollection > pEEClusters; + ev.getByToken( endcapClusterToken_, pEEClusters ); + const reco::BasicClusterCollection *eeClusters = pEEClusters.product(); + + EcalClusterLazyTools lazyTools( ev, es, reducedBarrelRecHitToken_, reducedEndcapRecHitToken_ ); + + std::cout << "========== BARREL ==========" << std::endl; + for (reco::BasicClusterCollection::const_iterator it = ebClusters->begin(); it != ebClusters->end(); ++it ) { + std::cout << "----- new cluster -----" << std::endl; + std::cout << "----------------- size: " << (*it).size() << " energy: " << (*it).energy() << std::endl; + + std::cout << "e1x3..................... " << lazyTools.e1x3( *it ) << std::endl; + std::cout << "e3x1..................... " << lazyTools.e3x1( *it ) << std::endl; + std::cout << "e1x5..................... " << lazyTools.e1x5( *it ) << std::endl; + //std::cout << "e5x1..................... " << lazyTools.e5x1( *it ) << std::endl; + std::cout << "e2x2..................... " << lazyTools.e2x2( *it ) << std::endl; + std::cout << "e3x3..................... " << lazyTools.e5x5( *it ) << std::endl; + std::cout << "e4x4..................... " << lazyTools.e4x4( *it ) << std::endl; + std::cout << "e5x5..................... " << lazyTools.e3x3( *it ) << std::endl; + std::cout << "e2x5Right................ " << lazyTools.e2x5Right( *it ) << std::endl; + std::cout << "e2x5Left................. " << lazyTools.e2x5Left( *it ) << std::endl; + std::cout << "e2x5Top.................. " << lazyTools.e2x5Top( *it ) << std::endl; + std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom( *it ) << std::endl; + std::cout << "e2x5Max.................. " << lazyTools.e2x5Max( *it ) << std::endl; + std::cout << "eMax..................... " << lazyTools.eMax( *it ) << std::endl; + std::cout << "e2nd..................... " << lazyTools.e2nd( *it ) << std::endl; + std::vector vEta = lazyTools.energyBasketFractionEta( *it ); + std::cout << "energyBasketFractionEta.."; + for (size_t i = 0; i < vEta.size(); ++i ) { + std::cout << " " << vEta[i]; + } + std::cout << std::endl; + std::vector vPhi = lazyTools.energyBasketFractionPhi( *it ); + std::cout << "energyBasketFractionPhi.."; + for (size_t i = 0; i < vPhi.size(); ++i ) { + std::cout << " " << vPhi[i]; + } + std::cout << std::endl; + std::vector vLat = lazyTools.lat( *it ); + std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl; + std::vector vCov = lazyTools.covariances( *it ); + std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl; + std::vector vLocCov = lazyTools.localCovariances( *it ); + std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl; + std::cout << "zernike20................ " << lazyTools.zernike20( *it ) << std::endl; + std::cout << "zernike42................ " << lazyTools.zernike42( *it ) << std::endl; + } + + std::cout << "========== ENDCAPS ==========" << std::endl; + for (reco::BasicClusterCollection::const_iterator it = eeClusters->begin(); it != eeClusters->end(); ++it ) { + std::cout << "----- new cluster -----" << std::endl; + std::cout << "----------------- size: " << (*it).size() << " energy: " << (*it).energy() << std::endl; + + std::cout << "e1x3..................... " << lazyTools.e1x3( *it ) << std::endl; + std::cout << "e3x1..................... " << lazyTools.e3x1( *it ) << std::endl; + std::cout << "e1x5..................... " << lazyTools.e1x5( *it ) << std::endl; + //std::cout << "e5x1..................... " << lazyTools.e5x1( *it ) << std::endl; + std::cout << "e2x2..................... " << lazyTools.e2x2( *it ) << std::endl; + std::cout << "e3x3..................... " << lazyTools.e5x5( *it ) << std::endl; + std::cout << "e4x4..................... " << lazyTools.e4x4( *it ) << std::endl; + std::cout << "e5x5..................... " << lazyTools.e3x3( *it ) << std::endl; + std::cout << "e2x5Right................ " << lazyTools.e2x5Right( *it ) << std::endl; + std::cout << "e2x5Left................. " << lazyTools.e2x5Left( *it ) << std::endl; + std::cout << "e2x5Top.................. " << lazyTools.e2x5Top( *it ) << std::endl; + std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom( *it ) << std::endl; + std::cout << "eMax..................... " << lazyTools.eMax( *it ) << std::endl; + std::cout << "e2nd..................... " << lazyTools.e2nd( *it ) << std::endl; + std::vector vLat = lazyTools.lat( *it ); + std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl; + std::vector vCov = lazyTools.covariances( *it ); + std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl; + std::vector vLocCov = lazyTools.localCovariances( *it ); + std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl; + std::cout << "zernike20................ " << lazyTools.zernike20( *it ) << std::endl; + std::cout << "zernike42................ " << lazyTools.zernike42( *it ) << std::endl; + } } //define this as a plug-in diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h index bac4050f6b4aa..fd26d875ffb2a 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTClusterShapeProducer.h @@ -22,6 +22,8 @@ #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h" #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" + namespace edm { class ConfigurationDescriptions; } @@ -37,8 +39,8 @@ class EgammaHLTClusterShapeProducer : public edm::EDProducer { // ----------member data --------------------------- edm::EDGetTokenT recoEcalCandidateProducer_; - edm::InputTag ecalRechitEBTag_; - edm::InputTag ecalRechitEETag_; + edm::EDGetTokenT ecalRechitEBToken_; + edm::EDGetTokenT ecalRechitEEToken_; bool EtaOrIeta_; edm::ParameterSet conf_; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h index f50a79ba844a9..1b2fe7e05d241 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9IDProducer.h @@ -27,6 +27,8 @@ #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h" #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" + namespace edm { class ConfigurationDescriptions; } @@ -44,8 +46,8 @@ class EgammaHLTR9IDProducer : public edm::EDProducer { // ----------member data --------------------------- edm::EDGetTokenT recoEcalCandidateProducer_; - edm::InputTag ecalRechitEBTag_; - edm::InputTag ecalRechitEETag_; + edm::EDGetTokenT ecalRechitEBToken_; + edm::EDGetTokenT ecalRechitEEToken_; edm::ParameterSet conf_; }; diff --git a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h index b1e8c6b3a5af9..c996b5df059c2 100644 --- a/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h +++ b/RecoEgamma/EgammaHLTProducers/interface/EgammaHLTR9Producer.h @@ -31,6 +31,8 @@ #include "DataFormats/EcalRecHit/interface/EcalRecHit.h" #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" + namespace edm { class ConfigurationDescriptions; } @@ -46,8 +48,6 @@ class EgammaHLTR9Producer : public edm::EDProducer { // ----------member data --------------------------- edm::EDGetTokenT recoEcalCandidateProducer_; - edm::InputTag ecalRechitEBTag_; - edm::InputTag ecalRechitEETag_; edm::EDGetTokenT ecalRechitEBToken_; edm::EDGetTokenT ecalRechitEEToken_; bool useSwissCross_; diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc index 335de39fb1fe9..192d4a2f8d941 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTClusterShapeProducer.cc @@ -20,8 +20,9 @@ EgammaHLTClusterShapeProducer::EgammaHLTClusterShapeProducer(const edm::Paramete // use configuration file to setup input/output collection names recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - ecalRechitEBTag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEB"); - ecalRechitEETag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEE"); + ecalRechitEBToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEB")); + ecalRechitEEToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEE")); + EtaOrIeta_ = conf_.getParameter< bool > ("isIeta"); //register your products @@ -47,7 +48,7 @@ void EgammaHLTClusterShapeProducer::produce(edm::Event& iEvent, const edm::Event edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); - EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBTag_, ecalRechitEETag_ ); + EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); reco::RecoEcalCandidateIsolationMap clshMap; diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc index 2b8669d7da1b3..8da96afff9b7d 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9IDProducer.cc @@ -27,8 +27,9 @@ EgammaHLTR9IDProducer::EgammaHLTR9IDProducer(const edm::ParameterSet& config) : // use configuration file to setup input/output collection names recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - ecalRechitEBTag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEB"); - ecalRechitEETag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEE"); + ecalRechitEBToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEB")); + ecalRechitEEToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEE")); + //register your products produces < reco::RecoEcalCandidateIsolationMap >(); @@ -53,7 +54,7 @@ void EgammaHLTR9IDProducer::produce(edm::Event& iEvent, const edm::EventSetup& i edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_, recoecalcandHandle); - EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBTag_, ecalRechitEETag_ ); + EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_ ); reco::RecoEcalCandidateIsolationMap r9Map; diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc index 49c2ca5800d07..0cf4b276a6688 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTR9Producer.cc @@ -18,10 +18,8 @@ EgammaHLTR9Producer::EgammaHLTR9Producer(const edm::ParameterSet& config) : conf { // use configuration file to setup input/output collection names recoEcalCandidateProducer_ = consumes(conf_.getParameter("recoEcalCandidateProducer")); - ecalRechitEBTag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEB"); - ecalRechitEETag_ = conf_.getParameter< edm::InputTag > ("ecalRechitEE"); - ecalRechitEBToken_ = consumes(ecalRechitEBTag_); - ecalRechitEEToken_ = consumes(ecalRechitEETag_); + ecalRechitEBToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEB")); + ecalRechitEEToken_ = consumes(conf_.getParameter< edm::InputTag > ("ecalRechitEE")); useSwissCross_ = conf_.getParameter< bool > ("useSwissCross"); @@ -51,7 +49,7 @@ void EgammaHLTR9Producer::produce(edm::Event& iEvent, const edm::EventSetup& iSe edm::Handle recoecalcandHandle; iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle); - EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBTag_, ecalRechitEETag_); + EcalClusterLazyTools lazyTools(iEvent, iSetup, ecalRechitEBToken_, ecalRechitEEToken_); reco::RecoEcalCandidateIsolationMap r9Map; From 3c62fbb630efe7a92638d916881accb92e021258 Mon Sep 17 00:00:00 2001 From: Matteo Date: Sun, 16 Feb 2014 00:52:25 +0100 Subject: [PATCH 2/6] more updates --- .../interface/EgammaHLTPixelMatchElectronAlgo.h | 9 +++++---- .../src/EgammaHLTPixelMatchElectronAlgo.cc | 14 +++++++------- .../src/EgammaHLTPixelMatchElectronProducers.cc | 10 +++++++--- ...EgammaHLTRegionalPixelSeedGeneratorProducers.cc | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTPixelMatchElectronAlgo.h b/RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTPixelMatchElectronAlgo.h index 38077aec0a82a..9bdec93ad2b22 100644 --- a/RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTPixelMatchElectronAlgo.h +++ b/RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTPixelMatchElectronAlgo.h @@ -17,6 +17,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h" @@ -32,7 +33,7 @@ class EgammaHLTPixelMatchElectronAlgo { public: - EgammaHLTPixelMatchElectronAlgo(const edm::ParameterSet& conf); + EgammaHLTPixelMatchElectronAlgo(const edm::ParameterSet& conf, edm::ConsumesCollector && iC); ~EgammaHLTPixelMatchElectronAlgo(); @@ -52,10 +53,10 @@ class EgammaHLTPixelMatchElectronAlgo { void process(edm::Handle tracksH, edm::Handle gsfTracksH, reco::ElectronCollection & outEle, Global3DPoint & bs); bool isInnerMostWithLostHits(const reco::GsfTrackRef&, const reco::GsfTrackRef&, bool&); - edm::InputTag trackProducer_; - edm::InputTag gsfTrackProducer_; + edm::EDGetTokenT trackProducer_; + edm::EDGetTokenT gsfTrackProducer_; bool useGsfTracks_; - edm::InputTag bsProducer_; + edm::EDGetTokenT bsProducer_; MultiTrajectoryStateMode* mtsMode_; //its not clear to me why this is a pointer but its not the only one so changing things wouldnt make this class safer MultiTrajectoryStateTransform* mtsTransform_; diff --git a/RecoEgamma/EgammaHLTAlgos/src/EgammaHLTPixelMatchElectronAlgo.cc b/RecoEgamma/EgammaHLTAlgos/src/EgammaHLTPixelMatchElectronAlgo.cc index 2522cfaa8d153..f25f8282317a5 100644 --- a/RecoEgamma/EgammaHLTAlgos/src/EgammaHLTPixelMatchElectronAlgo.cc +++ b/RecoEgamma/EgammaHLTAlgos/src/EgammaHLTPixelMatchElectronAlgo.cc @@ -46,11 +46,11 @@ using namespace edm; using namespace std; using namespace reco; -EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo(const edm::ParameterSet &conf) : - trackProducer_(conf.getParameter("TrackProducer")), - gsfTrackProducer_(conf.getParameter("GsfTrackProducer")), +EgammaHLTPixelMatchElectronAlgo::EgammaHLTPixelMatchElectronAlgo(const edm::ParameterSet &conf, edm::ConsumesCollector && iC) : + trackProducer_(iC.consumes(conf.getParameter("TrackProducer"))), + gsfTrackProducer_(iC.consumes(conf.getParameter("GsfTrackProducer"))), useGsfTracks_(conf.getParameter("UseGsfTracks")), - bsProducer_(conf.getParameter("BSProducer")), + bsProducer_(iC.consumes(conf.getParameter("BSProducer"))), mtsMode_(new MultiTrajectoryStateMode()), mtsTransform_(0), cacheIDTDGeom_(0), @@ -96,16 +96,16 @@ void EgammaHLTPixelMatchElectronAlgo::run(Event& e, ElectronCollection & outEle // get the input edm::Handle tracksH; if (!useGsfTracks_) - e.getByLabel(trackProducer_,tracksH); + e.getByToken(trackProducer_,tracksH); // get the input edm::Handle gsfTracksH; if (useGsfTracks_) - e.getByLabel(gsfTrackProducer_, gsfTracksH); + e.getByToken(gsfTrackProducer_, gsfTracksH); //Get the Beam Spot position edm::Handle recoBeamSpotHandle; - e.getByLabel(bsProducer_,recoBeamSpotHandle); + e.getByToken(bsProducer_,recoBeamSpotHandle); // gets its position const BeamSpot::Point& bsPosition = recoBeamSpotHandle->position(); diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc index 0d664a89abe9d..c9801cb144df8 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPixelMatchElectronProducers.cc @@ -44,11 +44,15 @@ using namespace reco; EgammaHLTPixelMatchElectronProducers::EgammaHLTPixelMatchElectronProducers(const edm::ParameterSet& iConfig) : conf_(iConfig) { - //register your products - produces(); + consumes(conf_.getParameter("TrackProducer")); + consumes(conf_.getParameter("GsfTrackProducer")); + consumes(conf_.getParameter("BSProducer")); //create algo - algo_ = new EgammaHLTPixelMatchElectronAlgo(conf_); + algo_ = new EgammaHLTPixelMatchElectronAlgo(conf_, consumesCollector()); + + //register your products + produces(); } diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc index 4fc137ef52ce7..50cd284a88e22 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc @@ -81,8 +81,8 @@ void EgammaHLTRegionalPixelSeedGeneratorProducers::fillDescriptions(edm::Configu edm::ParameterSetDescription orederedHitsPSET; orederedHitsPSET.add("ComponentName", "StandardHitPairGenerator"); - orederedHitsPSET.add("SeedingLayers", "hltESPPixelLayerPairs"); - orederedHitsPSET.add("maxElement", 0); + orederedHitsPSET.add("SeedingLayers", edm::InputTag("PixelLayerPairs")); + orederedHitsPSET.add("maxElement", 0); desc.add("OrderedHitsFactoryPSet", orederedHitsPSET); descriptions.add(("hltEgammaHLTRegionalPixelSeedGeneratorProducers"), desc); From 423f899ce7eb96a25b35bc3d1c7760debe419210 Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 17 Feb 2014 10:50:05 +0100 Subject: [PATCH 3/6] more updates --- DQM/Physics/src/QcdPhotonsDQM.cc | 2 +- .../HLTanalyzers/interface/HLTAnalyzer.h | 2 + HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc | 6 +- .../PatAlgos/plugins/PATElectronProducer.cc | 2 +- .../interface/PhotonEnergyCorrector.h | 6 +- .../src/PhotonEnergyCorrector.cc | 12 +- .../EgammaTools/plugins/EGEnergyAnalyzer.cc | 64 +- .../interface/ElectronIDAlgo.h | 4 +- .../plugins/ElectronIDSelectorLikelihood.cc | 2 +- .../src/ClassBasedElectronID.cc | 2 +- .../src/CutBasedElectronID.cc | 2 +- .../src/ElectronIDAlgo.cc | 38 +- .../src/PTDRElectronID.cc | 12 +- .../HiEgammaAlgos/plugins/HiSpikeCleaner.cc | 99 +- .../plugins/MCEmbeddingValidationAnalyzer.cc | 5 +- .../plugins/MCEmbeddingValidationAnalyzer.h | 29 +- .../interface/EgammaSuperClusters.h | 61 +- .../EcalClusters/src/EgammaSuperClusters.cc | 1203 ++++++++--------- 18 files changed, 763 insertions(+), 788 deletions(-) diff --git a/DQM/Physics/src/QcdPhotonsDQM.cc b/DQM/Physics/src/QcdPhotonsDQM.cc index cb81b144c09f3..dd5fab136c29f 100644 --- a/DQM/Physics/src/QcdPhotonsDQM.cc +++ b/DQM/Physics/src/QcdPhotonsDQM.cc @@ -315,7 +315,7 @@ void QcdPhotonsDQM::analyze(const Event& iEvent, const EventSetup& iSetup) { iEvent.getByToken(theBarrelRecHitToken_, EBReducedRecHits); Handle EEReducedRecHits; iEvent.getByToken(theEndcapRecHitToken_, EEReducedRecHits); - EcalClusterLazyTools lazyTool(iEvent, iSetup, theBarrelRecHitTag_, theEndcapRecHitTag_); + EcalClusterLazyTools lazyTool(iEvent, iSetup, theBarrelRecHitToken_, theEndcapRecHitToken_); // Find the highest et "decent" photon diff --git a/HLTrigger/HLTanalyzers/interface/HLTAnalyzer.h b/HLTrigger/HLTanalyzers/interface/HLTAnalyzer.h index ed4a5cd79d609..dbbbb229bfe81 100644 --- a/HLTrigger/HLTanalyzers/interface/HLTAnalyzer.h +++ b/HLTrigger/HLTanalyzers/interface/HLTAnalyzer.h @@ -185,6 +185,8 @@ class HLTAnalyzer : public edm::EDAnalyzer { edm::EDGetTokenT IsoPhoTrackIsolToken_; edm::EDGetTokenT HFECALClustersToken_; edm::EDGetTokenT HFElectronsToken_; + edm::EDGetTokenT EcalRecHitEBToken_; + edm::EDGetTokenT EcalRecHitEEToken_; // ECAL Activity edm::EDGetTokenT ECALActivityToken_; diff --git a/HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc b/HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc index 34c108eec3899..d51c946a3826c 100644 --- a/HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc +++ b/HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc @@ -300,6 +300,8 @@ HLTAnalyzer::HLTAnalyzer(edm::ParameterSet const& conf) { ActivityR9Token_ = consumes(ActivityR9_); ActivityR9IDToken_ = consumes(ActivityR9ID_); ActivityHoverEHToken_ = consumes(ActivityHoverEH_); + EcalRecHitEBToken_ = consumes(edm::InputTag("hltEcalRegionalEgammaRecHit:EcalRecHitsEB")); + EcalRecHitEEToken_ = consumes(edm::InputTag("hltEcalRegionalEgammaRecHit:EcalRecHitsEE")); CandIsoToken_ = consumes(CandIso_); CandNonIsoToken_ = consumes(CandNonIso_); @@ -533,9 +535,7 @@ void HLTAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetu edm::Handle recoVertexsOffline0; // new stuff for the egamma EleId - edm::InputTag ecalRechitEBTag (std::string("hltEcalRegionalEgammaRecHit:EcalRecHitsEB")); - edm::InputTag ecalRechitEETag (std::string("hltEcalRegionalEgammaRecHit:EcalRecHitsEE")); - EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBTag, ecalRechitEETag); + EcalClusterLazyTools lazyTools( iEvent, iSetup, EcalRecHitEBToken_, EcalRecHitEEToken_ ); edm::Handle electronHFClusterAssociation; iEvent.getByToken(HFEMClusterShapeAssociationToken_,electronHFClusterAssociation); diff --git a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc index 2e6e10370c1cd..62a437c66b1da 100755 --- a/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc @@ -195,7 +195,7 @@ void PATElectronProducer::produce(edm::Event & iEvent, const edm::EventSetup & i edm::InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB")); edm::InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE")); //EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection); - EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_); + EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_); // for conversion veto selection edm::Handle hConversions; diff --git a/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h b/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h index 087e68cfda69c..a46529a2d766a 100644 --- a/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h +++ b/RecoEgamma/EgammaPhotonAlgos/interface/PhotonEnergyCorrector.h @@ -27,7 +27,7 @@ class PhotonEnergyCorrector { public: - PhotonEnergyCorrector(const edm::ParameterSet& config); + PhotonEnergyCorrector(const edm::ParameterSet& config, edm::ConsumesCollector && iC); ~PhotonEnergyCorrector(); std::unique_ptr& gedRegression() @@ -51,9 +51,11 @@ class PhotonEnergyCorrector std::unique_ptr gedRegression_; double minR9Barrel_; double minR9Endcap_; - edm::ESHandle theCaloGeom_; + edm::ESHandle theCaloGeom_; edm::InputTag barrelEcalHits_; edm::InputTag endcapEcalHits_; + edm::EDGetTokenT barrelEcalHitsToken_; + edm::EDGetTokenT endcapEcalHitsToken_; EnergyUncertaintyPhotonSpecific* photonUncertaintyCalculator_; diff --git a/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc b/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc index 6ed5ac463d325..39dc257bfc49e 100644 --- a/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc +++ b/RecoEgamma/EgammaPhotonAlgos/src/PhotonEnergyCorrector.cc @@ -10,8 +10,7 @@ #include "RecoEgamma/EgammaPhotonAlgos/interface/EnergyUncertaintyPhotonSpecific.h" -PhotonEnergyCorrector::PhotonEnergyCorrector( const edm::ParameterSet& config) { - +PhotonEnergyCorrector::PhotonEnergyCorrector( const edm::ParameterSet& config, edm::ConsumesCollector && iC) { minR9Barrel_ = config.getParameter("minR9Barrel"); minR9Endcap_ = config.getParameter("minR9Endcap"); @@ -19,6 +18,9 @@ PhotonEnergyCorrector::PhotonEnergyCorrector( const edm::ParameterSet& config) { barrelEcalHits_ = config.getParameter("barrelEcalHits"); endcapEcalHits_ = config.getParameter("endcapEcalHits"); + barrelEcalHitsToken_ = iC.consumes(config.getParameter("barrelEcalHits")); + endcapEcalHitsToken_ = iC.consumes(config.getParameter("endcapEcalHits")); + // candidateP4type_ = config.getParameter("candidateP4type") ; @@ -112,11 +114,7 @@ void PhotonEnergyCorrector::calculate(edm::Event& evt, reco::Photon & thePhoton, minR9=minR9Endcap_; } - - - EcalClusterLazyTools lazyTools(evt, iSetup, barrelEcalHits_,endcapEcalHits_); - - + EcalClusterLazyTools lazyTools(evt, iSetup, barrelEcalHitsToken_,endcapEcalHitsToken_); ////////////// Here default Ecal corrections based on electrons //////////////////////// if ( thePhoton.r9() > minR9 ) { diff --git a/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc b/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc index 6032e6264fea3..8eb54c9f357c8 100644 --- a/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc +++ b/RecoEgamma/EgammaTools/plugins/EGEnergyAnalyzer.cc @@ -1,4 +1,4 @@ -// -*- C++ -*- + // -*- C++ -*- // // Package: EGEnergyAnalyzer // Class: EGEnergyAnalyzer @@ -46,45 +46,34 @@ // class EGEnergyAnalyzer : public edm::EDAnalyzer { - public: - explicit EGEnergyAnalyzer(const edm::ParameterSet&); - ~EGEnergyAnalyzer(); - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - - private: - virtual void beginJob() override ; - virtual void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override ; - - virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; - virtual void endRun(edm::Run const&, edm::EventSetup const&) override; - virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; - virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; - - EGEnergyCorrector corfile; - EGEnergyCorrector cordb; - - // ----------member data --------------------------- +public: + explicit EGEnergyAnalyzer(const edm::ParameterSet&); + ~EGEnergyAnalyzer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + +private: + virtual void beginJob() override ; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; + virtual void endRun(edm::Run const&, edm::EventSetup const&) override; + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + + EGEnergyCorrector corfile; + EGEnergyCorrector cordb; + + edm::EDGetTokenT ebRHToken_, eeRHToken_; }; -// -// constants, enums and typedefs -// - -// -// static data member definitions -// - -// -// constructors and destructor -// -EGEnergyAnalyzer::EGEnergyAnalyzer(const edm::ParameterSet& iConfig) -{ - //now do what ever initialization is needed +EGEnergyAnalyzer::EGEnergyAnalyzer(const edm::ParameterSet& iConfig) { + ebRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEB")); + eeRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEE")); } @@ -121,8 +110,7 @@ EGEnergyAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu Handle hPhotonProduct; iEvent.getByLabel("photons",hPhotonProduct); - EcalClusterLazyTools lazyTools(iEvent, iSetup, edm::InputTag("reducedEcalRecHitsEB"), - edm::InputTag("reducedEcalRecHitsEE")); + EcalClusterLazyTools lazyTools(iEvent, iSetup, ebRHToken_, eeRHToken_); Handle hVertexProduct; iEvent.getByLabel("offlinePrimaryVerticesWithBS", hVertexProduct); diff --git a/RecoEgamma/ElectronIdentification/interface/ElectronIDAlgo.h b/RecoEgamma/ElectronIdentification/interface/ElectronIDAlgo.h index d085158d9327c..6cdc47f91db99 100644 --- a/RecoEgamma/ElectronIdentification/interface/ElectronIDAlgo.h +++ b/RecoEgamma/ElectronIdentification/interface/ElectronIDAlgo.h @@ -26,13 +26,13 @@ class ElectronIDAlgo { virtual ~ElectronIDAlgo(){}; - void baseSetup(const edm::ParameterSet& conf) ; + //void baseSetup(const edm::ParameterSet& conf) ; virtual void setup(const edm::ParameterSet& conf) {}; virtual double result(const reco::GsfElectron*, const edm::Event&, const edm::EventSetup&) {return 0.;}; protected: - EcalClusterLazyTools getClusterShape(const edm::Event&, const edm::EventSetup&); + //EcalClusterLazyTools getClusterShape(const edm::Event&, const edm::EventSetup&); edm::InputTag reducedBarrelRecHitCollection_; edm::InputTag reducedEndcapRecHitCollection_; diff --git a/RecoEgamma/ElectronIdentification/plugins/ElectronIDSelectorLikelihood.cc b/RecoEgamma/ElectronIdentification/plugins/ElectronIDSelectorLikelihood.cc index 7286fe530405a..f3af6923c2905 100644 --- a/RecoEgamma/ElectronIdentification/plugins/ElectronIDSelectorLikelihood.cc +++ b/RecoEgamma/ElectronIdentification/plugins/ElectronIDSelectorLikelihood.cc @@ -31,7 +31,7 @@ double ElectronIDSelectorLikelihood::operator () (const reco::GsfElectron & ele, edm::Handle< EcalRecHitCollection > pEERecHits; e.getByToken( reducedEndcapRecHitCollectionToken_, pEERecHits ); - EcalClusterLazyTools lazyTools( e, es, reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_ ) ; + EcalClusterLazyTools lazyTools( e, es, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_ ) ; return static_cast(likelihoodAlgo_->resultLog (ele,lazyTools)) ; } return 0; diff --git a/RecoEgamma/ElectronIdentification/src/ClassBasedElectronID.cc b/RecoEgamma/ElectronIdentification/src/ClassBasedElectronID.cc index 89d582df69e28..b2c046c800b65 100644 --- a/RecoEgamma/ElectronIdentification/src/ClassBasedElectronID.cc +++ b/RecoEgamma/ElectronIdentification/src/ClassBasedElectronID.cc @@ -7,7 +7,7 @@ void ClassBasedElectronID::setup(const edm::ParameterSet& conf) // Get all the parameters - baseSetup(conf); + //baseSetup(conf); quality_ = conf.getParameter("electronQuality"); diff --git a/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc b/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc index 6408aba52c05e..da2da4c7f7eba 100644 --- a/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc +++ b/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc @@ -11,7 +11,7 @@ void CutBasedElectronID::setup(const edm::ParameterSet& conf) { // Get all the parameters - baseSetup(conf); + //baseSetup(conf); type_ = conf.getParameter("electronIDType"); quality_ = conf.getParameter("electronQuality"); diff --git a/RecoEgamma/ElectronIdentification/src/ElectronIDAlgo.cc b/RecoEgamma/ElectronIdentification/src/ElectronIDAlgo.cc index dfd73583c4133..13231a50c142e 100644 --- a/RecoEgamma/ElectronIdentification/src/ElectronIDAlgo.cc +++ b/RecoEgamma/ElectronIdentification/src/ElectronIDAlgo.cc @@ -2,22 +2,22 @@ #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/EgammaReco/interface/BasicClusterShapeAssociation.h" -void ElectronIDAlgo::baseSetup(const edm::ParameterSet& conf) { - reducedBarrelRecHitCollection_ = conf.getParameter("reducedBarrelRecHitCollection"); - reducedEndcapRecHitCollection_ = conf.getParameter("reducedEndcapRecHitCollection"); -} - -EcalClusterLazyTools ElectronIDAlgo::getClusterShape(const edm::Event& ev, - const edm::EventSetup& es) -{ - - edm::Handle< EcalRecHitCollection > pEBRecHits; - ev.getByLabel( reducedBarrelRecHitCollection_, pEBRecHits ); - - edm::Handle< EcalRecHitCollection > pEERecHits; - ev.getByLabel( reducedEndcapRecHitCollection_, pEERecHits ); - - EcalClusterLazyTools lazyTools( ev, es, reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_ ) ; - return lazyTools ; - -} +//void ElectronIDAlgo::baseSetup(const edm::ParameterSet& conf) { +// reducedBarrelRecHitCollection_ = conf.getParameter("reducedBarrelRecHitCollection"); +// reducedEndcapRecHitCollection_ = conf.getParameter("reducedEndcapRecHitCollection"); +//} +// +//EcalClusterLazyTools ElectronIDAlgo::getClusterShape(const edm::Event& ev, +// const edm::EventSetup& es) +//{ +// +// edm::Handle< EcalRecHitCollection > pEBRecHits; +// ev.getByLabel( reducedBarrelRecHitCollection_, pEBRecHits ); +// +// edm::Handle< EcalRecHitCollection > pEERecHits; +// ev.getByLabel( reducedEndcapRecHitCollection_, pEERecHits ); +// +// EcalClusterLazyTools lazyTools( ev, es, reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_ ) ; +// return lazyTools ; +// +//} diff --git a/RecoEgamma/ElectronIdentification/src/PTDRElectronID.cc b/RecoEgamma/ElectronIdentification/src/PTDRElectronID.cc index c6ab4a84c4ce7..d9fcd5afdb93e 100644 --- a/RecoEgamma/ElectronIdentification/src/PTDRElectronID.cc +++ b/RecoEgamma/ElectronIdentification/src/PTDRElectronID.cc @@ -3,7 +3,7 @@ void PTDRElectronID::setup(const edm::ParameterSet& conf) { // Get all the parameters - baseSetup(conf); + //baseSetup(conf); quality_ = conf.getParameter("electronQuality"); @@ -117,12 +117,12 @@ double PTDRElectronID::result(const reco::GsfElectron* electron, if (value vCov = lazyTools.localCovariances(*(electron->superCluster()->seed())) ; + //EcalClusterLazyTools lazyTools = getClusterShape(e,es); + //std::vector vCov = lazyTools.localCovariances(*(electron->superCluster()->seed())) ; //std::vector vCov = lazyTools.covariances(*(electron->superCluster()->seed())) ; if (useE9overE25_[variables_]) { - double value = lazyTools.e3x3(*(electron->superCluster()->seed()))/lazyTools.e5x5(*(electron->superCluster()->seed())); + double value = electron->r9()*electron->superCluster()->energy()/electron->e5x5(); std::vector mincut = cuts_.getParameter >("E9overE25"); if (fabs(value) maxcut = cuts_.getParameter >("sigmaEtaEtaMax"); std::vector mincut = cuts_.getParameter >("sigmaEtaEtaMin"); - if (sqrt(vCov[0])maxcut[icut]) return 0.; + if (electron->sigmaIetaIeta()sigmaIetaIeta()>maxcut[icut]) return 0.; } if (useSigmaPhiPhi_[variables_]) { std::vector mincut = cuts_.getParameter >("sigmaPhiPhiMin"); std::vector maxcut = cuts_.getParameter >("sigmaPhiPhiMax"); - if (sqrt(vCov[1])maxcut[icut]) return 0.; + if (electron->sigmaIphiIphi()sigmaIphiIphi()>maxcut[icut]) return 0.; } return 1.; diff --git a/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc b/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc index 97db36ef44b6b..753737a2974c0 100644 --- a/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc +++ b/RecoHI/HiEgammaAlgos/plugins/HiSpikeCleaner.cc @@ -47,40 +47,27 @@ // class HiSpikeCleaner : public edm::EDProducer { - public: - explicit HiSpikeCleaner(const edm::ParameterSet&); - ~HiSpikeCleaner(); - - private: - virtual void beginJob() override ; - virtual void produce(edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override ; - - // ----------member data --------------------------- - - edm::InputTag sCInputProducer_; - edm::InputTag rHInputProducerB_; - edm::InputTag rHInputProducerE_; - - std::string outputCollection_; - double TimingCut_; - double swissCutThr_; - double etCut_; - +public: + explicit HiSpikeCleaner(const edm::ParameterSet&); + ~HiSpikeCleaner(); + +private: + virtual void beginJob() override ; + virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override ; + + // ----------member data --------------------------- + + edm::EDGetTokenT sCInputProducerToken_; + edm::EDGetTokenT rHInputProducerBToken_; + edm::EDGetTokenT rHInputProducerEToken_; + + std::string outputCollection_; + double TimingCut_; + double swissCutThr_; + double etCut_; }; -// -// constants, enums and typedefs -// - - -// -// static data member definitions -// - -// -// constructors and destructor -// HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) { //register your products @@ -92,19 +79,16 @@ HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) */ //now do what ever other initialization is needed - rHInputProducerB_ = iConfig.getParameter("recHitProducerBarrel"); - rHInputProducerE_ = iConfig.getParameter("recHitProducerEndcap"); - - sCInputProducer_ = iConfig.getParameter("originalSuperClusterProducer"); - TimingCut_ = iConfig.getUntrackedParameter ("TimingCut",4.0); - swissCutThr_ = iConfig.getUntrackedParameter("swissCutThr",0.95); - etCut_ = iConfig.getParameter("etCut"); - - outputCollection_ = iConfig.getParameter("outputColl"); - produces(outputCollection_); - - - + rHInputProducerBToken_ = consumes(iConfig.getParameter("recHitProducerBarrel")); + rHInputProducerEToken_ = consumes(iConfig.getParameter("recHitProducerEndcap")); + + sCInputProducerToken_ = consumes(iConfig.getParameter("originalSuperClusterProducer")); + TimingCut_ = iConfig.getUntrackedParameter ("TimingCut",4.0); + swissCutThr_ = iConfig.getUntrackedParameter("swissCutThr",0.95); + etCut_ = iConfig.getParameter("etCut"); + + outputCollection_ = iConfig.getParameter("outputColl"); + produces(outputCollection_); } @@ -125,34 +109,31 @@ HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; - // Get raw SuperClusters from the event Handle pRawSuperClusters; try { - iEvent.getByLabel(sCInputProducer_, pRawSuperClusters); + iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters); } catch ( cms::Exception& ex ) { - edm::LogError("EgammaSCCorrectionMakerError") - << "Error! can't get the rawSuperClusters " - << sCInputProducer_.label() ; + edm::LogError("EgammaSCCorrectionMakerError") + << "Error! can't get the rawSuperClusters "; } // Get the RecHits from the event Handle pRecHitsB; try { - iEvent.getByLabel(rHInputProducerB_, pRecHitsB); + iEvent.getByToken(rHInputProducerBToken_, pRecHitsB); } catch ( cms::Exception& ex ) { - edm::LogError("EgammaSCCorrectionMakerError") - << "Error! can't get the RecHits " - << rHInputProducerB_.label(); + edm::LogError("EgammaSCCorrectionMakerError") + << "Error! can't get the RecHits "; } + // Get the RecHits from the event Handle pRecHitsE; try { - iEvent.getByLabel(rHInputProducerE_, pRecHitsE); + iEvent.getByToken(rHInputProducerEToken_, pRecHitsE); } catch ( cms::Exception& ex ) { - edm::LogError("EgammaSCCorrectionMakerError") - << "Error! can't get the RecHits " - << rHInputProducerE_.label(); + edm::LogError("EgammaSCCorrectionMakerError") + << "Error! can't get the RecHits "; } @@ -168,7 +149,7 @@ HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product(); - EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerB_,rHInputProducerE_); + EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerBToken_,rHInputProducerEToken_); // Define a collection of corrected SuperClusters to put back into the event std::auto_ptr corrClusters(new reco::SuperClusterCollection); diff --git a/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.cc b/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.cc index d32cae4ced4bd..95988730c080d 100644 --- a/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.cc +++ b/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.cc @@ -155,6 +155,9 @@ MCEmbeddingValidationAnalyzer::MCEmbeddingValidationAnalyzer(const edm::Paramete setupMEtL1TriggerEfficiency(jetBin->first, jetBin->second, cfg, "metL1TriggerEfficiencies", metL1TriggerEfficiencies_); } + ebRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEB")); + eeRHToken_ = consumes(edm::InputTag("reducedEcalRecHitsEE")); + verbosity_ = ( cfg.exists("verbosity") ) ? cfg.getParameter("verbosity") : 0; } @@ -243,7 +246,7 @@ void MCEmbeddingValidationAnalyzer::setupElectronDistributionExtra(int minJets, double dRmatch = cfgLeptonDistribution->exists("dRmatch") ? cfgLeptonDistribution->getParameter("dRmatch") : 0.3; std::string dqmDirectory = dqmDirectory_full(cfgLeptonDistribution->getParameter("dqmDirectory")); - electronDistributionExtra* electronDistribution = new electronDistributionExtra(minJets, maxJets, srcGen, cutGen, srcRec, cutRec, dRmatch, dqmDirectory, srcTheRecVertex_); + electronDistributionExtra* electronDistribution = new electronDistributionExtra(minJets, maxJets, srcGen, cutGen, srcRec, cutRec, dRmatch, dqmDirectory, srcTheRecVertex_, ebRHToken_, eeRHToken_); electronDistributionsExtra.push_back(electronDistribution); } } diff --git a/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.h b/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.h index 0900bbe3d7981..bb59085776e7b 100644 --- a/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.h +++ b/TauAnalysis/MCEmbeddingTools/plugins/MCEmbeddingValidationAnalyzer.h @@ -245,6 +245,8 @@ class MCEmbeddingValidationAnalyzer : public edm::EDAnalyzer vInputTag srcOtherWeights_; edm::InputTag srcGenFilterInfo_; + edm::EDGetTokenT ebRHToken_, eeRHToken_; + std::string dqmDirectory_; MonitorElement* histogramEventCounter_; @@ -737,16 +739,20 @@ class MCEmbeddingValidationAnalyzer : public edm::EDAnalyzer struct electronDistributionExtra { electronDistributionExtra(int minJets, int maxJets, - const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec, double dRmatch, const std::string& dqmDirectory, - const edm::InputTag& srcTheRecVertex) - : minJets_(minJets), - maxJets_(maxJets), - srcGen_(srcGen), - cutGen_(0), - srcRec_(srcRec), - cutRec_(0), - dRmatch_(dRmatch), - srcTheRecVertex_(srcTheRecVertex) + const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec, + double dRmatch, const std::string& dqmDirectory, + const edm::InputTag& srcTheRecVertex, + edm::EDGetTokenT tk1, edm::EDGetTokenT tk2) + : minJets_(minJets), + maxJets_(maxJets), + srcGen_(srcGen), + cutGen_(0), + srcRec_(srcRec), + cutRec_(0), + dRmatch_(dRmatch), + srcTheRecVertex_(srcTheRecVertex), + ebRHToken_(tk1), + eeRHToken_(tk2) { if ( cutGen != "" ) cutGen_ = new StringCutObjectSelector(cutGen); if ( cutRec != "" ) cutRec_ = new StringCutObjectSelector(cutRec); @@ -853,7 +859,7 @@ class MCEmbeddingValidationAnalyzer : public edm::EDAnalyzer if ( !trackBuilder ) throw cms::Exception("MCEmbeddingValidationAnalyzer") << " Failed to access TransientTrackBuilder !!\n"; - EcalClusterLazyTools myEcalCluster(evt, es, edm::InputTag("reducedEcalRecHitsEB"), edm::InputTag("reducedEcalRecHitsEE")); + EcalClusterLazyTools myEcalCluster(evt, es, ebRHToken_, eeRHToken_); /*double mva = fMVA_->mvaValue(*recLepton, theVertex->front(), *trackBuilder, myEcalCluster); if ( recLepton->pt() < 20. ) { if ( TMath::Abs(recLepton->eta()) < 0.8 ) histogramMVAptLt20AbsEtaLt0_8_->Fill(mva, evtWeight); @@ -917,6 +923,7 @@ class MCEmbeddingValidationAnalyzer : public edm::EDAnalyzer /*static EGammaMvaEleEstimator* fMVA_; static bool fMVA_isInitialized_;*/ edm::InputTag srcTheRecVertex_; + edm::EDGetTokenT ebRHToken_, eeRHToken_; MonitorElement* histogramMVAptLt20AbsEtaLt0_8_; MonitorElement* histogramMVAptLt20AbsEta0_8to1_479_; MonitorElement* histogramMVAptLt20AbsEtaGt1_479_; diff --git a/Validation/EcalClusters/interface/EgammaSuperClusters.h b/Validation/EcalClusters/interface/EgammaSuperClusters.h index 6e1dc65e0b0fa..baa4bd602a44e 100644 --- a/Validation/EcalClusters/interface/EgammaSuperClusters.h +++ b/Validation/EcalClusters/interface/EgammaSuperClusters.h @@ -23,39 +23,40 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" +#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" class EgammaSuperClusters : public edm::EDAnalyzer { - public: - explicit EgammaSuperClusters( const edm::ParameterSet& ); - ~EgammaSuperClusters(); - - virtual void analyze( const edm::Event&, const edm::EventSetup& ); - virtual void beginJob(); - virtual void endJob(); - - private: - std::string outputFile_; - //std::string CMSSW_Version_; - - bool verboseDBE_; - DQMStore* dbe_; - - // mc truth - edm::InputTag MCTruthCollection_; - - // barrel clusters - edm::InputTag barrelRawSuperClusterCollection_; - edm::InputTag barrelCorSuperClusterCollection_; - - // endcap clusters - edm::InputTag endcapRawSuperClusterCollection_; - edm::InputTag endcapPreSuperClusterCollection_; - edm::InputTag endcapCorSuperClusterCollection_; - - // collections of hits - edm::InputTag barrelRecHitCollection_; - edm::InputTag endcapRecHitCollection_; + public: + explicit EgammaSuperClusters( const edm::ParameterSet& ); + ~EgammaSuperClusters(); + + virtual void analyze( const edm::Event&, const edm::EventSetup& ); + virtual void beginJob(); + virtual void endJob(); + + private: + std::string outputFile_; + //std::string CMSSW_Version_; + + bool verboseDBE_; + DQMStore* dbe_; + + // mc truth + edm::EDGetTokenT MCTruthCollectionToken_; + + // barrel clusters + edm::EDGetTokenT barrelRawSuperClusterCollectionToken_; + edm::EDGetTokenT barrelCorSuperClusterCollectionToken_; + + // endcap clusters + edm::EDGetTokenT endcapRawSuperClusterCollectionToken_; + edm::EDGetTokenT endcapPreSuperClusterCollectionToken_; + edm::EDGetTokenT endcapCorSuperClusterCollectionToken_; + + // collections of hits + edm::EDGetTokenT barrelRecHitCollectionToken_; + edm::EDGetTokenT endcapRecHitCollectionToken_; MonitorElement* hist_EB_RawSC_Size_; MonitorElement* hist_EE_RawSC_Size_; diff --git a/Validation/EcalClusters/src/EgammaSuperClusters.cc b/Validation/EcalClusters/src/EgammaSuperClusters.cc index e807708308cfc..2c0736fece811 100644 --- a/Validation/EcalClusters/src/EgammaSuperClusters.cc +++ b/Validation/EcalClusters/src/EgammaSuperClusters.cc @@ -7,7 +7,6 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" -#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "DataFormats/Math/interface/deltaPhi.h" @@ -16,605 +15,599 @@ EgammaSuperClusters::EgammaSuperClusters( const edm::ParameterSet& ps ) { - outputFile_ = ps.getUntrackedParameter("outputFile", ""); - //CMSSW_Version_ = ps.getUntrackedParameter("CMSSW_Version", ""); - - verboseDBE_ = ps.getUntrackedParameter("verboseDBE", false); - - hist_min_Size_ = ps.getParameter("hist_min_Size"); - hist_max_Size_ = ps.getParameter("hist_max_Size"); - hist_bins_Size_ = ps.getParameter ("hist_bins_Size"); - - hist_min_NumBC_ = ps.getParameter("hist_min_NumBC"); - hist_max_NumBC_ = ps.getParameter("hist_max_NumBC"); - hist_bins_NumBC_ = ps.getParameter ("hist_bins_NumBC"); - - hist_min_ET_ = ps.getParameter("hist_min_ET"); - hist_max_ET_ = ps.getParameter("hist_max_ET"); - hist_bins_ET_ = ps.getParameter ("hist_bins_ET"); - - hist_min_Eta_ = ps.getParameter("hist_min_Eta"); - hist_max_Eta_ = ps.getParameter("hist_max_Eta"); - hist_bins_Eta_ = ps.getParameter ("hist_bins_Eta"); - - hist_min_Phi_ = ps.getParameter("hist_min_Phi"); - hist_max_Phi_ = ps.getParameter("hist_max_Phi"); - hist_bins_Phi_ = ps.getParameter ("hist_bins_Phi"); - - hist_min_S1toS9_ = ps.getParameter("hist_min_S1toS9"); - hist_max_S1toS9_ = ps.getParameter("hist_max_S1toS9"); - hist_bins_S1toS9_ = ps.getParameter ("hist_bins_S1toS9"); - - hist_min_S25toE_ = ps.getParameter("hist_min_S25toE"); - hist_max_S25toE_ = ps.getParameter("hist_max_S25toE"); - hist_bins_S25toE_ = ps.getParameter ("hist_bins_S25toE"); - - hist_min_EoverTruth_ = ps.getParameter("hist_min_EoverTruth"); - hist_max_EoverTruth_ = ps.getParameter("hist_max_EoverTruth"); - hist_bins_EoverTruth_ = ps.getParameter ("hist_bins_EoverTruth"); - - hist_min_deltaR_ = ps.getParameter("hist_min_deltaR"); - hist_max_deltaR_ = ps.getParameter("hist_max_deltaR"); - hist_bins_deltaR_ = ps.getParameter ("hist_bins_deltaR"); - - hist_min_phiWidth_ = ps.getParameter("hist_min_phiWidth"); - hist_max_phiWidth_ = ps.getParameter("hist_max_phiWidth"); - hist_bins_phiWidth_ = ps.getParameter("hist_bins_phiWidth"); - - hist_min_etaWidth_ = ps.getParameter("hist_min_etaWidth"); - hist_max_etaWidth_ = ps.getParameter("hist_max_etaWidth"); - hist_bins_etaWidth_ = ps.getParameter("hist_bins_etaWidth"); - - hist_bins_preshowerE_ = ps.getParameter("hist_bins_preshowerE"); - hist_min_preshowerE_ = ps.getParameter("hist_min_preshowerE"); - hist_max_preshowerE_ = ps.getParameter("hist_max_preshowerE"); - - hist_min_R_ = ps.getParameter("hist_min_R"); - hist_max_R_ = ps.getParameter("hist_max_R"); - hist_bins_R_ = ps.getParameter ("hist_bins_R"); - - MCTruthCollection_ = ps.getParameter("MCTruthCollection"); - - barrelRawSuperClusterCollection_ = ps.getParameter("barrelRawSuperClusterCollection"); - barrelCorSuperClusterCollection_ = ps.getParameter("barrelCorSuperClusterCollection"); - - endcapRawSuperClusterCollection_ = ps.getParameter("endcapRawSuperClusterCollection"); - endcapPreSuperClusterCollection_ = ps.getParameter("endcapPreSuperClusterCollection"); - endcapCorSuperClusterCollection_ = ps.getParameter("endcapCorSuperClusterCollection"); - - barrelRecHitCollection_ = ps.getParameter("barrelRecHitCollection"); - endcapRecHitCollection_ = ps.getParameter("endcapRecHitCollection"); + outputFile_ = ps.getUntrackedParameter("outputFile", ""); + //CMSSW_Version_ = ps.getUntrackedParameter("CMSSW_Version", ""); + + verboseDBE_ = ps.getUntrackedParameter("verboseDBE", false); + + hist_min_Size_ = ps.getParameter("hist_min_Size"); + hist_max_Size_ = ps.getParameter("hist_max_Size"); + hist_bins_Size_ = ps.getParameter ("hist_bins_Size"); + + hist_min_NumBC_ = ps.getParameter("hist_min_NumBC"); + hist_max_NumBC_ = ps.getParameter("hist_max_NumBC"); + hist_bins_NumBC_ = ps.getParameter ("hist_bins_NumBC"); + + hist_min_ET_ = ps.getParameter("hist_min_ET"); + hist_max_ET_ = ps.getParameter("hist_max_ET"); + hist_bins_ET_ = ps.getParameter ("hist_bins_ET"); + + hist_min_Eta_ = ps.getParameter("hist_min_Eta"); + hist_max_Eta_ = ps.getParameter("hist_max_Eta"); + hist_bins_Eta_ = ps.getParameter ("hist_bins_Eta"); + + hist_min_Phi_ = ps.getParameter("hist_min_Phi"); + hist_max_Phi_ = ps.getParameter("hist_max_Phi"); + hist_bins_Phi_ = ps.getParameter ("hist_bins_Phi"); + + hist_min_S1toS9_ = ps.getParameter("hist_min_S1toS9"); + hist_max_S1toS9_ = ps.getParameter("hist_max_S1toS9"); + hist_bins_S1toS9_ = ps.getParameter ("hist_bins_S1toS9"); + + hist_min_S25toE_ = ps.getParameter("hist_min_S25toE"); + hist_max_S25toE_ = ps.getParameter("hist_max_S25toE"); + hist_bins_S25toE_ = ps.getParameter ("hist_bins_S25toE"); + + hist_min_EoverTruth_ = ps.getParameter("hist_min_EoverTruth"); + hist_max_EoverTruth_ = ps.getParameter("hist_max_EoverTruth"); + hist_bins_EoverTruth_ = ps.getParameter ("hist_bins_EoverTruth"); + + hist_min_deltaR_ = ps.getParameter("hist_min_deltaR"); + hist_max_deltaR_ = ps.getParameter("hist_max_deltaR"); + hist_bins_deltaR_ = ps.getParameter ("hist_bins_deltaR"); + + hist_min_phiWidth_ = ps.getParameter("hist_min_phiWidth"); + hist_max_phiWidth_ = ps.getParameter("hist_max_phiWidth"); + hist_bins_phiWidth_ = ps.getParameter("hist_bins_phiWidth"); + + hist_min_etaWidth_ = ps.getParameter("hist_min_etaWidth"); + hist_max_etaWidth_ = ps.getParameter("hist_max_etaWidth"); + hist_bins_etaWidth_ = ps.getParameter("hist_bins_etaWidth"); + + hist_bins_preshowerE_ = ps.getParameter("hist_bins_preshowerE"); + hist_min_preshowerE_ = ps.getParameter("hist_min_preshowerE"); + hist_max_preshowerE_ = ps.getParameter("hist_max_preshowerE"); + + hist_min_R_ = ps.getParameter("hist_min_R"); + hist_max_R_ = ps.getParameter("hist_max_R"); + hist_bins_R_ = ps.getParameter ("hist_bins_R"); + + MCTruthCollectionToken_ = consumes(ps.getParameter("MCTruthCollection")); + + barrelRawSuperClusterCollectionToken_ = consumes(ps.getParameter("barrelRawSuperClusterCollection")); + barrelCorSuperClusterCollectionToken_ = consumes(ps.getParameter("barrelCorSuperClusterCollection")); + endcapRawSuperClusterCollectionToken_ = consumes(ps.getParameter("endcapRawSuperClusterCollection")); + + endcapPreSuperClusterCollectionToken_ = consumes(ps.getParameter("endcapPreSuperClusterCollection")); + endcapCorSuperClusterCollectionToken_ = consumes(ps.getParameter("endcapCorSuperClusterCollection")); + + barrelRecHitCollectionToken_ = consumes(ps.getParameter("barrelRecHitCollection")); + endcapRecHitCollectionToken_ = consumes(ps.getParameter("endcapRecHitCollection")); } EgammaSuperClusters::~EgammaSuperClusters() {} void EgammaSuperClusters::beginJob() { - dbe_ = edm::Service().operator->(); - - if ( verboseDBE_ ) - { - dbe_->setVerbose(1); - dbe_->showDirStructure(); - } - else - dbe_->setVerbose(0); - - //dbe_->setCurrentFolder("Ecal/CMSSW_"+CMSSW_Version_+"/EcalClusters/SuperClusters/"); - dbe_->setCurrentFolder("EcalClusterV/EcalSuperClusters/"); - - // Number of SuperClusters - // - hist_EB_RawSC_Size_ - = dbe_->book1D("hist_EB_RawSC_Size_","# Raw SuperClusters in Barrel", - hist_bins_Size_,hist_min_Size_,hist_max_Size_); - hist_EE_RawSC_Size_ - = dbe_->book1D("hist_EE_RawSC_Size_","# Raw SuperClusters in Endcap", - hist_bins_Size_,hist_min_Size_,hist_max_Size_); - hist_EB_CorSC_Size_ - = dbe_->book1D("hist_EB_CorSC_Size_","# Corrected SuperClusters in Barrel", - hist_bins_Size_,hist_min_Size_,hist_max_Size_); - hist_EE_CorSC_Size_ - = dbe_->book1D("hist_EE_CorSC_Size_","# Corrected SuperClusters in Endcap", - hist_bins_Size_,hist_min_Size_,hist_max_Size_); - hist_EE_PreSC_Size_ - = dbe_->book1D("hist_EE_PreSC_Size_","# SuperClusters with Preshower in Endcap", - hist_bins_Size_,hist_min_Size_,hist_max_Size_); - - // Number of BasicClusters in SuperCluster - // - hist_EB_RawSC_NumBC_ - = dbe_->book1D("hist_EB_RawSC_NumBC_","# of Basic Clusters in Raw Super Clusters in Barrel", - hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); - hist_EE_RawSC_NumBC_ - = dbe_->book1D("hist_EE_RawSC_NumBC_","# of Basic Clusters in Raw Super Clusters in Endcap", - hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); - hist_EB_CorSC_NumBC_ - = dbe_->book1D("hist_EB_CorSC_NumBC_","# of Basic Clusters in Corrected SuperClusters in Barrel", - hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); - hist_EE_CorSC_NumBC_ - = dbe_->book1D("hist_EE_CorSC_NumBC_","# of Basic Clusters in Corrected SuperClusters in Endcap", - hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); - hist_EE_PreSC_NumBC_ - = dbe_->book1D("hist_EE_PreSC_NumBC_","# of Basic Clusters in SuperClusters with Preshower in Endcap", - hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); - - // ET distribution of SuperClusters - // - hist_EB_RawSC_ET_ - = dbe_->book1D("hist_EB_RawSC_ET_","ET of Raw SuperClusters in Barrel", - hist_bins_ET_,hist_min_ET_,hist_max_ET_); - hist_EE_RawSC_ET_ - = dbe_->book1D("hist_EE_RawSC_ET_","ET of Raw SuperClusters in Endcap", - hist_bins_ET_,hist_min_ET_,hist_max_ET_); - hist_EB_CorSC_ET_ - = dbe_->book1D("hist_EB_CorSC_ET_","ET of Corrected SuperClusters in Barrel", - hist_bins_ET_,hist_min_ET_,hist_max_ET_); - hist_EE_CorSC_ET_ - = dbe_->book1D("hist_EE_CorSC_ET_","ET of Corrected SuperClusters in Endcap", - hist_bins_ET_,hist_min_ET_,hist_max_ET_); - hist_EE_PreSC_ET_ - = dbe_->book1D("hist_EE_PreSC_ET_","ET of SuperClusters with Preshower in Endcap", - hist_bins_ET_,hist_min_ET_,hist_max_ET_); - - // Eta distribution of SuperClusters - // - hist_EB_RawSC_Eta_ - = dbe_->book1D("hist_EB_RawSC_Eta_","Eta of Raw SuperClusters in Barrel", - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); - hist_EE_RawSC_Eta_ - = dbe_->book1D("hist_EE_RawSC_Eta_","Eta of Raw SuperClusters in Endcap", - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); - hist_EB_CorSC_Eta_ - = dbe_->book1D("hist_EB_CorSC_Eta_","Eta of Corrected SuperClusters in Barrel", - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); - hist_EE_CorSC_Eta_ - = dbe_->book1D("hist_EE_CorSC_Eta_","Eta of Corrected SuperClusters in Endcap", - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); - hist_EE_PreSC_Eta_ - = dbe_->book1D("hist_EE_PreSC_Eta_","Eta of SuperClusters with Preshower in Endcap", - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); - - // Phi distribution of SuperClusters - // - hist_EB_RawSC_Phi_ - = dbe_->book1D("hist_EB_RawSC_Phi_","Phi of Raw SuperClusters in Barrel", - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); - hist_EE_RawSC_Phi_ - = dbe_->book1D("hist_EE_RawSC_Phi_","Phi of Raw SuperClusters in Endcap", - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); - hist_EB_CorSC_Phi_ - = dbe_->book1D("hist_EB_CorSC_Phi_","Phi of Corrected SuperClusters in Barrel", - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); - hist_EE_CorSC_Phi_ - = dbe_->book1D("hist_EE_CorSC_Phi_","Phi of Corrected SuperClusters in Endcap", - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); - hist_EE_PreSC_Phi_ - = dbe_->book1D("hist_EE_PreSC_Phi_","Phi of SuperClusters with Preshower in Endcap", - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); - - // S1/S9 distribution of SuperClusters - // - hist_EB_RawSC_S1toS9_ - = dbe_->book1D("hist_EB_RawSC_S1toS9_","S1/S9 of Raw Super Clusters in Barrel", - hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); - hist_EE_RawSC_S1toS9_ - = dbe_->book1D("hist_EE_RawSC_S1toS9_","S1/S9 of Raw Super Clusters in Endcap", - hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); - hist_EB_CorSC_S1toS9_ - = dbe_->book1D("hist_EB_CorSC_S1toS9_","S1/S9 of Corrected SuperClusters in Barrel", - hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); - hist_EE_CorSC_S1toS9_ - = dbe_->book1D("hist_EE_CorSC_S1toS9_","S1/S9 of Corrected SuperClusters in Endcap", - hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); - hist_EE_PreSC_S1toS9_ - = dbe_->book1D("hist_EE_PreSC_S1toS9_","S1/S9 of SuperClusters with Preshower in Endcap", - hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); - - // S25/E distribution of SuperClusters - // - hist_EB_RawSC_S25toE_ - = dbe_->book1D("hist_EB_RawSC_S25toE_","S25/E of Raw Super Clusters in Barrel", - hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); - hist_EE_RawSC_S25toE_ - = dbe_->book1D("hist_EE_RawSC_S25toE_","S25/E of Raw Super Clusters in Endcap", - hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); - hist_EB_CorSC_S25toE_ - = dbe_->book1D("hist_EB_CorSC_S25toE_","S25/E of Corrected SuperClusters in Barrel", - hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); - hist_EE_CorSC_S25toE_ - = dbe_->book1D("hist_EE_CorSC_S25toE_","S25/E of Corrected SuperClusters in Endcap", - hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); - hist_EE_PreSC_S25toE_ - = dbe_->book1D("hist_EE_PreSC_S25toE_","S25/E of SuperClusters with Preshower in Endcap", - hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); - - // E/E(true) distribution of SuperClusters - // - hist_EB_RawSC_EoverTruth_ - = dbe_->book1D("hist_EB_RawSC_EoverTruth_","E/True E of Raw SuperClusters in Barrel", - hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); - hist_EE_RawSC_EoverTruth_ - = dbe_->book1D("hist_EE_RawSC_EoverTruth_","E/True E of Raw SuperClusters in Endcap", - hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); - hist_EB_CorSC_EoverTruth_ - = dbe_->book1D("hist_EB_CorSC_EoverTruth_","E/True E of Corrected SuperClusters in Barrel", - hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); - hist_EE_CorSC_EoverTruth_ - = dbe_->book1D("hist_EE_CorSC_EoverTruth_","E/True E of Corrected SuperClusters in Endcap", - hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); - hist_EE_PreSC_EoverTruth_ - = dbe_->book1D("hist_EE_PreSC_EoverTruth_","E/True E of SuperClusters with Preshower in Endcap", - hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); - - // dR distribution of SuperClusters from truth - // - hist_EB_RawSC_deltaR_ - = dbe_->book1D("hist_EB_RawSC_deltaR_","dR to MC truth of Raw Super Clusters in Barrel", - hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); - hist_EE_RawSC_deltaR_ - = dbe_->book1D("hist_EE_RawSC_deltaR_","dR to MC truth of Raw Super Clusters in Endcap", - hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); - hist_EB_CorSC_deltaR_ - = dbe_->book1D("hist_EB_CorSC_deltaR_","dR to MC truth of Corrected SuperClusters in Barrel", - hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); - hist_EE_CorSC_deltaR_ - = dbe_->book1D("hist_EE_CorSC_deltaR_","dR to MC truth of Corrected SuperClusters in Endcap", - hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); - hist_EE_PreSC_deltaR_ - = dbe_->book1D("hist_EE_PreSC_deltaR_","dR to MC truth of SuperClusters with Preshower in Endcap", - hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); - - // phi width stored in corrected SuperClusters - hist_EB_CorSC_phiWidth_ - = dbe_->book1D("hist_EB_CorSC_phiWidth_","phiWidth of Corrected Super Clusters in Barrel", - hist_bins_phiWidth_,hist_min_phiWidth_,hist_max_phiWidth_); - hist_EE_CorSC_phiWidth_ - = dbe_->book1D("hist_EE_CorSC_phiWidth_","phiWidth of Corrected Super Clusters in Endcap", - hist_bins_phiWidth_,hist_min_phiWidth_,hist_max_phiWidth_); - - // eta width stored in corrected SuperClusters - hist_EB_CorSC_etaWidth_ - = dbe_->book1D("hist_EB_CorSC_etaWidth_","etaWidth of Corrected Super Clusters in Barrel", - hist_bins_etaWidth_,hist_min_etaWidth_,hist_max_etaWidth_); - hist_EE_CorSC_etaWidth_ - = dbe_->book1D("hist_EE_CorSC_etaWidth_","etaWidth of Corrected Super Clusters in Endcap", - hist_bins_etaWidth_,hist_min_etaWidth_,hist_max_etaWidth_); - - - // preshower energy - hist_EE_PreSC_preshowerE_ - = dbe_->book1D("hist_EE_PreSC_preshowerE_","preshower energy in Super Clusters with Preshower in Endcap", - hist_bins_preshowerE_,hist_min_preshowerE_,hist_max_preshowerE_); - hist_EE_CorSC_preshowerE_ - = dbe_->book1D("hist_EE_CorSC_preshowerE_","preshower energy in Corrected Super Clusters with Preshower in Endcap", - hist_bins_preshowerE_,hist_min_preshowerE_,hist_max_preshowerE_); - - - // - hist_EB_CorSC_ET_vs_Eta_ = dbe_->book2D( "hist_EB_CorSC_ET_vs_Eta_", "Corr Super Cluster ET versus Eta in Barrel", - hist_bins_ET_, hist_min_ET_, hist_max_ET_, - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ ); - - hist_EB_CorSC_ET_vs_Phi_ = dbe_->book2D( "hist_EB_CorSC_ET_vs_Phi_", "Corr Super Cluster ET versus Phi in Barrel", - hist_bins_ET_, hist_min_ET_, hist_max_ET_, - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ ); - - hist_EE_CorSC_ET_vs_Eta_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_Eta_", "Corr Super Cluster ET versus Eta in Endcap", - hist_bins_ET_, hist_min_ET_, hist_max_ET_, - hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ ); - - hist_EE_CorSC_ET_vs_Phi_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_Phi_", "Corr Super Cluster ET versus Phi in Endcap", - hist_bins_ET_, hist_min_ET_, hist_max_ET_, - hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ ); - - hist_EE_CorSC_ET_vs_R_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_R_", "Corr Super Cluster ET versus Radius in Endcap", - hist_bins_ET_, hist_min_ET_, hist_max_ET_, - hist_bins_R_,hist_min_R_,hist_max_R_ ); - - + dbe_ = edm::Service().operator->(); + + if ( verboseDBE_ ) + { + dbe_->setVerbose(1); + dbe_->showDirStructure(); + } + else + dbe_->setVerbose(0); + + //dbe_->setCurrentFolder("Ecal/CMSSW_"+CMSSW_Version_+"/EcalClusters/SuperClusters/"); + dbe_->setCurrentFolder("EcalClusterV/EcalSuperClusters/"); + + // Number of SuperClusters + // + hist_EB_RawSC_Size_ + = dbe_->book1D("hist_EB_RawSC_Size_","# Raw SuperClusters in Barrel", + hist_bins_Size_,hist_min_Size_,hist_max_Size_); + hist_EE_RawSC_Size_ + = dbe_->book1D("hist_EE_RawSC_Size_","# Raw SuperClusters in Endcap", + hist_bins_Size_,hist_min_Size_,hist_max_Size_); + hist_EB_CorSC_Size_ + = dbe_->book1D("hist_EB_CorSC_Size_","# Corrected SuperClusters in Barrel", + hist_bins_Size_,hist_min_Size_,hist_max_Size_); + hist_EE_CorSC_Size_ + = dbe_->book1D("hist_EE_CorSC_Size_","# Corrected SuperClusters in Endcap", + hist_bins_Size_,hist_min_Size_,hist_max_Size_); + hist_EE_PreSC_Size_ + = dbe_->book1D("hist_EE_PreSC_Size_","# SuperClusters with Preshower in Endcap", + hist_bins_Size_,hist_min_Size_,hist_max_Size_); + + // Number of BasicClusters in SuperCluster + // + hist_EB_RawSC_NumBC_ + = dbe_->book1D("hist_EB_RawSC_NumBC_","# of Basic Clusters in Raw Super Clusters in Barrel", + hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); + hist_EE_RawSC_NumBC_ + = dbe_->book1D("hist_EE_RawSC_NumBC_","# of Basic Clusters in Raw Super Clusters in Endcap", + hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); + hist_EB_CorSC_NumBC_ + = dbe_->book1D("hist_EB_CorSC_NumBC_","# of Basic Clusters in Corrected SuperClusters in Barrel", + hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); + hist_EE_CorSC_NumBC_ + = dbe_->book1D("hist_EE_CorSC_NumBC_","# of Basic Clusters in Corrected SuperClusters in Endcap", + hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); + hist_EE_PreSC_NumBC_ + = dbe_->book1D("hist_EE_PreSC_NumBC_","# of Basic Clusters in SuperClusters with Preshower in Endcap", + hist_bins_NumBC_,hist_min_NumBC_,hist_max_NumBC_); + + // ET distribution of SuperClusters + // + hist_EB_RawSC_ET_ + = dbe_->book1D("hist_EB_RawSC_ET_","ET of Raw SuperClusters in Barrel", + hist_bins_ET_,hist_min_ET_,hist_max_ET_); + hist_EE_RawSC_ET_ + = dbe_->book1D("hist_EE_RawSC_ET_","ET of Raw SuperClusters in Endcap", + hist_bins_ET_,hist_min_ET_,hist_max_ET_); + hist_EB_CorSC_ET_ + = dbe_->book1D("hist_EB_CorSC_ET_","ET of Corrected SuperClusters in Barrel", + hist_bins_ET_,hist_min_ET_,hist_max_ET_); + hist_EE_CorSC_ET_ + = dbe_->book1D("hist_EE_CorSC_ET_","ET of Corrected SuperClusters in Endcap", + hist_bins_ET_,hist_min_ET_,hist_max_ET_); + hist_EE_PreSC_ET_ + = dbe_->book1D("hist_EE_PreSC_ET_","ET of SuperClusters with Preshower in Endcap", + hist_bins_ET_,hist_min_ET_,hist_max_ET_); + + // Eta distribution of SuperClusters + // + hist_EB_RawSC_Eta_ + = dbe_->book1D("hist_EB_RawSC_Eta_","Eta of Raw SuperClusters in Barrel", + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); + hist_EE_RawSC_Eta_ + = dbe_->book1D("hist_EE_RawSC_Eta_","Eta of Raw SuperClusters in Endcap", + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); + hist_EB_CorSC_Eta_ + = dbe_->book1D("hist_EB_CorSC_Eta_","Eta of Corrected SuperClusters in Barrel", + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); + hist_EE_CorSC_Eta_ + = dbe_->book1D("hist_EE_CorSC_Eta_","Eta of Corrected SuperClusters in Endcap", + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); + hist_EE_PreSC_Eta_ + = dbe_->book1D("hist_EE_PreSC_Eta_","Eta of SuperClusters with Preshower in Endcap", + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_); + + // Phi distribution of SuperClusters + // + hist_EB_RawSC_Phi_ + = dbe_->book1D("hist_EB_RawSC_Phi_","Phi of Raw SuperClusters in Barrel", + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); + hist_EE_RawSC_Phi_ + = dbe_->book1D("hist_EE_RawSC_Phi_","Phi of Raw SuperClusters in Endcap", + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); + hist_EB_CorSC_Phi_ + = dbe_->book1D("hist_EB_CorSC_Phi_","Phi of Corrected SuperClusters in Barrel", + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); + hist_EE_CorSC_Phi_ + = dbe_->book1D("hist_EE_CorSC_Phi_","Phi of Corrected SuperClusters in Endcap", + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); + hist_EE_PreSC_Phi_ + = dbe_->book1D("hist_EE_PreSC_Phi_","Phi of SuperClusters with Preshower in Endcap", + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_); + + // S1/S9 distribution of SuperClusters + // + hist_EB_RawSC_S1toS9_ + = dbe_->book1D("hist_EB_RawSC_S1toS9_","S1/S9 of Raw Super Clusters in Barrel", + hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); + hist_EE_RawSC_S1toS9_ + = dbe_->book1D("hist_EE_RawSC_S1toS9_","S1/S9 of Raw Super Clusters in Endcap", + hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); + hist_EB_CorSC_S1toS9_ + = dbe_->book1D("hist_EB_CorSC_S1toS9_","S1/S9 of Corrected SuperClusters in Barrel", + hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); + hist_EE_CorSC_S1toS9_ + = dbe_->book1D("hist_EE_CorSC_S1toS9_","S1/S9 of Corrected SuperClusters in Endcap", + hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); + hist_EE_PreSC_S1toS9_ + = dbe_->book1D("hist_EE_PreSC_S1toS9_","S1/S9 of SuperClusters with Preshower in Endcap", + hist_bins_S1toS9_,hist_min_S1toS9_,hist_max_S1toS9_); + + // S25/E distribution of SuperClusters + // + hist_EB_RawSC_S25toE_ + = dbe_->book1D("hist_EB_RawSC_S25toE_","S25/E of Raw Super Clusters in Barrel", + hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); + hist_EE_RawSC_S25toE_ + = dbe_->book1D("hist_EE_RawSC_S25toE_","S25/E of Raw Super Clusters in Endcap", + hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); + hist_EB_CorSC_S25toE_ + = dbe_->book1D("hist_EB_CorSC_S25toE_","S25/E of Corrected SuperClusters in Barrel", + hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); + hist_EE_CorSC_S25toE_ + = dbe_->book1D("hist_EE_CorSC_S25toE_","S25/E of Corrected SuperClusters in Endcap", + hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); + hist_EE_PreSC_S25toE_ + = dbe_->book1D("hist_EE_PreSC_S25toE_","S25/E of SuperClusters with Preshower in Endcap", + hist_bins_S25toE_,hist_min_S25toE_,hist_max_S25toE_); + + // E/E(true) distribution of SuperClusters + // + hist_EB_RawSC_EoverTruth_ + = dbe_->book1D("hist_EB_RawSC_EoverTruth_","E/True E of Raw SuperClusters in Barrel", + hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); + hist_EE_RawSC_EoverTruth_ + = dbe_->book1D("hist_EE_RawSC_EoverTruth_","E/True E of Raw SuperClusters in Endcap", + hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); + hist_EB_CorSC_EoverTruth_ + = dbe_->book1D("hist_EB_CorSC_EoverTruth_","E/True E of Corrected SuperClusters in Barrel", + hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); + hist_EE_CorSC_EoverTruth_ + = dbe_->book1D("hist_EE_CorSC_EoverTruth_","E/True E of Corrected SuperClusters in Endcap", + hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); + hist_EE_PreSC_EoverTruth_ + = dbe_->book1D("hist_EE_PreSC_EoverTruth_","E/True E of SuperClusters with Preshower in Endcap", + hist_bins_EoverTruth_,hist_min_EoverTruth_,hist_max_EoverTruth_); + + // dR distribution of SuperClusters from truth + // + hist_EB_RawSC_deltaR_ + = dbe_->book1D("hist_EB_RawSC_deltaR_","dR to MC truth of Raw Super Clusters in Barrel", + hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); + hist_EE_RawSC_deltaR_ + = dbe_->book1D("hist_EE_RawSC_deltaR_","dR to MC truth of Raw Super Clusters in Endcap", + hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); + hist_EB_CorSC_deltaR_ + = dbe_->book1D("hist_EB_CorSC_deltaR_","dR to MC truth of Corrected SuperClusters in Barrel", + hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); + hist_EE_CorSC_deltaR_ + = dbe_->book1D("hist_EE_CorSC_deltaR_","dR to MC truth of Corrected SuperClusters in Endcap", + hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); + hist_EE_PreSC_deltaR_ + = dbe_->book1D("hist_EE_PreSC_deltaR_","dR to MC truth of SuperClusters with Preshower in Endcap", + hist_bins_deltaR_,hist_min_deltaR_,hist_max_deltaR_); + + // phi width stored in corrected SuperClusters + hist_EB_CorSC_phiWidth_ + = dbe_->book1D("hist_EB_CorSC_phiWidth_","phiWidth of Corrected Super Clusters in Barrel", + hist_bins_phiWidth_,hist_min_phiWidth_,hist_max_phiWidth_); + hist_EE_CorSC_phiWidth_ + = dbe_->book1D("hist_EE_CorSC_phiWidth_","phiWidth of Corrected Super Clusters in Endcap", + hist_bins_phiWidth_,hist_min_phiWidth_,hist_max_phiWidth_); + + // eta width stored in corrected SuperClusters + hist_EB_CorSC_etaWidth_ + = dbe_->book1D("hist_EB_CorSC_etaWidth_","etaWidth of Corrected Super Clusters in Barrel", + hist_bins_etaWidth_,hist_min_etaWidth_,hist_max_etaWidth_); + hist_EE_CorSC_etaWidth_ + = dbe_->book1D("hist_EE_CorSC_etaWidth_","etaWidth of Corrected Super Clusters in Endcap", + hist_bins_etaWidth_,hist_min_etaWidth_,hist_max_etaWidth_); + + + // preshower energy + hist_EE_PreSC_preshowerE_ + = dbe_->book1D("hist_EE_PreSC_preshowerE_","preshower energy in Super Clusters with Preshower in Endcap", + hist_bins_preshowerE_,hist_min_preshowerE_,hist_max_preshowerE_); + hist_EE_CorSC_preshowerE_ + = dbe_->book1D("hist_EE_CorSC_preshowerE_","preshower energy in Corrected Super Clusters with Preshower in Endcap", + hist_bins_preshowerE_,hist_min_preshowerE_,hist_max_preshowerE_); + + + // + hist_EB_CorSC_ET_vs_Eta_ = dbe_->book2D( "hist_EB_CorSC_ET_vs_Eta_", "Corr Super Cluster ET versus Eta in Barrel", + hist_bins_ET_, hist_min_ET_, hist_max_ET_, + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ ); + + hist_EB_CorSC_ET_vs_Phi_ = dbe_->book2D( "hist_EB_CorSC_ET_vs_Phi_", "Corr Super Cluster ET versus Phi in Barrel", + hist_bins_ET_, hist_min_ET_, hist_max_ET_, + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ ); + + hist_EE_CorSC_ET_vs_Eta_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_Eta_", "Corr Super Cluster ET versus Eta in Endcap", + hist_bins_ET_, hist_min_ET_, hist_max_ET_, + hist_bins_Eta_,hist_min_Eta_,hist_max_Eta_ ); + + hist_EE_CorSC_ET_vs_Phi_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_Phi_", "Corr Super Cluster ET versus Phi in Endcap", + hist_bins_ET_, hist_min_ET_, hist_max_ET_, + hist_bins_Phi_,hist_min_Phi_,hist_max_Phi_ ); + + hist_EE_CorSC_ET_vs_R_ = dbe_->book2D( "hist_EE_CorSC_ET_vs_R_", "Corr Super Cluster ET versus Radius in Endcap", + hist_bins_ET_, hist_min_ET_, hist_max_ET_, + hist_bins_R_,hist_min_R_,hist_max_R_ ); + + } void EgammaSuperClusters::analyze( const edm::Event& evt, const edm::EventSetup& es ) { - - bool skipMC = false; - bool skipBarrel = false; - bool skipEndcap = false; - - // - // Get MCTRUTH - // - edm::Handle pMCTruth ; - evt.getByLabel(MCTruthCollection_, pMCTruth); - if (!pMCTruth.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << MCTruthCollection_.label(); - skipMC = true; - } - const HepMC::GenEvent* genEvent = pMCTruth->GetEvent(); - - if( skipMC ) return; - - // - // Get the BARREL products - // - edm::Handle pBarrelRawSuperClusters; - evt.getByLabel(barrelRawSuperClusterCollection_, pBarrelRawSuperClusters); - if (!pBarrelRawSuperClusters.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << barrelRawSuperClusterCollection_.label(); - skipBarrel = true; - } - - edm::Handle pBarrelCorSuperClusters; - evt.getByLabel(barrelCorSuperClusterCollection_, pBarrelCorSuperClusters); - if (!pBarrelCorSuperClusters.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << barrelCorSuperClusterCollection_.label(); - skipBarrel = true; - } - - edm::Handle< EBRecHitCollection > pBarrelRecHitCollection; - evt.getByLabel( barrelRecHitCollection_, pBarrelRecHitCollection ); - if ( ! pBarrelRecHitCollection.isValid() ) { - skipBarrel = true; + + bool skipMC = false; + bool skipBarrel = false; + bool skipEndcap = false; + + // + // Get MCTRUTH + // + edm::Handle pMCTruth ; + evt.getByToken(MCTruthCollectionToken_, pMCTruth); + if (!pMCTruth.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get MC collection "; + skipMC = true; + } + const HepMC::GenEvent* genEvent = pMCTruth->GetEvent(); + + if( skipMC ) return; + + // + // Get the BARREL products + // + edm::Handle pBarrelRawSuperClusters; + evt.getByToken(barrelRawSuperClusterCollectionToken_, pBarrelRawSuperClusters); + if (!pBarrelRawSuperClusters.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get collection Raw SC"; + skipBarrel = true; + } + + edm::Handle pBarrelCorSuperClusters; + evt.getByToken(barrelCorSuperClusterCollectionToken_, pBarrelCorSuperClusters); + if (!pBarrelCorSuperClusters.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get collection Cor SC"; + skipBarrel = true; + } + + edm::Handle< EBRecHitCollection > pBarrelRecHitCollection; + evt.getByToken( barrelRecHitCollectionToken_, pBarrelRecHitCollection ); + if ( ! pBarrelRecHitCollection.isValid() ) { + skipBarrel = true; + } + edm::Handle< EERecHitCollection > pEndcapRecHitCollection; + evt.getByToken( endcapRecHitCollectionToken_, pEndcapRecHitCollection ); + if ( ! pEndcapRecHitCollection.isValid() ) { + skipEndcap = true; + } + + if( skipBarrel || skipEndcap ) return; + + EcalClusterLazyTools lazyTool( evt, es, barrelRecHitCollectionToken_, endcapRecHitCollectionToken_ ); + + // Get the BARREL collections + const reco::SuperClusterCollection* barrelRawSuperClusters = pBarrelRawSuperClusters.product(); + const reco::SuperClusterCollection* barrelCorSuperClusters = pBarrelCorSuperClusters.product(); + + // Number of entries in collections + hist_EB_RawSC_Size_->Fill(barrelRawSuperClusters->size()); + hist_EB_CorSC_Size_->Fill(barrelCorSuperClusters->size()); + + // Do RAW BARREL SuperClusters + for(reco::SuperClusterCollection::const_iterator aClus = barrelRawSuperClusters->begin(); + aClus != barrelRawSuperClusters->end(); aClus++) + { + // kinematics + hist_EB_RawSC_NumBC_->Fill(aClus->clustersSize()); + hist_EB_RawSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); + hist_EB_RawSC_Eta_->Fill(aClus->position().eta()); + hist_EB_RawSC_Phi_->Fill(aClus->position().phi()); + + // cluster shape + const reco::CaloClusterPtr seed = aClus->seed(); + hist_EB_RawSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); + hist_EB_RawSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); + + // truth + double dRClosest = 999.9; + double energyClosest = 0; + closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); + + if (dRClosest < 0.1) + { + hist_EB_RawSC_EoverTruth_->Fill(aClus->energy()/energyClosest); + hist_EB_RawSC_deltaR_->Fill(dRClosest); + } - edm::Handle< EERecHitCollection > pEndcapRecHitCollection; - evt.getByLabel( endcapRecHitCollection_, pEndcapRecHitCollection ); - if ( ! pEndcapRecHitCollection.isValid() ) { - skipEndcap = true; + + } + + // Do CORRECTED BARREL SuperClusters + for(reco::SuperClusterCollection::const_iterator aClus = barrelCorSuperClusters->begin(); + aClus != barrelCorSuperClusters->end(); aClus++) + { + // kinematics + hist_EB_CorSC_NumBC_->Fill(aClus->clustersSize()); + hist_EB_CorSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); + hist_EB_CorSC_Eta_->Fill(aClus->position().eta()); + hist_EB_CorSC_Phi_->Fill(aClus->position().phi()); + + hist_EB_CorSC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() ); + hist_EB_CorSC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() ); + + + // cluster shape + const reco::CaloClusterPtr seed = aClus->seed(); + hist_EB_CorSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); + hist_EB_CorSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); + + // correction variables + hist_EB_CorSC_phiWidth_->Fill(aClus->phiWidth()); + hist_EB_CorSC_etaWidth_->Fill(aClus->etaWidth()); + + // truth + double dRClosest = 999.9; + double energyClosest = 0; + closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); + + if (dRClosest < 0.1) + { + hist_EB_CorSC_EoverTruth_->Fill(aClus->energy()/energyClosest); + hist_EB_CorSC_deltaR_->Fill(dRClosest); + } - - if( skipBarrel || skipEndcap ) return; - - EcalClusterLazyTools lazyTool( evt, es, barrelRecHitCollection_, endcapRecHitCollection_ ); - - // Get the BARREL collections - const reco::SuperClusterCollection* barrelRawSuperClusters = pBarrelRawSuperClusters.product(); - const reco::SuperClusterCollection* barrelCorSuperClusters = pBarrelCorSuperClusters.product(); - - // Number of entries in collections - hist_EB_RawSC_Size_->Fill(barrelRawSuperClusters->size()); - hist_EB_CorSC_Size_->Fill(barrelCorSuperClusters->size()); - - // Do RAW BARREL SuperClusters - for(reco::SuperClusterCollection::const_iterator aClus = barrelRawSuperClusters->begin(); - aClus != barrelRawSuperClusters->end(); aClus++) + + } + + // + // Get the ENDCAP products + // + edm::Handle pEndcapRawSuperClusters; + evt.getByToken(endcapRawSuperClusterCollectionToken_, pEndcapRawSuperClusters); + if (!pEndcapRawSuperClusters.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get collection Raw EE SC"; + } + + edm::Handle pEndcapPreSuperClusters; + evt.getByToken(endcapPreSuperClusterCollectionToken_, pEndcapPreSuperClusters); + if (!pEndcapPreSuperClusters.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get collection Pre EE SC"; + } + + edm::Handle pEndcapCorSuperClusters; + evt.getByToken(endcapCorSuperClusterCollectionToken_, pEndcapCorSuperClusters); + if (!pEndcapCorSuperClusters.isValid()) { + edm::LogError("EgammaSuperClusters") << "Error! can't get collection Cor EE SC"; + } + + // Get the ENDCAP collections + const reco::SuperClusterCollection* endcapRawSuperClusters = pEndcapRawSuperClusters.product(); + const reco::SuperClusterCollection* endcapPreSuperClusters = pEndcapPreSuperClusters.product(); + const reco::SuperClusterCollection* endcapCorSuperClusters = pEndcapCorSuperClusters.product(); + + // Number of entries in collections + hist_EE_RawSC_Size_->Fill(endcapRawSuperClusters->size()); + hist_EE_PreSC_Size_->Fill(endcapPreSuperClusters->size()); + hist_EE_CorSC_Size_->Fill(endcapCorSuperClusters->size()); + + // Do RAW ENDCAP SuperClusters + for(reco::SuperClusterCollection::const_iterator aClus = endcapRawSuperClusters->begin(); + aClus != endcapRawSuperClusters->end(); aClus++) + { + hist_EE_RawSC_NumBC_->Fill(aClus->clustersSize()); + hist_EE_RawSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); + hist_EE_RawSC_Eta_->Fill(aClus->position().eta()); + hist_EE_RawSC_Phi_->Fill(aClus->position().phi()); + + const reco::CaloClusterPtr seed = aClus->seed(); + hist_EE_RawSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); + hist_EE_RawSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); + + // truth + double dRClosest = 999.9; + double energyClosest = 0; + closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); + + if (dRClosest < 0.1) { - // kinematics - hist_EB_RawSC_NumBC_->Fill(aClus->clustersSize()); - hist_EB_RawSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); - hist_EB_RawSC_Eta_->Fill(aClus->position().eta()); - hist_EB_RawSC_Phi_->Fill(aClus->position().phi()); - - // cluster shape - const reco::CaloClusterPtr seed = aClus->seed(); - hist_EB_RawSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); - hist_EB_RawSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); - - // truth - double dRClosest = 999.9; - double energyClosest = 0; - closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); - - if (dRClosest < 0.1) - { - hist_EB_RawSC_EoverTruth_->Fill(aClus->energy()/energyClosest); - hist_EB_RawSC_deltaR_->Fill(dRClosest); - - } - - } - - // Do CORRECTED BARREL SuperClusters - for(reco::SuperClusterCollection::const_iterator aClus = barrelCorSuperClusters->begin(); - aClus != barrelCorSuperClusters->end(); aClus++) - { - // kinematics - hist_EB_CorSC_NumBC_->Fill(aClus->clustersSize()); - hist_EB_CorSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); - hist_EB_CorSC_Eta_->Fill(aClus->position().eta()); - hist_EB_CorSC_Phi_->Fill(aClus->position().phi()); - - hist_EB_CorSC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() ); - hist_EB_CorSC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() ); - - - // cluster shape - const reco::CaloClusterPtr seed = aClus->seed(); - hist_EB_CorSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); - hist_EB_CorSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); - - // correction variables - hist_EB_CorSC_phiWidth_->Fill(aClus->phiWidth()); - hist_EB_CorSC_etaWidth_->Fill(aClus->etaWidth()); - - // truth - double dRClosest = 999.9; - double energyClosest = 0; - closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); - - if (dRClosest < 0.1) - { - hist_EB_CorSC_EoverTruth_->Fill(aClus->energy()/energyClosest); - hist_EB_CorSC_deltaR_->Fill(dRClosest); - - } - - } - - // - // Get the ENDCAP products - // - edm::Handle pEndcapRawSuperClusters; - evt.getByLabel(endcapRawSuperClusterCollection_, pEndcapRawSuperClusters); - if (!pEndcapRawSuperClusters.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << endcapRawSuperClusterCollection_.label(); - } - - edm::Handle pEndcapPreSuperClusters; - evt.getByLabel(endcapPreSuperClusterCollection_, pEndcapPreSuperClusters); - if (!pEndcapPreSuperClusters.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << endcapPreSuperClusterCollection_.label(); - } - - edm::Handle pEndcapCorSuperClusters; - evt.getByLabel(endcapCorSuperClusterCollection_, pEndcapCorSuperClusters); - if (!pEndcapCorSuperClusters.isValid()) { - edm::LogError("EgammaSuperClusters") << "Error! can't get collection with label " - << endcapCorSuperClusterCollection_.label(); - } - - // Get the ENDCAP collections - const reco::SuperClusterCollection* endcapRawSuperClusters = pEndcapRawSuperClusters.product(); - const reco::SuperClusterCollection* endcapPreSuperClusters = pEndcapPreSuperClusters.product(); - const reco::SuperClusterCollection* endcapCorSuperClusters = pEndcapCorSuperClusters.product(); - - // Number of entries in collections - hist_EE_RawSC_Size_->Fill(endcapRawSuperClusters->size()); - hist_EE_PreSC_Size_->Fill(endcapPreSuperClusters->size()); - hist_EE_CorSC_Size_->Fill(endcapCorSuperClusters->size()); - - // Do RAW ENDCAP SuperClusters - for(reco::SuperClusterCollection::const_iterator aClus = endcapRawSuperClusters->begin(); - aClus != endcapRawSuperClusters->end(); aClus++) + hist_EE_RawSC_EoverTruth_->Fill(aClus->energy()/energyClosest); + hist_EE_RawSC_deltaR_->Fill(dRClosest); + } + + } + + // Do ENDCAP SuperClusters with PRESHOWER + for(reco::SuperClusterCollection::const_iterator aClus = endcapPreSuperClusters->begin(); + aClus != endcapPreSuperClusters->end(); aClus++) + { + hist_EE_PreSC_NumBC_->Fill(aClus->clustersSize()); + hist_EE_PreSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); + hist_EE_PreSC_Eta_->Fill(aClus->position().eta()); + hist_EE_PreSC_Phi_->Fill(aClus->position().phi()); + hist_EE_PreSC_preshowerE_->Fill(aClus->preshowerEnergy()); + + const reco::CaloClusterPtr seed = aClus->seed(); + hist_EE_PreSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); + hist_EE_PreSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); + + // truth + double dRClosest = 999.9; + double energyClosest = 0; + closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); + + if (dRClosest < 0.1) { - hist_EE_RawSC_NumBC_->Fill(aClus->clustersSize()); - hist_EE_RawSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); - hist_EE_RawSC_Eta_->Fill(aClus->position().eta()); - hist_EE_RawSC_Phi_->Fill(aClus->position().phi()); - - const reco::CaloClusterPtr seed = aClus->seed(); - hist_EE_RawSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); - hist_EE_RawSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); - - // truth - double dRClosest = 999.9; - double energyClosest = 0; - closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); - - if (dRClosest < 0.1) - { - hist_EE_RawSC_EoverTruth_->Fill(aClus->energy()/energyClosest); - hist_EE_RawSC_deltaR_->Fill(dRClosest); - } - - } - - // Do ENDCAP SuperClusters with PRESHOWER - for(reco::SuperClusterCollection::const_iterator aClus = endcapPreSuperClusters->begin(); - aClus != endcapPreSuperClusters->end(); aClus++) - { - hist_EE_PreSC_NumBC_->Fill(aClus->clustersSize()); - hist_EE_PreSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); - hist_EE_PreSC_Eta_->Fill(aClus->position().eta()); - hist_EE_PreSC_Phi_->Fill(aClus->position().phi()); - hist_EE_PreSC_preshowerE_->Fill(aClus->preshowerEnergy()); - - const reco::CaloClusterPtr seed = aClus->seed(); - hist_EE_PreSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); - hist_EE_PreSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); - - // truth - double dRClosest = 999.9; - double energyClosest = 0; - closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); - - if (dRClosest < 0.1) - { - hist_EE_PreSC_EoverTruth_->Fill(aClus->energy()/energyClosest); - hist_EE_PreSC_deltaR_->Fill(dRClosest); - } - - } - - // Do CORRECTED ENDCAP SuperClusters - for(reco::SuperClusterCollection::const_iterator aClus = endcapCorSuperClusters->begin(); - aClus != endcapCorSuperClusters->end(); aClus++) - { - hist_EE_CorSC_NumBC_->Fill(aClus->clustersSize()); - hist_EE_CorSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); - hist_EE_CorSC_Eta_->Fill(aClus->position().eta()); - hist_EE_CorSC_Phi_->Fill(aClus->position().phi()); - hist_EE_CorSC_preshowerE_->Fill(aClus->preshowerEnergy()); - - hist_EE_CorSC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() ); - hist_EE_CorSC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() ); - hist_EE_CorSC_ET_vs_R_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), - std::sqrt( std::pow(aClus->x(),2) + std::pow(aClus->y(),2) ) ); - - - // correction variables - hist_EE_CorSC_phiWidth_->Fill(aClus->phiWidth()); - hist_EE_CorSC_etaWidth_->Fill(aClus->etaWidth()); - - const reco::CaloClusterPtr seed = aClus->seed(); - hist_EE_CorSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); - hist_EE_CorSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); - - // truth - double dRClosest = 999.9; - double energyClosest = 0; - closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); - - if (dRClosest < 0.1) - { - hist_EE_CorSC_EoverTruth_->Fill(aClus->energy()/energyClosest); - hist_EE_CorSC_deltaR_->Fill(dRClosest); - } - - } - + hist_EE_PreSC_EoverTruth_->Fill(aClus->energy()/energyClosest); + hist_EE_PreSC_deltaR_->Fill(dRClosest); + } + + } + + // Do CORRECTED ENDCAP SuperClusters + for(reco::SuperClusterCollection::const_iterator aClus = endcapCorSuperClusters->begin(); + aClus != endcapCorSuperClusters->end(); aClus++) + { + hist_EE_CorSC_NumBC_->Fill(aClus->clustersSize()); + hist_EE_CorSC_ET_->Fill(aClus->energy()/std::cosh(aClus->position().eta())); + hist_EE_CorSC_Eta_->Fill(aClus->position().eta()); + hist_EE_CorSC_Phi_->Fill(aClus->position().phi()); + hist_EE_CorSC_preshowerE_->Fill(aClus->preshowerEnergy()); + + hist_EE_CorSC_ET_vs_Eta_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->eta() ); + hist_EE_CorSC_ET_vs_Phi_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), aClus->phi() ); + hist_EE_CorSC_ET_vs_R_->Fill( aClus->energy()/std::cosh(aClus->position().eta()), + std::sqrt( std::pow(aClus->x(),2) + std::pow(aClus->y(),2) ) ); + + + // correction variables + hist_EE_CorSC_phiWidth_->Fill(aClus->phiWidth()); + hist_EE_CorSC_etaWidth_->Fill(aClus->etaWidth()); + + const reco::CaloClusterPtr seed = aClus->seed(); + hist_EE_CorSC_S1toS9_->Fill( lazyTool.eMax( *seed ) / lazyTool.e3x3( *seed ) ); + hist_EE_CorSC_S25toE_->Fill( lazyTool.e5x5( *seed ) / aClus->energy() ); + + // truth + double dRClosest = 999.9; + double energyClosest = 0; + closestMCParticle(genEvent, *aClus, dRClosest, energyClosest); + + if (dRClosest < 0.1) + { + hist_EE_CorSC_EoverTruth_->Fill(aClus->energy()/energyClosest); + hist_EE_CorSC_deltaR_->Fill(dRClosest); + } + + } + } void EgammaSuperClusters::endJob() { - if (outputFile_.size() != 0 && dbe_) dbe_->save(outputFile_); + if (outputFile_.size() != 0 && dbe_) dbe_->save(outputFile_); } // // Closest MC Particle // void EgammaSuperClusters::closestMCParticle(const HepMC::GenEvent *genEvent, const reco::SuperCluster &sc, - double &dRClosest, double &energyClosest) + double &dRClosest, double &energyClosest) { - - // SuperCluster eta, phi - double scEta = sc.eta(); - double scPhi = sc.phi(); - - // initialize dRClosest to a large number - dRClosest = 999.9; - - // loop over the MC truth particles to find the - // closest to the superCluster in dR space - for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin(); - currentParticle != genEvent->particles_end(); currentParticle++ ) - { - if((*currentParticle)->status() == 1) - { - // need GenParticle in ECAL co-ordinates - HepMC::FourVector vtx = (*currentParticle)->production_vertex()->position(); - double phiTrue = (*currentParticle)->momentum().phi(); - double etaTrue = ecalEta((*currentParticle)->momentum().eta(), vtx.z()/10., vtx.perp()/10.); - - double dPhi = reco::deltaPhi(phiTrue, scPhi); - double dEta = scEta - etaTrue; - double deltaR = std::sqrt(dPhi*dPhi + dEta*dEta); - - if(deltaR < dRClosest) - { - dRClosest = deltaR; - energyClosest = (*currentParticle)->momentum().e(); - } - - } // end if stable particle - - } // end loop on get particles - + + // SuperCluster eta, phi + double scEta = sc.eta(); + double scPhi = sc.phi(); + + // initialize dRClosest to a large number + dRClosest = 999.9; + + // loop over the MC truth particles to find the + // closest to the superCluster in dR space + for(HepMC::GenEvent::particle_const_iterator currentParticle = genEvent->particles_begin(); + currentParticle != genEvent->particles_end(); currentParticle++ ) + { + if((*currentParticle)->status() == 1) + { + // need GenParticle in ECAL co-ordinates + HepMC::FourVector vtx = (*currentParticle)->production_vertex()->position(); + double phiTrue = (*currentParticle)->momentum().phi(); + double etaTrue = ecalEta((*currentParticle)->momentum().eta(), vtx.z()/10., vtx.perp()/10.); + + double dPhi = reco::deltaPhi(phiTrue, scPhi); + double dEta = scEta - etaTrue; + double deltaR = std::sqrt(dPhi*dPhi + dEta*dEta); + + if(deltaR < dRClosest) + { + dRClosest = deltaR; + energyClosest = (*currentParticle)->momentum().e(); + } + + } // end if stable particle + + } // end loop on get particles + } @@ -623,38 +616,38 @@ void EgammaSuperClusters::closestMCParticle(const HepMC::GenEvent *genEvent, con // float EgammaSuperClusters::ecalEta(float EtaParticle , float Zvertex, float plane_Radius) { - const float R_ECAL = 136.5; - const float Z_Endcap = 328.0; - const float etaBarrelEndcap = 1.479; - - if(EtaParticle != 0.) - { - float Theta = 0.0 ; - float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex; - - if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal); - if(Theta<0.0) Theta = Theta+Geom::pi() ; - - float ETA = - log(tan(0.5*Theta)); - - if( fabs(ETA) > etaBarrelEndcap ) - { - float Zend = Z_Endcap ; - if(EtaParticle<0.0 ) Zend = -Zend ; - float Zlen = Zend - Zvertex ; - float RR = Zlen/sinh(EtaParticle); - Theta = atan((RR+plane_Radius)/Zend); - if(Theta<0.0) Theta = Theta+Geom::pi() ; - ETA = - log(tan(0.5*Theta)); - } - - return ETA; - } - else + const float R_ECAL = 136.5; + const float Z_Endcap = 328.0; + const float etaBarrelEndcap = 1.479; + + if(EtaParticle != 0.) + { + float Theta = 0.0 ; + float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex; + + if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal); + if(Theta<0.0) Theta = Theta+Geom::pi() ; + + float ETA = - log(tan(0.5*Theta)); + + if( fabs(ETA) > etaBarrelEndcap ) { - edm::LogWarning("") << "[EgammaSuperClusters::ecalEta] Warning: Eta equals to zero, not correcting" ; - return EtaParticle; + float Zend = Z_Endcap ; + if(EtaParticle<0.0 ) Zend = -Zend ; + float Zlen = Zend - Zvertex ; + float RR = Zlen/sinh(EtaParticle); + Theta = atan((RR+plane_Radius)/Zend); + if(Theta<0.0) Theta = Theta+Geom::pi() ; + ETA = - log(tan(0.5*Theta)); } + + return ETA; + } + else + { + edm::LogWarning("") << "[EgammaSuperClusters::ecalEta] Warning: Eta equals to zero, not correcting" ; + return EtaParticle; + } } From 3cbe6c28affacdc05ece9cb5dbbc2445d925055c Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 17 Feb 2014 11:49:44 +0100 Subject: [PATCH 4/6] updates --- .../Trigger/src/FourVectorHLTOffline.cc | 2 +- .../plugins/ElectronIdMVAProducer.cc | 233 +++++++++--------- .../test/ElectronTestAnalyzer.cc | 57 ++--- 3 files changed, 143 insertions(+), 149 deletions(-) diff --git a/DQMOffline/Trigger/src/FourVectorHLTOffline.cc b/DQMOffline/Trigger/src/FourVectorHLTOffline.cc index 72803cc3b3526..5f8a7a10177db 100644 --- a/DQMOffline/Trigger/src/FourVectorHLTOffline.cc +++ b/DQMOffline/Trigger/src/FourVectorHLTOffline.cc @@ -2352,7 +2352,7 @@ void FourVectorHLTOffline::selectElectrons(const edm::Event& iEvent, const edm:: if(pEBRecHits.isValid() && pEERecHits.isValid()) { - EcalClusterLazyTools lazyTool(iEvent, iSetup, recHitsEBTag_, recHitsEETag_); + EcalClusterLazyTools lazyTool(iEvent, iSetup, recHitsEBToken, recHitsEEToken); const reco::CaloCluster* bc = iter->superCluster()->seed().get(); // get the basic cluster float eleMaxOver3x3 = ( lazyTool.eMax(*bc) / lazyTool.e3x3(*bc) ); diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc index 084f6982caae6..ab6822b1cbca6 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc @@ -24,29 +24,28 @@ using namespace std; using namespace reco; class ElectronIdMVAProducer : public edm::EDFilter { - public: - explicit ElectronIdMVAProducer(const edm::ParameterSet&); - ~ElectronIdMVAProducer(); - - private: - virtual bool filter(edm::Event&, const edm::EventSetup&); - - // ----------member data --------------------------- - bool verbose_; - edm::EDGetTokenT vertexToken_; - edm::EDGetTokenT electronToken_; - edm::EDGetTokenT eventrhoToken_; - edm::InputTag reducedEBRecHitCollection_; - edm::InputTag reducedEERecHitCollection_; - - double _Rho; - string method_; - vector mvaWeightFiles_; - bool Trig_; - bool NoIP_; - - EGammaMvaEleEstimator* mvaID_; - +public: + explicit ElectronIdMVAProducer(const edm::ParameterSet&); + ~ElectronIdMVAProducer(); + +private: + virtual bool filter(edm::Event&, const edm::EventSetup&); + + // ----------member data --------------------------- + bool verbose_; + edm::EDGetTokenT vertexToken_; + edm::EDGetTokenT electronToken_; + edm::EDGetTokenT eventrhoToken_; + edm::EDGetTokenT reducedEBRecHitCollectionToken_; + edm::EDGetTokenT reducedEERecHitCollectionToken_; + + double _Rho; + string method_; + vector mvaWeightFiles_; + bool Trig_; + bool NoIP_; + + EGammaMvaEleEstimator* mvaID_; }; // @@ -61,47 +60,47 @@ class ElectronIdMVAProducer : public edm::EDFilter { // constructors and destructor // ElectronIdMVAProducer::ElectronIdMVAProducer(const edm::ParameterSet& iConfig) { - verbose_ = iConfig.getUntrackedParameter("verbose", false); - vertexToken_ = consumes(iConfig.getParameter("vertexTag")); - electronToken_ = consumes(iConfig.getParameter("electronTag")); - eventrhoToken_ = consumes(edm::InputTag("kt6PFJets", "rho")); - reducedEBRecHitCollection_ = iConfig.getParameter("reducedEBRecHitCollection"); - reducedEERecHitCollection_ = iConfig.getParameter("reducedEERecHitCollection"); - method_ = iConfig.getParameter("method"); - std::vector fpMvaWeightFiles = iConfig.getParameter >("mvaWeightFile"); - Trig_ = iConfig.getParameter("Trig"); - NoIP_ = iConfig.getParameter("NoIP"); - - produces >(""); - - mvaID_ = new EGammaMvaEleEstimator(); - - EGammaMvaEleEstimator::MVAType type_; - if(Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig;} - - if(Trig_ && NoIP_){type_ = EGammaMvaEleEstimator::kTrigNoIP;} - - if(!Trig_){type_ = EGammaMvaEleEstimator::kNonTrig;} - - bool manualCat_ = true; - - string path_mvaWeightFileEleID; - for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) { - path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath(); - mvaWeightFiles_.push_back(path_mvaWeightFileEleID); - } - - mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_); - + verbose_ = iConfig.getUntrackedParameter("verbose", false); + vertexToken_ = consumes(iConfig.getParameter("vertexTag")); + electronToken_ = consumes(iConfig.getParameter("electronTag")); + eventrhoToken_ = consumes(edm::InputTag("kt6PFJets", "rho")); + reducedEBRecHitCollectionToken_ = consumes(iConfig.getParameter("reducedEBRecHitCollection")); + reducedEERecHitCollectionToken_ = consumes(iConfig.getParameter("reducedEERecHitCollection")); + method_ = iConfig.getParameter("method"); + std::vector fpMvaWeightFiles = iConfig.getParameter >("mvaWeightFile"); + Trig_ = iConfig.getParameter("Trig"); + NoIP_ = iConfig.getParameter("NoIP"); + + produces >(""); + + mvaID_ = new EGammaMvaEleEstimator(); + + EGammaMvaEleEstimator::MVAType type_; + if(Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig;} + + if(Trig_ && NoIP_){type_ = EGammaMvaEleEstimator::kTrigNoIP;} + + if(!Trig_){type_ = EGammaMvaEleEstimator::kNonTrig;} + + bool manualCat_ = true; + + string path_mvaWeightFileEleID; + for(unsigned ifile=0 ; ifile < fpMvaWeightFiles.size() ; ++ifile) { + path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str() ).fullPath(); + mvaWeightFiles_.push_back(path_mvaWeightFileEleID); + } + + mvaID_->initialize(method_, type_, manualCat_, mvaWeightFiles_); + } ElectronIdMVAProducer::~ElectronIdMVAProducer() { - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + } @@ -111,64 +110,64 @@ ElectronIdMVAProducer::~ElectronIdMVAProducer() // ------------ method called on each new Event ------------ bool ElectronIdMVAProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { - using namespace edm; - - std::auto_ptr > out(new edm::ValueMap() ); - - Handle vertexCollection; - iEvent.getByToken(vertexToken_, vertexCollection); - - Vertex dummy; - const Vertex *pv = &dummy; - if ( vertexCollection->size() != 0) { - pv = &*vertexCollection->begin(); - } else { // create a dummy PV - Vertex::Error e; - e(0, 0) = 0.0015 * 0.0015; - e(1, 1) = 0.0015 * 0.0015; - e(2, 2) = 15. * 15.; - Vertex::Point p(0, 0, 0); - dummy = Vertex(p, e, 0, 0, 0); - } - - EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection_, reducedEERecHitCollection_); - - edm::ESHandle builder; - iSetup.get().get("TransientTrackBuilder", builder); - TransientTrackBuilder thebuilder = *(builder.product()); - - Handle egCollection; - iEvent.getByToken(electronToken_,egCollection); - const reco::GsfElectronCollection egCandidates = (*egCollection.product()); - - _Rho=0; - edm::Handle rhoPtr; - iEvent.getByToken(eventrhoToken_,rhoPtr); - _Rho=*rhoPtr; - - std::vector values; - values.reserve(egCollection->size()); - - for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) { - - double mvaVal = -999999; - if(!NoIP_){ - mvaVal = mvaID_->mvaValue( *egIter, *pv,thebuilder,lazyTools, verbose_); - } - if(NoIP_){ - mvaVal = mvaID_->mvaValue( *egIter, *pv, _Rho,/*thebuilder,*/lazyTools, verbose_); - } - - values.push_back( mvaVal ); - } - - edm::ValueMap::Filler filler(*out); - filler.insert(egCollection, values.begin(), values.end() ); - filler.fill(); - - iEvent.put(out); - - return true; + using namespace edm; + + std::auto_ptr > out(new edm::ValueMap() ); + + Handle vertexCollection; + iEvent.getByToken(vertexToken_, vertexCollection); + + Vertex dummy; + const Vertex *pv = &dummy; + if ( vertexCollection->size() != 0) { + pv = &*vertexCollection->begin(); + } else { // create a dummy PV + Vertex::Error e; + e(0, 0) = 0.0015 * 0.0015; + e(1, 1) = 0.0015 * 0.0015; + e(2, 2) = 15. * 15.; + Vertex::Point p(0, 0, 0); + dummy = Vertex(p, e, 0, 0, 0); + } + + EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_); + + edm::ESHandle builder; + iSetup.get().get("TransientTrackBuilder", builder); + TransientTrackBuilder thebuilder = *(builder.product()); + + Handle egCollection; + iEvent.getByToken(electronToken_,egCollection); + const reco::GsfElectronCollection egCandidates = (*egCollection.product()); + + _Rho=0; + edm::Handle rhoPtr; + iEvent.getByToken(eventrhoToken_,rhoPtr); + _Rho=*rhoPtr; + + std::vector values; + values.reserve(egCollection->size()); + + for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end(); ++egIter) { + + double mvaVal = -999999; + if(!NoIP_){ + mvaVal = mvaID_->mvaValue( *egIter, *pv,thebuilder,lazyTools, verbose_); + } + if(NoIP_){ + mvaVal = mvaID_->mvaValue( *egIter, *pv, _Rho,/*thebuilder,*/lazyTools, verbose_); + } + + values.push_back( mvaVal ); + } + + edm::ValueMap::Filler filler(*out); + filler.insert(egCollection, values.begin(), values.end() ); + filler.fill(); + + iEvent.put(out); + + return true; } //define this as a plug-in diff --git a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc index 3d455d1244e78..421dd7eb355a5 100644 --- a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc +++ b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc @@ -67,27 +67,27 @@ using namespace edm; using namespace reco; using namespace std; class ElectronTestAnalyzer : public edm::EDAnalyzer { - public: - explicit ElectronTestAnalyzer(const edm::ParameterSet&); - ~ElectronTestAnalyzer(); - - - private: - virtual void beginJob(const edm::EventSetup&) ; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - virtual void myBindVariables(); - virtual void myVar(const reco::GsfElectron& ele, - const reco::Vertex& vertex, - const TransientTrackBuilder& transientTrackBuilder, - EcalClusterLazyTools myEcalCluster, - bool printDebug = kFALSE); - virtual void evaluate_mvas(const edm::Event& iEvent, const edm::EventSetup& iSetup); - +public: + explicit ElectronTestAnalyzer(const edm::ParameterSet&); + ~ElectronTestAnalyzer(); + + +private: + virtual void beginJob(const edm::EventSetup&) ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + virtual void myBindVariables(); + virtual void myVar(const reco::GsfElectron& ele, + const reco::Vertex& vertex, + const TransientTrackBuilder& transientTrackBuilder, + EcalClusterLazyTools myEcalCluster, + bool printDebug = kFALSE); + virtual void evaluate_mvas(const edm::Event& iEvent, const edm::EventSetup& iSetup); + bool trainTrigPresel(const reco::GsfElectron& ele); - + ParameterSet conf_; - + edm::EDGetTokenT gsfEleToken_; edm::EDGetTokenT genToken_; //edm::EDGetTokenT mcTruthToken_; @@ -95,6 +95,8 @@ class ElectronTestAnalyzer : public edm::EDAnalyzer { //edm::EDGetTokenT pfCandToken_; edm::EDGetTokenT eventrhoToken_; edm::EDGetTokenT muonToken_; + edm::EDGetTokenT reducedEBRecHitCollectionToken_; + edm::EDGetTokenT reducedEERecHitCollectionToken_; EGammaMvaEleEstimator* myMVATrigV0; EGammaMvaEleEstimator* myMVATrigNoIPV0; @@ -181,8 +183,9 @@ ElectronTestAnalyzer::ElectronTestAnalyzer(const edm::ParameterSet& iConfig): vertexToken_(consumes(edm::InputTag("offlinePrimaryVertices"))), //pfCandToken_(consumes(edm::InputTag("particleFlow"))), eventrhoToken_(consumes(edm::InputTag("kt6PFJets", "rho"))), - muonToken_(consumes(edm::InputTag("muons"))) - + muonToken_(consumes(edm::InputTag("muons"))), + reducedEBRecHitCollectionToken_(consumes(edm::InputTag("reducedEcalRecHitsEB"))), + reducedEERecHitCollectionToken_(consumes(edm::InputTag("reducedEcalRecHitsEE"))) { Bool_t manualCat = true; @@ -320,12 +323,7 @@ ElectronTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& i Vertex::Point p(0, 0, 0); dummy = Vertex(p, e, 0, 0, 0); } - - - InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB")); - InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE")); - - EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection); + EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_); edm::ESHandle builder; iSetup.get().get("TransientTrackBuilder", builder); @@ -777,10 +775,7 @@ ElectronTestAnalyzer::evaluate_mvas(const edm::Event& iEvent, const edm::EventSe IdentifiedMuons.push_back(*iM); } - InputTag reducedEBRecHitCollection(string("reducedEcalRecHitsEB")); - InputTag reducedEERecHitCollection(string("reducedEcalRecHitsEE")); - - EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollection, reducedEERecHitCollection); + EcalClusterLazyTools lazyTools(iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_); edm::ESHandle builder; iSetup.get().get("TransientTrackBuilder", builder); From b810b66c07acf9f9c1618fbc7250d36569e02e5a Mon Sep 17 00:00:00 2001 From: Matteo Date: Mon, 17 Feb 2014 13:21:41 +0100 Subject: [PATCH 5/6] final updates --- RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc | 2 +- RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc index d21ccd6b60a81..a9e966788be5d 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc @@ -130,7 +130,7 @@ GEDPhotonProducer::GEDPhotonProducer(const edm::ParameterSet& config) : StringToEnumValue(severitynamesEE); thePhotonEnergyCorrector_ = - new PhotonEnergyCorrector(conf_); + new PhotonEnergyCorrector(conf_, consumesCollector()); if( config.existsAs("regressionConfig") ) { const edm::ParameterSet regr_conf = config.getParameterSet("regressionConfig"); diff --git a/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc b/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc index d3eb00d67f925..1af0888daeea6 100644 --- a/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc +++ b/RecoEgamma/EgammaPhotonProducers/src/PhotonProducer.cc @@ -132,6 +132,8 @@ PhotonProducer::PhotonProducer(const edm::ParameterSet& config) : preselCutValuesEndcap_.push_back(conf_.getParameter("sigmaIetaIetaCutEndcap")); // + thePhotonEnergyCorrector_ = new PhotonEnergyCorrector(conf_, consumesCollector()); + // Register the product produces< reco::PhotonCollection >(PhotonCollection_); @@ -150,11 +152,9 @@ void PhotonProducer::beginRun (edm::Run const& r, edm::EventSetup const & theEv thePhotonIsolationCalculator_ = new PhotonIsolationCalculator(); edm::ParameterSet isolationSumsCalculatorSet = conf_.getParameter("isolationSumsCalculatorSet"); thePhotonIsolationCalculator_->setup(isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_); - thePhotonMIPHaloTagger_ = new PhotonMIPHaloTagger(); edm::ParameterSet mipVariableSet = conf_.getParameter("mipVariableSet"); thePhotonMIPHaloTagger_->setup(mipVariableSet); - thePhotonEnergyCorrector_ = new PhotonEnergyCorrector(conf_); thePhotonEnergyCorrector_ -> init(theEventSetup); } From b535452dce8581e82c13adfac7f7a943fca86448 Mon Sep 17 00:00:00 2001 From: Matteo Date: Wed, 19 Feb 2014 17:28:00 +0100 Subject: [PATCH 6/6] fix typo --- .../src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc index cbef6af58a9b4..86ccc7367e995 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc @@ -94,12 +94,12 @@ void EgammaHLTRegionalPixelSeedGeneratorProducers::fillDescriptions(edm::Configu desc.add(("UseZInVertex"), false); desc.add("TTRHBuilder", "WithTrackAngle"); - ed::ParameterSetDescription orderedHitsPSET; + edm::ParameterSetDescription orderedHitsPSET; orderedHitsPSET.add("ComponentName", "StandardHitPairGenerator"); orderedHitsPSET.add("SeedingLayers", edm::InputTag("PixelLayerPairs")); orderedHitsPSET.add("maxElement", 0); desc.add("OrderedHitsFactoryPSet", orderedHitsPSET); - + descriptions.add(("hltEgammaHLTRegionalPixelSeedGeneratorProducers"), desc); }