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 
21 
22 #include<cmath>
23 
24 
25 
26 namespace {
27  typedef Basic2DVector<float> Vector2D;
28 
29  inline float sqr(float x) { return x*x; }
30 
31  /*****************************************************************************/
32  inline
33  float areaParallelogram
34  (const Vector2D& a, const Vector2D& b)
35  {
36  return a.x() * b.y() - a.y() * b.x();
37  }
38 
39  /*****************************************************************************/
40 
41  inline
42  bool getGlobalDirs(GlobalPoint const * g, GlobalVector * globalDirs)
43  {
44 
45 
46  // Determine circle
47  CircleFromThreePoints circle(g[0],g[1],g[2]);
48 
49  float curvature = circle.curvature();
50  if(0.f == curvature) {
51  LogDebug("LowPtClusterShapeSeedComparitor")<<"the curvature is null:"
52  <<"\n point1: "<<g[0]
53  <<"\n point2: "<<g[1]
54  <<"\n point3: "<<g[2];
55  return false;
56  }
57 
58  // Get 2d points
59  Vector2D p[3];
60  Vector2D c = circle.center();
61  for(int i=0; i!=3; i++)
62  p[i] = g[i].basicVector().xy() -c;
63 
64 
65  float area = std::abs(areaParallelogram(p[1] - p[0], p[1]));
66 
67  float a12 = std::asin(std::min(area*curvature*curvature,1.f));
68 
69  float slope = (g[1].z() - g[0].z()) / a12;
70 
71  // Calculate globalDirs
72 
73  float cotTheta = slope * curvature;
74  float sinTheta = 1.f/std::sqrt(1.f + sqr(cotTheta));
75  float cosTheta = cotTheta*sinTheta;
76 
77  if (areaParallelogram(p[0], p[1] ) < 0) sinTheta = - sinTheta;
78 
79  for(int i = 0; i!=3; i++) {
80  Vector2D vl = p[i]*(curvature*sinTheta);
81  globalDirs[i] = GlobalVector(-vl.y(),
82  vl.x(),
83  cosTheta
84  );
85  }
86  return true;
87  }
88 
89  /*****************************************************************************/
90 
91 
92  inline
93  void getGlobalPos(const SeedingHitSet &hits, GlobalPoint * globalPoss)
94  {
95 
96  for(unsigned int i=0; i!=hits.size(); ++i)
97  globalPoss[i] = hits[i]->globalPosition();
98  }
99 
100 } // namespace
101 
102 /*****************************************************************************/
104  es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", theShapeFilter);
105 }
106 
108 //(const reco::Track* track, const vector<const TrackingRecHit *> & recHits) const
109 {
110  assert(hits.size()==3);
111 
113  assert(filter != 0 && "LowPtClusterShapeSeedComparitor: init(EventSetup) method was not called");
114 
115  // Get global positions
116  GlobalPoint globalPoss[3];
117  getGlobalPos(hits, globalPoss);
118 
119  // Get global directions
120  GlobalVector globalDirs[3];
121 
122  bool ok = getGlobalDirs(globalPoss,globalDirs);
123 
124  // Check whether shape of pixel cluster is compatible
125  // with local track direction
126 
127  if (!ok)
128  {
129  LogDebug("LowPtClusterShapeSeedComparitor")<<"curvarture 0:"
130  <<"\nnHits: "<<hits.size()
131  <<" will say the seed is good anyway.";
132  return true;
133  }
134 
135  for(int i = 0; i < 3; i++)
136  {
137  const SiPixelRecHit* pixelRecHit =
138  dynamic_cast<const SiPixelRecHit *>(hits[i]->hit());
139 
140  if (!pixelRecHit){
141  edm::LogError("LowPtClusterShapeSeedComparitor")<<"this is not a pixel cluster";
142  ok = false; break;
143  }
144 
145  if(!pixelRecHit->isValid())
146  {
147  ok = false; break;
148  }
149 
150  LogDebug("LowPtClusterShapeSeedComparitor")<<"about to compute compatibility."
151  <<"hit ptr: "<<pixelRecHit
152  <<"global direction:"<< globalDirs[i];
153 
154 
155  if(! filter->isCompatible(*pixelRecHit, globalDirs[i]) )
156  {
157  LogTrace("LowPtClusterShapeSeedComparitor")
158  << " clusShape is not compatible"
159  << HitInfo::getInfo(*hits[i]->hit());
160 
161  ok = false; break;
162  }
163  }
164 
165  return ok;
166 }
167 
#define LogDebug(id)
static std::string getInfo(const DetId &id)
Definition: HitInfo.cc:24
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
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:46
T z() const
Definition: PV3DBase.h:63
double f[11][100]
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
bool isValid() const
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:31
x
Definition: VDTMath.h:216
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Our base class.
Definition: SiPixelRecHit.h:22