CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LowPtClusterShapeSeedComparitor.cc
Go to the documentation of this file.
2 
6 
11 
15 
17 
22 
23 #include<cmath>
24 
25 
26 
27 namespace {
28  typedef Basic2DVector<float> Vector2D;
29 
30  inline float sqr(float x) { return x*x; }
31 
32  /*****************************************************************************/
33  inline
34  float areaParallelogram
35  (const Vector2D& a, const Vector2D& b)
36  {
37  return a.x() * b.y() - a.y() * b.x();
38  }
39 
40  /*****************************************************************************/
41 
42  inline
43  bool getGlobalDirs(GlobalPoint const * g, GlobalVector * globalDirs)
44  {
45 
46 
47  // Determine circle
48  CircleFromThreePoints circle(g[0],g[1],g[2]);
49 
50  float curvature = circle.curvature();
51  if(0.f == curvature) {
52  LogDebug("LowPtClusterShapeSeedComparitor")<<"the curvature is null:"
53  <<"\n point1: "<<g[0]
54  <<"\n point2: "<<g[1]
55  <<"\n point3: "<<g[2];
56  return false;
57  }
58 
59  // Get 2d points
60  Vector2D p[3];
61  Vector2D c = circle.center();
62  for(int i=0; i!=3; i++)
63  p[i] = g[i].basicVector().xy() -c;
64 
65 
66  float area = std::abs(areaParallelogram(p[1] - p[0], p[1]));
67 
68  float a12 = std::asin(std::min(area*curvature*curvature,1.f));
69 
70  float slope = (g[1].z() - g[0].z()) / a12;
71 
72  // Calculate globalDirs
73 
74  float cotTheta = slope * curvature;
75  float sinTheta = 1.f/std::sqrt(1.f + sqr(cotTheta));
76  float cosTheta = cotTheta*sinTheta;
77 
78  if (areaParallelogram(p[0], p[1] ) < 0) sinTheta = - sinTheta;
79 
80  for(int i = 0; i!=3; i++) {
81  Vector2D vl = p[i]*(curvature*sinTheta);
82  globalDirs[i] = GlobalVector(-vl.y(),
83  vl.x(),
84  cosTheta
85  );
86  }
87  return true;
88  }
89 
90  /*****************************************************************************/
91 
92 
93  inline
94  void getGlobalPos(const SeedingHitSet &hits, GlobalPoint * globalPoss)
95  {
96 
97  for(unsigned int i=0; i!=hits.size(); ++i)
98  globalPoss[i] = hits[i]->globalPosition();
99  }
100 
101 } // namespace
102 
103 /*****************************************************************************/
105  es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", theShapeFilter);
106  es.get<IdealGeometryRecord>().get(theTTopo);
107 }
108 
110 //(const reco::Track* track, const vector<const TrackingRecHit *> & recHits) const
111 {
112  assert(hits.size()==3);
113 
115  assert(filter != 0 && "LowPtClusterShapeSeedComparitor: init(EventSetup) method was not called");
116 
117  // Get global positions
118  GlobalPoint globalPoss[3];
119  getGlobalPos(hits, globalPoss);
120 
121  // Get global directions
122  GlobalVector globalDirs[3];
123 
124  bool ok = getGlobalDirs(globalPoss,globalDirs);
125 
126  // Check whether shape of pixel cluster is compatible
127  // with local track direction
128 
129  if (!ok)
130  {
131  LogDebug("LowPtClusterShapeSeedComparitor")<<"curvarture 0:"
132  <<"\nnHits: "<<hits.size()
133  <<" will say the seed is good anyway.";
134  return true;
135  }
136 
137  for(int i = 0; i < 3; i++)
138  {
139  const SiPixelRecHit* pixelRecHit =
140  dynamic_cast<const SiPixelRecHit *>(hits[i]->hit());
141 
142  if (!pixelRecHit){
143  edm::LogError("LowPtClusterShapeSeedComparitor")<<"this is not a pixel cluster";
144  ok = false; break;
145  }
146 
147  if(!pixelRecHit->isValid())
148  {
149  ok = false; break;
150  }
151 
152  LogDebug("LowPtClusterShapeSeedComparitor")<<"about to compute compatibility."
153  <<"hit ptr: "<<pixelRecHit
154  <<"global direction:"<< globalDirs[i];
155 
156 
157  if(! filter->isCompatible(*pixelRecHit, globalDirs[i]) )
158  {
159  LogTrace("LowPtClusterShapeSeedComparitor")
160  << " clusShape is not compatible"
161  << HitInfo::getInfo(*hits[i]->hit(),theTTopo.product());
162 
163  ok = false; break;
164  }
165  }
166 
167  return ok;
168 }
169 
#define LogDebug(id)
virtual void init(const edm::EventSetup &es)
int i
Definition: DBlmapReader.cc:9
static const double slope[3]
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
edm::ESHandle< ClusterShapeHitFilter > theShapeFilter
something
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
edm::ESHandle< TrackerTopology > theTTopo
T curvature(T InversePt, const edm::EventSetup &iSetup)
virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion &region) const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
double f[11][100]
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
double b
Definition: hdecay.h:120
string const
Definition: compareJSON.py:14
double a
Definition: hdecay.h:121
Square< F >::type sqr(const F &f)
Definition: Square.h:13
unsigned int size() const
Definition: SeedingHitSet.h:40
Definition: DDAxes.h:10
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:25
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Pixel Reconstructed Hit.