-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7896 from VinInn/Loopers
factorize out choice of plane, use it for loopers as well
- Loading branch information
Showing
3 changed files
with
150 additions
and
31 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
TrackingTools/GeomPropagators/interface/OptimalHelixPlaneCrossing.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef OptimalHelixPlaneCrossing_H | ||
#define OptimalHelixPlaneCrossing_H | ||
|
||
|
||
#include "TrackingTools/GeomPropagators/interface/HelixBarrelPlaneCrossingByCircle.h" | ||
#include "TrackingTools/GeomPropagators/interface/HelixForwardPlaneCrossing.h" | ||
#include "TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing.h" | ||
|
||
#include<memory> | ||
|
||
|
||
class OptimalHelixPlaneCrossing { | ||
public: | ||
using Base = HelixPlaneCrossing; | ||
|
||
|
||
template<typename ... Args> | ||
OptimalHelixPlaneCrossing(Plane const & plane, Args&&... args) { | ||
|
||
GlobalVector u = plane.normalVector(); | ||
constexpr float small = 1.e-6; // for orientation of planes | ||
|
||
|
||
if (std::abs(u.z()) < small) { | ||
// barrel plane: | ||
// instantiate HelixBarrelPlaneCrossing, | ||
new(get()) HelixBarrelPlaneCrossingByCircle(args...); | ||
} | ||
else if ( (std::abs(u.x()) < small) & (std::abs(u.y()) < small) ) { | ||
// forward plane: | ||
// instantiate HelixForwardPlaneCrossing | ||
new(get()) HelixForwardPlaneCrossing(args...); | ||
} else { | ||
// arbitrary plane: | ||
// instantiate HelixArbitraryPlaneCrossing | ||
new(get()) HelixArbitraryPlaneCrossing(args...); | ||
} | ||
|
||
} | ||
|
||
|
||
~OptimalHelixPlaneCrossing() { get()->~Base(); } | ||
|
||
Base & operator*() { return *get(); } | ||
Base const & operator*() const { return *get();} | ||
|
||
|
||
|
||
private: | ||
|
||
|
||
Base * get() { return (Base*)&mem;} | ||
Base const * get() const { return (Base const *)&mem;} | ||
|
||
union Tmp { HelixBarrelPlaneCrossingByCircle a; HelixForwardPlaneCrossing b; HelixArbitraryPlaneCrossing c;}; | ||
using aligned_union_t = typename std::aligned_storage<sizeof(Tmp),alignof(Tmp)>::type; | ||
aligned_union_t mem; | ||
|
||
}; | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters