Skip to content

Commit

Permalink
Merge pull request #12 from gpetruc/micro-from71X
Browse files Browse the repository at this point in the history
nonZS cluster shapes as userFloats: 71X version
  • Loading branch information
arizzi committed Apr 16, 2014
2 parents d77d4d6 + 2b2938a commit 2df1412
Show file tree
Hide file tree
Showing 10 changed files with 2,626 additions and 2,436 deletions.
26 changes: 23 additions & 3 deletions PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h"

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "FWCore/Utilities/interface/isFinite.h"

namespace pat {

Expand All @@ -48,6 +49,8 @@ namespace pat {
edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>> pf2pc_;
edm::EDGetTokenT<pat::PackedCandidateCollection> pc_;
bool linkToPackedPF_;
StringCutObjectSelector<pat::Electron> saveNonZSClusterShapes_;
edm::EDGetTokenT<EcalRecHitCollection> reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_;
};

} // namespace
Expand All @@ -65,7 +68,10 @@ pat::PATElectronSlimmer::PATElectronSlimmer(const edm::ParameterSet & iConfig) :
dropShapes_(iConfig.getParameter<std::string>("dropShapes")),
dropExtrapolations_(iConfig.getParameter<std::string>("dropExtrapolations")),
dropClassifications_(iConfig.getParameter<std::string>("dropClassifications")),
linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates"))
linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
reducedBarrelRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
reducedEndcapRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection")))
{
produces<std::vector<pat::Electron> >();
if (linkToPackedPF_) {
Expand All @@ -91,6 +97,7 @@ pat::PATElectronSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iS
iEvent.getByToken(pf2pc_, pf2pc);
iEvent.getByToken(pc_, pc);
}
noZS::EcalClusterLazyTools lazyToolsNoZS(iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);

auto_ptr<vector<pat::Electron> > out(new vector<pat::Electron>());
out->reserve(src->size());
Expand Down Expand Up @@ -128,7 +135,20 @@ pat::PATElectronSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iS
} else {
electron.refToOrig_ = reco::CandidatePtr(pc.id());
}
}
}
if (saveNonZSClusterShapes_(electron)) {
std::vector<float> vCov = lazyToolsNoZS.localCovariances(*( electron.superCluster()->seed()));
float r9 = lazyToolsNoZS.e3x3( *( electron.superCluster()->seed())) / electron.superCluster()->rawEnergy() ;
float sigmaIetaIeta = ( !edm::isNotFinite(vCov[0]) ) ? sqrt(vCov[0]) : 0;
float sigmaIetaIphi = vCov[1];
float sigmaIphiIphi = ( !edm::isNotFinite(vCov[2]) ) ? sqrt(vCov[2]) : 0;
float e15o55 = lazyToolsNoZS.e1x5( *( electron.superCluster()->seed()) ) / lazyToolsNoZS.e5x5( *( electron.superCluster()->seed()) );
electron.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
electron.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
electron.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
electron.addUserFloat("r9_NoZS", r9);
electron.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
}

}

Expand Down
23 changes: 22 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATPhotonSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "CommonTools/UtilAlgos/interface/StringCutObjectSelector.h"
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "FWCore/Utilities/interface/isFinite.h"

namespace pat {

Expand All @@ -39,6 +41,8 @@ namespace pat {
edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>> pf2pc_;
edm::EDGetTokenT<pat::PackedCandidateCollection> pc_;
bool linkToPackedPF_;
StringCutObjectSelector<pat::Photon> saveNonZSClusterShapes_;
edm::EDGetTokenT<EcalRecHitCollection> reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_;
};

} // namespace
Expand All @@ -50,7 +54,10 @@ pat::PATPhotonSlimmer::PATPhotonSlimmer(const edm::ParameterSet & iConfig) :
dropPreshowerClusters_(iConfig.getParameter<std::string>("dropPreshowerClusters")),
dropSeedCluster_(iConfig.getParameter<std::string>("dropSeedCluster")),
dropRecHits_(iConfig.getParameter<std::string>("dropRecHits")),
linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates"))
linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
saveNonZSClusterShapes_(iConfig.getParameter<std::string>("saveNonZSClusterShapes")),
reducedBarrelRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedBarrelRecHitCollection"))),
reducedEndcapRecHitCollectionToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEndcapRecHitCollection")))
{
produces<std::vector<pat::Photon> >();
if (linkToPackedPF_) {
Expand All @@ -76,6 +83,7 @@ pat::PATPhotonSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSet
iEvent.getByToken(pf2pc_, pf2pc);
iEvent.getByToken(pc_, pc);
}
noZS::EcalClusterLazyTools lazyToolsNoZS(iEvent, iSetup, reducedBarrelRecHitCollectionToken_, reducedEndcapRecHitCollectionToken_);

auto_ptr<vector<pat::Photon> > out(new vector<pat::Photon>());
out->reserve(src->size());
Expand Down Expand Up @@ -108,6 +116,19 @@ pat::PATPhotonSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSet
photon.refToOrig_ = reco::CandidatePtr(pc.id());
}
}
if (saveNonZSClusterShapes_(photon)) {
std::vector<float> vCov = lazyToolsNoZS.localCovariances(*( photon.superCluster()->seed()));
float r9 = lazyToolsNoZS.e3x3( *( photon.superCluster()->seed())) / photon.superCluster()->rawEnergy() ;
float sigmaIetaIeta = ( !edm::isNotFinite(vCov[0]) ) ? sqrt(vCov[0]) : 0;
float sigmaIetaIphi = vCov[1];
float sigmaIphiIphi = ( !edm::isNotFinite(vCov[2]) ) ? sqrt(vCov[2]) : 0;
float e15o55 = lazyToolsNoZS.e1x5( *( photon.superCluster()->seed()) ) / lazyToolsNoZS.e5x5( *( photon.superCluster()->seed()) );
photon.addUserFloat("sigmaIetaIeta_NoZS", sigmaIetaIeta);
photon.addUserFloat("sigmaIetaIphi_NoZS", sigmaIetaIphi);
photon.addUserFloat("sigmaIphiIphi_NoZS", sigmaIphiIphi);
photon.addUserFloat("r9_NoZS", r9);
photon.addUserFloat("e1x5_over_e5x5_NoZS", e15o55);
}
}

iEvent.put(out);
Expand Down
3 changes: 3 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimmedElectrons_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
linkToPackedPFCandidates = cms.bool(True),
recoToPFMap = cms.InputTag("particleBasedIsolation","gedGsfElectrons"),
packedPFCandidates = cms.InputTag("packedPFCandidates"),
saveNonZSClusterShapes = cms.string("pt > 5"), # save additional user floats: (sigmaIetaIeta,sigmaIphiIphi,sigmaIetaIphi,r9,e1x5_over_e5x5)_NoZS
reducedBarrelRecHitCollection = cms.InputTag("reducedEcalRecHitsEB"),
reducedEndcapRecHitCollection = cms.InputTag("reducedEcalRecHitsEE"),
)

3 changes: 3 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimmedPhotons_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
linkToPackedPFCandidates = cms.bool(True),
recoToPFMap = cms.InputTag("particleBasedIsolation","gedPhotons"),
packedPFCandidates = cms.InputTag("packedPFCandidates"),
saveNonZSClusterShapes = cms.string("(r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), # save additional user floats: (sigmaIetaIeta,sigmaIphiIphi,sigmaIetaIphi,r9,e1x5_over_e5x5)_NoZS
reducedBarrelRecHitCollection = cms.InputTag("reducedEcalRecHitsEB"),
reducedEndcapRecHitCollection = cms.InputTag("reducedEcalRecHitsEE"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Geometry/CaloTopology/interface/CaloTopology.h"

#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"

/**\class PFECALSuperClusterProducer
Expand All @@ -38,8 +39,6 @@ class CaloSubdetectorGeometry;
class DetId;
class GBRForest;
class GBRWrapperRcd;
class EcalClusterTools;


class PFECALSuperClusterProducer : public edm::EDProducer {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"

#include "DataFormats/Common/interface/ValueMap.h"

Expand Down
Loading

0 comments on commit 2df1412

Please sign in to comment.