CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FastTrackingUtilities.h
Go to the documentation of this file.
1 
2 #ifndef FASTSIMULATION_TRACKING_FASTTRACKINGHELPER_H
3 #define FASTSIMULATION_TRACKING_FASTTRACKINGHELPER_H
4 
7 
8 namespace fastTrackingUtilities {
9 
10  template <class T>
11  inline void setRecHitCombinationIndex(edm::OwnVector<T> &recHits, int32_t icomb) {
12  for (auto &recHit : recHits) {
13  if (!trackerHitRTTI::isFast(recHit)) {
14  throw cms::Exception("fastTrackingHelpers::setRecHitCombinationIndex: one of hits in OwnVector is non-fastsim");
15  }
16  static_cast<FastTrackerRecHit &>(recHit).setRecHitCombinationIndex(icomb);
17  }
18  }
19 
20  // get recHitCombination for TrackCandidate and TrajectorySeed
21  template <class T>
22  int32_t getRecHitCombinationIndex(const T &object) {
23  // seed must have at least one hit
24  if (object.recHits().empty()) {
25  throw cms::Exception("fastTrackingHelpers::getRecHitCombinationIndex")
26  << " given object has 0 hits" << std::endl;
27  }
28 
29  const TrackingRecHit &recHit = *object.recHits().begin();
30  if (!trackerHitRTTI::isFast(recHit)) {
31  throw cms::Exception("fastTrackingHelpers::setRecHitCombinationIndex")
32  << " one of hits in OwnVector is non-fastsim" << std::endl;
33  }
34  // cast and return combination index
35  return static_cast<const FastTrackerRecHit &>(recHit).recHitCombinationIndex();
36  // return combination index of first hit
37  }
38 
39  inline bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector<bool> &hitMasks) {
40  for (unsigned int i = 0; i < hit->nIds(); i++) {
41  if (!(hitMasks)[hit->id(i)]) {
42  return false;
43  }
44  }
45  return true;
46  }
47 
48  inline double hitLocalError(const TrackingRecHit *hit) {
49  double xx = hit->localPositionError().xx();
50  double yy = hit->localPositionError().yy();
51  double xy = hit->localPositionError().xy();
52  double delta = std::sqrt((xx - yy) * (xx - yy) + 4. * xy * xy);
53  return 0.5 * (xx + yy - delta);
54  }
55 } // namespace fastTrackingUtilities
56 
57 #endif
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
float xx() const
Definition: LocalError.h:22
virtual size_t nIds() const
float xy() const
Definition: LocalError.h:23
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
bool isFast(TrackingRecHit const &hit)
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
int32_t getRecHitCombinationIndex(const T &object)
Basic2DVector< T > xy() const
virtual LocalError localPositionError() const =0
double hitLocalError(const TrackingRecHit *hit)
virtual int32_t id(size_t i=0) const
long double T