1 |
#include "RecoTracker/TransientTrackingRecHit/interface/TSiStripMatchedRecHit.h"
|
2 |
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
|
3 |
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
|
4 |
#include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h"
|
5 |
#include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
|
6 |
//#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
7 |
#include "RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h"
|
8 |
|
9 |
#undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj
|
10 |
#undef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
|
11 |
#ifdef RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitLGL
|
12 |
// Local lo Global lo Local
|
13 |
inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
|
14 |
const BoundPlane &stripPlane = gdet->stereoDet()->surface();
|
15 |
LocalPoint lp = stripPlane.toLocal(tsos.globalPosition());
|
16 |
LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
|
17 |
return LocalTrajectoryParameters(lp,ld,tsos.charge());
|
18 |
}
|
19 |
#elif defined(RecoTracker_TransientTrackingRecHit_TSiStripMatchedRecHit_RefitProj)
|
20 |
// A la RecHitProjector
|
21 |
inline LocalTrajectoryParameters gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
|
22 |
const BoundPlane &stripPlane = gdet->stereoDet()->surface();
|
23 |
double delta = stripPlane.localZ( tsos.globalPosition());
|
24 |
LocalVector ld = stripPlane.toLocal(tsos.globalParameters().momentum());
|
25 |
LocalPoint lp = stripPlane.toLocal(tsos.globalPosition()) - ld*delta/ld.z();
|
26 |
return LocalTrajectoryParameters(lp,ld,tsos.charge());
|
27 |
}
|
28 |
#else
|
29 |
// Dummy
|
30 |
inline const LocalTrajectoryParameters & gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet) {
|
31 |
return tsos.localParameters();
|
32 |
}
|
33 |
#endif
|
34 |
|
35 |
TSiStripMatchedRecHit::RecHitPointer
|
36 |
TSiStripMatchedRecHit::clone( const TrajectoryStateOnSurface& ts) const
|
37 |
{
|
38 |
if (theMatcher != 0) {
|
39 |
const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
|
40 |
const GeomDet *det = this->det();
|
41 |
const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
|
42 |
//if ((orig == 0) || (gdet == 0)) return this->clone(); // or just die ?
|
43 |
LocalVector tkDir = (ts.isValid() ? ts.localDirection() :
|
44 |
det->surface().toLocal( det->position()-GlobalPoint(0,0,0)));
|
45 |
|
46 |
if(theCPE != 0){
|
47 |
//approximation: the ts parameter on the glued surface are used on the mono
|
48 |
// and stereo surface to re-evaluate cluster parameter. A further propagation
|
49 |
//is slow// and useless (?) in this case.
|
50 |
|
51 |
const SiStripMatchedRecHit2D* better;
|
52 |
|
53 |
if(!orig->monoHit()->cluster().isNull()){
|
54 |
const SiStripCluster& monoclust = *orig->monoHit()->cluster();
|
55 |
const SiStripCluster& stereoclust = *orig->stereoHit()->cluster();
|
56 |
|
57 |
StripClusterParameterEstimator::LocalValues lvMono =
|
58 |
theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
|
59 |
StripClusterParameterEstimator::LocalValues lvStereo =
|
60 |
theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
|
61 |
|
62 |
SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
|
63 |
gdet->monoDet()->geographicalId(),
|
64 |
orig->monoHit()->cluster());
|
65 |
|
66 |
SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
|
67 |
gdet->stereoDet()->geographicalId(),
|
68 |
orig->stereoHit()->cluster());
|
69 |
better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
|
70 |
}else{
|
71 |
const SiStripCluster& monoclust = *orig->monoHit()->cluster_regional();
|
72 |
const SiStripCluster& stereoclust = *orig->stereoHit()->cluster_regional();
|
73 |
StripClusterParameterEstimator::LocalValues lvMono =
|
74 |
theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
|
75 |
StripClusterParameterEstimator::LocalValues lvStereo =
|
76 |
theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
|
77 |
|
78 |
SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
|
79 |
gdet->monoDet()->geographicalId(),
|
80 |
orig->monoHit()->cluster_regional());
|
81 |
|
82 |
SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
|
83 |
gdet->stereoDet()->geographicalId(),
|
84 |
orig->stereoHit()->cluster_regional());
|
85 |
better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
|
86 |
}
|
87 |
|
88 |
if (better == 0) {
|
89 |
//dm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
|
90 |
return this->clone();
|
91 |
}
|
92 |
|
93 |
return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor(), false, DontCloneRecHit()));
|
94 |
// delete better; //the ownership of the object is passed to the caller of the matcher
|
95 |
|
96 |
}else{
|
97 |
const SiStripMatchedRecHit2D *better = theMatcher->match(orig,gdet,tkDir);
|
98 |
if (better == 0) {
|
99 |
//edm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
|
100 |
return this->clone();
|
101 |
}
|
102 |
return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, weight(), getAnnealingFactor(), false, DontCloneRecHit()));
|
103 |
// delete better; //the ownership of the object is passed to the caller of the matcher
|
104 |
}
|
105 |
}
|
106 |
return this->clone();
|
107 |
|
108 |
}
|
109 |
|
110 |
|
111 |
|
112 |
TransientTrackingRecHit::ConstRecHitContainer
|
113 |
TSiStripMatchedRecHit::transientHits () const {
|
114 |
ConstRecHitContainer result;
|
115 |
|
116 |
const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (this->det());
|
117 |
const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
|
118 |
|
119 |
result.push_back(TSiStripRecHit2DLocalPos::build( gdet->monoDet(),orig->monoHit(),theCPE));
|
120 |
result.push_back(TSiStripRecHit2DLocalPos::build( gdet->stereoDet(),orig->stereoHit(),theCPE));
|
121 |
return result;
|
122 |
}
|