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> inline void setRecHitCombinationIndex(edm::OwnVector<T> & recHits,int32_t icomb){
11  for(auto & recHit : recHits){
13  throw cms::Exception("fastTrackingHelpers::setRecHitCombinationIndex: one of hits in OwnVector is non-fastsim");
14  }
15  static_cast<FastTrackerRecHit &>(recHit).setRecHitCombinationIndex(icomb);
16  }
17  }
18 
19  // get recHitCombination for TrackCandidate and TrajectorySeed
20  template<class T> int32_t getRecHitCombinationIndex(const T & object)
21  {
22  // seed must have at least one hit
23  if(object.recHits().first == object.recHits().second){
24  throw cms::Exception("fastTrackingHelpers::getRecHitCombinationIndex") << " given object has 0 hits" << std::endl;
25  }
26 
27  const TrackingRecHit & recHit = *object.recHits().first;
28  if(!trackerHitRTTI::isFast(recHit)){
29  throw cms::Exception("fastTrackingHelpers::setRecHitCombinationIndex") << " one of hits in OwnVector is non-fastsim" << std::endl;
30  }
31  // cast and return combination index
32  return static_cast<const FastTrackerRecHit &>(recHit).recHitCombinationIndex();
33  // return combination index of first hit
34  }
35 
36 
37  inline bool hitIsMasked(const FastTrackerRecHit * hit, const std::vector<bool>& hitMasks)
38  {
39  for(unsigned int i = 0;i<hit->nIds();i++)
40  {
41  if(!(hitMasks)[hit->id(i)])
42  {
43  return false;
44  }
45  }
46  return true;
47  }
48 
49  inline double hitLocalError(const TrackingRecHit * hit)
50  {
51  double xx = hit->localPositionError().xx();
52  double yy = hit->localPositionError().yy();
53  double xy = hit->localPositionError().xy();
54  double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
55  return 0.5 * (xx+yy-delta);
56  }
57 }
58 
59 #endif
dbl * delta
Definition: mlp_gen.cc:36
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
float xx() const
Definition: LocalError.h:24
virtual size_t nIds() const
U second(std::pair< T, U > const &p)
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
bool isFast(TrackingRecHit const &hit)
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
int32_t getRecHitCombinationIndex(const T &object)
double hitLocalError(const TrackingRecHit *hit)
virtual int32_t id(size_t i=0) const
virtual LocalError localPositionError() const =0
long double T