CMS 3D CMS Logo

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