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 
16 
17 namespace {
18 
19  template <class T>
20  inline
21  T sqr( T t) {return t*t;}
22 
23 }
24 
26 
28  const edm::EventSetup& es,
29  const SeedComparitor *ifilter) {
30  region = &iregion;
31  filter = ifilter;
32  // get tracker
34  // get propagator
36  // mag field
38  // edm::ESInputTag mfESInputTag(mfName_);
39  // es.get<IdealMagneticFieldRecord>().get(mfESInputTag, bfield);
40  nomField = bfield->nominalValue();
41  isBOFF = (0==nomField);
42 
44  try { // one sure we need to propagate the ocnfig to HLT
45  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
46  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
47  cloner = (*builder).cloner();
48  } catch(...) {
49  es.get<TransientRecHitRecord>().get("hltESPTTRHBWithTrackAngle", builderH);
50  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
51  cloner = (*builder).cloner();
52  }
53 
54 }
55 
57  const SeedingHitSet & hits) {
58  if ( hits.size() < 2) return;
59 
61  if (!initialKinematic(kine, hits)) return;
62 
63  float sin2Theta = kine.momentum().perp2()/kine.momentum().mag2();
64 
66  FreeTrajectoryState fts(kine, error);
67  if(region->direction().x()!=0 && forceKinematicWithRegionDirection_) // a direction was given, check if it is an etaPhi region
68  {
69  const RectangularEtaPhiTrackingRegion * etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion *>(region);
70  if(etaPhiRegion) {
71 
72  //the following completely reset the kinematics, perhaps it makes no sense and newKine=kine would do better
73  GlobalVector direction=region->direction()/region->direction().mag();
74  GlobalVector momentum=direction*fts.momentum().mag();
75  GlobalPoint position=region->origin()+5*direction;
76  GlobalTrajectoryParameters newKine(position,momentum,fts.charge(),&fts.parameters().magneticField());
77 
78  GlobalError vertexErr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
79  0, 0, sqr(region->originZBound()));
80 
81  float ptMin = region->ptMin();
82  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
83 
84  float minC00 = 0.4;
85  C[0][0] = std::max(sin2Theta/sqr(ptMin), minC00);
86  float zErr = vertexErr.czz();
87  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
88  float deltaEta = (etaPhiRegion->etaRange().first-etaPhiRegion->etaRange().second)/2.;
89  float deltaPhi = (etaPhiRegion->phiMargin().right()+etaPhiRegion->phiMargin().left())/2.;
90  C[1][1] = deltaEta*deltaEta*4; //2 sigma of what given in input
91  C[2][2] = deltaPhi*deltaPhi*4;
92  C[3][3] = transverseErr;
93  C[4][4] = zErr*sin2Theta + transverseErr*(1-sin2Theta);
94  CurvilinearTrajectoryError newError(C);
95  fts = FreeTrajectoryState(newKine,newError);
96  }
97  }
98 
99 
100  buildSeed(seedCollection,hits,fts);
101 }
102 
103 
104 
106  const SeedingHitSet & hits) const{
107 
108  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
109  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
110 
111  const GlobalPoint& vertexPos = region->origin();
112 
113  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield);
114  if (helix.isValid()) {
115  kine = helix.stateAtVertex();
116  } else {
117  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
118  initMomentum *= (100./initMomentum.perp());
119  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
120  }
121 
122  if unlikely(isBOFF && (theBOFFMomentum > 0)) {
123  kine = GlobalTrajectoryParameters(kine.position(),
124  kine.momentum().unit() * theBOFFMomentum,
125  kine.charge(),
126  &*bfield);
127  }
128  return (filter ? filter->compatible(hits, kine, helix, *region) : true);
129 }
130 
131 
132 
135 {
136  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
137  // information.
138  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
139 
140 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
141 // to avoid instabilities.
142 // N.B. This parameter needs optimising ...
143  // Probably OK based on quick study: KS 22/11/12.
144  float sin2th = sin2Theta;
145  float minC00 = sqr(theMinOneOverPtError);
146  C[0][0] = std::max(sin2th/sqr(region->ptMin()), minC00);
147  float zErr = sqr(region->originZBound());
148  float transverseErr = sqr(theOriginTransverseErrorMultiplier*region->originRBound());
149  C[3][3] = transverseErr;
150  C[4][4] = zErr*sin2th + transverseErr*(1.f-sin2th);
151 
152  return CurvilinearTrajectoryError(C);
153 }
154 
156  TrajectorySeedCollection & seedCollection,
157  const SeedingHitSet & hits,
158  const FreeTrajectoryState & fts) const
159 {
160  const Propagator* propagator = &(*propagatorHandle);
161 
162  // get updator
163  KFUpdator updator;
164 
165  // Now update initial state track using information from seed hits.
166 
167  TrajectoryStateOnSurface updatedState;
169 
170  const TrackingRecHit* hit = 0;
171  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
172  hit = hits[iHit]->hit();
173  TrajectoryStateOnSurface state = (iHit==0) ?
174  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
175  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
176  if (!state.isValid()) return;
177 
178  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
179 
180  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
181 
182  if (!checkHit(state,&*newtth)) return;
183 
184  updatedState = updator.update(state, *newtth);
185  if (!updatedState.isValid()) return;
186 
187  seedHits.push_back(newtth.release());
188 
189  }
190 
191 
192  PTrajectoryStateOnDet const & PTraj =
194  TrajectorySeed seed(PTraj,std::move(seedHits),alongMomentum);
195  if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed));
196 
197 }
198 
201  const TrajectoryStateOnSurface &state) const
202 {
203  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
204 }
205 
206 bool
208  const TrajectoryStateOnSurface &tsos,
210 {
211  return (filter ? filter->compatible(tsos,hit) : true);
212 }
213 
float originRBound() const
bounds the particle vertex in the transverse plane
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
T mag2() const
Definition: PV3DBase.h:66
GlobalPoint const & origin() const
const GlobalTrajectoryParameters & parameters() const
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter)
edm::ESHandle< Propagator > propagatorHandle
void buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts) const
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
TrackCharge charge() const
CurvilinearTrajectoryError initialError(float sin2Theta) const
virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion &region) const =0
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
#define unlikely(x)
GlobalVector const & direction() const
the direction around which region is constructed
void push_back(D *&d)
Definition: OwnVector.h:280
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
T mag() const
Definition: PV3DBase.h:67
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
std::vector< TrajectorySeed > TrajectorySeedCollection
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
virtual void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits)
GlobalVector momentum() const
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:86
edm::ESHandle< TrackerGeometry > tracker
float ptMin() const
minimal pt of interest
Square< F >::type sqr(const F &f)
Definition: Square.h:13
static int position[264][3]
Definition: ReadPGInfo.cc:509
unsigned int size() const
Definition: SeedingHitSet.h:44
const MagneticField & magneticField() const
DetId geographicalId() const
long double T
T x() const
Definition: PV3DBase.h:62
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval