CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TSiStripMatchedRecHit.h
Go to the documentation of this file.
1 #ifndef RECOTRACKER_TRANSIENTRACKINGRECHIT_TSiStripMatchedRecHit_H
2 #define RECOTRACKER_TRANSIENTRACKINGRECHIT_TSiStripMatchedRecHit_H
3 
8 #include<memory>
9 
12 
14 public:
15 
16  virtual void getKfComponents( KfComponentsHolder & holder ) const {
18  }
19 
22  }
23 
24  const GeomDetUnit* detUnit() const {return 0;}
25 
26  static RecHitPointer build( const GeomDet * geom, const TrackingRecHit * rh,
27  const SiStripRecHitMatcher *matcher,
28  const StripClusterParameterEstimator* cpe=0,
29  float weight=1., float annealing=1.,
30  bool computeCoarseLocalPosition=false) {
31  return RecHitPointer( new TSiStripMatchedRecHit( geom, rh, matcher,cpe, weight, annealing, computeCoarseLocalPosition));
32  }
33 
34  static RecHitPointer build( const GeomDet * geom, std::auto_ptr<TrackingRecHit> rh,
35  const SiStripRecHitMatcher *matcher,
36  const StripClusterParameterEstimator* cpe=0,
37  float weight=1., float annealing=1.,
38  bool computeCoarseLocalPosition=false) {
39  return RecHitPointer( new TSiStripMatchedRecHit( geom, rh, matcher,cpe,weight, annealing, computeCoarseLocalPosition));
40  }
41 
42  virtual RecHitPointer clone( const TrajectoryStateOnSurface& ts) const;
43  virtual bool canImproveWithTrack() const {return (theMatcher != 0);}
44  virtual ConstRecHitContainer transientHits () const;
45 
47  struct DontCloneRecHit {};
48 
53  static void buildInPlace(std::auto_ptr<TSiStripMatchedRecHit> &memory,
54  const GeomDet * geom, const TrackingRecHit * rh,
55  const SiStripRecHitMatcher *matcher,
56  const StripClusterParameterEstimator* cpe=0,
57  float weight=1., float annealing=1.,
58  bool computeCoarseLocalPosition=false) {
59  if (memory.get()) {
60  memory->~TSiStripMatchedRecHit(); // call destructor
61  new (memory.get()) TSiStripMatchedRecHit( geom, rh, matcher,cpe,weight, annealing, computeCoarseLocalPosition, DontCloneRecHit());
62  } else {
63  memory.reset(new TSiStripMatchedRecHit( geom, rh, matcher,cpe,weight, annealing, computeCoarseLocalPosition, DontCloneRecHit()));
64  }
65  }
66 
72 
73 private:
77  const SiStripRecHitMatcher *matcher,
79  float weight, float annealing,
80  bool computeCoarseLocalPosition) :
81  GenericTransientTrackingRecHit(geom, *rh, weight, annealing), theMatcher(matcher),theCPE(cpe) {
82  if (computeCoarseLocalPosition) ComputeCoarseLocalPosition();
83  }
84 
85  TSiStripMatchedRecHit (const GeomDet * geom, std::auto_ptr<TrackingRecHit> rh,
86  const SiStripRecHitMatcher *matcher,
88  float weight, float annealing,
89  bool computeCoarseLocalPosition) :
90  GenericTransientTrackingRecHit(geom, rh.release(), weight, annealing), theMatcher(matcher),theCPE(cpe) {
91  if (computeCoarseLocalPosition) ComputeCoarseLocalPosition();
92  }
94  const SiStripRecHitMatcher *matcher,
96  float weight, float annealing,
97  bool computeCoarseLocalPosition,
98  const DontCloneRecHit &) :
99  GenericTransientTrackingRecHit(geom, const_cast<TrackingRecHit *>(rh), weight, annealing), theMatcher(matcher),theCPE(cpe) {
100  if (computeCoarseLocalPosition) ComputeCoarseLocalPosition();
101  }
102 
103 
105  if (!theCPE || !theMatcher) return;
106  const SiStripMatchedRecHit2D *orig = static_cast<const SiStripMatchedRecHit2D *> (trackingRecHit_);
107  if (orig && !orig->hasPositionAndError()){
108  LogDebug("TSiStripMatchedRecHit")<<"calculating coarse position/error.";
109  const GeomDet *det = this->det();
110  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *> (det);
111  LocalVector tkDir = det->surface().toLocal( det->position()-GlobalPoint(0,0,0));
112 
113  const SiStripMatchedRecHit2D* better=0;
114 
115  if(!orig->monoHit()->cluster().isNull()){
116  const SiStripCluster& monoclust = *orig->monoHit()->cluster();
117  const SiStripCluster& stereoclust = *orig->stereoHit()->cluster();
118 
120  theCPE->localParameters( monoclust, *gdet->monoDet());
122  theCPE->localParameters( stereoclust, *gdet->stereoDet());
123 
124  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
125  gdet->monoDet()->geographicalId(),
126  orig->monoHit()->cluster());
127 
128  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
129  gdet->stereoDet()->geographicalId(),
130  orig->stereoHit()->cluster());
131  better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
132  }else{
133  const SiStripCluster& monoclust = *orig->monoHit()->cluster_regional();
134  const SiStripCluster& stereoclust = *orig->stereoHit()->cluster_regional();
136  theCPE->localParameters( monoclust, *gdet->monoDet());
138  theCPE->localParameters( stereoclust, *gdet->stereoDet());
139 
140  SiStripRecHit2D monoHit = SiStripRecHit2D( lvMono.first, lvMono.second,
141  gdet->monoDet()->geographicalId(),
142  orig->monoHit()->cluster_regional());
143 
144  SiStripRecHit2D stereoHit = SiStripRecHit2D( lvStereo.first, lvStereo.second,
145  gdet->stereoDet()->geographicalId(),
146  orig->stereoHit()->cluster_regional());
147  better = theMatcher->match(&monoHit,&stereoHit,gdet,tkDir);
148 
149  }
150  if (!better) {
151  edm::LogWarning("TSiStripMatchedRecHit")<<"could not get a matching rechit.";
152  }else{
153  trackingRecHit_ = better->clone();
154  }
155  }
156  }
157 
158  virtual TSiStripMatchedRecHit* clone() const {
159  return new TSiStripMatchedRecHit(*this);
160  }
161 
162 };
163 
164 
165 
166 #endif
#define LogDebug(id)
ReferenceCountingPointer< TransientTrackingRecHit > RecHitPointer
virtual AlgebraicSymMatrix parametersError() const
void clonePersistentHit()
take ownership of the hit, if it wasn&#39;t owned (note: if it was owned, this code will leak it) ...
virtual SiStripMatchedRecHit2D * clone() const
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
Definition: vlib.h:187
SiStripMatchedRecHit2D * match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection) const
const GeomDetUnit * detUnit() const
const SiStripRecHit2D * stereoHit() const
virtual const TrackingRecHit * hit() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static void getKfComponents(KfComponentsHolder &holder, const TrackingRecHit &hit2dLocalPos, const GeomDet &det)
const StripClusterParameterEstimator * theCPE
ClusterRegionalRef const & cluster_regional() const
std::pair< LocalPoint, LocalError > LocalValues
virtual LocalValues localParameters(const T &, const GeomDetUnit &) const =0
static void buildInPlace(std::auto_ptr< TSiStripMatchedRecHit > &memory, const GeomDet *geom, const TrackingRecHit *rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe=0, float weight=1., float annealing=1., bool computeCoarseLocalPosition=false)
virtual LocalError localPositionError() const
bool isNull() const
Checks for null.
Definition: Ref.h:244
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
LocalPoint toLocal(const GlobalPoint &gp) const
TSiStripMatchedRecHit(const GeomDet *geom, std::auto_ptr< TrackingRecHit > rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe, float weight, float annealing, bool computeCoarseLocalPosition)
const SiStripRecHitMatcher * theMatcher
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:74
virtual bool canImproveWithTrack() const
virtual void getKfComponents(KfComponentsHolder &holder) const
virtual TrackingRecHit * clone() const =0
Dummy struct to pass to the constructor to say &#39;please don&#39;t clone the hit&#39;.
ClusterRef const & cluster() const
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe=0, float weight=1., float annealing=1., bool computeCoarseLocalPosition=false)
TSiStripMatchedRecHit(const GeomDet *geom, const TrackingRecHit *rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe, float weight, float annealing, bool computeCoarseLocalPosition)
const GeomDet * det() const
The GomeDet* can be zero for InvalidTransientRecHits and for TConstraintRecHit2Ds.
CLHEP::HepSymMatrix AlgebraicSymMatrix
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
TSiStripMatchedRecHit(const GeomDet *geom, const TrackingRecHit *rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe, float weight, float annealing, bool computeCoarseLocalPosition, const DontCloneRecHit &)
const SiStripRecHit2D * monoHit() const
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
static RecHitPointer build(const GeomDet *geom, std::auto_ptr< TrackingRecHit > rh, const SiStripRecHitMatcher *matcher, const StripClusterParameterEstimator *cpe=0, float weight=1., float annealing=1., bool computeCoarseLocalPosition=false)
virtual ConstRecHitContainer transientHits() const
Composite interface: returns the component hits, if any.
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
virtual TSiStripMatchedRecHit * clone() const
static AlgebraicSymMatrix parError(const LocalError &le, const GeomDet &det)