CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
SiStripRecHitMatcher Class Reference

#include <SiStripRecHitMatcher.h>

Public Types

typedef boost::function< void(SiStripMatchedRecHit2D
const &)> 
Collector
 
typedef
SiStripMatchedRecHit2DCollectionNew::FastFiller 
CollectorMatched
 
typedef
SiStripRecHit2DCollectionNew::DetSet::const_iterator 
RecHitIterator
 
typedef std::vector< const
SiStripRecHit2D * > 
SimpleHitCollection
 
typedef
SimpleHitCollection::const_iterator 
SimpleHitIterator
 
typedef std::pair< LocalPoint,
LocalPoint
StripPosition
 

Public Member Functions

template<typename MonoIterator , typename StereoIterator , typename CollectorHelper >
void doubleMatch (MonoIterator monoRHiter, MonoIterator monoRHend, StereoIterator seconditer, StereoIterator seconditerend, const GluedGeomDet *gluedDet, LocalVector trdir, CollectorHelper &collectorHelper) const
 
std::unique_ptr
< SiStripMatchedRecHit2D > 
match (const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
 
void match (const SiStripRecHit2D *monoRH, RecHitIterator begin, RecHitIterator end, CollectorMatched &collector, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
void match (const SiStripRecHit2D *monoRH, SimpleHitIterator begin, SimpleHitIterator end, CollectorMatched &collector, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
void match (const SiStripRecHit2D *monoRH, SimpleHitIterator begin, SimpleHitIterator end, edm::OwnVector< SiStripMatchedRecHit2D > &collector, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
void match (const SiStripRecHit2D *monoRH, SimpleHitIterator begin, SimpleHitIterator end, std::vector< SiStripMatchedRecHit2D * > &collector, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
void match (const SiStripRecHit2D *monoRH, SimpleHitIterator begin, SimpleHitIterator end, Collector &collector, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 the actual implementation More...
 
bool preFilter () const
 
StripPosition project (const GeomDetUnit *det, const GluedGeomDet *glueddet, StripPosition strip, LocalVector trackdirection) const
 
 SiStripRecHitMatcher (const edm::ParameterSet &conf)
 
 SiStripRecHitMatcher (const double theScale)
 

Static Public Member Functions

static float sigmaPitch (LocalPoint const &pos, LocalError const &err, const StripTopology &topol)
 

Public Attributes

bool preFilter_ =false
 
float scale_
 

Detailed Description

Definition at line 26 of file SiStripRecHitMatcher.h.

Member Typedef Documentation

typedef boost::function<void(SiStripMatchedRecHit2D const&)> SiStripRecHitMatcher::Collector

Definition at line 36 of file SiStripRecHitMatcher.h.

Definition at line 30 of file SiStripRecHitMatcher.h.

Definition at line 32 of file SiStripRecHitMatcher.h.

typedef std::vector<const SiStripRecHit2D *> SiStripRecHitMatcher::SimpleHitCollection

Definition at line 33 of file SiStripRecHitMatcher.h.

typedef SimpleHitCollection::const_iterator SiStripRecHitMatcher::SimpleHitIterator

Definition at line 34 of file SiStripRecHitMatcher.h.

Definition at line 39 of file SiStripRecHitMatcher.h.

Constructor & Destructor Documentation

SiStripRecHitMatcher::SiStripRecHitMatcher ( const edm::ParameterSet conf)

Definition at line 18 of file SiStripRecHitMatcher.cc.

18  :
19  scale_(conf.getParameter<double>("NSigmaInside")),
20  preFilter_(conf.existsAs<bool>("PreFilter") ? conf.getParameter<bool>("PreFilter") : false)
21  {}
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
SiStripRecHitMatcher::SiStripRecHitMatcher ( const double  theScale)

Definition at line 23 of file SiStripRecHitMatcher.cc.

23  :
24  scale_(theScale){}

Member Function Documentation

template<typename MonoIterator , typename StereoIterator , typename CollectorHelper >
void SiStripRecHitMatcher::doubleMatch ( MonoIterator  monoRHiter,
MonoIterator  monoRHend,
StereoIterator  seconditer,
StereoIterator  seconditerend,
const GluedGeomDet gluedDet,
LocalVector  trdir,
CollectorHelper &  collectorHelper 
) const

Definition at line 16 of file SSEMatcher.h.

References mathSSE::Vec2< T >::arr, PV3DBase< T, PVType, FrameType >::basicVector(), alignmentValidation::c1, diffTreeTool::diff, relativeConstraints::error, f, mathSSE::Vec4< T >::get1(), i, info(), StripTopology::localPosition(), PV3DBase< T, PVType, FrameType >::mag2(), Topology::measurementPosition(), GluedGeomDet::monoDet(), VarParsing::mult, evf::evtn::offset(), position, query::result, indexGen::s2, scale_, GluedGeomDet::stereoDet(), GeomDet::surface(), GeomDetUnit::topology(), Basic3DVector< T >::v, and x.

19  {
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
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:35
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
tuple s2
Definition: indexGen.py:106
virtual const Topology & topology() const =0
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)
Vec2< double > Vec2D
Definition: ExtVec.h:124
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
virtual LocalPoint localPosition(float strip) const =0
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
std::unique_ptr< SiStripMatchedRecHit2D > SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
const SiStripRecHit2D *  stereoRH,
const GluedGeomDet gluedDet,
LocalVector  trackdirection,
bool  force = false 
) const

Definition at line 269 of file SiStripRecHitMatcher.cc.

References trackerHits::c, alignmentValidation::c1, diffTreeTool::diff, relativeConstraints::error, f, StripTopology::localPosition(), m, PV3DBase< T, PVType, FrameType >::mag2(), Topology::measurementPosition(), GluedGeomDet::monoDet(), position, project(), indexGen::s2, scale_, sigmaPitch(), GluedGeomDet::stereoDet(), GeomDet::surface(), toLocal(), GeomDetUnit::topology(), x, and create_public_lumi_plots::xy.

Referenced by match(), and TkClonerImpl::operator()().

272  {
273  // stripdet = mono
274  // partnerstripdet = stereo
275  const GeomDetUnit* stripdet = gluedDet->monoDet();
276  const GeomDetUnit* partnerstripdet = gluedDet->stereoDet();
277  const StripTopology& topol=(const StripTopology&)stripdet->topology();
278 
279  // position of the initial and final point of the strip (RPHI cluster) in local strip coordinates
280  auto RPHIpointX = topol.measurementPosition(monoRH->localPositionFast()).x();
281  MeasurementPoint RPHIpointini(RPHIpointX,-0.5f);
282  MeasurementPoint RPHIpointend(RPHIpointX,0.5f);
283 
284  // position of the initial and final point of the strip in local coordinates (mono det)
285  StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
286 
287  if(trackdirection.mag2()<float(FLT_MIN)){// in case of no track hypothesis assume a track from the origin through the center of the strip
288  LocalPoint lcenterofstrip=monoRH->localPositionFast();
289  GlobalPoint gcenterofstrip=(stripdet->surface()).toGlobal(lcenterofstrip);
290  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
291  trackdirection=(gluedDet->surface()).toLocal(gtrackdirection);
292  }
293 
294  //project mono hit on glued det
295  StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
296  const StripTopology& partnertopol=(const StripTopology&)partnerstripdet->topology();
297 
298  double m00 = -(projectedstripmono.second.y()-projectedstripmono.first.y());
299  double m01 = (projectedstripmono.second.x()-projectedstripmono.first.x());
300  double c0 = m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
301 
302  //error calculation (the part that depends on mono RH only)
303  // LocalVector RPHIpositiononGluedendvector=projectedstripmono.second-projectedstripmono.first;
304  /*
305  double l1 = 1./RPHIpositiononGluedendvector.perp2();
306  double c1 = RPHIpositiononGluedendvector.y();
307  double s1 =-RPHIpositiononGluedendvector.x();
308  */
309  double c1 = -m00;
310  double s1 = -m01;
311  double l1 = 1./(c1*c1+s1*s1);
312 
313 
314  float sigmap12 = sigmaPitch(monoRH->localPosition(), monoRH->localPositionError(),topol);
315  // auto sigmap12 = monoRH->sigmaPitch();
316  // assert(sigmap12>=0);
317 
318 
319 
320 
321  // position of the initial and final point of the strip (STEREO cluster)
322  auto STEREOpointX=partnertopol.measurementPosition(stereoRH->localPositionFast()).x();
323  MeasurementPoint STEREOpointini(STEREOpointX,-0.5f);
324  MeasurementPoint STEREOpointend(STEREOpointX,0.5f);
325 
326  // position of the initial and final point of the strip in local coordinates (stereo det)
327  StripPosition stripstereo(partnertopol.localPosition(STEREOpointini),partnertopol.localPosition(STEREOpointend));
328 
329  //project stereo hit on glued det
330  StripPosition projectedstripstereo=project(partnerstripdet,gluedDet,stripstereo,trackdirection);
331 
332 
333  double m10=-(projectedstripstereo.second.y()-projectedstripstereo.first.y());
334  double m11=(projectedstripstereo.second.x()-projectedstripstereo.first.x());
335 
336  //perform the matching
337  //(x2-x1)(y-y1)=(y2-y1)(x-x1)
339  m(0,0)=m00;
340  m(0,1)=m01;
341  m(1,0)=m10;
342  m(1,1)=m11;
343  c(0)=c0;
344  c(1)=m11*projectedstripstereo.first.y()+m10*projectedstripstereo.first.x();
345  m.Invert();
346  AlgebraicVector2 solution = m * c;
347  Local2DPoint position(solution(0),solution(1));
348 
349 
350  if ((!force) && (!((gluedDet->surface()).bounds().inside(position,10.f*scale_))) ) return std::unique_ptr<SiStripMatchedRecHit2D>(nullptr);
351 
352  double c2 = -m10;
353  double s2 = -m11;
354  double l2 = 1./(c2*c2+s2*s2);
355 
356 
357  float sigmap22 = sigmaPitch(stereoRH->localPosition(),stereoRH->localPositionError(),partnertopol);
358  // auto sigmap22 = stereoRH->sigmaPitch();
359  // assert (sigmap22>0);
360 
361  double diff=(c1*s2-c2*s1);
362  double invdet2=1/(diff*diff*l1*l2);
363  float xx= invdet2*(sigmap12*s2*s2*l2+sigmap22*s1*s1*l1);
364  float xy=-invdet2*(sigmap12*c2*s2*l2+sigmap22*c1*s1*l1);
365  float yy= invdet2*(sigmap12*c2*c2*l2+sigmap22*c1*c1*l1);
366  LocalError error(xx,xy,yy);
367 
368 
369  //if it is inside the gluedet bonds
370  //Change NSigmaInside in the configuration file to accept more hits
371  if(force || (gluedDet->surface()).bounds().inside(position,error,scale_))
372  return std::unique_ptr<SiStripMatchedRecHit2D> (new SiStripMatchedRecHit2D(LocalPoint(position), error, *gluedDet, monoRH,stereoRH));
373  return std::unique_ptr<SiStripMatchedRecHit2D>(nullptr);
374 }
T mag2() const
Definition: PV3DBase.h:66
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
StripPosition project(const GeomDetUnit *det, const GluedGeomDet *glueddet, StripPosition strip, LocalVector trackdirection) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static float sigmaPitch(LocalPoint const &pos, LocalError const &err, const StripTopology &topol)
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
tuple s2
Definition: indexGen.py:106
virtual const Topology & topology() const =0
std::pair< LocalPoint, LocalPoint > StripPosition
double f[11][100]
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
virtual LocalPoint localPosition(float strip) const =0
Definition: DDAxes.h:10
ROOT::Math::SVector< double, 2 > AlgebraicVector2
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
RecHitIterator  begin,
RecHitIterator  end,
CollectorMatched collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 83 of file SiStripRecHitMatcher.cc.

References end, i, and match().

87  {
88 
89  // is this really needed now????
90  SimpleHitCollection stereoHits;
91  stereoHits.reserve(end-begin);
92  for (RecHitIterator i=begin; i != end; ++i)
93  stereoHits.push_back( &(*i)); // convert to simple pointer
94 
95  return match( monoRH,
96  stereoHits.begin(), stereoHits.end(),
97  collector,
98  gluedDet,trackdirection);
99 }
int i
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:37
std::vector< const SiStripRecHit2D * > SimpleHitCollection
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
SiStripRecHit2DCollectionNew::DetSet::const_iterator RecHitIterator
#define begin
Definition: vmac.h:30
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
SimpleHitIterator  begin,
SimpleHitIterator  end,
CollectorMatched collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 68 of file SiStripRecHitMatcher.cc.

References match(), and query::result.

72  {
73 
74  Collector result(boost::bind(pb2,boost::ref(collector),_1));
75  match(monoRH,begin,end,result,gluedDet,trackdirection);
76 
77 }
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
#define begin
Definition: vmac.h:30
boost::function< void(SiStripMatchedRecHit2D const &)> Collector
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
SimpleHitIterator  begin,
SimpleHitIterator  end,
edm::OwnVector< SiStripMatchedRecHit2D > &  collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 42 of file SiStripRecHitMatcher.cc.

References match(), AlCaHLTBitMon_ParallelJobs::p, edm::OwnVector< T, P >::push_back(), and query::result.

46  {
47 
48  std::vector<SiStripMatchedRecHit2D*> result;
49  result.reserve(end-begin);
50  match(monoRH,begin,end,result,gluedDet,trackdirection);
51  for (std::vector<SiStripMatchedRecHit2D*>::iterator p=result.begin(); p!=result.end();
52  p++) collector.push_back(*p);
53 }
void push_back(D *&d)
Definition: OwnVector.h:274
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
#define begin
Definition: vmac.h:30
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
SimpleHitIterator  begin,
SimpleHitIterator  end,
std::vector< SiStripMatchedRecHit2D * > &  collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 57 of file SiStripRecHitMatcher.cc.

References clone(), match(), and query::result.

61  {
62  Collector result(boost::bind(&pb1,boost::ref(collector),
63  boost::bind(&SiStripMatchedRecHit2D::clone,_1)));
64  match(monoRH,begin,end,result,gluedDet,trackdirection);
65 }
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force=false) const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
#define begin
Definition: vmac.h:30
boost::function< void(SiStripMatchedRecHit2D const &)> Collector
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
SimpleHitIterator  begin,
SimpleHitIterator  end,
Collector collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

the actual implementation

Definition at line 105 of file SiStripRecHitMatcher.cc.

References trackerHits::c, alignmentValidation::c1, diffTreeTool::diff, end, relativeConstraints::error, StripTopology::localPosition(), m, PV3DBase< T, PVType, FrameType >::mag2(), Topology::measurementPosition(), GluedGeomDet::monoDet(), position, project(), indexGen::s2, scale_, sigmaPitch(), GluedGeomDet::stereoDet(), GeomDet::surface(), toLocal(), GeomDetUnit::topology(), x, and create_public_lumi_plots::xy.

109  {
110  // stripdet = mono
111  // partnerstripdet = stereo
112  const GeomDetUnit* stripdet = gluedDet->monoDet();
113  const GeomDetUnit* partnerstripdet = gluedDet->stereoDet();
114  const StripTopology& topol=(const StripTopology&)stripdet->topology();
115 
116  // position of the initial and final point of the strip (RPHI cluster) in local strip coordinates
117  double RPHIpointX = topol.measurementPosition(monoRH->localPositionFast()).x();
118  MeasurementPoint RPHIpointini(RPHIpointX,-0.5);
119  MeasurementPoint RPHIpointend(RPHIpointX,0.5);
120 
121  // position of the initial and final point of the strip in local coordinates (mono det)
122  StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
123 
124  if(trackdirection.mag2()<FLT_MIN){// in case of no track hypothesis assume a track from the origin through the center of the strip
125  LocalPoint lcenterofstrip=monoRH->localPositionFast();
126  GlobalPoint gcenterofstrip=(stripdet->surface()).toGlobal(lcenterofstrip);
127  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
128  trackdirection=(gluedDet->surface()).toLocal(gtrackdirection);
129  }
130 
131  //project mono hit on glued det
132  StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
133  const StripTopology& partnertopol=(const StripTopology&)partnerstripdet->topology();
134 
135  double m00 = -(projectedstripmono.second.y()-projectedstripmono.first.y());
136  double m01 = (projectedstripmono.second.x()-projectedstripmono.first.x());
137  double c0 = m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
138 
139  //error calculation (the part that depends on mono RH only)
140  // LocalVector RPHIpositiononGluedendvector=projectedstripmono.second-projectedstripmono.first;
141  /*
142  double l1 = 1./RPHIpositiononGluedendvector.perp2();
143  double c1 = RPHIpositiononGluedendvector.y();
144  double s1 =-RPHIpositiononGluedendvector.x();
145  */
146  double c1 = -m00;
147  double s1 = -m01;
148  double l1 = 1./(c1*c1+s1*s1);
149 
150 
151  float sigmap12 = sigmaPitch(monoRH->localPosition(), monoRH->localPositionError(),topol);
152  // auto sigmap12 = monoRH->sigmaPitch();
153  // assert(sigmap12>=0);
154 
155 
156  SimpleHitIterator seconditer;
157 
158  for(seconditer=begin;seconditer!=end;++seconditer){//iterate on stereo rechits
159 
160  // position of the initial and final point of the strip (STEREO cluster)
161  double STEREOpointX=partnertopol.measurementPosition((*seconditer)->localPositionFast()).x();
162  MeasurementPoint STEREOpointini(STEREOpointX,-0.5);
163  MeasurementPoint STEREOpointend(STEREOpointX,0.5);
164 
165  // position of the initial and final point of the strip in local coordinates (stereo det)
166  StripPosition stripstereo(partnertopol.localPosition(STEREOpointini),partnertopol.localPosition(STEREOpointend));
167 
168  //project stereo hit on glued det
169  StripPosition projectedstripstereo=project(partnerstripdet,gluedDet,stripstereo,trackdirection);
170 
171 
172  double m10=-(projectedstripstereo.second.y()-projectedstripstereo.first.y());
173  double m11=(projectedstripstereo.second.x()-projectedstripstereo.first.x());
174 
175  //perform the matching
176  //(x2-x1)(y-y1)=(y2-y1)(x-x1)
177  AlgebraicMatrix22 m; AlgebraicVector2 c; // FIXME understand why moving this initializer out of the loop changes the output!
178  m(0,0)=m00;
179  m(0,1)=m01;
180  m(1,0)=m10;
181  m(1,1)=m11;
182  c(0)=c0;
183  c(1)=m11*projectedstripstereo.first.y()+m10*projectedstripstereo.first.x();
184  m.Invert();
185  AlgebraicVector2 solution = m * c;
186  LocalPoint position(solution(0),solution(1));
187 
188  /*
189  {
190  double m00 = -(projectedstripmono.second.y()-projectedstripmono.first.y());
191  double m01 = (projectedstripmono.second.x()-projectedstripmono.first.x());
192  double m10 = -(projectedstripstereo.second.y()-projectedstripstereo.first.y());
193  double m11 = (projectedstripstereo.second.x()-projectedstripstereo.first.x());
194  double c0 = m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
195  double c1 = m11*projectedstripstereo.first.y() + m10*projectedstripstereo.first.x();
196 
197  double invDet = 1./(m00*m11-m10*m01);
198  }
199  */
200 
201  //
202  // temporary fix by tommaso
203  //
204 
205 
206  LocalError tempError (100,0,100);
207  if (!((gluedDet->surface()).bounds().inside(position,tempError,scale_))) continue;
208 
209  // then calculate the error
210  /*
211  LocalVector stereopositiononGluedendvector=projectedstripstereo.second-projectedstripstereo.first;
212  double l2 = 1./stereopositiononGluedendvector.perp2();
213  double c2 = stereopositiononGluedendvector.y();
214  double s2 =-stereopositiononGluedendvector.x();
215  */
216 
217  double c2 = -m10;
218  double s2 = -m11;
219  double l2 = 1./(c2*c2+s2*s2);
220 
221  float sigmap22 = sigmaPitch((*seconditer)->localPosition(),(*seconditer)->localPositionError(),partnertopol);
222  // auto sigmap22 = (*seconditer)->sigmaPitch();
223  // assert(sigmap22>=0);
224 
225  double diff=(c1*s2-c2*s1);
226  double invdet2=1/(diff*diff*l1*l2);
227  float xx= invdet2*(sigmap12*s2*s2*l2+sigmap22*s1*s1*l1);
228  float xy=-invdet2*(sigmap12*c2*s2*l2+sigmap22*c1*s1*l1);
229  float yy= invdet2*(sigmap12*c2*c2*l2+sigmap22*c1*c1*l1);
230  LocalError error(xx,xy,yy);
231 
232  if((gluedDet->surface()).bounds().inside(position,error,scale_)){ //if it is inside the gluedet bonds
233  //Change NSigmaInside in the configuration file to accept more hits
234  //...and add it to the Rechit collection
235 
236  const SiStripRecHit2D* secondHit = *seconditer;
237  collector(SiStripMatchedRecHit2D(position, error,*gluedDet,
238  monoRH,secondHit));
239  }
240  }
241 }
T mag2() const
Definition: PV3DBase.h:66
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
StripPosition project(const GeomDetUnit *det, const GluedGeomDet *glueddet, StripPosition strip, LocalVector trackdirection) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static float sigmaPitch(LocalPoint const &pos, LocalError const &err, const StripTopology &topol)
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
tuple s2
Definition: indexGen.py:106
virtual const Topology & topology() const =0
std::pair< LocalPoint, LocalPoint > StripPosition
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
SimpleHitCollection::const_iterator SimpleHitIterator
virtual LocalPoint localPosition(float strip) const =0
Definition: DDAxes.h:10
ROOT::Math::SVector< double, 2 > AlgebraicVector2
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
bool SiStripRecHitMatcher::preFilter ( ) const
inline

Definition at line 44 of file SiStripRecHitMatcher.h.

References preFilter_.

SiStripRecHitMatcher::StripPosition SiStripRecHitMatcher::project ( const GeomDetUnit det,
const GluedGeomDet glueddet,
StripPosition  strip,
LocalVector  trackdirection 
) const

Definition at line 245 of file SiStripRecHitMatcher.cc.

References pileupReCalc_HLTpaths::scale, GeomDet::surface(), toLocal(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by match().

246  {
247 
248  GlobalPoint globalpointini=(det->surface()).toGlobal(strip.first);
249  GlobalPoint globalpointend=(det->surface()).toGlobal(strip.second);
250 
251  // position of the initial and final point of the strip in glued local coordinates
252  LocalPoint positiononGluedini=(glueddet->surface()).toLocal(globalpointini);
253  LocalPoint positiononGluedend=(glueddet->surface()).toLocal(globalpointend);
254 
255  //correct the position with the track direction
256 
257  float scale=-positiononGluedini.z()/trackdirection.z();
258 
259  LocalPoint projpositiononGluedini= positiononGluedini + scale*trackdirection;
260  LocalPoint projpositiononGluedend= positiononGluedend + scale*trackdirection;
261 
262  return StripPosition(projpositiononGluedini,projpositiononGluedend);
263 }
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
std::pair< LocalPoint, LocalPoint > StripPosition
T z() const
Definition: PV3DBase.h:64
static float SiStripRecHitMatcher::sigmaPitch ( LocalPoint const &  pos,
LocalError const &  err,
const StripTopology topol 
)
inlinestatic

Definition at line 48 of file SiStripRecHitMatcher.h.

References relativeConstraints::error, StripTopology::localPitch(), Topology::measurementError(), and MeasurementError::uu().

Referenced by match().

49  {
50  MeasurementError error = topol.measurementError(pos,err);
51  auto pitch=topol.localPitch(pos);
52  return error.uu()*pitch*pitch;
53  }
virtual float localPitch(const LocalPoint &) const =0
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
float uu() const

Member Data Documentation

bool SiStripRecHitMatcher::preFilter_ =false

Definition at line 124 of file SiStripRecHitMatcher.h.

Referenced by preFilter().

float SiStripRecHitMatcher::scale_

Definition at line 123 of file SiStripRecHitMatcher.h.

Referenced by doubleMatch(), and match().