Skip to content

Commit

Permalink
Merge pull request #15 from gpetruc/micro-from700
Browse files Browse the repository at this point in the history
rebase of bugfixes from the miniAOD-from710pre5 pull request
  • Loading branch information
arizzi committed Apr 16, 2014
2 parents 3684f74 + 00ac0cb commit 0412d70
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 131 deletions.
9 changes: 9 additions & 0 deletions DataFormats/EgammaCandidates/interface/GsfElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ class GsfElectron : public RecoCandidate
math::XYZVectorF trackMomentumAtVtxWithConstraint() const { return trackExtrapolations_.momentumAtVtxWithConstraint ; }
const TrackExtrapolations & trackExtrapolations() const { return trackExtrapolations_ ; }

// setter (if you know what you're doing)
void setTrackExtrapolations(const TrackExtrapolations &te) { trackExtrapolations_ = te; }

// for backward compatibility
math::XYZPointF TrackPositionAtVtx() const { return trackPositionAtVtx() ; }
math::XYZPointF TrackPositionAtCalo() const { return trackPositionAtCalo() ; }
Expand Down Expand Up @@ -394,6 +397,9 @@ class GsfElectron : public RecoCandidate
float hcalOverEcalBc() const { return hcalDepth1OverEcalBc() + hcalDepth2OverEcalBc() ; }
const ShowerShape & showerShape() const { return showerShape_ ; }

// setters (if you know what you're doing)
void setShowerShape(const ShowerShape &s) { showerShape_ = s; }

// for backward compatibility
float scSigmaEtaEta() const { return sigmaEtaEta() ; }
float scSigmaIEtaIEta() const { return sigmaIetaIeta() ; }
Expand Down Expand Up @@ -725,6 +731,9 @@ class GsfElectron : public RecoCandidate
float p4Error( P4Kind kind ) const ;
P4Kind candidateP4Kind() const { return corrections_.candidateP4Kind ; }
const Corrections & corrections() const { return corrections_ ; }

// bare setter (if you know what you're doing)
void setCorrections(const Corrections &c) { corrections_ = c; }

// for backward compatibility
void setEcalEnergyError( float energyError ) { setCorrectedEcalEnergyError(energyError) ; }
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/JetReco/interface/GenJet.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class GenJet : public Jet {

const Specific& getSpecific () const {return m_specific;}

/// set the specific (note: responsibility of keeping it consistent with the jet daughers belongs to the caller)
void setSpecific (const Specific &spec ) {m_specific = spec;}

/// Polymorphic clone
virtual GenJet* clone () const;
Expand Down
9 changes: 7 additions & 2 deletions DataFormats/PatCandidates/interface/Electron.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "DataFormats/Common/interface/AtomicPtrCache.h"

// Define typedefs for convenience
namespace pat {
Expand All @@ -46,7 +47,7 @@ namespace reco {

// Class definition
namespace pat {

class PATElectronSlimmer;

class Electron : public Lepton<reco::GsfElectron> {

Expand Down Expand Up @@ -241,6 +242,8 @@ namespace pat {
/// References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet reclustering)
void setAssociatedPackedPFCandidates(const edm::RefVector<pat::PackedCandidateCollection> &refvector) ;

friend class PATElectronSlimmer;

protected:
/// init impact parameter defaults (for use in a constructor)
void initImpactParameters();
Expand All @@ -259,7 +262,9 @@ namespace pat {
/// True if electron's pflowsupercluster is stored internally
bool embeddedPflowSuperCluster_;
/// Place to store electron's supercluster internally
mutable std::vector<reco::SuperCluster> superCluster_;
std::vector<reco::SuperCluster> superCluster_;
/// Place to temporarily store the electron's supercluster after relinking the seed to it
edm::AtomicPtrCache<std::vector<reco::SuperCluster> > superClusterRelinked_;
/// Place to store electron's basic clusters internally
std::vector<reco::CaloCluster> basicClusters_;
/// Place to store electron's preshower clusters internally
Expand Down
3 changes: 3 additions & 0 deletions DataFormats/PatCandidates/interface/Jet.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ namespace reco {
// Class definition
namespace pat {

class PATJetSlimmer;

typedef reco::CaloJet::Specific CaloSpecific;
typedef reco::JPTJet::Specific JPTSpecific;
typedef reco::PFJet::Specific PFSpecific;
Expand All @@ -72,6 +74,7 @@ namespace pat {
/// jet energy scale unequal to raw calling the private initializeJEC
/// function, which should be non accessible to any other user
friend class PATJetProducer;
friend class PATJetSlimmer;

public:

Expand Down
3 changes: 3 additions & 0 deletions DataFormats/PatCandidates/interface/Muon.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace reco {
// Class definition
namespace pat {

class PATMuonSlimmer;

class Muon : public Lepton<reco::Muon> {

Expand Down Expand Up @@ -236,6 +237,8 @@ namespace pat {
/// pipe operator (introduced to use pat::Muon with PFTopProjectors)
friend std::ostream& reco::operator<<(std::ostream& out, const Muon& obj);

friend class PATMuonSlimmer;

protected:

// ---- for content embedding ----
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/PatCandidates/interface/PackedCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace pat {
/// set 4-momentum
virtual void setP4( const PolarLorentzVector & p4 ) {
maybeUnpackBoth(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
p4_ = p4_;
p4_ = p4;
packBoth();
}
/// set particle mass
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/PatCandidates/interface/PackedGenParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace pat {
/// set 4-momentum
virtual void setP4( const PolarLorentzVector & p4 ) {
unpack(); // changing px,py,pz changes also mapping between dxy,dz and x,y,z
p4_ = p4_;
p4_ = p4;
pack();
}
/// set particle mass
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/interface/PackedTriggerPrescales.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class PackedTriggerPrescales {

// use this method first if you want to be able to access the prescales by name
// you can get the TriggerNames from the TriggerResults and the Event (edm or fwlite)
void setTriggerNames(const edm::TriggerNames &names) const { triggerNames_ = &names; }
void setTriggerNames(const edm::TriggerNames &names) { triggerNames_ = &names; }

// set that the trigger of given index has a given prescale
void addPrescaledTrigger(int index, int prescale) ;

protected:
std::vector<int> prescaleValues_;
edm::RefCore triggerResults_;
mutable const edm::TriggerNames *triggerNames_;
const edm::TriggerNames *triggerNames_;
};


Expand Down
9 changes: 6 additions & 3 deletions DataFormats/PatCandidates/interface/Photon.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "DataFormats/PatCandidates/interface/Isolation.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/Common/interface/AtomicPtrCache.h"


// Define typedefs for convenience
Expand All @@ -41,7 +42,7 @@ namespace reco {

// Class definition
namespace pat {

class PATPhotonSlimmer;

class Photon : public PATObject<reco::Photon> {

Expand Down Expand Up @@ -235,13 +236,15 @@ namespace pat {
/// get the source candidate pointer with index i
reco::CandidatePtr sourceCandidatePtr( size_type i ) const;


friend class PATPhotonSlimmer;

protected:

// ---- for content embedding ----
bool embeddedSuperCluster_;
mutable std::vector<reco::SuperCluster> superCluster_;
std::vector<reco::SuperCluster> superCluster_;
/// Place to temporarily store the electron's supercluster after relinking the seed to it
edm::AtomicPtrCache<std::vector<reco::SuperCluster> > superClusterRelinked_;
/// Place to store electron's basic clusters internally
std::vector<reco::CaloCluster> basicClusters_;
/// Place to store electron's preshower clusters internally
Expand Down
4 changes: 4 additions & 0 deletions DataFormats/PatCandidates/interface/Tau.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace reco {
// Class definition
namespace pat {

class PATTauSlimmer;

class Tau : public Lepton<reco::BaseTau> {
/// make friends with PATTauProducer so that it can set the initial
/// jet energy scale unequal to raw calling the private initializeJEC
Expand Down Expand Up @@ -350,6 +352,8 @@ namespace pat {
return correctedTauJet(level, set).p4();
}

friend class PATTauSlimmer;

protected:

/// index of the set of jec factors with given label; returns -1 if no set
Expand Down
43 changes: 26 additions & 17 deletions DataFormats/PatCandidates/src/Electron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,33 @@ reco::GsfElectronCoreRef Electron::core() const {
/// override the reco::GsfElectron::superCluster method, to access the internal storage of the supercluster
reco::SuperClusterRef Electron::superCluster() const {
if (embeddedSuperCluster_) {
//relink caloclusters if needed
if (embeddedSeedCluster_ && !superCluster_[0].seed().isAvailable()) {
superCluster_[0].setSeed(seed());
}
if (basicClusters_.size() && !superCluster_[0].clusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&basicClusters_,iclus));
}
superCluster_[0].setClusters(clusters);
}
if (preshowerClusters_.size() && !superCluster_[0].preshowerClusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&preshowerClusters_,iclus));
}
superCluster_[0].setPreshowerClusters(clusters);
if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
if (!superClusterRelinked_.isSet()) {
std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
(*sc)[0].setSeed(seed());
}
if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&basicClusters_,iclus));
}
(*sc)[0].setClusters(clusters);
}
if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&preshowerClusters_,iclus));
}
(*sc)[0].setPreshowerClusters(clusters);
}
superClusterRelinked_.set(std::move(sc));
}
return reco::SuperClusterRef(&*superClusterRelinked_, 0);
} else {
return reco::SuperClusterRef(&superCluster_, 0);
}
//relink caloclusters if needed
return reco::SuperClusterRef(&superCluster_, 0);
} else {
return reco::GsfElectron::superCluster();
Expand Down
43 changes: 25 additions & 18 deletions DataFormats/PatCandidates/src/Photon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,32 @@ reco::operator<<(std::ostream& out, const pat::Photon& obj)
/// this returns a transient Ref which *should never be persisted*!
reco::SuperClusterRef Photon::superCluster() const {
if (embeddedSuperCluster_) {
//relink caloclusters if needed
if (embeddedSeedCluster_ && !superCluster_[0].seed().isAvailable()) {
superCluster_[0].setSeed(seed());
}
if (basicClusters_.size() && !superCluster_[0].clusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&basicClusters_,iclus));
}
superCluster_[0].setClusters(clusters);
}
if (preshowerClusters_.size() && !superCluster_[0].preshowerClusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&preshowerClusters_,iclus));
}
superCluster_[0].setPreshowerClusters(clusters);
if (embeddedSeedCluster_ || !basicClusters_.empty() || !preshowerClusters_.empty()) {
if (!superClusterRelinked_.isSet()) {
std::unique_ptr<std::vector<reco::SuperCluster> > sc(new std::vector<reco::SuperCluster>(superCluster_));
if (embeddedSeedCluster_ && !(*sc)[0].seed().isAvailable()) {
(*sc)[0].setSeed(seed());
}
if (basicClusters_.size() && !(*sc)[0].clusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<basicClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&basicClusters_,iclus));
}
(*sc)[0].setClusters(clusters);
}
if (preshowerClusters_.size() && !(*sc)[0].preshowerClusters().isAvailable()) {
reco::CaloClusterPtrVector clusters;
for (unsigned int iclus=0; iclus<preshowerClusters_.size(); ++iclus) {
clusters.push_back(reco::CaloClusterPtr(&preshowerClusters_,iclus));
}
(*sc)[0].setPreshowerClusters(clusters);
}
superClusterRelinked_.set(std::move(sc));
}
return reco::SuperClusterRef(&*superClusterRelinked_, 0);
} else {
return reco::SuperClusterRef(&superCluster_, 0);
}
return reco::SuperClusterRef(&superCluster_, 0);
} else {
return reco::Photon::superCluster();
}
Expand Down
13 changes: 13 additions & 0 deletions DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<!-- PAT Objects, and embedded data -->
<class name="pat::Electron" ClassVersion="23">
<field name="superClusterRelinked_" transient="true"/>
<version ClassVersion="23" checksum="434577157"/>
<version ClassVersion="22" checksum="4113394532"/>
<version ClassVersion="21" checksum="366535823"/>
Expand All @@ -27,6 +28,12 @@
<version ClassVersion="15" checksum="990589145"/>
<version ClassVersion="10" checksum="1662079993"/>
</class>
<!--NOTE: the declaration of AtomicPtrCache are a temporary work around until ROOT 6 where they will not be needed -->
<class name="edm::AtomicPtrCache<std::vector<reco::SuperCluster> >" />
<ioread sourceClass="pat::Electron" targetClass="pat::Electron" version="[1-]" source="" target="superClusterRelinked_">
<![CDATA[superClusterRelinked_.reset();]]>
</ioread>

<class name="pat::Muon" ClassVersion="13">
<version ClassVersion="13" checksum="2943499125"/>
<version ClassVersion="12" checksum="462627330"/>
Expand Down Expand Up @@ -94,10 +101,16 @@
</class>
<class name="std::vector<pat::tau::TauCaloSpecific>" />
<class name="pat::Photon" ClassVersion="12">
<field name="superClusterRelinked_" transient="true"/>
<version ClassVersion="12" checksum="2518470540"/>
<version ClassVersion="11" checksum="3277818926"/>
<version ClassVersion="10" checksum="865744757"/>
</class>
<!--NOTE: the declaration of AtomicPtrCache are a temporary work around until ROOT 6 where they will not be needed -->
<ioread sourceClass="pat::Photon" targetClass="pat::Photon" version="[1-]" source="" target="superClusterRelinked_">
<![CDATA[superClusterRelinked_.reset();]]>
</ioread>

<class name="pat::Jet" ClassVersion="11">
<field name="caloTowersTemp_" transient="true"/>
<field name="pfCandidatesTemp_" transient="true"/>
Expand Down
15 changes: 5 additions & 10 deletions PhysicsTools/PatAlgos/plugins/PATElectronSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
\brief Matcher of reconstructed objects to L1 Muons
\author Giovanni Petrucciani
\version $Id: PATElectronSlimmer.cc,v 1.1 2011/03/24 18:45:45 mwlebour Exp $
*/
#define private public
#define protected public
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
#undef protected
#undef private


#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand Down Expand Up @@ -114,11 +109,11 @@ pat::PATElectronSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iS
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; }
if (dropCorrections_(electron)) { electron.corrections_ = reco::GsfElectron::Corrections(); }
if (dropIsolations_(electron)) { electron.dr03_=reco::GsfElectron::IsolationVariables(); electron.dr04_=reco::GsfElectron::IsolationVariables(); electron.pfIso_=reco::GsfElectron::PflowIsolationVariables(); }
if (dropShapes_(electron)) { electron.pfShowerShape_=reco::GsfElectron::ShowerShape(); electron.showerShape_=reco::GsfElectron::ShowerShape(); }
if (dropExtrapolations_(electron)) { electron.trackExtrapolations_=reco::GsfElectron::TrackExtrapolations(); }
if (dropClassifications_(electron)) { electron.classVariables_=reco::GsfElectron::ClassificationVariables(); electron.class_=reco::GsfElectron::Classification(); }
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()); }
if (dropShapes_(electron)) { electron.setPfShowerShape(reco::GsfElectron::ShowerShape()); 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_) {
electron.setPackedPFCandidateCollection(edm::RefProd<pat::PackedCandidateCollection>(pc));
//std::cout << " PAT electron in " << src.id() << " comes from " << electron.refToOrig_.id() << ", " << electron.refToOrig_.key() << std::endl;
Expand Down
7 changes: 1 addition & 6 deletions PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
\brief Matcher of reconstructed objects to L1 Muons
\author Giovanni Petrucciani
\version $Id: PATGenJetSlimmer.cc,v 1.1 2011/03/24 18:45:45 mwlebour Exp $
*/


Expand All @@ -17,11 +16,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"

#define protected public
#define private public
#include "DataFormats/JetReco/interface/GenJet.h"
#undef private
#undef protected

namespace pat {

Expand Down Expand Up @@ -74,7 +69,7 @@ pat::PATGenJetSlimmer::produce(edm::Event & iEvent, const edm::EventSetup & iSet
jet.clearDaughters();
}
if (dropSpecific_) {
jet.m_specific = reco::GenJet::Specific();
jet.setSpecific( reco::GenJet::Specific() );
}
}

Expand Down
Loading

0 comments on commit 0412d70

Please sign in to comment.