Skip to content

Commit

Permalink
Merge in 7_5_X with root6 class version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetruc committed Mar 10, 2015
2 parents 62a64d7 + 0604dd8 commit 1e179d9
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 215 deletions.
26 changes: 11 additions & 15 deletions DataFormats/PatCandidates/interface/Electron.h
Expand Up @@ -175,13 +175,17 @@ namespace pat {
reco::CandidatePtr sourceCandidatePtr( size_type i ) const;

// ---- embed various impact parameters with errors ----
typedef enum IPTYPE { None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4 } IpType;
typedef enum IPTYPE { PV2D = 0, PV3D = 1, BS2D = 2, BS3D = 3, IpTypeSize = 4 } IpType;
/// Impact parameter wrt primary vertex or beamspot
double dB(IpType type = None) const;
double dB(IpType type) const;
/// Uncertainty on the corresponding impact parameter
double edB(IpType type = None) const;
double edB(IpType type) const;
/// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
double dB() const { return std::abs(dB(PV2D)); }
/// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
double edB() const { return std::abs(edB(PV2D)); }
/// Set impact parameter of a certain type and its uncertainty
void setDB(double dB, double edB, IpType type = None);
void setDB(double dB, double edB, IpType type);

// ---- Momentum estimate specific methods ----
const LorentzVector & ecalDrivenMomentum() const {return ecalDrivenMomentum_;}
Expand Down Expand Up @@ -311,14 +315,6 @@ namespace pat {
/// ECAL-driven momentum
LorentzVector ecalDrivenMomentum_;

// V+Jets group selection variables.
/// True if impact parameter has been cached
bool cachedDB_;
/// Impact parameter at the primary vertex
double dB_;
/// Impact paramater uncertainty at the primary vertex
double edB_;

/// additional missing mva variables : 14/04/2012
float sigmaIetaIphi_, full5x5_sigmaIetaIphi_;
double ip3d_;
Expand All @@ -345,11 +341,11 @@ namespace pat {

// ---- cached impact parameters ----
/// True if the IP (former dB) has been cached
std::vector<bool> cachedIP_;
uint8_t cachedIP_;
/// Impact parameter at the primary vertex,
std::vector<double> ip_;
float ip_[IpTypeSize];
/// Impact parameter uncertainty as recommended by the tracking group
std::vector<double> eip_;
float eip_[IpTypeSize];

// ---- link to PackedPFCandidates
edm::RefProd<pat::PackedCandidateCollection> packedPFCandidates_;
Expand Down
40 changes: 20 additions & 20 deletions DataFormats/PatCandidates/interface/Muon.h
Expand Up @@ -28,7 +28,6 @@
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h"


// Define typedefs for convenience
namespace pat {
class Muon;
Expand Down Expand Up @@ -204,21 +203,21 @@ namespace pat {
// muon->edB(pat::Muon::PV2D);
//
// IpType defines the type of the impact parameter
// None is default and reverts to old behavior controlled by
// patMuons.usePV = True/False
typedef enum IPTYPE
{
None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4
PV2D = 0, PV3D = 1, BS2D = 2, BS3D = 3, IpTypeSize = 4
} IpType;
void initImpactParameters(void); // init IP defaults in a constructor
double dB(IpType type = None) const;
double edB(IpType type = None) const;
void setDB ( double dB, double edB, IpType type = None ) {
if (type == None) {
dB_ = dB; edB_ = edB;
cachedDB_ = true;
}
ip_[type] = dB; eip_[type] = edB; cachedIP_[type] = true;
double dB(IpType type) const;
double edB(IpType type) const;

/// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
double dB() const { return std::abs(dB(PV2D)); }
/// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility)
double edB() const { return std::abs(edB(PV2D)); }

void setDB ( double dB, double edB, IpType type = PV2D ) {
ip_[type] = dB; eip_[type] = edB; cachedIP_ |= (1 << int(type));
}

/// numberOfValidHits returns the number of valid hits on the global track.
Expand All @@ -239,6 +238,9 @@ namespace pat {

friend class PATMuonSlimmer;

float pfEcalEnergy() const { return pfEcalEnergy_; }
void setPfEcalEnergy(float pfEcalEnergy) { pfEcalEnergy_ = pfEcalEnergy; }

protected:

// ---- for content embedding ----
Expand Down Expand Up @@ -286,20 +288,18 @@ namespace pat {

// V+Jets group selection variables.
bool cachedNormChi2_; /// has the normalized chi2 been cached?
bool cachedDB_; /// has the dB been cached?
double normChi2_; /// globalTrack->chi2() / globalTrack->ndof()

bool cachedNumberOfValidHits_;/// has the numberOfValidHits been cached?
double normChi2_; /// globalTrack->chi2() / globalTrack->ndof()
double dB_; /// dB and edB are the impact parameter at the primary vertex,
double edB_; // and its uncertainty as recommended by the tracking group
unsigned int numberOfValidHits_;/// globalTrack->numberOfValidHits()

// ---- cached impact parameters ----
std::vector<bool> cachedIP_; // has the IP (former dB) been cached?
std::vector<double> ip_; // dB and edB are the impact parameter at the primary vertex,
std::vector<double> eip_; // and its uncertainty as recommended by the tracking group
uint8_t cachedIP_; // has the IP (former dB) been cached?
float ip_[IpTypeSize]; // dB and edB are the impact parameter at the primary vertex,
float eip_[IpTypeSize]; // and its uncertainty as recommended by the tracking group

unsigned int numberOfValidHits_;/// globalTrack->numberOfValidHits()

float pfEcalEnergy_;
};


Expand Down
56 changes: 9 additions & 47 deletions DataFormats/PatCandidates/src/Electron.cc
Expand Up @@ -21,9 +21,6 @@ Electron::Electron() :
embeddedRecHits_(false),
embeddedPFCandidate_(false),
ecalDrivenMomentum_(Candidate::LorentzVector(0.,0.,0.,0.)),
cachedDB_(false),
dB_(0.0),
edB_(0.0),
ecalRegressionEnergy_(0.0),
ecalTrackRegressionEnergy_(0.0),
ecalRegressionError_(0.0),
Expand Down Expand Up @@ -51,10 +48,7 @@ Electron::Electron(const reco::GsfElectron & anElectron) :
embeddedSeedCluster_(false),
embeddedRecHits_(false),
embeddedPFCandidate_(false),
ecalDrivenMomentum_(anElectron.p4()),
cachedDB_(false),
dB_(0.0),
edB_(0.0)
ecalDrivenMomentum_(anElectron.p4())
{
initImpactParameters();
}
Expand All @@ -70,10 +64,7 @@ Electron::Electron(const edm::RefToBase<reco::GsfElectron> & anElectronRef) :
embeddedSeedCluster_(false),
embeddedRecHits_(false),
embeddedPFCandidate_(false),
ecalDrivenMomentum_(anElectronRef->p4()),
cachedDB_(false),
dB_(0.0),
edB_(0.0)
ecalDrivenMomentum_(anElectronRef->p4())
{
initImpactParameters();
}
Expand All @@ -89,10 +80,7 @@ Electron::Electron(const edm::Ptr<reco::GsfElectron> & anElectronRef) :
embeddedSeedCluster_(false),
embeddedRecHits_(false),
embeddedPFCandidate_(false),
ecalDrivenMomentum_(anElectronRef->p4()),
cachedDB_(false),
dB_(0.0),
edB_(0.0)
ecalDrivenMomentum_(anElectronRef->p4())
{
initImpactParameters();
}
Expand Down Expand Up @@ -121,11 +109,9 @@ reco::operator<<(std::ostream& out, const pat::Electron& obj)

/// initializes the impact parameter container vars
void Electron::initImpactParameters() {
for (int i_ = 0; i_<5; ++i_){
ip_.push_back(0.0);
eip_.push_back(0.0);
cachedIP_.push_back(false);
}
std::fill(ip_, ip_+IpTypeSize, 0.0f);
std::fill(eip_, eip_+IpTypeSize, 0.0f);
cachedIP_ = 0;
}


Expand Down Expand Up @@ -412,16 +398,8 @@ reco::CandidatePtr Electron::sourceCandidatePtr( size_type i ) const {
/// will return the electron transverse impact parameter
/// relative to the primary vertex.
double Electron::dB(IpType type_) const {
// preserve old functionality exactly
if (type_ == None){
if ( cachedDB_ ) {
return dB_;
} else {
return std::numeric_limits<double>::max();
}
}
// more IP types (new)
else if ( cachedIP_[type_] ) {
if ( cachedIP_ & (1 << int(type_))) {
return ip_[type_];
} else {
return std::numeric_limits<double>::max();
Expand All @@ -439,33 +417,17 @@ double Electron::dB(IpType type_) const {
/// will return the electron transverse impact parameter uncertainty
/// relative to the primary vertex.
double Electron::edB(IpType type_) const {
// preserve old functionality exactly
if (type_ == None) {
if ( cachedDB_ ) {
return edB_;
} else {
return std::numeric_limits<double>::max();
}
}
// more IP types (new)
else if ( cachedIP_[type_] ) {
if ( cachedIP_ & (1 << int(type_))) {
return eip_[type_];
} else {
return std::numeric_limits<double>::max();
}

}

/// Sets the impact parameter and its error wrt the beamline and caches it.
void Electron::setDB(double dB, double edB, IpType type){
if (type == None) { // Preserve old functionality exactly
dB_ = dB; edB_ = edB;
cachedDB_ = true;
} else {
ip_[type] = dB;
eip_[type] = edB;
cachedIP_[type] = true;
}
ip_[type] = dB; eip_[type] = edB; cachedIP_ |= (1 << int(type));
}

/// Set additional missing mva input variables for new mva ID (71X update)
Expand Down
70 changes: 17 additions & 53 deletions DataFormats/PatCandidates/src/Muon.cc
Expand Up @@ -26,12 +26,10 @@ Muon::Muon() :
embeddedPFCandidate_(false),
pfCandidateRef_(),
cachedNormChi2_(false),
cachedDB_(false),
cachedNumberOfValidHits_(0),
normChi2_(0.0),
dB_(0.0),
edB_(0.0),
numberOfValidHits_(0)
cachedNumberOfValidHits_(false),
numberOfValidHits_(0),
pfEcalEnergy_(0)
{
initImpactParameters();
}
Expand All @@ -52,12 +50,10 @@ Muon::Muon(const reco::Muon & aMuon) :
embeddedPFCandidate_(false),
pfCandidateRef_(),
cachedNormChi2_(false),
cachedDB_(false),
cachedNumberOfValidHits_(0),
normChi2_(0.0),
dB_(0.0),
edB_(0.0),
numberOfValidHits_(0)
cachedNumberOfValidHits_(false),
numberOfValidHits_(0),
pfEcalEnergy_(0)
{
initImpactParameters();
}
Expand All @@ -78,12 +74,10 @@ Muon::Muon(const edm::RefToBase<reco::Muon> & aMuonRef) :
embeddedPFCandidate_(false),
pfCandidateRef_(),
cachedNormChi2_(false),
cachedDB_(false),
cachedNumberOfValidHits_(0),
normChi2_(0.0),
dB_(0.0),
edB_(0.0),
numberOfValidHits_(0)
cachedNumberOfValidHits_(0),
numberOfValidHits_(0),
pfEcalEnergy_(0)
{
initImpactParameters();
}
Expand All @@ -104,12 +98,10 @@ Muon::Muon(const edm::Ptr<reco::Muon> & aMuonRef) :
embeddedPFCandidate_(false),
pfCandidateRef_(),
cachedNormChi2_(false),
cachedDB_(false),
cachedNumberOfValidHits_(0),
normChi2_(0.0),
dB_(0.0),
edB_(0.0),
numberOfValidHits_(0)
cachedNumberOfValidHits_(0),
numberOfValidHits_(0),
pfEcalEnergy_(0)
{
initImpactParameters();
}
Expand Down Expand Up @@ -137,11 +129,9 @@ reco::operator<<(std::ostream& out, const pat::Muon& obj)

// initialize impact parameter container vars
void Muon::initImpactParameters() {
for (int i_ = 0; i_<5; ++i_){
ip_.push_back(0.0);
eip_.push_back(0.0);
cachedIP_.push_back(false);
}
std::fill(ip_, ip_+IpTypeSize, 0.0f);
std::fill(eip_, eip_+IpTypeSize, 0.0f);
cachedIP_ = 0;
}


Expand Down Expand Up @@ -405,22 +395,9 @@ unsigned int Muon::numberOfValidHits() const {

// embed various impact parameters with errors
// IpType defines the type of the impact parameter
// None is default and reverts to old behavior controlled by
// patMuons.usePV = True/False
double Muon::dB(IpType type_) const {

// preserve old functionality exactly
if (type_ == None){
if ( cachedDB_ ) {
return dB_;
}
else {
return std::numeric_limits<double>::max();
}
}

// more IP types (new)
else if ( cachedIP_[type_] ) {
if ( cachedIP_ & (1 << int(type_))) {
return ip_[type_];
} else {
return std::numeric_limits<double>::max();
Expand All @@ -430,22 +407,9 @@ double Muon::dB(IpType type_) const {

// embed various impact parameters with errors
// IpType defines the type of the impact parameter
// None is default and reverts to old behavior controlled by
// patMuons.usePV = True/False
double Muon::edB(IpType type_) const {

// preserve old functionality exactly
if (type_ == None){
if ( cachedDB_ ) {
return edB_;
}
else {
return std::numeric_limits<double>::max();
}
}

// more IP types (new)
else if ( cachedIP_[type_] ) {
if ( cachedIP_ & (1 << int(type_))) {
return eip_[type_];
} else {
return std::numeric_limits<double>::max();
Expand Down

0 comments on commit 1e179d9

Please sign in to comment.