00001 #include "FastSimulation/TrackingRecHitProducer/interface/GSRecHitMatcher.h"
00002
00003 #include "DataFormats/DetId/interface/DetId.h"
00004 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00005 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00006 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00007 #include <cfloat>
00008
00009 SiTrackerGSMatchedRecHit2D * GSRecHitMatcher::match( const SiTrackerGSRecHit2D *monoRH,
00010 const SiTrackerGSRecHit2D *stereoRH,
00011 const GluedGeomDet* gluedDet,
00012 LocalVector& trackdirection) const
00013 {
00014
00015
00016
00017
00018 const GeomDetUnit* stripdet = gluedDet->monoDet();
00019 const GeomDetUnit* partnerstripdet = gluedDet->stereoDet();
00020 const StripTopology& topol=(const StripTopology&)stripdet->topology();
00021
00022 LocalPoint position;
00023
00024
00025 MeasurementPoint RPHIpoint=topol.measurementPosition(monoRH->localPosition());
00026 MeasurementPoint RPHIpointini=MeasurementPoint(RPHIpoint.x(),-0.5);
00027 MeasurementPoint RPHIpointend=MeasurementPoint(RPHIpoint.x(),0.5);
00028
00029
00030 StripPosition stripmono=StripPosition(topol.localPosition(RPHIpointini),topol.localPosition(RPHIpointend));
00031
00032 if(trackdirection.mag2()<FLT_MIN){
00033 LocalPoint lcenterofstrip=monoRH->localPosition();
00034 GlobalPoint gcenterofstrip=(stripdet->surface()).toGlobal(lcenterofstrip);
00035 GlobalVector gtrackdirection=gcenterofstrip-GlobalPoint(0,0,0);
00036 trackdirection=(gluedDet->surface()).toLocal(gtrackdirection);
00037 }
00038
00039
00040 StripPosition projectedstripmono=project(stripdet,gluedDet,stripmono,trackdirection);
00041 const StripTopology& partnertopol=(const StripTopology&)partnerstripdet->topology();
00042
00043
00044 LocalVector RPHIpositiononGluedendvector=projectedstripmono.second-projectedstripmono.first;
00045 double c1=sin(RPHIpositiononGluedendvector.phi());
00046 double s1=-cos(RPHIpositiononGluedendvector.phi());
00047 MeasurementError errormonoRH=topol.measurementError(monoRH->localPosition(),monoRH->localPositionError());
00048 double pitch=topol.localPitch(monoRH->localPosition());
00049 double sigmap12=errormonoRH.uu()*pitch*pitch;
00050
00051
00052 MeasurementPoint STEREOpoint=partnertopol.measurementPosition(stereoRH->localPosition());
00053
00054 MeasurementPoint STEREOpointini=MeasurementPoint(STEREOpoint.x(),-0.5);
00055 MeasurementPoint STEREOpointend=MeasurementPoint(STEREOpoint.x(),0.5);
00056
00057
00058 StripPosition stripstereo(partnertopol.localPosition(STEREOpointini),partnertopol.localPosition(STEREOpointend));
00059
00060
00061 StripPosition projectedstripstereo=project(partnerstripdet,gluedDet,stripstereo,trackdirection);
00062
00063
00064
00065 AlgebraicMatrix22 m; AlgebraicVector2 c, solution;
00066 m(0,0)=-(projectedstripmono.second.y()-projectedstripmono.first.y()); m(0,1)=(projectedstripmono.second.x()-projectedstripmono.first.x());
00067 m(1,0)=-(projectedstripstereo.second.y()-projectedstripstereo.first.y()); m(1,1)=(projectedstripstereo.second.x()-projectedstripstereo.first.x());
00068 c(0)=m(0,1)*projectedstripmono.first.y()+m(0,0)*projectedstripmono.first.x();
00069 c(1)=m(1,1)*projectedstripstereo.first.y()+m(1,0)*projectedstripstereo.first.x();
00070 m.Invert(); solution = m * c;
00071 position=LocalPoint(solution(0),solution(1));
00072
00073
00074
00075
00076
00077
00078
00079 LocalError tempError (100,0,100);
00080
00081
00082 LocalVector stereopositiononGluedendvector=projectedstripstereo.second-projectedstripstereo.first;
00083 double c2=sin(stereopositiononGluedendvector.phi()); double s2=-cos(stereopositiononGluedendvector.phi());
00084 MeasurementError errorstereoRH=partnertopol.measurementError(stereoRH->localPosition(), stereoRH->localPositionError());
00085 pitch=partnertopol.localPitch(stereoRH->localPosition());
00086 double sigmap22=errorstereoRH.uu()*pitch*pitch;
00087 double diff=(c1*s2-c2*s1);
00088 double invdet2=1/(diff*diff);
00089 float xx=invdet2*(sigmap12*s2*s2+sigmap22*s1*s1);
00090 float xy=-invdet2*(sigmap12*c2*s2+sigmap22*c1*s1);
00091 float yy=invdet2*(sigmap12*c2*c2+sigmap22*c1*c1);
00092 LocalError error=LocalError(xx,xy,yy);
00093
00094
00095
00096
00097
00098
00099
00100
00101 return new SiTrackerGSMatchedRecHit2D(position, error,gluedDet->geographicalId(), monoRH->simhitId(),
00102 monoRH->simtrackId(), monoRH->eeId(), monoRH->cluster(), monoRH->simMultX(), monoRH->simMultY(),
00103 true, monoRH, stereoRH);
00104 }
00105
00106
00107 GSRecHitMatcher::StripPosition
00108 GSRecHitMatcher::project(const GeomDetUnit *det,
00109 const GluedGeomDet* glueddet,
00110 const StripPosition& strip,
00111 const LocalVector& trackdirection)const
00112 {
00113
00114 GlobalPoint globalpointini=(det->surface()).toGlobal(strip.first);
00115 GlobalPoint globalpointend=(det->surface()).toGlobal(strip.second);
00116
00117
00118 LocalPoint positiononGluedini=(glueddet->surface()).toLocal(globalpointini);
00119 LocalPoint positiononGluedend=(glueddet->surface()).toLocal(globalpointend);
00120
00121
00122
00123 float scale=-positiononGluedini.z()/trackdirection.z();
00124
00125 LocalPoint projpositiononGluedini= positiononGluedini + scale*trackdirection;
00126 LocalPoint projpositiononGluedend= positiononGluedend + scale*trackdirection;
00127
00128 return StripPosition(projpositiononGluedini,projpositiononGluedend);
00129 }
00130
00131
00132
00133 SiTrackerGSMatchedRecHit2D * GSRecHitMatcher::projectOnly( const SiTrackerGSRecHit2D *monoRH,
00134 const GeomDet * monoDet,
00135 const GluedGeomDet* gluedDet,
00136 LocalVector& ldir) const
00137 {
00138 LocalPoint position(monoRH->localPosition().x(), 0.,0.);
00139 const BoundPlane& gluedPlane = gluedDet->surface();
00140 const BoundPlane& hitPlane = monoDet->surface();
00141
00142 double delta = gluedPlane.localZ( hitPlane.position());
00143
00144 LocalPoint lhitPos = gluedPlane.toLocal( monoDet->surface().toGlobal(position ) );
00145 LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
00146
00147 LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1,0,0)));
00148 LocalError hitErr = monoRH->localPositionError();
00149
00150 if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
00151
00152 hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
00153 }
00154 LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
00155
00156 return new SiTrackerGSMatchedRecHit2D(projectedHitPos, rotatedError, gluedDet->geographicalId(),
00157 monoRH->simhitId(), monoRH->simtrackId(), monoRH->eeId(), monoRH->cluster(),
00158 monoRH->simMultX(), monoRH->simMultY());
00159 }
00160