test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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> inline void setRecHitCombinationIndex(edm::OwnVector<T> & recHits,int32_t icomb){
11  for(auto & recHit : recHits){
12  if(!trackerHitRTTI::isFast(recHit)){
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  // seed must have at least one hit
22  if(object.recHits().first == object.recHits().second){
23  throw cms::Exception("fastTrackingHelpers::getRecHitCombinationIndex") << " given object has 0 hits" << std::endl;
24  }
25 
26  const TrackingRecHit & recHit = *object.recHits().first;
27  if(!trackerHitRTTI::isFast(recHit)){
28  throw cms::Exception("fastTrackingHelpers::setRecHitCombinationIndex") << " one of hits in OwnVector is non-fastsim" << std::endl;
29  }
30  // cast and return combination index
31  return static_cast<const FastTrackerRecHit &>(recHit).recHitCombinationIndex();
32  // return combination index of first hit
33  }
34 
35 
36  inline bool hitIsMasked(const FastTrackerRecHit * hit,const std::vector<bool> * hitMasks){
37  for(unsigned int i = 0;i<hit->nIds();i++){
38  if(!(*hitMasks)[hit->id(i)]){
39  return false;
40  }
41  }
42  return true;
43  }
44 
45  inline double hitLocalError(const TrackingRecHit * hit)
46  {
47 
48  double xx = hit->localPositionError().xx();
49  double yy = hit->localPositionError().yy();
50  double xy = hit->localPositionError().xy();
51  double delta = std::sqrt((xx-yy)*(xx-yy)+4.*xy*xy);
52  return 0.5 * (xx+yy-delta);
53  }
54 
55 
56 }
57 
58 #endif
dbl * delta
Definition: mlp_gen.cc:36
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
virtual size_t nIds() const
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > *hitMasks)
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
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
bool isFast(TrackingRecHit const &hit)
int32_t getRecHitCombinationIndex(const T &object)
virtual LocalError localPositionError() const =0
double hitLocalError(const TrackingRecHit *hit)
virtual int32_t id(size_t i=0) const
long double T