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 
15 
16 namespace {
17 
18  template <class T>
19  inline
20  T sqr( T t) {return t*t;}
21 
22 }
23 
25 
27  const edm::EventSetup& es,
28  const SeedComparitor *ifilter) {
29  region = &iregion;
30  filter = ifilter;
31  // get tracker
33  // get propagator
35  // mag field
37  // edm::ESInputTag mfESInputTag(mfName_);
38  // es.get<IdealMagneticFieldRecord>().get(mfESInputTag, bfield);
39  nomField = bfield->nominalValue();
40  isBOFF = (0==nomField);
41 
43  try { // one sure we need to propagate the ocnfig to HLT
44  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
45  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
46  cloner = (*builder).cloner();
47  } catch(...) {
48  es.get<TransientRecHitRecord>().get("hltESPTTRHBWithTrackAngle", builderH);
49  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
50  cloner = (*builder).cloner();
51  }
52 
53 }
54 
56  const SeedingHitSet & hits) {
57  if ( hits.size() < 2) return;
58 
60  if (!initialKinematic(kine, hits)) return;
61 
62  float sin2Theta = kine.momentum().perp2()/kine.momentum().mag2();
63 
65  FreeTrajectoryState fts(kine, error);
66 
67  buildSeed(seedCollection,hits,fts);
68 }
69 
70 
71 
73  const SeedingHitSet & hits) const{
74 
75  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
76  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
77 
78  const GlobalPoint& vertexPos = region->origin();
79 
80  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield);
81  if (helix.isValid()) {
82  kine = helix.stateAtVertex();
83  } else {
84  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
85  initMomentum *= (100./initMomentum.perp());
86  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
87  }
88 
89  if unlikely(isBOFF && (theBOFFMomentum > 0)) {
91  kine.momentum().unit() * theBOFFMomentum,
92  kine.charge(),
93  &*bfield);
94  }
95  return (filter ? filter->compatible(hits, kine, helix, *region) : true);
96 }
97 
98 
99 
102 {
103  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
104  // information.
105  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
106 
107 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
108 // to avoid instabilities.
109 // N.B. This parameter needs optimising ...
110  // Probably OK based on quick study: KS 22/11/12.
111  float sin2th = sin2Theta;
112  float minC00 = sqr(theMinOneOverPtError);
113  C[0][0] = std::max(sin2th/sqr(region->ptMin()), minC00);
114  float zErr = sqr(region->originZBound());
115  float transverseErr = sqr(theOriginTransverseErrorMultiplier*region->originRBound());
116  C[3][3] = transverseErr;
117  C[4][4] = zErr*sin2th + transverseErr*(1.f-sin2th);
118 
119  return CurvilinearTrajectoryError(C);
120 }
121 
123  TrajectorySeedCollection & seedCollection,
124  const SeedingHitSet & hits,
125  const FreeTrajectoryState & fts) const
126 {
127  const Propagator* propagator = &(*propagatorHandle);
128 
129  // get updator
130  KFUpdator updator;
131 
132  // Now update initial state track using information from seed hits.
133 
134  TrajectoryStateOnSurface updatedState;
136 
137  const TrackingRecHit* hit = 0;
138  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
139  hit = hits[iHit]->hit();
140  TrajectoryStateOnSurface state = (iHit==0) ?
141  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
142  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
143  if (!state.isValid()) return;
144 
145  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
146 
147  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
148 
149  if (!checkHit(state,&*newtth)) return;
150 
151  updatedState = updator.update(state, *newtth);
152  if (!updatedState.isValid()) return;
153 
154  seedHits.push_back(newtth.release());
155 
156  }
157 
158 
159  PTrajectoryStateOnDet const & PTraj =
161  TrajectorySeed seed(PTraj,std::move(seedHits),alongMomentum);
162  if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed));
163 
164 }
165 
168  const TrajectoryStateOnSurface &state) const
169 {
170  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
171 }
172 
173 bool
175  const TrajectoryStateOnSurface &tsos,
177 {
178  return (filter ? filter->compatible(tsos,hit) : true);
179 }
180 
float originRBound() const
bounds the particle vertex in the transverse plane
T mag2() const
Definition: PV3DBase.h:66
GlobalPoint const & origin() const
edm::ESHandle< Propagator > propagatorHandle
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
virtual bool initialKinematic(GlobalTrajectoryParameters &kine, const SeedingHitSet &hits) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
T perp2() const
Definition: PV3DBase.h:71
virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion &region) const =0
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts) const dso_hidden
#define unlikely(x)
Definition: Likely.h:21
void push_back(D *&d)
Definition: OwnVector.h:274
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const dso_hidden
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const dso_hidden
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) GCC11_FINAL
float originZBound() const
bounds the particle vertex in the longitudinal plane
Vector3DBase unit() const
Definition: Vector3DBase.h:57
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
edm::ESHandle< TrackerGeometry > tracker
float ptMin() const
minimal pt of interest
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:56
Square< F >::type sqr(const F &f)
Definition: Square.h:13
virtual void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) GCC11_FINAL
CurvilinearTrajectoryError initialError(float sin2Theta) const dso_hidden
unsigned int size() const
Definition: SeedingHitSet.h:44
DetId geographicalId() const
long double T
edm::ESHandle< MagneticField > bfield