CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedFromConsecutiveHitsCreator.cc
Go to the documentation of this file.
3 
18 
19 template <class T> T sqr( T t) {return t*t;}
20 
22  TrajectorySeedCollection & seedCollection,
23  const SeedingHitSet & hits,
24  const TrackingRegion & region,
25  const edm::EventSetup& es)
26 {
27  if ( hits.size() < 2) return 0;
28 
29  GlobalTrajectoryParameters kine = initialKinematic(hits, region, es);
30  float sinTheta = sin(kine.momentum().theta());
31 
32  CurvilinearTrajectoryError error = initialError(region, sinTheta);
33  FreeTrajectoryState fts(kine, error);
34 
35  return buildSeed(seedCollection,hits,fts,es);
36 }
37 
38 
40  const SeedingHitSet & hits,
41  const TrackingRegion & region,
42  const edm::EventSetup& es) const
43 {
45  es.get<IdealMagneticFieldRecord>().get(bfield);
46 
48 
51  const GlobalPoint& vertexPos = region.origin();
52 
53  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, es);
54  if (helix.isValid()) {
55  kine = helix.stateAtVertex().parameters();
56  } else {
57  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
58  initMomentum *= (100./initMomentum.perp());
59  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
60  }
61 
62  bool isBOFF = ( std::abs(bfield->inTesla(GlobalPoint(0,0,0)).z()) < 1e-3 );
63  if (isBOFF && (theBOFFMomentum > 0)) {
65  kine.momentum().unit() * theBOFFMomentum,
66  kine.charge(),
67  &*bfield);
68  }
69  return kine;
70 }
71 
72 
73 
75  initialError( const TrackingRegion& region, float sinTheta) const
76 {
77  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
78  // information.
79  GlobalError vertexErr( sqr(region.originRBound()), 0, sqr(region.originRBound()),
80  0, 0, sqr(region.originZBound()));
81 
82  float ptMin = region.ptMin();
83 
84 
85  AlgebraicSymMatrix C(5,1);
86 
87 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
88 // to avoid instabilities.
89 // N.B. This parameter needs optimising ...
90  float sin2th = sqr(sinTheta);
91  float minC00 = 1.0;
92  C[0][0] = std::max(sin2th/sqr(ptMin), minC00);
93  float zErr = vertexErr.czz();
94  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
95  C[3][3] = transverseErr;
96  C[4][4] = zErr*sin2th + transverseErr*(1-sin2th);
97 
99 }
100 
102  TrajectorySeedCollection & seedCollection,
103  const SeedingHitSet & hits,
104  const FreeTrajectoryState & fts,
105  const edm::EventSetup& es) const
106 {
107  // get tracker
109  es.get<TrackerDigiGeometryRecord>().get(tracker);
110 
111  // get propagator
112  edm::ESHandle<Propagator> propagatorHandle;
113  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagatorHandle);
114  const Propagator* propagator = &(*propagatorHandle);
115 
116  // get updator
118 
119  // Now update initial state track using information from seed hits.
120 
121  TrajectoryStateOnSurface updatedState;
123 
124  const TrackingRecHit* hit = 0;
125  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
126  hit = hits[iHit]->hit();
127  TrajectoryStateOnSurface state = (iHit==0) ?
128  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
129  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
130  if (!state.isValid()) return 0;
131 
133 
134  TransientTrackingRecHit::RecHitPointer newtth = refitHit( tth, state);
135 
136  if (!checkHit(state,newtth,es)) return 0;
137 
138  updatedState = updator.update(state, *newtth);
139  if (!updatedState.isValid()) return 0;
140 
141  seedHits.push_back(newtth->hit()->clone());
142  }
143 
144  TrajectoryStateTransform transformer;
145  boost::shared_ptr<PTrajectoryStateOnDet> PTraj(
146  transformer.persistentState(updatedState, hit->geographicalId().rawId()));
147 
148  seedCollection.push_back( TrajectorySeed(*PTraj,seedHits,alongMomentum));
149  return &seedCollection.back();
150 }
151 
154  const TrajectoryStateOnSurface &state) const
155 {
156  return hit->clone(state);
157 }
virtual bool checkHit(const TrajectoryStateOnSurface &, const TransientTrackingRecHit::ConstRecHitPointer &hit, const edm::EventSetup &es) const
virtual const TrajectorySeed * buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es) const
virtual float ptMin() const =0
minimal pt of interest
virtual GlobalPoint origin() const =0
virtual TransientTrackingRecHit::RecHitPointer refitHit(const TransientTrackingRecHit::ConstRecHitPointer &hit, const TrajectoryStateOnSurface &state) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
virtual GlobalTrajectoryParameters initialKinematic(const SeedingHitSet &hits, const TrackingRegion &region, const edm::EventSetup &es) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual CurvilinearTrajectoryError initialError(const TrackingRegion &region, float sinTheta) const
void push_back(D *&d)
Definition: OwnVector.h:288
virtual const TrajectorySeed * trajectorySeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &ordered, const TrackingRegion &region, const edm::EventSetup &es)
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
PTrajectoryStateOnDet * persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid) const
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:9
Vector3DBase unit() const
Definition: Vector3DBase.h:57
const T & get() const
Definition: EventSetup.h:55
virtual float originRBound() const =0
bounds the particle vertex in the transverse plane
char state
Definition: procUtils.cc:75
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const
Definition: KFUpdator.cc:10
virtual float originZBound() const =0
bounds the particle vertex in the longitudinal plane
Square< F >::type sqr(const F &f)
Definition: Square.h:13
unsigned int size() const
Definition: SeedingHitSet.h:14
CLHEP::HepSymMatrix AlgebraicSymMatrix
DetId geographicalId() const