Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second part of miniAOD developments #3545

Merged
merged 17 commits into from May 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DataFormats/BTauReco/src/classes_def.xml
@@ -1,5 +1,5 @@
<lcgdict>

<enum name="reco::btau::TaggingVariableName"/>
<class name="reco::BaseTagInfo" ClassVersion="10">
<version ClassVersion="10" checksum="2760058808"/>
</class>
Expand Down
78 changes: 78 additions & 0 deletions DataFormats/Candidate/interface/VertexCompositePtrCandidate.h
@@ -0,0 +1,78 @@
#ifndef DataFormats_Candidate_VertexCompositePtrCandidate_H
#define DataFormats_Candidate_VertexCompositePtrCandidate_H
/** \class reco::VertexCompositePtrCandidate
*
* A composite Candidate with error
* matrix and other vertex fix information.
*
* \author Luca Lista, INFN
*
*
*/
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidateFwd.h"
#include "DataFormats/Candidate/interface/CompositePtrCandidate.h"

namespace reco {
class VertexCompositePtrCandidate : public CompositePtrCandidate {
public:
VertexCompositePtrCandidate() : CompositePtrCandidate() { }
/// constructor from values
VertexCompositePtrCandidate(Charge q, const LorentzVector & p4, const Point & vtx,
int pdgId = 0, int status = 0, bool integerCharge = true) :
CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge),
chi2_(0), ndof_(0) { }
/// constructor from values
VertexCompositePtrCandidate(Charge q, const LorentzVector & p4, const Point & vtx,
const CovarianceMatrix & err, double chi2, double ndof,
int pdgId = 0, int status = 0, bool integerCharge = true);
/// constructor from values
explicit VertexCompositePtrCandidate(const Candidate & p) :
CompositePtrCandidate(p), chi2_(0), ndof_(0) { }
/// constructor from values
explicit VertexCompositePtrCandidate(const CompositePtrCandidate & p) :
CompositePtrCandidate(p), chi2_(0), ndof_(0) { }
/// destructor
virtual ~VertexCompositePtrCandidate();
/// returns a clone of the candidate
virtual VertexCompositePtrCandidate * clone() const;
/// chi-squares
virtual double vertexChi2() const { return chi2_; }
/** Number of degrees of freedom
* Meant to be Double32_t for soft-assignment fitters:
* tracks may contribute to the vertex with fractional weights.
* The ndof is then = to the sum of the track weights.
* see e.g. CMS NOTE-2006/032, CMS NOTE-2004/002
*/
virtual double vertexNdof() const { return ndof_; }
/// chi-squared divided by n.d.o.f.
virtual double vertexNormalizedChi2() const { return chi2_ / ndof_; }
/// (i, j)-th element of error matrix, i, j = 0, ... 2
virtual double vertexCovariance(int i, int j) const {
return covariance_[idx(i, j)];
}
using reco::LeafCandidate::vertexCovariance; // avoid hiding the
/// fill SMatrix
virtual void fillVertexCovariance(CovarianceMatrix & v) const;
/// set chi2 and ndof
void setChi2AndNdof(double chi2, double ndof) {
chi2_ = chi2; ndof_ = ndof;
}
/// set covariance matrix
void setCovariance(const CovarianceMatrix &m);
private:
/// chi-sqared
Double32_t chi2_;
/// number of degrees of freedom
Double32_t ndof_;
/// covariance matrix (3x3) as vector
Double32_t covariance_[size];
/// position index
index idx(index i, index j) const {
int a = (i <= j ? i : j), b = (i <= j ? j : i);
return b * (b + 1)/2 + a;
}
};

}

#endif
36 changes: 36 additions & 0 deletions DataFormats/Candidate/interface/VertexCompositePtrCandidateFwd.h
@@ -0,0 +1,36 @@
#ifndef DataFormats_Candidate_VertexCompositePtrCandidateFwd_h
#define DataFormats_Candidate_VertexCompositePtrCandidateFwd_h
#include "DataFormats/Common/interface/OwnVector.h"

namespace reco {
class VertexCompositePtrCandidate;
}

#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/RefProd.h"
#include "DataFormats/Common/interface/RefVector.h"
#include "DataFormats/Common/interface/RefToBase.h"
#include "DataFormats/Common/interface/RefToBaseVector.h"
#include "DataFormats/Common/interface/RefToBaseProd.h"
#include "DataFormats/Common/interface/View.h"

namespace reco {
/// collection of Candidate objects
typedef std::vector<VertexCompositePtrCandidate> VertexCompositePtrCandidateCollection;
/// view of a collection containing candidates
typedef edm::View<VertexCompositePtrCandidate> VertexCompositePtrCandidateView;
/// persistent reference to an object in a collection of Candidate objects
typedef edm::Ref<VertexCompositePtrCandidateCollection> VertexCompositePtrCandidateRef;
/// persistent reference to an object in a collection of Candidate objects
typedef edm::RefToBase<VertexCompositePtrCandidate> VertexCompositePtrCandidateBaseRef;
/// vector of references to objects in the same collection of Candidate objects
typedef edm::RefVector<VertexCompositePtrCandidateCollection> VertexCompositePtrCandidateRefVector;
/// vector of references to objects in the same collection of Candidate objects via base type
typedef edm::RefToBaseVector<VertexCompositePtrCandidate> VertexCompositePtrCandidateBaseRefVector;
/// reference to a collection of Candidate objects
typedef edm::RefProd<VertexCompositePtrCandidateCollection> VertexCompositePtrCandidateRefProd;
/// vector of references to objects in the same collection of Candidate objects via base type
typedef edm::RefToBaseProd<VertexCompositePtrCandidate> VertexCompositePtrCandidateBaseRefProd;
}

#endif
31 changes: 31 additions & 0 deletions DataFormats/Candidate/src/VertexCompositePtrCandidate.cc
@@ -0,0 +1,31 @@
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"

using namespace reco;

VertexCompositePtrCandidate::VertexCompositePtrCandidate(Charge q, const LorentzVector & p4, const Point & vtx,
const CovarianceMatrix & err, double chi2, double ndof,
int pdgId, int status, bool integerCharge) :
CompositePtrCandidate(q, p4, vtx, pdgId, status, integerCharge),
chi2_(chi2), ndof_(ndof) {
setCovariance(err);
}

VertexCompositePtrCandidate::~VertexCompositePtrCandidate() { }

VertexCompositePtrCandidate * VertexCompositePtrCandidate::clone() const {
return new VertexCompositePtrCandidate(*this);
}

void VertexCompositePtrCandidate::fillVertexCovariance(CovarianceMatrix& err) const {
index idx = 0;
for(index i = 0; i < dimension; ++i)
for(index j = 0; j <= i; ++ j)
err(i, j) = covariance_[idx++];
}

void VertexCompositePtrCandidate::setCovariance(const CovarianceMatrix & err) {
index idx = 0;
for(index i = 0; i < dimension; ++i)
for(index j = 0; j <= i; ++j)
covariance_[idx++] = err(i, j);
}
6 changes: 6 additions & 0 deletions DataFormats/Candidate/src/classes.h
Expand Up @@ -8,6 +8,7 @@
#include "Math/PxPyPzE4D.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"
#include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
#include "DataFormats/Candidate/interface/CompositeRefCandidate.h"
#include "DataFormats/Candidate/interface/CompositePtrCandidate.h"
#include "DataFormats/Candidate/interface/CompositeRefBaseCandidate.h"
Expand Down Expand Up @@ -102,6 +103,11 @@ namespace DataFormats_Candidate {
edm::reftobase::RefHolder<reco::CompositeCandidateRef> hcc2;
edm::reftobase::VectorHolder<reco::Candidate, reco::CompositeCandidateRefVector> hcc3;
edm::reftobase::RefVectorHolder<reco::CompositeCandidateRefVector> hcc4;
edm::Wrapper<reco::VertexCompositePtrCandidateCollection> wcc2p;
edm::reftobase::Holder<reco::Candidate, reco::VertexCompositePtrCandidateRef> hcc5p;
edm::reftobase::RefHolder<reco::VertexCompositePtrCandidateRef> hcc6p;
edm::reftobase::VectorHolder<reco::Candidate, reco::VertexCompositePtrCandidateRefVector> hcc7p;
edm::reftobase::RefVectorHolder<reco::VertexCompositePtrCandidateRefVector> hcc8p;
edm::Wrapper<reco::VertexCompositeCandidateCollection> wcc2;
edm::reftobase::Holder<reco::Candidate, reco::VertexCompositeCandidateRef> hcc5;
edm::reftobase::RefHolder<reco::VertexCompositeCandidateRef> hcc6;
Expand Down
12 changes: 12 additions & 0 deletions DataFormats/Candidate/src/classes_def.xml
Expand Up @@ -35,6 +35,9 @@
<class name="reco::CompositeCandidate" ClassVersion="10">
<version ClassVersion="10" checksum="2953566340"/>
</class>
<class name="reco::VertexCompositePtrCandidate" ClassVersion="10">
<version ClassVersion="10" checksum="955269040"/>
</class>
<class name="reco::VertexCompositeCandidate" ClassVersion="10">
<version ClassVersion="10" checksum="4177206274"/>
</class>
Expand Down Expand Up @@ -75,6 +78,7 @@
<class name="reco::CompositeCandidateRef" />
<class name="reco::CompositeCandidateRefVector" />
<class name="reco::VertexCompositeCandidateRefVector" />
<class name="reco::VertexCompositePtrCandidateRefVector" />
<class name="reco::CandidateRefProd" />

<class name="edm::reftobase::BaseHolder<reco::Candidate>" />
Expand Down Expand Up @@ -160,6 +164,14 @@
<class name="edm::reftobase::VectorHolder<reco::Candidate, reco::VertexCompositeCandidateRefVector>" />
<class name="edm::reftobase::RefVectorHolder<reco::VertexCompositeCandidateRefVector>" />

<class name="reco::VertexCompositePtrCandidateCollection" />
<class name="edm::Wrapper<reco::VertexCompositePtrCandidateCollection>" />
<class name="edm::reftobase::Holder<reco::Candidate, reco::VertexCompositePtrCandidateRef>" />
<class name="edm::reftobase::RefHolder<reco::VertexCompositePtrCandidateRef>" />
<class name="edm::reftobase::VectorHolder<reco::Candidate, reco::VertexCompositePtrCandidateRefVector>" />
<class name="edm::reftobase::RefVectorHolder<reco::VertexCompositePtrCandidateRefVector>" />


<class name="reco::NamedCompositeCandidateCollection" />
<class name="edm::Wrapper<reco::NamedCompositeCandidateCollection>" />
<class name="edm::reftobase::Holder<reco::Candidate, reco::NamedCompositeCandidateRef>" />
Expand Down
1 change: 1 addition & 0 deletions DataFormats/PatCandidates/BuildFile.xml
@@ -1,4 +1,5 @@
<use name="FWCore/Utilities"/>
<use name="FWCore/Common"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/StdDictionaries"/>
<use name="DataFormats/Candidate"/>
Expand Down
1 change: 1 addition & 0 deletions DataFormats/PatCandidates/src/classes_def_objects.xml
Expand Up @@ -180,6 +180,7 @@
]]>
</ioread>


<class name="pat::PackedGenParticle">
<field name="p4_" transient="true" />
<field name="p4c_" transient="true" />
Expand Down
28 changes: 24 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc
Expand Up @@ -22,7 +22,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 @@ -43,6 +44,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 @@ -60,7 +63,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 @@ -86,6 +92,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 All @@ -97,7 +104,7 @@ pat::PATElectronSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iS
if (dropBasicClusters_(electron)) { electron.basicClusters_.clear(); }
if (dropSuperClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowSuperCluster_.clear(); electron.embeddedPflowSuperCluster_ = false; }
if (dropBasicClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowBasicClusters_.clear(); }
if (dropPreshowerClusters_(electron)) { electron.preshowerClusters_.clear(); electron.embeddedSuperCluster_ = false; }
if (dropPreshowerClusters_(electron)) { electron.preshowerClusters_.clear(); }
if (dropPreshowerClusters_(electron) || dropPFlowClusters_(electron)) { electron.pflowPreshowerClusters_.clear(); }
if (dropSeedCluster_(electron)) { electron.seedCluster_.clear(); electron.embeddedSeedCluster_ = false; }
if (dropRecHits_(electron)) { electron.recHits_ = EcalRecHitCollection(); electron.embeddedRecHits_ = false; }
Expand All @@ -123,7 +130,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