CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SSEMatcher.h
Go to the documentation of this file.
3 
4 namespace matcherDetails {
5 
6  struct StereoInfo {
9  double sigmap22;
10  double m10, m11;
11  };
12 
13 }
14 
15 template<typename MonoIterator, typename StereoIterator, typename CollectorHelper>
16 void SiStripRecHitMatcher::doubleMatch(MonoIterator monoRHiter, MonoIterator monoRHend,
17  StereoIterator seconditer, StereoIterator seconditerend,
18  const GluedGeomDet* gluedDet, LocalVector trdir,
19  CollectorHelper & collectorHelper) const{
20 
22  using mathSSE::Vec3F;
23  using mathSSE::Vec2D;
24  using mathSSE::Vec3D;
25  using mathSSE::Rot3F;
26  typedef GloballyPositioned<float> ToGlobal;
27  typedef typename GloballyPositioned<float>::ToLocal ToLocal;
28 
29  // hits in both mono and stero
30  // match
31  bool notk = trdir.mag2()<FLT_MIN;
32  // FIXME we shall find a faster approximation for trdir: not useful to compute it each time for each strip
33 
34  // stripdet = mono
35  // partnerstripdet = stereo
36  const GeomDetUnit* stripdet = gluedDet->monoDet();
37  const GeomDetUnit* partnerstripdet = gluedDet->stereoDet();
38  const StripTopology& topol=(const StripTopology&)stripdet->topology();
39  const StripTopology& partnertopol=(const StripTopology&)partnerstripdet->topology();
40 
41  // toGlobal is fast, toLocal is slow
42  ToGlobal const & stripDetTrans = stripdet->surface();
43  ToGlobal const & partnerStripDetTrans = partnerstripdet->surface();
44  ToLocal gluedDetInvTrans(gluedDet->surface());
45 
46 
47 
48  StereoInfo cache[std::distance(seconditer,seconditerend)];
49  //iterate on stereo rechits
50  // fill cache with relevant info
51  int cacheSize=0;
52  for (;seconditer!=seconditerend; ++seconditer){
53 
54  const SiStripRecHit2D & secondHit = CollectorHelper::stereoHit(seconditer);
55 
56  double sigmap22 =secondHit.sigmaPitch();
57 
58 
59 
60  double STEREOpointX=partnertopol.measurementPosition( secondHit.localPositionFast()).x();
61  MeasurementPoint STEREOpointini(STEREOpointX,-0.5);
62  MeasurementPoint STEREOpointend(STEREOpointX,0.5);
63 
64  LocalPoint locp1 = partnertopol.localPosition(STEREOpointini);
65  LocalPoint locp2 = partnertopol.localPosition(STEREOpointend);
66 
67  GlobalPoint globalpointini=partnerStripDetTrans.toGlobal(locp1);
68  GlobalPoint globalpointend=partnerStripDetTrans.toGlobal(locp2);
69 
70  // position of the initial and final point of the strip in glued local coordinates
71  LocalPoint positiononGluedini=gluedDetInvTrans.toLocal(globalpointini);
72  LocalPoint positiononGluedend=gluedDetInvTrans.toLocal(globalpointend);
73 
74  // in case of no track hypothesis assume a track from the origin through the center of the strip
75  if(notk){
76  LocalPoint lcenterofstrip=secondHit.localPositionFast();
77  GlobalPoint gcenterofstrip= partnerStripDetTrans.toGlobal(lcenterofstrip);
78  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
79  trdir=gluedDetInvTrans.toLocal(gtrackdirection);
80  }
81 
82 
83  Vec3F offset = trdir.basicVector().v * positiononGluedini.basicVector().v.get1<2>()/trdir.basicVector().v.get1<2>();
84 
85 
86  Vec3F ret1 = positiononGluedini.basicVector().v - offset;
87  Vec3F ret2 = positiononGluedend.basicVector().v - offset;
88 
89  double m10=-(ret2.arr[1] - ret1.arr[1]);
90  double m11= ret2.arr[0] - ret1.arr[0];
91 
92  Vec2D c1vec; c1vec.set1(m11*ret1.arr[1] + m10 * ret1.arr[0]);
93 
94  // store
95  StereoInfo info = {c1vec,&secondHit,sigmap22,m10,m11};
96  cache[cacheSize++] = info;
97  }
98 
99 
100 
101  for (;monoRHiter != monoRHend; ++monoRHiter) {
102 
103  SiStripRecHit2D const & monoRH = CollectorHelper::monoHit(monoRHiter);
104 
105  // position of the initial and final point of the strip (RPHI cluster) in local strip coordinates
106  double RPHIpointX = topol.measurementPosition(monoRH.localPositionFast()).x();
107  MeasurementPoint RPHIpointini(RPHIpointX,-0.5);
108  MeasurementPoint RPHIpointend(RPHIpointX,0.5);
109 
110  // position of the initial and final point of the strip in local coordinates (mono det)
111  //StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
112  LocalPoint locp1o = topol.localPosition(RPHIpointini);
113  LocalPoint locp2o = topol.localPosition(RPHIpointend);
114 
115 
116  // in case of no track hypothesis assume a track from the origin through the center of the strip
117  if(notk){
118  LocalPoint lcenterofstrip=monoRH.localPositionFast();
119  GlobalPoint gcenterofstrip= stripDetTrans.toGlobal(lcenterofstrip);
120  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
121  trdir=gluedDetInvTrans.toLocal(gtrackdirection);
122  }
123 
124 
125  //project mono hit on glued det
126  //StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
127 
128 
129  GlobalPoint globalpointini=stripDetTrans.toGlobal(locp1o);
130  GlobalPoint globalpointend=stripDetTrans.toGlobal(locp2o);
131 
132  // position of the initial and final point of the strip in glued local coordinates
133  LocalPoint positiononGluedini=gluedDetInvTrans.toLocal(globalpointini);
134  LocalPoint positiononGluedend=gluedDetInvTrans.toLocal(globalpointend);
135 
136  Vec3F offset = trdir.basicVector().v * positiononGluedini.basicVector().v.get1<2>()/trdir.basicVector().v.get1<2>();
137 
138 
139  Vec3F projini= positiononGluedini.basicVector().v - offset;
140  Vec3F projend = positiononGluedend.basicVector().v -offset;
141 
142  // ret1o = ret1o + (trdir * (ret1o.getSimd(2) / trdirz));
143  // ret2o = ret2o + (trdir * (ret2o.getSimd(2) / trdirz));
144 
145  double m00 = -(projend.arr[1] - projini.arr[1]);//-(projectedstripmono.second.y()-projectedstripmono.first.y());
146  double m01 = (projend.arr[0] - projini.arr[0]); // (projectedstripmono.second.x()-projectedstripmono.first.x());
147  double c0 = m01*projini.arr[1] + m00*projini.arr[0];//m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
148 
149  Vec2D c0vec(c0,c0);
150  Vec2D minv00(-m01, m00);
151 
152  //error calculation (the part that depends on mono RH only)
153  double c1 = -m00;
154  double s1 = -m01;
155  double l1 = 1./(c1*c1+s1*s1);
156 
157  // FIXME: here for test...
158  double sigmap12 = monoRH.sigmaPitch();
159 
160 
161  //float code
162  float fc1(c1), fs1(s1);
163  Vec3F scc1(fs1, fc1, fc1, 0.f);
164  Vec3F ssc1(fs1, fs1, fc1, 0.f);
165  Vec3F l1vec; l1vec.set1(l1);
166  const Vec3F cslsimd = scc1 * ssc1 * l1vec;
167  Vec3F sigmap12simd; sigmap12simd.set1(sigmap12);
168 
169  for (int i=0; i!=cacheSize; ++i) {
170  StereoInfo const si = cache[i];
171 
172  // match
173  Vec2D minv10(si.m11, -si.m10);
174  Vec2D mult; mult.set1(1./(m00*si.m11 - m01*si.m10));
175  Vec2D resultmatmul = mult * (minv10 * c0vec + minv00 * si.c1vec);
176 
177  Local2DPoint position(resultmatmul.arr[0], resultmatmul.arr[1]);
178 
179  // LocalError tempError (100,0,100);
180  if (!((gluedDet->surface()).bounds().inside(position,10.f*scale_))) continue;
181 
182  double c2 = -si.m10;
183  double s2 = -si.m11;
184  double l2 = 1./(c2*c2+s2*s2);
185 
186  double diff=(c1*s2-c2*s1);
187  double invdet2 = 1./(diff*diff*l1*l2);
188 
189  float fc2(c2), fs2(s2), fid2(invdet2);
190  Vec3F invdet2simd(fid2, -fid2, fid2, 0.f);
191  Vec3F ccssimd(fs2, fc2, fc2, 0.f);
192  Vec3F csssimd(fs2, fs2, fc2, 0.f);
193  Vec3F l2simd; l2simd.set1(l2);
194  Vec3F sigmap22simd; sigmap22simd.set1(si.sigmap22);
195  Vec3F result = invdet2simd * (sigmap22simd * cslsimd + sigmap12simd * ccssimd * csssimd * l2simd);
196 
197 
198  LocalError error(result.arr[0], result.arr[1], result.arr[2]);
199 
200 
201  if((gluedDet->surface()).bounds().inside(position,error,scale_)){ //if it is inside the gluedet bonds
202 
203  //Change NSigmaInside in the configuration file to accept more hits
204  //...and add it to the Rechit collection
205 
206  collectorHelper.collector()(SiStripMatchedRecHit2D(LocalPoint(position), error,
207  *gluedDet,&monoRH,si.secondHit));
208  }
209 
210  } // loop on cache info
211 
212  collectorHelper.closure(monoRHiter);
213  } // loop on mono hit
214 
215 }
Vec4 get1() const
Definition: SSEVec.h:209
int i
Definition: DBlmapReader.cc:9
T mag2() const
Definition: PV3DBase.h:66
static const TGPicture * info(bool iBackgroundIsBlack)
Vec4< float > Vec3F
Definition: SSEVec.h:531
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
virtual const Topology & topology() const
Definition: GeomDet.cc:86
mathSSE::Vec2D c1vec
Definition: SSEMatcher.h:7
T arr[2]
Definition: SSEVec.h:188
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Vec4< float > Vec3F
Definition: ExtVec.h:123
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
tuple s2
Definition: indexGen.py:106
tuple result
Definition: query.py:137
double f[11][100]
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
Vec4< double > Vec3D
Definition: SSEVec.h:533
Rot3< float > Rot3F
Definition: SSERot.h:73
unsigned int offset(bool)
void doubleMatch(MonoIterator monoRHiter, MonoIterator monoRHend, StereoIterator seconditer, StereoIterator seconditerend, const GluedGeomDet *gluedDet, LocalVector trdir, CollectorHelper &collectorHelper) const
Definition: SSEMatcher.h:16
static int position[264][3]
Definition: ReadPGInfo.cc:509
const SiStripRecHit2D * secondHit
Definition: SSEMatcher.h:8
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
virtual LocalPoint localPosition(float strip) const =0
const LocalPoint & localPositionFast() const
Definition: DDAxes.h:10
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
Vec2< double > Vec2D
Definition: SSEVec.h:532