Skip to content

Commit

Permalink
Merge pull request #15280 from fwyzard/backport_13819_80x
Browse files Browse the repository at this point in the history
backport of #13819: Speed seeding for HLT
  • Loading branch information
davidlange6 committed Aug 26, 2016
2 parents 2d0538d + bb3c568 commit 86b00f3
Show file tree
Hide file tree
Showing 30 changed files with 374 additions and 467 deletions.
27 changes: 17 additions & 10 deletions DataFormats/GeometrySurface/src/BoundSpan.cc
Expand Up @@ -14,10 +14,10 @@ void BoundSpan::compute(Surface const & plane) {
if (trapezoidalBounds) {
std::array<const float, 4> const & parameters = (*trapezoidalBounds).parameters();

float hbotedge = parameters[0];
float htopedge = parameters[1];
float hapothem = parameters[3];
float thickness = (*trapezoidalBounds).thickness();
auto hbotedge = parameters[0];
auto htopedge = parameters[1];
auto hapothem = parameters[3];
auto thickness = (*trapezoidalBounds).thickness();

corners[0] = plane.toGlobal( LocalPoint( -htopedge, hapothem, thickness/2));
corners[1] = plane.toGlobal( LocalPoint( htopedge, hapothem, thickness/2));
Expand All @@ -29,9 +29,9 @@ void BoundSpan::compute(Surface const & plane) {
corners[7] = plane.toGlobal( LocalPoint( -hbotedge, -hapothem, -thickness/2));

}else if(rectangularBounds) {
float length = rectangularBounds->length();
float width = rectangularBounds->width();
float thickness = (*rectangularBounds).thickness();
auto length = rectangularBounds->length();
auto width = rectangularBounds->width();
auto thickness = (*rectangularBounds).thickness();

corners[0] = plane.toGlobal( LocalPoint( -width/2, -length/2, thickness/2));
corners[1] = plane.toGlobal( LocalPoint( -width/2, +length/2, thickness/2));
Expand All @@ -47,16 +47,23 @@ void BoundSpan::compute(Surface const & plane) {

float phimin = corners[0].barePhi(); float phimax = phimin;
float zmin = corners[0].z(); float zmax = zmin;
float rmin = corners[0].perp2(); float rmax = rmin;
for ( int i = 1; i < 8; i++ ) {
float cPhi = corners[i].barePhi();
auto cPhi = corners[i].barePhi();
if ( Geom::phiLess( cPhi, phimin)) { phimin = cPhi; }
if ( Geom::phiLess( phimax, cPhi)) { phimax = cPhi; }
float z = corners[i].z();
auto z = corners[i].z();
if ( z < zmin) zmin = z;
if ( z > zmax) zmax = z;
if ( z > zmax) zmax = z;
auto r = corners[i].perp2();
if ( r < rmin) rmin = r;
if ( r > rmax) rmax = r;

}
m_zSpan.first = zmin;
m_zSpan.second = zmax;
m_rSpan.first = std::sqrt(rmin);
m_rSpan.second = std::sqrt(rmax);
m_phiSpan.first = phimin;
m_phiSpan.second = phimax;
}
12 changes: 6 additions & 6 deletions DataFormats/GeometryVector/interface/Pi.h
Expand Up @@ -28,13 +28,13 @@

namespace Geom {

inline double pi() {return 3.141592653589793238;}
inline double twoPi() {return 2. *3.141592653589793238;}
inline double halfPi() {return 0.5*3.141592653589793238;}
inline constexpr double pi() {return 3.141592653589793238;}
inline constexpr double twoPi() {return 2. *3.141592653589793238;}
inline constexpr double halfPi() {return 0.5*3.141592653589793238;}

inline float fpi() {return 3.141592653589793238f;}
inline float ftwoPi() {return 2.f *3.141592653589793238f;}
inline float fhalfPi() {return 0.5f*3.141592653589793238f;}
inline constexpr float fpi() {return 3.141592653589793238f;}
inline constexpr float ftwoPi() {return 2.f *3.141592653589793238f;}
inline constexpr float fhalfPi() {return 0.5f*3.141592653589793238f;}


}
Expand Down
25 changes: 16 additions & 9 deletions Geometry/CommonDetUnit/interface/GeomDet.h
Expand Up @@ -28,11 +28,13 @@ class SurfaceDeformation;

class GeomDet {
public:
typedef GeomDetEnumerators::SubDetector SubDetector;
using SubDetector = GeomDetEnumerators::SubDetector;


explicit GeomDet( Plane* plane): thePlane(plane) {}
explicit GeomDet( const ReferenceCountingPointer<Plane>& plane) : thePlane(plane) {}

explicit GeomDet(Plane* plane);

explicit GeomDet(const ReferenceCountingPointer<Plane>& plane);

virtual ~GeomDet();

Expand Down Expand Up @@ -77,7 +79,7 @@ class GeomDet {
DetId geographicalId() const { return m_detId; }

/// Which subdetector
virtual SubDetector subDetector() const;;
virtual SubDetector subDetector() const;

/// is a Unit
virtual bool isLeaf() const { return components().empty();}
Expand All @@ -93,10 +95,14 @@ class GeomDet {
AlignmentPositionError const* alignmentPositionError() const { return theAlignmentPositionError;}


// specific unix index in a given subdetector (such as Tracker)
// specific unit index in a given subdetector (such as Tracker)
int index() const { return m_index;}
void setIndex(int i) { m_index=i;}

// specific geomDet index in a given subdetector (such as Tracker)
int gdetIndex() const { return m_gdetIndex;}
void setGdetIndex(int i) { m_gdetIndex=i;}


virtual const Topology& topology() const;

Expand All @@ -105,7 +111,7 @@ class GeomDet {

/// Return pointer to surface deformation.
/// Defaults to "null" if not reimplemented in the derived classes.
virtual const SurfaceDeformation* surfaceDeformation() const { return 0; }
virtual const SurfaceDeformation* surfaceDeformation() const { return nullptr; }



Expand All @@ -119,9 +125,10 @@ class GeomDet {

ReferenceCountingPointer<Plane> thePlane;
DetId m_detId;
int m_index;
int m_index=-1;
int m_gdetIndex=-1;
protected:
AlignmentPositionError* theAlignmentPositionError;
AlignmentPositionError* theAlignmentPositionError=nullptr;

private:

Expand Down Expand Up @@ -158,7 +165,7 @@ class GeomDet {

};

typedef GeomDet GeomDetUnit;
using GeomDetUnit = GeomDet;

#endif

Expand Down
5 changes: 0 additions & 5 deletions Geometry/CommonDetUnit/src/GeomDet.cc
Expand Up @@ -2,11 +2,6 @@
#include "Geometry/CommonDetUnit/interface/ModifiedSurfaceGenerator.h"
#include "DataFormats/TrackingRecHit/interface/AlignmentPositionError.h"

GeomDet::GeomDet( Plane* plane):
thePlane(plane), m_index(-1), theAlignmentPositionError(nullptr) {}

GeomDet::GeomDet( const ReferenceCountingPointer<Plane>& plane) :
thePlane(plane), m_index(-1), theAlignmentPositionError(nullptr) {}

GeomDet::~GeomDet() {delete theAlignmentPositionError;}

Expand Down
15 changes: 7 additions & 8 deletions Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h
Expand Up @@ -45,14 +45,13 @@ class TrackerGeometry final : public TrackingGeometry {

virtual ~TrackerGeometry() ;


virtual const DetTypeContainer& detTypes() const;
virtual const DetUnitContainer& detUnits() const;
virtual const DetContainer& dets() const;
virtual const DetIdContainer& detUnitIds() const;
virtual const DetIdContainer& detIds() const;
virtual const TrackerGeomDet* idToDetUnit(DetId) const;
virtual const TrackerGeomDet* idToDet(DetId) const;
const DetTypeContainer& detTypes() const {return theDetTypes;}
const DetUnitContainer& detUnits() const {return theDetUnits;}
const DetContainer& dets() const {return theDets;}
const DetIdContainer& detUnitIds() const {return theDetUnitIds;}
const DetIdContainer& detIds() const { return theDetIds;}
const TrackerGeomDet* idToDetUnit(DetId) const;
const TrackerGeomDet* idToDet(DetId) const;

const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const;
unsigned int numberOfLayers(int subdet) const;
Expand Down
31 changes: 2 additions & 29 deletions Geometry/TrackerGeometryBuilder/src/TrackerGeometry.cc
Expand Up @@ -156,6 +156,8 @@ void TrackerGeometry::addDetUnitId(DetId p){
}

void TrackerGeometry::addDet(GeomDet const * p) {
// set index
const_cast<GeomDet *>(p)->setGdetIndex(theDets.size());
theDets.push_back(p); // add to vector
theMap.insert(std::make_pair(p->geographicalId().rawId(),p));
DetId id(p->geographicalId());
Expand Down Expand Up @@ -189,17 +191,6 @@ void TrackerGeometry::addDetId(DetId p){
theDetIds.push_back(p);
}

const TrackerGeometry::DetUnitContainer&
TrackerGeometry::detUnits() const
{
return theDetUnits;
}

const TrackerGeometry::DetContainer&
TrackerGeometry::dets() const
{
return theDets;
}

const TrackerGeometry::DetContainer&
TrackerGeometry::detsPXB() const
Expand Down Expand Up @@ -283,24 +274,6 @@ TrackerGeometry::isThere(GeomDetEnumerators::SubDetector subdet) const {
return false;
}

const TrackerGeometry::DetTypeContainer&
TrackerGeometry::detTypes() const
{
return theDetTypes;
}


const TrackerGeometry::DetIdContainer&
TrackerGeometry::detUnitIds() const
{
return theDetUnitIds;
}

const TrackerGeometry::DetIdContainer&
TrackerGeometry::detIds() const
{
return theDetIds;
}
void TrackerGeometry::fillTestMap(const GeometricDet* gd) {

std::string temp = gd->name();
Expand Down
18 changes: 9 additions & 9 deletions RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h
Expand Up @@ -34,10 +34,10 @@ class ExceptionSafeStlPtrCol : public StlColType
template <typename RealType>
RealType normalized_phi( RealType phi )
{
if (phi>CLHEP::pi)
{ phi -= (2*CLHEP::pi) ; }
if (phi<-CLHEP::pi)
{ phi += (2*CLHEP::pi) ; }
constexpr RealType pi(M_PI);
constexpr RealType pi2(2*M_PI);
if (phi>pi) { phi -= pi2 ; }
if (phi<-pi) { phi += pi2; }
return phi ;
}

Expand Down Expand Up @@ -66,7 +66,7 @@ class EleRelPoint
EleRelPoint( const GlobalPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
double eta() { return relP_.eta() ; }
double phi() { return normalized_phi(relP_.phi()) ; }
double perp() { return sqrt(relP_.x()*relP_.x()+relP_.y()*relP_.y()) ; }
double perp() { return std::sqrt(relP_.x()*relP_.x()+relP_.y()*relP_.y()) ; }
private :
math::XYZVector relP_ ;
} ;
Expand All @@ -82,10 +82,10 @@ class EleRelPointPair
EleRelPointPair( const math::XYZPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
EleRelPointPair( const GlobalPoint & p1, const math::XYZPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
EleRelPointPair( const GlobalPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
double dEta() { return (relP1_.eta()-relP2_.eta()) ; }
double dPhi() { return normalized_phi(relP1_.phi()-relP2_.phi()) ; }
double dZ() { return (relP1_.z()-relP2_.z()) ; }
double dPerp() { return normalized_phi(relP1_.perp()-relP2_.perp()) ; }
auto dEta() { return (relP1_.eta()-relP2_.eta()) ; }
auto dPhi() { return normalized_phi(relP1_.barePhi()-relP2_.barePhi()) ; }
auto dZ() { return (relP1_.z()-relP2_.z()) ; }
auto dPerp() { return (relP1_.perp()-relP2_.perp()) ; }
private :
GlobalVector relP1_ ;
GlobalVector relP2_ ;
Expand Down
1 change: 0 additions & 1 deletion RecoEgamma/EgammaElectronAlgos/interface/PixelHitMatcher.h
Expand Up @@ -231,7 +231,6 @@ class PixelHitMatcher

bool searchInTIDTEC_ ;
bool useRecoVertex_ ;
std::unordered_map<const GeomDet*, TrajectoryStateOnSurface> mapTsos_fast_;
std::unordered_map<std::pair<const GeomDet*,GlobalPoint>, TrajectoryStateOnSurface> mapTsos2_fast_;
std::vector<GlobalPoint> hit_gp_map_;
} ;
Expand Down
20 changes: 9 additions & 11 deletions RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc
Expand Up @@ -18,7 +18,6 @@

#include "RecoEgamma/EgammaElectronAlgos/interface/BarrelMeasurementEstimator.h"
#include "RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h"
#include "RecoTracker/TkTrackingRegions/interface/GlobalDetRangeZPhi.h"
#include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
#include "TrackingTools/DetLayers/interface/rangesIntersect.h"
#include "TrackingTools/DetLayers/interface/PhiLess.h"
Expand Down Expand Up @@ -81,20 +80,20 @@ std::pair<bool,double> BarrelMeasurementEstimator::estimate
float zDiff = myZ -ts.z() ;
float myZmax = theZMax;
float myZmin = theZMin;
if(std::abs(myZ)<30. && myR>8.)
if( (std::abs(myZ)<30.f) & (myR>8.f) )
{
myZmax = 0.09;
myZmin = -0.09;
myZmax = 0.09f;
myZmin = -0.09f;
}


if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);

float rhPhi = gp.phi() ;
float tsPhi = ts.phi();
float rhPhi = gp.barePhi() ;
float tsPhi = ts.barePhi();
float phiDiff = normalized_phi(rhPhi-tsPhi) ;

if ( phiDiff < thePhiMax && phiDiff > thePhiMin )
if ( (phiDiff < thePhiMax) & (phiDiff > thePhiMin) )
{ return std::pair<bool,double>(true,1.) ; }
else
{ return std::pair<bool,double>(false,0.) ; }
Expand All @@ -108,13 +107,12 @@ bool BarrelMeasurementEstimator::estimate


GlobalPoint trajPos(ts.globalParameters().position());
GlobalDetRangeZPhi detRange(plane);

Range trajZRange(trajPos.z() - std::abs(theZMin), trajPos.z() + std::abs(theZMax));
Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));

if(rangesIntersect(trajZRange, detRange.zRange()) &&
rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess()))
if(rangesIntersect(trajZRange, plane.zSpan()) &&
rangesIntersect(trajPhiRange, plane.phiSpan(), PhiLess()))
{
return true;
}
Expand Down Expand Up @@ -142,7 +140,7 @@ BarrelMeasurementEstimator::maximalLocalDisplacement
if ( ts.hasError())
{
LocalError le = ts.localError().positionError() ;
return Local2DVector( sqrt(le.xx())*nSigmaCut, sqrt(le.yy())*nSigmaCut) ;
return Local2DVector( std::sqrt(le.xx())*nSigmaCut, std::sqrt(le.yy())*nSigmaCut) ;
}
else return Local2DVector(99999,99999) ;
}
Expand Down
27 changes: 24 additions & 3 deletions RecoEgamma/EgammaElectronAlgos/src/ElectronSeedGenerator.cc
Expand Up @@ -47,6 +47,21 @@
#include <vector>
#include <utility>


#ifdef COUNT_ElectronSeeds
namespace {
struct Count {
long long s=0;
long long n=0;
~Count() { std::cout << "ElectronSeeds res " << s<<'/'<<n << std::endl;}
};

Count stcount;
}
#endif



ElectronSeedGenerator::ElectronSeedGenerator(const edm::ParameterSet &pset,
const ElectronSeedGenerator::Tokens& ts)
: dynamicphiroad_(pset.getParameter<bool>("dynamicPhiRoad")),
Expand Down Expand Up @@ -263,13 +278,19 @@ void ElectronSeedGenerator::run
// Find the seeds
recHits_.clear();

LogDebug ("run") << "new cluster, calling seedsFromThisCluster";
LogDebug ("ElectronSeedGenerator") << "new cluster, calling seedsFromThisCluster";
seedsFromThisCluster(sclRefs[i],hoe1s[i],hoe2s[i],out,tTopo);
}

LogDebug ("run") << ": For event "<<e.id();
LogDebug ("run") <<"Nr of superclusters after filter: "<<sclRefs.size()
LogDebug ("ElectronSeedGenerator") << ": For event "<<e.id();
LogDebug ("ElectronSeedGenerator") <<"Nr of superclusters after filter: "<<sclRefs.size()
<<", no. of ElectronSeeds found = " << out.size();

#ifdef COUNT_ElectronSeeds
stcount.s+=sclRefs.size();
stcount.n+=out.size();
#endif

}

void ElectronSeedGenerator::seedsFromThisCluster
Expand Down

0 comments on commit 86b00f3

Please sign in to comment.