Skip to content

Commit

Permalink
Merge pull request #13959 from VinInn/SpeedPFC81
Browse files Browse the repository at this point in the history
SpeedUp ParticleFlow for HLT
  • Loading branch information
davidlange6 committed Apr 13, 2016
2 parents cd8f381 + 99a4c72 commit f366b48
Show file tree
Hide file tree
Showing 27 changed files with 366 additions and 340 deletions.
22 changes: 16 additions & 6 deletions DataFormats/Common/interface/RefCore.h
Expand Up @@ -23,17 +23,27 @@ namespace edm {
// Since we need to freely convert one to the other the friendship is used
friend class RefCoreWithIndex;
public:
RefCore() : cachePtr_(0),processIndex_(0),productIndex_(0){}
RefCore() : cachePtr_(nullptr),processIndex_(0),productIndex_(0){}

RefCore(ProductID const& theId, void const* prodPtr, EDProductGetter const* prodGetter, bool transient);

RefCore( RefCore const&);

RefCore& operator=(RefCore const&);

RefCore( RefCore&& iOther) : cachePtr_(iOther.cachePtr_.load()), processIndex_(iOther.processIndex_),
productIndex_(iOther.productIndex_) {}
RefCore& operator=(RefCore&&) = default;
RefCore( RefCore && iOther) noexcept :
cachePtr_(iOther.cachePtr_.load()),
processIndex_(iOther.processIndex_),
productIndex_(iOther.productIndex_) {}

RefCore& operator=( RefCore && iOther) noexcept{
cachePtr_ = iOther.cachePtr_.load();
processIndex_ = iOther.processIndex_;
productIndex_ = iOther.productIndex_;
return *this;
}

~RefCore() noexcept {}

ProductID id() const {ID_IMPL;}

Expand Down Expand Up @@ -90,7 +100,7 @@ namespace edm {

void nullPointerForTransientException(std::type_info const& type) const;

void swap(RefCore &);
void swap(RefCore &) noexcept;

bool isTransient() const {ISTRANSIENT_IMPL;}

Expand Down Expand Up @@ -143,7 +153,7 @@ namespace edm {

inline
void
RefCore::swap(RefCore & other) {
RefCore::swap(RefCore & other) noexcept {
std::swap(processIndex_, other.processIndex_);
std::swap(productIndex_, other.productIndex_);
other.cachePtr_.store(cachePtr_.exchange(other.cachePtr_.load()));
Expand Down
12 changes: 10 additions & 2 deletions DataFormats/Common/interface/RefCoreWithIndex.h
Expand Up @@ -33,9 +33,17 @@ namespace edm {

RefCoreWithIndex& operator=(RefCoreWithIndex const&);

RefCoreWithIndex( RefCoreWithIndex&& iOther): cachePtr_(iOther.cachePtr_.load()),processIndex_(iOther.processIndex_),
RefCoreWithIndex( RefCoreWithIndex&& iOther) noexcept : cachePtr_(iOther.cachePtr_.load()),processIndex_(iOther.processIndex_),
productIndex_(iOther.productIndex_),elementIndex_(iOther.elementIndex_) {}
RefCoreWithIndex& operator=(RefCoreWithIndex&&) = default;
RefCoreWithIndex& operator=(RefCoreWithIndex&& iOther) noexcept {
cachePtr_ = iOther.cachePtr_.load();
processIndex_ = iOther.processIndex_;
productIndex_ = iOther.productIndex_;
elementIndex_ = iOther.elementIndex_;
return *this;
}

~RefCoreWithIndex() noexcept {}

ProductID id() const {ID_IMPL;}

Expand Down
19 changes: 17 additions & 2 deletions DataFormats/Common/interface/RefToBase.h
Expand Up @@ -69,6 +69,9 @@ namespace edm {

RefToBase();
RefToBase(RefToBase const& other);
RefToBase(RefToBase && other) noexcept;
RefToBase & operator=(RefToBase && other) noexcept;

template <typename C1, typename T1, typename F1>
explicit RefToBase(Ref<C1, T1, F1> const& r);
template <typename C>
Expand All @@ -80,7 +83,7 @@ namespace edm {
RefToBase(std::unique_ptr<reftobase::BaseHolder<value_type>>);
RefToBase(std::shared_ptr<reftobase::RefHolderBase> p);

~RefToBase();
~RefToBase() noexcept;

RefToBase& operator= (RefToBase const& rhs);

Expand Down Expand Up @@ -138,6 +141,18 @@ namespace edm {
holder_(other.holder_ ? other.holder_->clone() : nullptr)
{ }

template <class T>
inline
RefToBase<T>::RefToBase(RefToBase && other) noexcept :
holder_(other.holder_) { other.holder_=nullptr;}

template <class T>
inline
RefToBase<T>& RefToBase<T>::operator=(RefToBase && other) noexcept {
delete holder_; holder_=other.holder_; other.holder_=nullptr; return *this;
}


template <class T>
template <typename C1, typename T1, typename F1>
inline
Expand Down Expand Up @@ -182,7 +197,7 @@ namespace edm {

template <class T>
inline
RefToBase<T>::~RefToBase()
RefToBase<T>::~RefToBase() noexcept
{
delete holder_;
}
Expand Down
24 changes: 11 additions & 13 deletions DataFormats/Common/interface/RefVector.h
Expand Up @@ -19,7 +19,6 @@ RefVector: A template for a vector of interproduct references.
#include "DataFormats/Common/interface/RefVectorTraits.h"
#include "DataFormats/Common/interface/traits.h"
#include "DataFormats/Provenance/interface/ProductID.h"
#include "FWCore/Utilities/interface/GCC11Compatibility.h"

#include <algorithm>
#include <stdexcept>
Expand Down Expand Up @@ -52,16 +51,25 @@ namespace edm {
/// Default constructor needed for reading from persistent
/// store. Not for direct use.
RefVector() : refVector_() {}
~RefVector() = default;

RefVector(RefVector const& rh) : refVector_(rh.refVector_){}
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
RefVector(RefVector && rh) noexcept : refVector_(std::move(rh.refVector_)){}
#endif

RefVector& operator=(RefVector const& rhs);
RefVector& operator=(RefVector && rhs) noexcept {
refVector_ = std::move(rhs.refVector_);
return *this;
}



RefVector(ProductID const& iId) : refVector_(iId) {}
/// Add a Ref<C, T> to the RefVector
void push_back(value_type const& ref) {
refVector_.pushBack(ref.refCore(), ref.key());
}


/// Retrieve an element of the RefVector
value_type const operator[](size_type idx) const {
Expand Down Expand Up @@ -141,14 +149,6 @@ namespace edm {
/// Swap two vectors.
void swap(RefVector<C, T, F> & other) noexcept;

/// Copy assignment.
RefVector& operator=(RefVector const& rhs);
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
RefVector& operator=(RefVector && rhs) noexcept {
refVector_ = std::move(rhs.refVector_);
return *this;
}
#endif
/// Checks if product is in memory.
bool hasProductCache() const {return refVector_.refCore().productPtr() != 0;}

Expand Down Expand Up @@ -187,7 +187,6 @@ namespace edm {
a.swap(b);
}

#if defined(__GXX_EXPERIMENTAL_CXX0X__)
template<typename C, typename T, typename F>
void
RefVector<C,T,F>::fillView(ProductID const&,
Expand All @@ -204,7 +203,6 @@ namespace edm {
helpers.emplace_back(i->id(),i->key());
}
}
#endif

template<typename C, typename T, typename F>
inline
Expand Down
32 changes: 15 additions & 17 deletions DataFormats/Common/interface/RefVectorBase.h
Expand Up @@ -12,7 +12,6 @@ RefVectorBase: Base class for a vector of interproduct references.
#include "DataFormats/Common/interface/EDProductfwd.h"
#include "DataFormats/Common/interface/RefCore.h"
#include <vector>
#include "FWCore/Utilities/interface/GCC11Compatibility.h"

namespace edm {

Expand All @@ -37,15 +36,28 @@ namespace edm {
RefVectorBase() : product_(), keys_() {}
RefVectorBase( RefVectorBase const & rhs) : product_(rhs.product_), keys_(rhs.keys_),
memberPointersHolder_(rhs.memberPointersHolder_) {}
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
RefVectorBase( RefVectorBase && rhs) noexcept : product_(std::move(rhs.product_)), keys_(std::move(rhs.keys_)),
memberPointersHolder_(std::move(rhs.memberPointersHolder_)) {}
#endif

RefVectorBase& operator=(RefVectorBase const& rhs) {
RefVectorBase temp(rhs);
this->swap(temp);
return *this;
}
RefVectorBase& operator=(RefVectorBase && rhs) noexcept {
product_ = std::move(rhs.product_);
keys_ =std::move(rhs.keys_);
memberPointersHolder_ = std::move(rhs.memberPointersHolder_);
return *this;
}



explicit RefVectorBase(ProductID const& productID, void const* prodPtr = 0,
EDProductGetter const* prodGetter = 0) :
product_(productID, prodPtr, prodGetter, false), keys_() {}


/// Destructor
~RefVectorBase() noexcept {}

Expand Down Expand Up @@ -108,20 +120,6 @@ namespace edm {
memberPointersHolder_.memberPointers().swap(other.memberPointersHolder_.memberPointers());
}

/// Copy assignment
RefVectorBase& operator=(RefVectorBase const& rhs) {
RefVectorBase temp(rhs);
this->swap(temp);
return *this;
}
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
RefVectorBase& operator=(RefVectorBase && rhs) noexcept {
product_ = std::move(rhs.product_);
keys_ =std::move(rhs.keys_);
memberPointersHolder_ = std::move(rhs.memberPointersHolder_);
return *this;
}
#endif

//Needed for ROOT storage
CMS_CLASS_VERSION(13)
Expand Down
29 changes: 29 additions & 0 deletions DataFormats/EcalDetId/interface/ESDetId.h
Expand Up @@ -111,5 +111,34 @@ class ESDetId : public DetId {

std::ostream& operator<<(std::ostream&,const ESDetId& id);

inline
ESDetId::ESDetId( const DetId& gen ) : DetId(gen)
{
#ifdef EDM_ML_DEBUG
if( !gen.null() &&
( gen.det() != Ecal ||
gen.subdetId() != EcalPreshower ) )
{
throw cms::Exception("InvalidDetId");
}
#endif
}

inline
ESDetId&
ESDetId::operator=( const DetId& gen )
{
#ifdef EDM_ML_DEBUG
if (!gen.null() &&
( gen.det() != Ecal ||
gen.subdetId() != EcalPreshower ) )
{
throw cms::Exception("InvalidDetId");
}
#endif
id_=gen.rawId();
return *this;
}


#endif
25 changes: 0 additions & 25 deletions DataFormats/EcalDetId/src/ESDetId.cc
Expand Up @@ -3,18 +3,6 @@

#include <ostream>

ESDetId::ESDetId( const DetId& gen )
{
if( !gen.null() &&
( gen.det() != Ecal ||
gen.subdetId() != EcalPreshower ) )
{
throw cms::Exception("InvalidDetId");
}
id_ = gen.rawId() ;
}


void ESDetId::verify( int strip,
int ixs,
int iys,
Expand Down Expand Up @@ -52,19 +40,6 @@ ESDetId::validDetId( int istrip,
0 == hxy2[ixs-1][iys-1] ) ) ) ;
}

ESDetId&
ESDetId::operator=( const DetId& gen )
{
if (!gen.null() &&
( gen.det() != Ecal ||
gen.subdetId() != EcalPreshower ) )
{
throw cms::Exception("InvalidDetId");
}
id_=gen.rawId();
return *this;
}

int
ESDetId::hashedIndex() const
{
Expand Down
22 changes: 19 additions & 3 deletions DataFormats/EcalRecHit/interface/EcalRecHit.h
Expand Up @@ -5,7 +5,7 @@
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h"

#include <vector>
#include <math.h>
#include <cmath>

/** \class EcalRecHit
*
Expand Down Expand Up @@ -104,6 +104,13 @@ class EcalRecHit {
return value;
}

static inline int getPower10(float e) {
static constexpr float p10[] = {1.e-2f,1.e-1f,1.f,1.e1f,1.e2f,1.e3f,1.e4f,1.e5f,1.e6f};
int b = e<p10[4] ? 0 : 5;
for (;b<9;++b) if (e<p10[b]) break;
return b;
}


/* the new bit structure
* 0..6 - chi2 in time events (chi2()), offset=0, width=7
Expand Down Expand Up @@ -136,10 +143,19 @@ class EcalRecHit {
void setEnergyError(float energy) {
uint32_t rawEnergy = 0;
if (energy > 0.001) {
uint16_t exponent = lround(floor(log10(energy))) + 3;
uint16_t significand = lround(energy/pow(10, exponent - 5));
uint16_t exponent = getPower10(energy);
static constexpr float ip10[] = {1.e5f,1.e4f,1.e3f,1.e2f,1.e1f,1.e0f,1.e-1f,1.e-2f,1.e-3f,1.e-4};
uint16_t significand = lround(energy*ip10[exponent]);
// use 13 bits (3 exponent, 10 significand)
rawEnergy = exponent << 10 | significand;
/* here for doc and regression test
uint16_t exponent_old = lround(floor(log10(energy))) + 3;
uint16_t significand_old = lround(energy/pow(10, exponent - 5));
std::cout << energy << ' ' << exponent << ' ' << significand
<< ' ' << exponent_old << ' ' << significand_old << std::endl;
assert(exponent==exponent_old);
assert(significand==significand_old);
*/
}

extra_ = setMasked(extra_, rawEnergy, 8, 13);
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/EcalRecHit/test/testEcalRecHit.cppunit.cc
Expand Up @@ -83,8 +83,8 @@ void testEcalRecHit::testOne() {
CPPUNIT_ASSERT_DOUBLES_EQUAL(urh.jitterError()*25, rh.timeError(), 0.00001);

// test energyError
rh.setEnergyError(0.51);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.51, rh.energyError(), 0.01);
rh.setEnergyError(50.8);
CPPUNIT_ASSERT_DOUBLES_EQUAL(50.8, rh.energyError(), 0.01);
for (float x=0.0011; x<10.e4; x*=5.){
rh.setEnergyError(x);
CPPUNIT_ASSERT_DOUBLES_EQUAL(x, rh.energyError(), 0.01*x);
}
}
1 change: 1 addition & 0 deletions DataFormats/ParticleFlowReco/BuildFile.xml
Expand Up @@ -8,6 +8,7 @@
<use name="boost"/>
<use name="rootcore"/>
<use name="rootmath"/>
<use name="vdt_headers"/>

<flags LCG_DICT_HEADER="classes_1.h classes_2.h"/>
<flags LCG_DICT_XML="classes_def_1.xml classes_def_2.xml"/>
Expand Down

0 comments on commit f366b48

Please sign in to comment.