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 | 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
 
SiStripMatchedRecHit2D * match (const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
SiStripMatchedRecHit2D * match (const SiStripMatchedRecHit2D *originalRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
edm::OwnVector
< SiStripMatchedRecHit2D > 
match (const SiStripRecHit2D *monoRH, RecHitIterator begin, RecHitIterator end, const GluedGeomDet *gluedDet) const
 
edm::OwnVector
< SiStripMatchedRecHit2D > 
match (const SiStripRecHit2D *monoRH, RecHitIterator begin, RecHitIterator end, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
 
edm::OwnVector
< SiStripMatchedRecHit2D > 
match (const SiStripRecHit2D *monoRH, SimpleHitIterator begin, SimpleHitIterator end, const GluedGeomDet *gluedDet, LocalVector trackdirection) 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...
 
StripPosition project (const GeomDetUnit *det, const GluedGeomDet *glueddet, StripPosition strip, LocalVector trackdirection) const
 
 SiStripRecHitMatcher (const edm::ParameterSet &conf)
 
 SiStripRecHitMatcher (const double theScale)
 

Public Attributes

float scale_
 

Detailed Description

Definition at line 23 of file SiStripRecHitMatcher.h.

Member Typedef Documentation

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

Definition at line 33 of file SiStripRecHitMatcher.h.

Definition at line 27 of file SiStripRecHitMatcher.h.

Definition at line 29 of file SiStripRecHitMatcher.h.

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

Definition at line 30 of file SiStripRecHitMatcher.h.

typedef SimpleHitCollection::const_iterator SiStripRecHitMatcher::SimpleHitIterator

Definition at line 31 of file SiStripRecHitMatcher.h.

Definition at line 36 of file SiStripRecHitMatcher.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file SiStripRecHitMatcher.cc.

References edm::ParameterSet::getParameter(), and scale_.

18  {
19  scale_=conf.getParameter<double>("NSigmaInside");
20 }
T getParameter(std::string const &) const
SiStripRecHitMatcher::SiStripRecHitMatcher ( const double  theScale)

Definition at line 22 of file SiStripRecHitMatcher.cc.

References scale_.

22  {
23  scale_=theScale;
24 }

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, GeomDet::geographicalId(), mathSSE::Vec4< T >::get1(), i, info(), StripTopology::localPitch(), StripTopology::localPosition(), PV3DBase< T, PVType, FrameType >::mag2(), Topology::measurementError(), Topology::measurementPosition(), GluedGeomDet::monoDet(), VarParsing::mult, evf::evtn::offset(), position, query::result, indexGen::s2, scale_, GluedGeomDet::stereoDet(), GeomDet::surface(), GeomDetUnit::topology(), HelpertRecHit2DLocalPos::updateWithAPE(), MeasurementError::uu(), 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  if (sigmap22<0) {
58  LocalError tmpError( secondHit.localPositionErrorFast());
59  HelpertRecHit2DLocalPos::updateWithAPE(tmpError, *partnerstripdet);
60  MeasurementError errorstereoRH=partnertopol.measurementError(secondHit.localPositionFast(),tmpError);
61 
62  double pitch=partnertopol.localPitch(secondHit.localPositionFast());
63  secondHit.setSigmaPitch(sigmap22=errorstereoRH.uu()*pitch*pitch);
64  }
65 
66 
67  double STEREOpointX=partnertopol.measurementPosition( secondHit.localPositionFast()).x();
68  MeasurementPoint STEREOpointini(STEREOpointX,-0.5);
69  MeasurementPoint STEREOpointend(STEREOpointX,0.5);
70 
71  LocalPoint locp1 = partnertopol.localPosition(STEREOpointini);
72  LocalPoint locp2 = partnertopol.localPosition(STEREOpointend);
73 
74  GlobalPoint globalpointini=partnerStripDetTrans.toGlobal(locp1);
75  GlobalPoint globalpointend=partnerStripDetTrans.toGlobal(locp2);
76 
77  // position of the initial and final point of the strip in glued local coordinates
78  LocalPoint positiononGluedini=gluedDetInvTrans.toLocal(globalpointini);
79  LocalPoint positiononGluedend=gluedDetInvTrans.toLocal(globalpointend);
80 
81  // in case of no track hypothesis assume a track from the origin through the center of the strip
82  if(notk){
83  LocalPoint lcenterofstrip=secondHit.localPositionFast();
84  GlobalPoint gcenterofstrip= partnerStripDetTrans.toGlobal(lcenterofstrip);
85  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
86  trdir=gluedDetInvTrans.toLocal(gtrackdirection);
87  }
88 
89 
90  Vec3F offset = trdir.basicVector().v * positiononGluedini.basicVector().v.get1<2>()/trdir.basicVector().v.get1<2>();
91 
92 
93  Vec3F ret1 = positiononGluedini.basicVector().v - offset;
94  Vec3F ret2 = positiononGluedend.basicVector().v - offset;
95 
96  double m10=-(ret2.arr[1] - ret1.arr[1]);
97  double m11= ret2.arr[0] - ret1.arr[0];
98 
99  Vec2D c1vec; c1vec.set1(m11*ret1.arr[1] + m10 * ret1.arr[0]);
100 
101  // store
102  StereoInfo info = {c1vec,&secondHit,sigmap22,m10,m11};
103  cache[cacheSize++] = info;
104  }
105 
106 
107 
108  for (;monoRHiter != monoRHend; ++monoRHiter) {
109 
110  SiStripRecHit2D const & monoRH = CollectorHelper::monoHit(monoRHiter);
111 
112  // position of the initial and final point of the strip (RPHI cluster) in local strip coordinates
113  double RPHIpointX = topol.measurementPosition(monoRH.localPositionFast()).x();
114  MeasurementPoint RPHIpointini(RPHIpointX,-0.5);
115  MeasurementPoint RPHIpointend(RPHIpointX,0.5);
116 
117  // position of the initial and final point of the strip in local coordinates (mono det)
118  //StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
119  LocalPoint locp1o = topol.localPosition(RPHIpointini);
120  LocalPoint locp2o = topol.localPosition(RPHIpointend);
121 
122 
123  // in case of no track hypothesis assume a track from the origin through the center of the strip
124  if(notk){
125  LocalPoint lcenterofstrip=monoRH.localPositionFast();
126  GlobalPoint gcenterofstrip= stripDetTrans.toGlobal(lcenterofstrip);
127  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
128  trdir=gluedDetInvTrans.toLocal(gtrackdirection);
129  }
130 
131 
132  //project mono hit on glued det
133  //StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
134 
135 
136  GlobalPoint globalpointini=stripDetTrans.toGlobal(locp1o);
137  GlobalPoint globalpointend=stripDetTrans.toGlobal(locp2o);
138 
139  // position of the initial and final point of the strip in glued local coordinates
140  LocalPoint positiononGluedini=gluedDetInvTrans.toLocal(globalpointini);
141  LocalPoint positiononGluedend=gluedDetInvTrans.toLocal(globalpointend);
142 
143  Vec3F offset = trdir.basicVector().v * positiononGluedini.basicVector().v.get1<2>()/trdir.basicVector().v.get1<2>();
144 
145 
146  Vec3F projini= positiononGluedini.basicVector().v - offset;
147  Vec3F projend = positiononGluedend.basicVector().v -offset;
148 
149  // ret1o = ret1o + (trdir * (ret1o.getSimd(2) / trdirz));
150  // ret2o = ret2o + (trdir * (ret2o.getSimd(2) / trdirz));
151 
152  double m00 = -(projend.arr[1] - projini.arr[1]);//-(projectedstripmono.second.y()-projectedstripmono.first.y());
153  double m01 = (projend.arr[0] - projini.arr[0]); // (projectedstripmono.second.x()-projectedstripmono.first.x());
154  double c0 = m01*projini.arr[1] + m00*projini.arr[0];//m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
155 
156  Vec2D c0vec(c0,c0);
157  Vec2D minv00(-m01, m00);
158 
159  //error calculation (the part that depends on mono RH only)
160  double c1 = -m00;
161  double s1 = -m01;
162  double l1 = 1./(c1*c1+s1*s1);
163 
164  // FIXME: here for test...
165  double sigmap12 = monoRH.sigmaPitch();
166  if (sigmap12<0) {
167 
168  LocalError tmpError(monoRH.localPositionErrorFast());
169  HelpertRecHit2DLocalPos::updateWithAPE(tmpError,*stripdet);
170  MeasurementError errormonoRH=topol.measurementError(monoRH.localPositionFast(),tmpError);
171 
172  double pitch=topol.localPitch(monoRH.localPositionFast());
173  monoRH.setSigmaPitch(sigmap12=errormonoRH.uu()*pitch*pitch);
174  }
175 
176  //float code
177  float fc1(c1), fs1(s1);
178  Vec3F scc1(fs1, fc1, fc1, 0.f);
179  Vec3F ssc1(fs1, fs1, fc1, 0.f);
180  Vec3F l1vec; l1vec.set1(l1);
181  const Vec3F cslsimd = scc1 * ssc1 * l1vec;
182  Vec3F sigmap12simd; sigmap12simd.set1(sigmap12);
183 
184  for (int i=0; i!=cacheSize; ++i) {
185  StereoInfo const si = cache[i];
186 
187  // match
188  Vec2D minv10(si.m11, -si.m10);
189  Vec2D mult; mult.set1(1./(m00*si.m11 - m01*si.m10));
190  Vec2D resultmatmul = mult * (minv10 * c0vec + minv00 * si.c1vec);
191 
192  Local2DPoint position(resultmatmul.arr[0], resultmatmul.arr[1]);
193 
194  // LocalError tempError (100,0,100);
195  if (!((gluedDet->surface()).bounds().inside(position,10.f*scale_))) continue;
196 
197  double c2 = -si.m10;
198  double s2 = -si.m11;
199  double l2 = 1./(c2*c2+s2*s2);
200 
201  double diff=(c1*s2-c2*s1);
202  double invdet2 = 1./(diff*diff*l1*l2);
203 
204  float fc2(c2), fs2(s2), fid2(invdet2);
205  Vec3F invdet2simd(fid2, -fid2, fid2, 0.f);
206  Vec3F ccssimd(fs2, fc2, fc2, 0.f);
207  Vec3F csssimd(fs2, fs2, fc2, 0.f);
208  Vec3F l2simd; l2simd.set1(l2);
209  Vec3F sigmap22simd; sigmap22simd.set1(si.sigmap22);
210  Vec3F result = invdet2simd * (sigmap22simd * cslsimd + sigmap12simd * ccssimd * csssimd * l2simd);
211 
212 
213  LocalError error(result.arr[0], result.arr[1], result.arr[2]);
214 
215 
216  if((gluedDet->surface()).bounds().inside(position,error,scale_)){ //if it is inside the gluedet bonds
217 
218  //Change NSigmaInside in the configuration file to accept more hits
219  //...and add it to the Rechit collection
220 
221  collectorHelper.collector()(SiStripMatchedRecHit2D(LocalPoint(position), error,gluedDet->geographicalId() ,
222  &monoRH,si.secondHit));
223  }
224 
225  } // loop on cache info
226 
227  collectorHelper.closure(monoRHiter);
228  } // loop on mono hit
229 
230 }
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
static void updateWithAPE(LocalError &le, const GeomDet &det)
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
virtual float localPitch(const LocalPoint &) const =0
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
tuple result
Definition: query.py:137
float uu() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
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
SiStripMatchedRecHit2D * SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
const SiStripRecHit2D *  stereoRH,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 28 of file SiStripRecHitMatcher.cc.

References runEdmFileComparison::collection.

Referenced by match().

31  {
32  SimpleHitCollection stereoHits(1,stereoRH);
33  std::vector<SiStripMatchedRecHit2D*> collection;
34  match( monoRH,
35  stereoHits.begin(), stereoHits.end(),
36  collection,
37  gluedDet,trackdirection);
38 
39  return collection.empty() ? (SiStripMatchedRecHit2D*)(0) : collection.front();
40 }
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
std::vector< const SiStripRecHit2D * > SimpleHitCollection
SiStripMatchedRecHit2D * SiStripRecHitMatcher::match ( const SiStripMatchedRecHit2D *  originalRH,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 43 of file SiStripRecHitMatcher.cc.

45  {
46 
47  throw "SiStripRecHitMatcher::match(const SiStripMatchedRecHit2D *,..) is obsoltete since 5.2.0";
48 
49  /*
50  const SiStripRecHit2D* theMonoRH = origRH->monoHit();
51  // const SiStripRecHit2D* theStereoRH = origRH->stereoHit();
52  SimpleHitCollection theStereoHits(1, origRH->stereoHit());
53  // theStereoHits.push_back(theStereoRH);
54 
55  std::vector<SiStripMatchedRecHit2D*> collection;
56  match( theMonoRH,
57  theStereoHits.begin(), theStereoHits.end(),
58  collection,
59  gluedDet,trackdirection);
60 
61  return collection.empty() ? (SiStripMatchedRecHit2D*)(0) : collection.front();
62  */
63 
64  return nullptr;
65 }
edm::OwnVector<SiStripMatchedRecHit2D> SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
RecHitIterator  begin,
RecHitIterator  end,
const GluedGeomDet gluedDet 
) const
inline

Definition at line 61 of file SiStripRecHitMatcher.h.

References match().

63  {
64  return match(monoRH,begin, end, gluedDet,LocalVector(0.,0.,0.));
65  }
Local3DVector LocalVector
Definition: LocalVector.h:12
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
edm::OwnVector< SiStripMatchedRecHit2D > SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
RecHitIterator  begin,
RecHitIterator  end,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 69 of file SiStripRecHitMatcher.cc.

References end, i, and match().

73 {
74  SimpleHitCollection stereoHits;
75  stereoHits.reserve(end-begin);
76 
77  for (RecHitIterator i=begin; i != end; ++i) {
78  stereoHits.push_back( &(*i)); // convert to simple pointer
79  }
80  return match( monoRH,
81  stereoHits.begin(), stereoHits.end(),
82  gluedDet,trackdirection);
83 }
int i
Definition: DBlmapReader.cc:9
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
#define end
Definition: vmac.h:37
std::vector< const SiStripRecHit2D * > SimpleHitCollection
SiStripRecHit2DCollectionNew::DetSet::const_iterator RecHitIterator
#define begin
Definition: vmac.h:30
edm::OwnVector< SiStripMatchedRecHit2D > SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
SimpleHitIterator  begin,
SimpleHitIterator  end,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 86 of file SiStripRecHitMatcher.cc.

References match(), and edm::OwnVector< T, P >::reserve().

89  {
91  collector.reserve(end-begin); // a resonable estimate of its size...
92  match(monoRH,begin,end,collector,gluedDet,trackdirection);
93  return collector;
94 }
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
void reserve(size_t)
Definition: OwnVector.h:267
void SiStripRecHitMatcher::match ( const SiStripRecHit2D *  monoRH,
RecHitIterator  begin,
RecHitIterator  end,
CollectorMatched collector,
const GluedGeomDet gluedDet,
LocalVector  trackdirection 
) const

Definition at line 136 of file SiStripRecHitMatcher.cc.

References end, i, and match().

140  {
141 
142  // is this really needed now????
143  SimpleHitCollection stereoHits;
144  stereoHits.reserve(end-begin);
145  for (RecHitIterator i=begin; i != end; ++i)
146  stereoHits.push_back( &(*i)); // convert to simple pointer
147 
148  return match( monoRH,
149  stereoHits.begin(), stereoHits.end(),
150  collector,
151  gluedDet,trackdirection);
152 }
int i
Definition: DBlmapReader.cc:9
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
#define end
Definition: vmac.h:37
std::vector< const SiStripRecHit2D * > SimpleHitCollection
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 155 of file SiStripRecHitMatcher.cc.

References match(), and query::result.

159  {
160 
161  Collector result(boost::bind(pb2,boost::ref(collector),_1));
162  match(monoRH,begin,end,result,gluedDet,trackdirection);
163 
164 }
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
#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 98 of file SiStripRecHitMatcher.cc.

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

102  {
103 
104  std::vector<SiStripMatchedRecHit2D*> result;
105  result.reserve(end-begin);
106  match(monoRH,begin,end,result,gluedDet,trackdirection);
107  for (std::vector<SiStripMatchedRecHit2D*>::iterator p=result.begin(); p!=result.end();
108  p++) collector.push_back(*p);
109 }
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
void push_back(D *&d)
Definition: OwnVector.h:273
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
#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 123 of file SiStripRecHitMatcher.cc.

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

127  {
128  Collector result(boost::bind(&pb1,boost::ref(collector),
129  boost::bind(&SiStripMatchedRecHit2D::clone,_1)));
130  match(monoRH,begin,end,result,gluedDet,trackdirection);
131 }
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
tuple clone
Definition: statics.py:58
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 169 of file SiStripRecHitMatcher.cc.

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

173  {
174  // stripdet = mono
175  // partnerstripdet = stereo
176  const GeomDetUnit* stripdet = gluedDet->monoDet();
177  const GeomDetUnit* partnerstripdet = gluedDet->stereoDet();
178  const StripTopology& topol=(const StripTopology&)stripdet->topology();
179 
180  // position of the initial and final point of the strip (RPHI cluster) in local strip coordinates
181  double RPHIpointX = topol.measurementPosition(monoRH->localPositionFast()).x();
182  MeasurementPoint RPHIpointini(RPHIpointX,-0.5);
183  MeasurementPoint RPHIpointend(RPHIpointX,0.5);
184 
185  // position of the initial and final point of the strip in local coordinates (mono det)
186  StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
187 
188  if(trackdirection.mag2()<FLT_MIN){// in case of no track hypothesis assume a track from the origin through the center of the strip
189  LocalPoint lcenterofstrip=monoRH->localPositionFast();
190  GlobalPoint gcenterofstrip=(stripdet->surface()).toGlobal(lcenterofstrip);
191  GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
192  trackdirection=(gluedDet->surface()).toLocal(gtrackdirection);
193  }
194 
195  //project mono hit on glued det
196  StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
197  const StripTopology& partnertopol=(const StripTopology&)partnerstripdet->topology();
198 
199  double m00 = -(projectedstripmono.second.y()-projectedstripmono.first.y());
200  double m01 = (projectedstripmono.second.x()-projectedstripmono.first.x());
201  double c0 = m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
202 
203  //error calculation (the part that depends on mono RH only)
204  // LocalVector RPHIpositiononGluedendvector=projectedstripmono.second-projectedstripmono.first;
205  /*
206  double l1 = 1./RPHIpositiononGluedendvector.perp2();
207  double c1 = RPHIpositiononGluedendvector.y();
208  double s1 =-RPHIpositiononGluedendvector.x();
209  */
210  double c1 = -m00;
211  double s1 = -m01;
212  double l1 = 1./(c1*c1+s1*s1);
213 
214 
215  // FIXME: here for test...
216  double sigmap12 = monoRH->sigmaPitch();
217  if (sigmap12<0) {
218  //AlgebraicSymMatrix tmpMatrix = monoRH->parametersError();
219  /*
220  std::cout << "DEBUG START" << std::endl;
221  std::cout << "APE mono,stereo,glued : "
222  << stripdet->alignmentPositionError()->globalError().cxx() << " , "
223  << partnerstripdet->alignmentPositionError()->globalError().cxx() << " , "
224  << gluedDet->alignmentPositionError()->globalError().cxx() << std::endl;
225  */
226  LocalError tmpError(monoRH->localPositionErrorFast());
227  HelpertRecHit2DLocalPos::updateWithAPE(tmpError,*stripdet);
228  MeasurementError errormonoRH=topol.measurementError(monoRH->localPositionFast(),tmpError);
229  /*
230  std::cout << "localPosError.xx(), helper.xx(), param.xx(): "
231  << monoRH->localPositionError().xx() << " , "
232  << monoRH->parametersError()[0][0] << " , "
233  << tmpMatrix[0][0] << std::endl;
234  */
235  //MeasurementError errormonoRH=topol.measurementError(monoRH->localPosition(),monoRH->localPositionError());
236  double pitch=topol.localPitch(monoRH->localPositionFast());
237  monoRH->setSigmaPitch(sigmap12=errormonoRH.uu()*pitch*pitch);
238  }
239 
240  SimpleHitIterator seconditer;
241 
242  for(seconditer=begin;seconditer!=end;++seconditer){//iterate on stereo rechits
243 
244  // position of the initial and final point of the strip (STEREO cluster)
245  double STEREOpointX=partnertopol.measurementPosition((*seconditer)->localPositionFast()).x();
246  MeasurementPoint STEREOpointini(STEREOpointX,-0.5);
247  MeasurementPoint STEREOpointend(STEREOpointX,0.5);
248 
249  // position of the initial and final point of the strip in local coordinates (stereo det)
250  StripPosition stripstereo(partnertopol.localPosition(STEREOpointini),partnertopol.localPosition(STEREOpointend));
251 
252  //project stereo hit on glued det
253  StripPosition projectedstripstereo=project(partnerstripdet,gluedDet,stripstereo,trackdirection);
254 
255 
256  double m10=-(projectedstripstereo.second.y()-projectedstripstereo.first.y());
257  double m11=(projectedstripstereo.second.x()-projectedstripstereo.first.x());
258 
259  //perform the matching
260  //(x2-x1)(y-y1)=(y2-y1)(x-x1)
261  AlgebraicMatrix22 m; AlgebraicVector2 c; // FIXME understand why moving this initializer out of the loop changes the output!
262  m(0,0)=m00;
263  m(0,1)=m01;
264  m(1,0)=m10;
265  m(1,1)=m11;
266  c(0)=c0;
267  c(1)=m11*projectedstripstereo.first.y()+m10*projectedstripstereo.first.x();
268  m.Invert();
269  AlgebraicVector2 solution = m * c;
270  LocalPoint position(solution(0),solution(1));
271 
272  /*
273  {
274  double m00 = -(projectedstripmono.second.y()-projectedstripmono.first.y());
275  double m01 = (projectedstripmono.second.x()-projectedstripmono.first.x());
276  double m10 = -(projectedstripstereo.second.y()-projectedstripstereo.first.y());
277  double m11 = (projectedstripstereo.second.x()-projectedstripstereo.first.x());
278  double c0 = m01*projectedstripmono.first.y() + m00*projectedstripmono.first.x();
279  double c1 = m11*projectedstripstereo.first.y() + m10*projectedstripstereo.first.x();
280 
281  double invDet = 1./(m00*m11-m10*m01);
282  }
283  */
284 
285  //
286  // temporary fix by tommaso
287  //
288 
289 
290  LocalError tempError (100,0,100);
291  if (!((gluedDet->surface()).bounds().inside(position,tempError,scale_))) continue;
292 
293  // then calculate the error
294  /*
295  LocalVector stereopositiononGluedendvector=projectedstripstereo.second-projectedstripstereo.first;
296  double l2 = 1./stereopositiononGluedendvector.perp2();
297  double c2 = stereopositiononGluedendvector.y();
298  double s2 =-stereopositiononGluedendvector.x();
299  */
300 
301  double c2 = -m10;
302  double s2 = -m11;
303  double l2 = 1./(c2*c2+s2*s2);
304 
305 
306  // FIXME: here for test...
307  double sigmap22 = (*seconditer)->sigmaPitch();
308  if (sigmap22<0) {
309  //AlgebraicSymMatrix tmpMatrix = (*seconditer)->parametersError();
310  LocalError tmpError((*seconditer)->localPositionErrorFast());
311  HelpertRecHit2DLocalPos::updateWithAPE(tmpError, *partnerstripdet);
312  MeasurementError errorstereoRH=partnertopol.measurementError((*seconditer)->localPositionFast(),tmpError);
313  //MeasurementError errorstereoRH=partnertopol.measurementError((*seconditer)->localPosition(),(*seconditer)->localPositionError());
314  double pitch=partnertopol.localPitch((*seconditer)->localPositionFast());
315  (*seconditer)->setSigmaPitch(sigmap22=errorstereoRH.uu()*pitch*pitch);
316  }
317 
318  double diff=(c1*s2-c2*s1);
319  double invdet2=1/(diff*diff*l1*l2);
320  float xx= invdet2*(sigmap12*s2*s2*l2+sigmap22*s1*s1*l1);
321  float xy=-invdet2*(sigmap12*c2*s2*l2+sigmap22*c1*s1*l1);
322  float yy= invdet2*(sigmap12*c2*c2*l2+sigmap22*c1*c1*l1);
323  LocalError error(xx,xy,yy);
324 
325  if((gluedDet->surface()).bounds().inside(position,error,scale_)){ //if it is inside the gluedet bonds
326  //Change NSigmaInside in the configuration file to accept more hits
327  //...and add it to the Rechit collection
328 
329  const SiStripRecHit2D* secondHit = *seconditer;
330  collector(SiStripMatchedRecHit2D(position, error,gluedDet->geographicalId() ,
331  monoRH,secondHit));
332  }
333  }
334 }
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 void updateWithAPE(LocalError &le, const GeomDet &det)
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
virtual float localPitch(const LocalPoint &) const =0
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
std::pair< LocalPoint, LocalPoint > StripPosition
float uu() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
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
SiStripRecHitMatcher::StripPosition SiStripRecHitMatcher::project ( const GeomDetUnit det,
const GluedGeomDet glueddet,
StripPosition  strip,
LocalVector  trackdirection 
) const

Definition at line 337 of file SiStripRecHitMatcher.cc.

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

Referenced by match().

338 {
339 
340  GlobalPoint globalpointini=(det->surface()).toGlobal(strip.first);
341  GlobalPoint globalpointend=(det->surface()).toGlobal(strip.second);
342 
343  // position of the initial and final point of the strip in glued local coordinates
344  LocalPoint positiononGluedini=(glueddet->surface()).toLocal(globalpointini);
345  LocalPoint positiononGluedend=(glueddet->surface()).toLocal(globalpointend);
346 
347  //correct the position with the track direction
348 
349  float scale=-positiononGluedini.z()/trackdirection.z();
350 
351  LocalPoint projpositiononGluedini= positiononGluedini + scale*trackdirection;
352  LocalPoint projpositiononGluedend= positiononGluedend + scale*trackdirection;
353 
354  return StripPosition(projpositiononGluedini,projpositiononGluedend);
355 }
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

Member Data Documentation

float SiStripRecHitMatcher::scale_

Definition at line 130 of file SiStripRecHitMatcher.h.

Referenced by doubleMatch(), match(), and SiStripRecHitMatcher().