CMS 3D CMS Logo

FastTrackingUtilities.h
Go to the documentation of this file.
1 
2 #ifndef FASTSIMULATION_TRACKING_FASTTRACKINGHELPER_H
3 #define FASTSIMULATION_TRACKING_FASTTRACKINGHELPER_H
4 
7 
9 
10  template <class T>
11  inline void setRecHitCombinationIndex(edm::OwnVector<T> &recHits, int32_t icomb) {
12  for (auto &recHit : recHits) {
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();
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)
T sqrt(T t)
Definition: SSEVec.h:19
bool isFast(TrackingRecHit const &hit)
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
unsigned int id
int32_t getRecHitCombinationIndex(const T &object)
double hitLocalError(const TrackingRecHit *hit)
long double T