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