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

Running code-format for analysis-reconstruction #27169

Merged
merged 2 commits into from Jun 12, 2019
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
67 changes: 37 additions & 30 deletions PhysicsTools/PatAlgos/interface/BaseIsolator.h
Expand Up @@ -8,40 +8,47 @@

#include <atomic>

namespace pat { namespace helper {
class BaseIsolator {
namespace pat {
namespace helper {
class BaseIsolator {
public:
typedef edm::ValueMap<float> Isolation;
BaseIsolator() {}
BaseIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector & iC, bool withCut) ;
virtual ~BaseIsolator() {}
virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) = 0;
virtual void endEvent() = 0;
typedef edm::ValueMap<float> Isolation;
BaseIsolator() {}
BaseIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut);
virtual ~BaseIsolator() {}
virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) = 0;
virtual void endEvent() = 0;

/// Tests if the value associated to this item is strictly below the cut.
template<typename AnyRef> bool test(const AnyRef &ref) const {
bool ok = (getValue(ref.id(), ref.key()) < cut_);
try_++; if (!ok) fail_++;
return ok;
}
/// Returns the associated isolation value given any sort of ref
template<typename AnyRef> float getValue(const AnyRef &ref) const {
return getValue(ref.id(), ref.key());
}
/// Tests if the value associated to this item is strictly below the cut.
template <typename AnyRef>
bool test(const AnyRef &ref) const {
bool ok = (getValue(ref.id(), ref.key()) < cut_);
try_++;
if (!ok)
fail_++;
return ok;
}
/// Returns the associated isolation value given any sort of ref
template <typename AnyRef>
float getValue(const AnyRef &ref) const {
return getValue(ref.id(), ref.key());
}

virtual std::string description() const = 0;
void print(std::ostream &out) const;

virtual std::string description() const = 0;
void print(std::ostream &out) const ;
protected:
virtual float getValue(const edm::ProductID &id, size_t index) const = 0;
edm::InputTag input_;
edm::EDGetTokenT<Isolation> inputToken_;
float cut_;
mutable std::atomic<uint64_t> try_, fail_;
}; // class BaseIsolator
} } // namespaces
virtual float getValue(const edm::ProductID &id, size_t index) const = 0;
edm::InputTag input_;
edm::EDGetTokenT<Isolation> inputToken_;
float cut_;
mutable std::atomic<uint64_t> try_, fail_;
}; // class BaseIsolator
} // namespace helper
} // namespace pat

inline std::ostream & operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso) {
iso.print(stream);
return stream;
inline std::ostream &operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso) {
iso.print(stream);
return stream;
}
#endif
53 changes: 26 additions & 27 deletions PhysicsTools/PatAlgos/interface/EfficiencyLoader.h
Expand Up @@ -11,41 +11,40 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"


namespace pat { namespace helper {
class EfficiencyLoader {
namespace pat {
namespace helper {
class EfficiencyLoader {
public:
/// Empty constructor
EfficiencyLoader() {}
/// Empty constructor
EfficiencyLoader() {}

/// Constructor from a PSet
EfficiencyLoader(const edm::ParameterSet &iConfig, edm::ConsumesCollector && iC) ;
/// Constructor from a PSet
EfficiencyLoader(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC);

/// 'true' if this there is at least one efficiency configured
bool enabled() const { return !names_.empty(); }
/// 'true' if this there is at least one efficiency configured
bool enabled() const { return !names_.empty(); }

/// To be called for each new event, reads in the ValueMaps for efficiencies
void newEvent(const edm::Event &event);
/// To be called for each new event, reads in the ValueMaps for efficiencies
void newEvent(const edm::Event &event);

/// Sets the efficiencies for this object, using the reference to the original objects
template<typename T, typename R>
void setEfficiencies( pat::PATObject<T> &obj, const R & originalRef ) const ;
/// Sets the efficiencies for this object, using the reference to the original objects
template <typename T, typename R>
void setEfficiencies(pat::PATObject<T> &obj, const R &originalRef) const;

private:
std::vector<std::string> names_;
std::vector<edm::EDGetTokenT<edm::ValueMap<pat::LookupTableRecord> > > tokens_;
std::vector<edm::Handle< edm::ValueMap<pat::LookupTableRecord> > > handles_;
}; // class

template<typename T, typename R>
void
EfficiencyLoader::setEfficiencies( pat::PATObject<T> &obj, const R & originalRef ) const
{
for (size_t i = 0, n = names_.size(); i < n; ++i) {
obj.setEfficiency(names_[i], (* handles_[i])[originalRef] );
std::vector<std::string> names_;
std::vector<edm::EDGetTokenT<edm::ValueMap<pat::LookupTableRecord> > > tokens_;
std::vector<edm::Handle<edm::ValueMap<pat::LookupTableRecord> > > handles_;
}; // class

template <typename T, typename R>
void EfficiencyLoader::setEfficiencies(pat::PATObject<T> &obj, const R &originalRef) const {
for (size_t i = 0, n = names_.size(); i < n; ++i) {
obj.setEfficiency(names_[i], (*handles_[i])[originalRef]);
}
}
}

} }
} // namespace helper
} // namespace pat

#endif
130 changes: 61 additions & 69 deletions PhysicsTools/PatAlgos/interface/HemisphereAlgo.h
@@ -1,7 +1,6 @@
#ifndef HemisphereAlgo_h
#define HemisphereAlgo_h


/* \class HemisphereAlgo
*
* Class that, given the 4-momenta of the objects in the event,
Expand All @@ -22,80 +21,73 @@ Transported to PAT by Wolfgang Adam and Tanja Rommerskirchen
#include <cmath>

class HemisphereAlgo {

public:

// There are 2 constructors:
// 1. Constructor taking as argument vectors of Px, Py, Pz and E of the objects in
// the event that should be separated, the seeding method and the hemisphere
// association method,
// 2. Constructor taking as argument vectors of Px, Py, Pz and E of the objects in
// the event that should be separated. The seeding method and the hemisphere
// association method should then be defined by SetMethod(seeding_method, association_method).
//
// Seeding method: choice of 2 inital axes
// 1: 1st: max P ; 2nd: max P * delta R wrt first one
// 2: 2 objects who give maximal invariant mass (recommended)
//
// HemisphereAlgo association method:
// 1: maximum pt longitudinal projected on the axes
// 2: minimal mass squared sum of the hemispheres
// 3: minimal Lund distance (recommended)
//
// Note that SetMethod also allows the seeding and/or association method to be
// redefined for an existing hemisphere object. The GetAxis or GetGrouping is
// then recomputed using the newly defined methods.
//

HemisphereAlgo(const std::vector<reco::CandidatePtr>& componentRefs_, const int seed_method = 0, const int hemisphere_association_method = 0);

// Destructor
~HemisphereAlgo(){};


std::vector<float> getAxis1(); // returns Nx, Ny, Nz, P, E of the axis of group 1
std::vector<float> getAxis2(); // returns Nx, Ny, Nz, P, E of the axis of group 2

// where Nx, Ny, Nz are the direction cosines e.g. Nx = Px/P,
// P is the momentum, E is the energy

std::vector<int> getGrouping(); // returns vector with "1" and "2"'s according to
// which group the object belongs
// (order of objects in vector is same as input)

void SetMethod(int seed_method, int hemisphere_association_method){
seed_meth = seed_method;
hemi_meth = hemisphere_association_method;
status = 0;
} // sets or overwrites the seed and association methods

void SetNoSeed(int object_number) {
Object_Noseed[object_number] = 1;
status = 0;
}
// prevents an object from being used as a seed
// (method introduced on 15/09/06)
// There are 2 constructors:
// 1. Constructor taking as argument vectors of Px, Py, Pz and E of the objects in
// the event that should be separated, the seeding method and the hemisphere
// association method,
// 2. Constructor taking as argument vectors of Px, Py, Pz and E of the objects in
// the event that should be separated. The seeding method and the hemisphere
// association method should then be defined by SetMethod(seeding_method, association_method).
//
// Seeding method: choice of 2 inital axes
// 1: 1st: max P ; 2nd: max P * delta R wrt first one
// 2: 2 objects who give maximal invariant mass (recommended)
//
// HemisphereAlgo association method:
// 1: maximum pt longitudinal projected on the axes
// 2: minimal mass squared sum of the hemispheres
// 3: minimal Lund distance (recommended)
//
// Note that SetMethod also allows the seeding and/or association method to be
// redefined for an existing hemisphere object. The GetAxis or GetGrouping is
// then recomputed using the newly defined methods.
//

HemisphereAlgo(const std::vector<reco::CandidatePtr>& componentRefs_,
const int seed_method = 0,
const int hemisphere_association_method = 0);

// Destructor
~HemisphereAlgo(){};

std::vector<float> getAxis1(); // returns Nx, Ny, Nz, P, E of the axis of group 1
std::vector<float> getAxis2(); // returns Nx, Ny, Nz, P, E of the axis of group 2

// where Nx, Ny, Nz are the direction cosines e.g. Nx = Px/P,
// P is the momentum, E is the energy

std::vector<int> getGrouping(); // returns vector with "1" and "2"'s according to
// which group the object belongs
// (order of objects in vector is same as input)

void SetMethod(int seed_method, int hemisphere_association_method) {
seed_meth = seed_method;
hemi_meth = hemisphere_association_method;
status = 0;
} // sets or overwrites the seed and association methods

void SetNoSeed(int object_number) {
Object_Noseed[object_number] = 1;
status = 0;
}
// prevents an object from being used as a seed
// (method introduced on 15/09/06)

private:
int reconstruct(); // the hemisphere separation algorithm
std::vector<reco::CandidatePtr> Object;

std::vector<int> Object_Group;
std::vector<int> Object_Noseed;

int reconstruct(); // the hemisphere separation algorithm
std::vector<reco::CandidatePtr> Object;

std::vector<int> Object_Group;
std::vector<int> Object_Noseed;

std::vector<float> Axis1;
std::vector<float> Axis2;

//static const float hemivsn = 1.01;
int seed_meth;
int hemi_meth;
int status;



std::vector<float> Axis1;
std::vector<float> Axis2;

//static const float hemivsn = 1.01;
int seed_meth;
int hemi_meth;
int status;
};

#endif
48 changes: 25 additions & 23 deletions PhysicsTools/PatAlgos/interface/IsoDepositIsolator.h
Expand Up @@ -5,32 +5,34 @@
#include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
#include "PhysicsTools/IsolationAlgos/interface/EventDependentAbsVeto.h"


namespace pat { namespace helper {
class IsoDepositIsolator : public BaseIsolator {
namespace pat {
namespace helper {
class IsoDepositIsolator : public BaseIsolator {
public:
typedef edm::ValueMap<reco::IsoDeposit> Isolation;
typedef edm::ValueMap<reco::IsoDeposit> Isolation;

IsoDepositIsolator() {}
IsoDepositIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut);
~IsoDepositIsolator() override;
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) override;
void endEvent() override;

IsoDepositIsolator() {}
IsoDepositIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector & iC, bool withCut) ;
~IsoDepositIsolator() override ;
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) override ;
void endEvent() override ;
std::string description() const override;

std::string description() const override ;
protected:
enum Mode { Sum, Sum2, SumRelative, Sum2Relative, Max, MaxRelative, Count };
edm::Handle<Isolation> handle_;

float deltaR_;
Mode mode_;
reco::isodeposit::AbsVetos vetos_;
reco::isodeposit::EventDependentAbsVetos evdepVetos_; // subset of the above, don't delete twice
bool skipDefaultVeto_;
edm::EDGetTokenT<Isolation> inputIsoDepositToken_;

float getValue(const edm::ProductID &id, size_t index) const override ;
}; // class IsoDepositIsolator
} } // namespaces
enum Mode { Sum, Sum2, SumRelative, Sum2Relative, Max, MaxRelative, Count };
edm::Handle<Isolation> handle_;

float deltaR_;
Mode mode_;
reco::isodeposit::AbsVetos vetos_;
reco::isodeposit::EventDependentAbsVetos evdepVetos_; // subset of the above, don't delete twice
bool skipDefaultVeto_;
edm::EDGetTokenT<Isolation> inputIsoDepositToken_;

float getValue(const edm::ProductID &id, size_t index) const override;
}; // class IsoDepositIsolator
} // namespace helper
} // namespace pat

#endif