CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterShapeTrackFilter.cc
Go to the documentation of this file.
2 
6 
11 
15 
19 
21 
22 inline float sqr(float x) { return x*x; }
23 
24 using namespace std;
25 
26 /*****************************************************************************/
28  (const edm::ParameterSet& ps, const edm::EventSetup& es)
29 {
30  // Get tracker geometry
32  es.get<TrackerDigiGeometryRecord>().get(tracker);
33  theTracker = tracker.product();
34 
35  // Get cluster shape hit filter
37  es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter",shape);
38  theFilter = shape.product();
39 
40  // Get ptMin if available
41  ptMin = (ps.exists("ptMin") ? ps.getParameter<double>("ptMin") : 0.);
42  ptMax = (ps.exists("ptMax") ? ps.getParameter<double>("ptMax") : 999999.);
43 }
44 
45 /*****************************************************************************/
47 {
48 }
49 
50 /*****************************************************************************/
52  (const Global2DVector& a, const Global2DVector& b) const
53 {
54  return a.x() * b.y() - a.y() * b.x();
55 }
56 
57 /*****************************************************************************/
58 vector<GlobalVector> ClusterShapeTrackFilter::getGlobalDirs
59  (const vector<GlobalPoint> & g) const
60 {
61  // Get 2d points
62  vector<Global2DVector> p;
63  for(vector<GlobalPoint>::const_iterator ig = g.begin();
64  ig!= g.end(); ig++)
65  p.push_back( Global2DVector(ig->x(), ig->y()) );
66 
67  //
68  vector<GlobalVector> globalDirs;
69 
70  // Determine circle
71  CircleFromThreePoints circle(g[0],g[1],g[2]);
72 
73  if(circle.curvature() != 0.)
74  {
75  Global2DVector c (circle.center().x(), circle.center().y());
76 
77  float rad2 = (p[0] - c).mag2();
78  float a12 = asin(fabsf(areaParallelogram(p[0] - c, p[1] - c)) / rad2);
79 
80  float slope = (g[1].z() - g[0].z()) / a12;
81 
82  float cotTheta = slope * circle.curvature(); // == sinhEta
83  float coshEta = sqrt(1 + sqr(cotTheta)); // == 1/sinTheta
84 
85  // Calculate globalDirs
86  float sinTheta = 1. / coshEta;
87  float cosTheta = cotTheta * sinTheta;
88 
89  int dir;
90  if(areaParallelogram(p[0] - c, p[1] - c) > 0) dir = 1; else dir = -1;
91 
92  float curvature = circle.curvature();
93 
94  for(vector<Global2DVector>::const_iterator ip = p.begin();
95  ip!= p.end(); ip++)
96  {
97  Global2DVector v = (*ip - c)*curvature*dir;
98  globalDirs.push_back(GlobalVector(-v.y()*sinTheta,
99  v.x()*sinTheta,
100  cosTheta));
101  }
102  }
103 
104  return globalDirs;
105 }
106 
107 /*****************************************************************************/
108 vector<GlobalPoint> ClusterShapeTrackFilter::getGlobalPoss
109  (const vector<const TrackingRecHit *> & recHits) const
110 {
111  vector<GlobalPoint> globalPoss;
112 
113  for(vector<const TrackingRecHit *>::const_iterator recHit = recHits.begin();
114  recHit!= recHits.end();
115  recHit++)
116  {
117  DetId detId = (*recHit)->geographicalId();
118 
119  GlobalPoint gpos =
120  theTracker->idToDet(detId)->toGlobal((*recHit)->localPosition());
121 
122  globalPoss.push_back(gpos);
123  }
124 
125  return globalPoss;
126 }
127 
128 /*****************************************************************************/
130  (const reco::Track* track,
131  const vector<const TrackingRecHit *> & recHits) const
132 {
133  // Do not even look at pairs
134  if(recHits.size() <= 2) return true;
135 
136  // Check pt
137  if(track->pt() < ptMin ||
138  track->pt() > ptMax)
139  {
140  LogTrace("ClusterShapeTrackFilter")
141  << " [ClusterShapeTrackFilter] pt not in range: "
142  << ptMin << " " << track->pt() << " " << ptMax;
143  return false;
144  }
145 
146  // Get global positions
147  vector<GlobalPoint> globalPoss = getGlobalPoss(recHits);
148 
149  // Get global directions
150  vector<GlobalVector> globalDirs = getGlobalDirs(globalPoss);
151 
152  bool ok = true;
153 
154  // Check whether shape of pixel cluster is compatible
155  // with local track direction
156  for(unsigned int i = 0; i < recHits.size(); i++)
157  {
158  const SiPixelRecHit* pixelRecHit =
159  dynamic_cast<const SiPixelRecHit *>(recHits[i]);
160 
161  if(!pixelRecHit->isValid())
162  {
163  ok = false; break;
164  }
165 
166  if(! theFilter->isCompatible(*pixelRecHit, globalDirs[i]) )
167  {
168  LogTrace("ClusterShapeTrackFilter")
169  << " [ClusterShapeTrackFilter] clusShape problem"
170  << HitInfo::getInfo(*recHits[i]);
171 
172  ok = false; break;
173  }
174  }
175 
176  return ok;
177 }
178 
static std::string getInfo(const DetId &id)
Definition: HitInfo.cc:24
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
T y() const
Definition: PV2DBase.h:45
ClusterShapeTrackFilter(const edm::ParameterSet &ps, const edm::EventSetup &es)
static const double slope[3]
bool exists(std::string const &parameterName) const
checks if a parameter exists
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)
T sqrt(T t)
Definition: SSEVec.h:46
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::vector< GlobalPoint > getGlobalPoss(const std::vector< const TrackingRecHit * > &recHits) const
T y() const
Cartesian y coordinate.
#define LogTrace(id)
float areaParallelogram(const Global2DVector &a, const Global2DVector &b) const
Definition: DetId.h:20
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
std::vector< GlobalVector > getGlobalDirs(const std::vector< GlobalPoint > &globalPoss) const
double a
Definition: hdecay.h:121
Square< F >::type sqr(const F &f)
Definition: Square.h:13
dbl *** dir
Definition: mlp_gen.cc:35
x
Definition: VDTMath.h:216
T x() const
Definition: PV2DBase.h:44
mathSSE::Vec4< T > v
T x() const
Cartesian x coordinate.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Our base class.
Definition: SiPixelRecHit.h:22