CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TSiStripMatchedRecHit.cc
Go to the documentation of this file.
6 //#include "FWCore/MessageLogger/interface/MessageLogger.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
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
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
31  return tsos.localParameters();
32 }
33 #endif
34 
35 TSiStripMatchedRecHit::RecHitPointer
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 
52  const SiStripCluster& monoclust = orig->monoCluster();
53  const SiStripCluster& stereoclust = orig->stereoCluster();
54 
56  theCPE->localParameters( monoclust, *gdet->monoDet(), ts);
58  theCPE->localParameters( stereoclust, *gdet->stereoDet(), gluedToStereo(ts, gdet));
59 
60  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
61  gdet->monoDet()->geographicalId(),
62  orig->monoClusterRef());
63 
64  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
65  gdet->stereoDet()->geographicalId(),
66  orig->stereoClusterRef());
67  const SiStripMatchedRecHit2D* better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
68 
69  if (better == 0) {
70  //dm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
71  return this->clone();
72  }
73 
74  return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, false, DontCloneRecHit()));
75  // delete better; //the ownership of the object is passed to the caller of the matcher
76 
77  }
78  /*
79  // not supported anymore....
80  else{
81  const SiStripMatchedRecHit2D *better = theMatcher->match(orig,gdet,tkDir);
82  if (better == 0) {
83  //edm::LogWarning("TSiStripMatchedRecHit") << "Refitting of a matched rechit returns NULL";
84  return this->clone();
85  }
86  return RecHitPointer(new TSiStripMatchedRecHit( gdet, better, theMatcher,theCPE, false, DontCloneRecHit()));
87  // delete better; //the ownership of the object is passed to the caller of the matcher
88  }
89  */
90  }
91  return this->clone();
92 
93 }
94 
95 
96 
98 TSiStripMatchedRecHit::transientHits () const {
100 
101  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (this->det());
102  const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (this->hit());
103 
104  if (theCPE!=nullptr) {
105  // this is at least the third place I read (write) this logic...
106  const SiStripCluster& monoclust = orig->monoCluster();
107  const SiStripCluster& stereoclust = orig->stereoCluster();
108 
110  theCPE->localParameters( monoclust, *gdet->monoDet());
112  theCPE->localParameters( stereoclust, *gdet->stereoDet());
113 
114  result.push_back(TSiStripRecHit2DLocalPos::build(lvMono.first, lvMono.second, gdet->monoDet(),
115  orig->monoClusterRef(), theCPE));
116  result.push_back(TSiStripRecHit2DLocalPos::build(lvStereo.first, lvStereo.second, gdet->stereoDet(),
117  orig->stereoClusterRef(), theCPE));
118  }
119  else {
120  auto m = orig->monoHit(); auto s = orig->stereoHit();
121  result.push_back(TSiStripRecHit2DLocalPos::build( gdet->monoDet(),&m,theCPE));
122  result.push_back(TSiStripRecHit2DLocalPos::build( gdet->stereoDet(),&s,theCPE));
123  }
124  return result;
125 }
126 
127  void TSiStripMatchedRecHit::ComputeCoarseLocalPosition(){
128  if (!theCPE || !theMatcher) return;
129  const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (trackingRecHit_);
130  if ( (!orig) || orig->hasPositionAndError()) return;
131 
132  LogDebug("TSiStripMatchedRecHit")<<"calculating coarse position/error.";
133  const GeomDet *det = this->det();
134  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
135  LocalVector tkDir = det->surface().toLocal( det->position()-GlobalPoint(0,0,0));
136 
137  const SiStripCluster& monoclust = orig->monoCluster();
138  const SiStripCluster& stereoclust = orig->stereoCluster();
139 
141  theCPE->localParameters( monoclust, *gdet->monoDet());
143  theCPE->localParameters( stereoclust, *gdet->stereoDet());
144 
145  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
146  gdet->monoDet()->geographicalId(),
147  orig->monoClusterRef());
148 
149  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
150  gdet->stereoDet()->geographicalId(),
151  orig->stereoClusterRef());
152  SiStripMatchedRecHit2D* better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
153 
154  if (!better) {
155  edm::LogWarning("TSiStripMatchedRecHit")<<"could not get a matching rechit.";
156  }else{
157  delete trackingRecHit_;
158  trackingRecHit_ = better;
159  }
160 
161 }
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
const LocalTrajectoryParameters & localParameters() const
LocalVector localDirection() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
const LocalTrajectoryParameters & gluedToStereo(const TrajectoryStateOnSurface &tsos, const GluedGeomDet *gdet)
std::pair< LocalPoint, LocalError > LocalValues
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:41
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
std::vector< ConstRecHitPointer > ConstRecHitContainer
const GlobalTrajectoryParameters & globalParameters() const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
tuple clone
Definition: statics.py:58
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21