Skip to content

Commit

Permalink
update producers and other code to squashed shower shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
lgray committed Sep 18, 2015
1 parent ade3563 commit a8bd036
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 100 deletions.
5 changes: 1 addition & 4 deletions PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc
Expand Up @@ -131,10 +131,7 @@ pat::PATElectronSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iS
if (dropRecHits_(electron)) { electron.recHits_ = EcalRecHitCollection(); electron.embeddedRecHits_ = false; }
if (dropCorrections_(electron)) { electron.setCorrections(reco::GsfElectron::Corrections()); }
if (dropIsolations_(electron)) { electron.setDr03Isolation(reco::GsfElectron::IsolationVariables()); electron.setDr04Isolation(reco::GsfElectron::IsolationVariables()); electron.setPfIsolationVariables(reco::GsfElectron::PflowIsolationVariables()); electron.setEcalPFClusterIso(0); electron.setHcalPFClusterIso(0); }
if (dropShapes_(electron)) {
electron.setShowerShape(reco::GsfElectron::ShowerShape());
electron.setExtraShowerShapes(reco::GsfElectron::ExtraShowerShapes());
}
if (dropShapes_(electron)) { electron.setShowerShape(reco::GsfElectron::ShowerShape()); }
if (dropExtrapolations_(electron)) { electron.setTrackExtrapolations(reco::GsfElectron::TrackExtrapolations()); }
if (dropClassifications_(electron)) { electron.setClassificationVariables(reco::GsfElectron::ClassificationVariables()); electron.setClassification(reco::GsfElectron::Classification()); }
if (linkToPackedPF_) {
Expand Down
4 changes: 2 additions & 2 deletions RecoEgamma/EgammaElectronAlgos/interface/GsfElectronAlgo.h
Expand Up @@ -250,9 +250,9 @@ class GsfElectronAlgo {
void setPflowPreselectionFlag( reco::GsfElectron * ele ) ;
bool isPreselected( reco::GsfElectron * ele ) ;
void calculateShowerShape( const reco::SuperClusterRef &, bool pflow,
reco::GsfElectron::ShowerShape & , reco::GsfElectron::ExtraShowerShapes & ) ;
reco::GsfElectron::ShowerShape & ) ;
void calculateShowerShape_full5x5( const reco::SuperClusterRef &, bool pflow,
reco::GsfElectron::ShowerShape &, reco::GsfElectron::ExtraShowerShapes & ) ;
reco::GsfElectron::ShowerShape & ) ;


// associations
Expand Down
54 changes: 23 additions & 31 deletions RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc
Expand Up @@ -538,7 +538,7 @@ Candidate::LorentzVector GsfElectronAlgo::ElectronData::calculateMomentum()
}

void GsfElectronAlgo::calculateShowerShape( const reco::SuperClusterRef & theClus, bool pflow,
reco::GsfElectron::ShowerShape & showerShape, reco::GsfElectron::ExtraShowerShapes & exShowerShape )
reco::GsfElectron::ShowerShape & showerShape )
{
const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
// temporary, till CaloCluster->seed() is made available
Expand Down Expand Up @@ -593,23 +593,22 @@ void GsfElectronAlgo::calculateShowerShape( const reco::SuperClusterRef & theClu
// extra shower shapes
const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
if( see_by_spp > 0 ) {
exShowerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
} else if ( localCovariances[1] > 0 ) {
exShowerShape.sigmaIetaIphi = 1.f;
showerShape.sigmaIetaIphi = 1.f;
} else {
exShowerShape.sigmaIetaIphi = -1.f;
showerShape.sigmaIetaIphi = -1.f;
}
exShowerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
exShowerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
exShowerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
exShowerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
exShowerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
exShowerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);

showerShape.eMax = EcalClusterTools::eMax(seedCluster,recHits);
showerShape.e2nd = EcalClusterTools::e2nd(seedCluster,recHits);
showerShape.eTop = EcalClusterTools::eTop(seedCluster,recHits,topology);
showerShape.eLeft = EcalClusterTools::eLeft(seedCluster,recHits,topology);
showerShape.eRight = EcalClusterTools::eRight(seedCluster,recHits,topology);
showerShape.eBottom = EcalClusterTools::eBottom(seedCluster,recHits,topology);
}

void GsfElectronAlgo::calculateShowerShape_full5x5( const reco::SuperClusterRef & theClus, bool pflow,
reco::GsfElectron::ShowerShape & showerShape, reco::GsfElectron::ExtraShowerShapes & exShowerShape )
reco::GsfElectron::ShowerShape & showerShape )
{
const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
// temporary, till CaloCluster->seed() is made available
Expand Down Expand Up @@ -664,19 +663,18 @@ void GsfElectronAlgo::calculateShowerShape_full5x5( const reco::SuperClusterRef
// extra shower shapes
const float see_by_spp = showerShape.sigmaIetaIeta*showerShape.sigmaIphiIphi;
if( see_by_spp > 0 ) {
exShowerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
showerShape.sigmaIetaIphi = localCovariances[1] / see_by_spp;
} else if ( localCovariances[1] > 0 ) {
exShowerShape.sigmaIetaIphi = 1.f;
showerShape.sigmaIetaIphi = 1.f;
} else {
exShowerShape.sigmaIetaIphi = -1.f;
showerShape.sigmaIetaIphi = -1.f;
}
exShowerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
exShowerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
exShowerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
exShowerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
exShowerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
exShowerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);

showerShape.eMax = noZS::EcalClusterTools::eMax(seedCluster,recHits);
showerShape.e2nd = noZS::EcalClusterTools::e2nd(seedCluster,recHits);
showerShape.eTop = noZS::EcalClusterTools::eTop(seedCluster,recHits,topology);
showerShape.eLeft = noZS::EcalClusterTools::eLeft(seedCluster,recHits,topology);
showerShape.eRight = noZS::EcalClusterTools::eRight(seedCluster,recHits,topology);
showerShape.eBottom = noZS::EcalClusterTools::eBottom(seedCluster,recHits,topology);
}


Expand Down Expand Up @@ -1362,12 +1360,10 @@ void GsfElectronAlgo::createElectron(const gsfAlgoHelpers::HeavyObjectCache* hoc
//====================================================

reco::GsfElectron::ShowerShape showerShape ;
reco::GsfElectron::ExtraShowerShapes exShowerShapes ;
calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape, exShowerShapes) ;
calculateShowerShape(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),showerShape) ;

reco::GsfElectron::ShowerShape full5x5_showerShape ;
reco::GsfElectron::ExtraShowerShapes full5x5_exShowerShapes ;
calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape, full5x5_exShowerShapes) ;
calculateShowerShape_full5x5(electronData_->superClusterRef,!(electronData_->coreRef->ecalDrivenSeed()),full5x5_showerShape) ;

//====================================================
// ConversionRejection
Expand Down Expand Up @@ -1413,11 +1409,7 @@ void GsfElectronAlgo::createElectron(const gsfAlgoHelpers::HeavyObjectCache* hoc
// Will be overwritten later in the case of the regression
ele->setCorrectedEcalEnergyError(generalData_->superClusterErrorFunction->getValue(*(ele->superCluster()),0)) ;
ele->setP4(GsfElectron::P4_FROM_SUPER_CLUSTER,momentum,0,true) ;

// set the extra shower shapes
ele->setExtraShowerShapes(exShowerShapes);
ele->full5x5_setExtraShowerShapes(full5x5_exShowerShapes);


//====================================================
// brems fractions
//====================================================
Expand Down
84 changes: 39 additions & 45 deletions RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc
Expand Up @@ -566,29 +566,29 @@ void GEDPhotonProducer::fillPhotonCollection(edm::Event& evt,
showerShape.hcalDepth1OverEcalBc = hcalDepth1OverEcalBc;
showerShape.hcalDepth2OverEcalBc = hcalDepth2OverEcalBc;
showerShape.hcalTowersBehindClusters = TowersBehindClus;
newCandidate.setShowerShapeVariables ( showerShape );

/// fill extra shower shapes
const float spp = (edm::isFinite(locCov[2]) ? 0. : sqrt(locCov[2]));
const float sep = locCov[1];

reco::Photon::ExtraShowerShapes exShowerShape;
exShowerShape.sigmaIetaIphi = spp;
exShowerShape.sigmaIphiIphi = sep;
exShowerShape.e2nd = EcalClusterTools::e2nd(*(scRef->seed()),&(*hits));
exShowerShape.eTop = EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.eLeft = EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.eRight = EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.eBottom = EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e1x3 = EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x2 = EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x5Max = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x5Left = EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x5Right = EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x5Top = EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology));
exShowerShape.e2x5Bottom = EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology));
newCandidate.setExtraShowerShapes( exShowerShape );

showerShape.sigmaIetaIphi = spp;
showerShape.sigmaIphiIphi = sep;
showerShape.e2nd = EcalClusterTools::e2nd(*(scRef->seed()),&(*hits));
showerShape.eTop = EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology));
showerShape.eLeft = EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology));
showerShape.eRight = EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology));
showerShape.eBottom = EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e1x3 = EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x2 = EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x5Max = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x5Left = EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x5Right = EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x5Top = EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology));
showerShape.e2x5Bottom = EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology));
// fill preshower shapes
EcalClusterLazyTools toolsforES(evt, es, barrelEcalHits_, endcapEcalHits_, preshowerHits_);
const float sigmaRR = toolsforES.eseffsirir( *scRef );
showerShape.effSigmaRR = sigmaRR;
newCandidate.setShowerShapeVariables ( showerShape );

/// fill full5x5 shower shape block
reco::Photon::ShowerShape full5x5_showerShape;
full5x5_showerShape.e1x5= full5x5_e1x5;
Expand All @@ -598,34 +598,28 @@ void GEDPhotonProducer::fillPhotonCollection(edm::Event& evt,
full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );

/// fill extra full5x5 shower shapes
const float full5x5_spp = (edm::isFinite(full5x5_locCov[2]) ? 0. : sqrt(full5x5_locCov[2]));
const float full5x5_sep = full5x5_locCov[1];
reco::Photon::ExtraShowerShapes full5x5_exShowerShape;
full5x5_exShowerShape.sigmaIetaIphi = full5x5_spp;
full5x5_exShowerShape.sigmaIphiIphi = full5x5_sep;
full5x5_exShowerShape.e2nd = noZS::EcalClusterTools::e2nd(*(scRef->seed()),&(*hits));
full5x5_exShowerShape.eTop = noZS::EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.eLeft = noZS::EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.eRight = noZS::EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.eBottom = noZS::EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e1x3 = noZS::EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x2 = noZS::EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x5Left = noZS::EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x5Right = noZS::EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x5Top = noZS::EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology));
full5x5_exShowerShape.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology));
newCandidate.full5x5_setExtraShowerShapes(full5x5_exShowerShape);

// fill preshower shapes
EcalClusterLazyTools toolsforES(evt, es, barrelEcalHits_, endcapEcalHits_, preshowerHits_);
reco::Photon::PreshowerShapes esShowerShape;
esShowerShape.effSigmaRR = toolsforES.eseffsirir( *scRef );

newCandidate.setPreshowerShapes(esShowerShape);
full5x5_showerShape.sigmaIetaIphi = full5x5_spp;
full5x5_showerShape.sigmaIphiIphi = full5x5_sep;
full5x5_showerShape.e2nd = noZS::EcalClusterTools::e2nd(*(scRef->seed()),&(*hits));
full5x5_showerShape.eTop = noZS::EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.eLeft = noZS::EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.eRight = noZS::EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.eBottom = noZS::EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e1x3 = noZS::EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x2 = noZS::EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x5Left = noZS::EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x5Right = noZS::EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x5Top = noZS::EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology));
full5x5_showerShape.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology));
// fill preshower shapes
full5x5_showerShape.effSigmaRR = sigmaRR;
newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );



/// get ecal photon specific corrected energy
/// plus values from regressions and store them in the Photon
Expand Down
36 changes: 18 additions & 18 deletions RecoEgamma/EgammaTools/plugins/EGExtraInfoModifierFromDB.cc
Expand Up @@ -393,7 +393,7 @@ void EGExtraInfoModifierFromDB::modifyObject(reco::GsfElectron& ele) const {

std::array<float, 33> eval;
const double raw_energy = the_sc->rawEnergy();
const auto& ess = ele.extraShowerShapes();
const auto& ess = ele.showerShape();

// SET INPUTS
eval[0] = nVtx_;
Expand All @@ -402,15 +402,15 @@ void EGExtraInfoModifierFromDB::modifyObject(reco::GsfElectron& ele) const {
eval[3] = the_sc->phi();
eval[4] = the_sc->etaWidth();
eval[5] = the_sc->phiWidth();
eval[6] = ele.r9();
eval[6] = ess.r9;
eval[7] = theseed->energy()/raw_energy;
eval[8] = ess.eMax/raw_energy;
eval[9] = ess.e2nd/raw_energy;
eval[10] = (ess.eLeft + ess.eRight != 0.f ? (ess.eLeft-ess.eRight)/(ess.eLeft+ess.eRight) : 0.f);
eval[11] = (ess.eTop + ess.eBottom != 0.f ? (ess.eTop-ess.eBottom)/(ess.eTop+ess.eBottom) : 0.f);
eval[12] = ele.sigmaIetaIeta();
eval[12] = ess.sigmaIetaIeta;
eval[13] = ess.sigmaIetaIphi;
eval[14] = ele.sigmaIphiIphi();
eval[14] = ess.sigmaIphiIphi;
eval[15] = std::max(0,numberOfClusters-1);

// calculate sub-cluster variables
Expand Down Expand Up @@ -590,7 +590,7 @@ void EGExtraInfoModifierFromDB::modifyObject(reco::Photon& pho) const {
if( missing_clusters ) return ; // do not apply corrections in case of missing info (slimmed MiniAOD electrons)

const double raw_energy = the_sc->rawEnergy();
const auto& ess = pho.extraShowerShapes();
const auto& ess = pho.showerShapeVariables();

// SET INPUTS
eval[0] = raw_energy;
Expand All @@ -606,21 +606,21 @@ void EGExtraInfoModifierFromDB::modifyObject(reco::Photon& pho) const {
eval[8] = theseed->eta()-the_sc->position().Eta();
eval[9] = reco::deltaPhi(theseed->phi(),the_sc->position().Phi());
eval[10] = theseed->energy()/raw_energy;
eval[11] = pho.e3x3()/pho.e5x5();
eval[12] = pho.sigmaIetaIeta();
eval[11] = ess.e3x3/ess.e5x5;
eval[12] = ess.sigmaIetaIeta;
eval[13] = ess.sigmaIphiIphi;
eval[14] = ess.sigmaIetaIphi;
eval[15] = pho.maxEnergyXtal()/pho.e5x5();
eval[16] = ess.e2nd/pho.e5x5();
eval[17] = ess.eTop/pho.e5x5();
eval[18] = ess.eBottom/pho.e5x5();
eval[19] = ess.eLeft/pho.e5x5();
eval[20] = ess.eRight/pho.e5x5();
eval[21] = ess.e2x5Max/pho.e5x5();
eval[22] = ess.e2x5Left/pho.e5x5();
eval[23] = ess.e2x5Right/pho.e5x5();
eval[24] = ess.e2x5Top/pho.e5x5();
eval[25] = ess.e2x5Bottom/pho.e5x5();
eval[15] = ess.maxEnergyXtal/ess.e5x5;
eval[16] = ess.e2nd/ess.e5x5;
eval[17] = ess.eTop/ess.e5x5;
eval[18] = ess.eBottom/ess.e5x5;
eval[19] = ess.eLeft/ess.e5x5;
eval[20] = ess.eRight/ess.e5x5;
eval[21] = ess.e2x5Max/ess.e5x5;
eval[22] = ess.e2x5Left/ess.e5x5;
eval[23] = ess.e2x5Right/ess.e5x5;
eval[24] = ess.e2x5Top/ess.e5x5;
eval[25] = ess.e2x5Bottom/ess.e5x5;

const bool iseb = pho.isEB();
if (iseb) {
Expand Down

0 comments on commit a8bd036

Please sign in to comment.