CMS 3D CMS Logo

SeedFromConsecutiveHitsCreator.cc
Go to the documentation of this file.
3 
16 
17 namespace {
18 
19  template <class T>
20  inline T sqr(T t) {
21  return t * t;
22  }
23 
24 } // namespace
25 
28  : thePropagatorLabel(cfg.getParameter<std::string>("propagator")),
29  theBOFFMomentum(cfg.getParameter<double>("SeedMomentumForBOFF")),
30  theOriginTransverseErrorMultiplier(cfg.getParameter<double>("OriginTransverseErrorMultiplier")),
31  theMinOneOverPtError(cfg.getParameter<double>("MinOneOverPtError")),
32  TTRHBuilder(cfg.getParameter<std::string>("TTRHBuilder")),
33  mfName_(cfg.getParameter<std::string>("magneticField")),
34  forceKinematicWithRegionDirection_(cfg.getParameter<bool>("forceKinematicWithRegionDirection")),
35  trackerGeometryESToken_(iC.esConsumes()),
36  propagatorESToken_(iC.esConsumes(edm::ESInputTag("", thePropagatorLabel))),
37  magneticFieldESToken_(iC.esConsumes(edm::ESInputTag("", mfName_))),
38  transientTrackingRecHitBuilderESToken_(iC.esConsumes(edm::ESInputTag("", TTRHBuilder))) {}
39 
41 
43  desc.add<std::string>("propagator", "PropagatorWithMaterialParabolicMf");
44  desc.add<double>("SeedMomentumForBOFF", 5.0);
45  desc.add<double>("OriginTransverseErrorMultiplier", 1.0);
46  desc.add<double>("MinOneOverPtError", 1.0);
47  desc.add<std::string>("TTRHBuilder", "WithTrackAngle");
48  desc.add<std::string>("magneticField", "ParabolicMf");
49  desc.add<bool>("forceKinematicWithRegionDirection", false);
50 }
51 
53  const edm::EventSetup& es,
54  const SeedComparitor* ifilter) {
55  region = &iregion;
56  filter = ifilter;
61  isBOFF = (0 == nomField);
62 
63  TransientTrackingRecHitBuilder const* transientTrackingRecHitBuilder =
65  auto builder = (TkTransientTrackingRecHitBuilder const*)(transientTrackingRecHitBuilder);
66  cloner = (*builder).cloner();
67 }
68 
70  if (hits.size() < 2)
71  return;
72 
74  if (!initialKinematic(kine, hits))
75  return;
76 
77  auto sin2Theta = kine.momentum().perp2() / kine.momentum().mag2();
78 
80  FreeTrajectoryState fts(kine, error);
81 
82  if (region->direction().x() != 0 &&
83  forceKinematicWithRegionDirection_) // a direction was given, check if it is an etaPhi region
84  {
85  const RectangularEtaPhiTrackingRegion* etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion*>(region);
86  if (etaPhiRegion) {
87  //the following completely reset the kinematics, perhaps it makes no sense and newKine=kine would do better
88  GlobalVector direction = region->direction() / region->direction().mag();
89  GlobalVector momentum = direction * fts.momentum().mag();
90  GlobalPoint position = region->origin() + 5 * direction;
91  GlobalTrajectoryParameters newKine(position, momentum, fts.charge(), &fts.parameters().magneticField());
92 
93  auto ptMin = region->ptMin();
94  CurvilinearTrajectoryError newError; //zeroed
95  auto& C = newError.matrix();
96  constexpr float minC00 = 0.4f;
97  C[0][0] = std::max(sin2Theta / sqr(ptMin), minC00);
98  auto zErr = sqr(region->originZBound());
99  auto transverseErr = sqr(region->originRBound()); // assume equal cxx cyy
100  auto twiceDeltaLambda =
101  std::atan(etaPhiRegion->tanLambdaRange().first) - std::atan(etaPhiRegion->tanLambdaRange().second);
102  auto twiceDeltaPhi = etaPhiRegion->phiMargin().right() + etaPhiRegion->phiMargin().left();
103  C[1][1] = twiceDeltaLambda * twiceDeltaLambda; //2 sigma of what given in input
104  C[2][2] = twiceDeltaPhi * twiceDeltaPhi;
105  C[3][3] = transverseErr;
106  C[4][4] = zErr * sin2Theta + transverseErr * (1.f - sin2Theta);
107  fts = FreeTrajectoryState(newKine, newError);
108  }
109  }
110 
112 }
113 
115  const SeedingHitSet& hits) const {
118 
119  const GlobalPoint& vertexPos = region->origin();
120 
121  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField, magneticField_);
122  if (helix.isValid()) {
123  kine = helix.stateAtVertex();
124  } else {
125  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
126  initMomentum *= (100.f / initMomentum.perp());
127  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, magneticField_);
128  }
129 
130  if UNLIKELY (isBOFF && (theBOFFMomentum > 0)) {
132  kine.position(), kine.momentum().unit() * theBOFFMomentum, kine.charge(), magneticField_);
133  }
134  return (filter ? filter->compatible(hits, kine, helix) : true);
135 }
136 
138  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
139  // information.
140  CurvilinearTrajectoryError newError; // zeroed
141  auto& C = newError.matrix();
142 
143  // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
144  // to avoid instabilities.
145  // N.B. This parameter needs optimising ...
146  // Probably OK based on quick study: KS 22/11/12.
147  auto sin2th = sin2Theta;
148  auto minC00 = sqr(theMinOneOverPtError);
149  C[0][0] = std::max(sin2th / sqr(region->ptMin()), minC00);
150  auto zErr = sqr(region->originZBound());
151  auto transverseErr = sqr(theOriginTransverseErrorMultiplier * region->originRBound());
152  C[1][1] = C[2][2] = 1.; // no good reason. no bad reason....
153  C[3][3] = transverseErr;
154  C[4][4] = zErr * sin2th + transverseErr * (1.f - sin2th);
155 
156  return newError;
157 }
158 
160  const SeedingHitSet& hits,
161  const FreeTrajectoryState& fts) const {
162  // get updator
164 
165  // Now update initial state track using information from seed hits.
166 
167  TrajectoryStateOnSurface updatedState;
169 
170  const TrackingRecHit* hit = nullptr;
171  for (unsigned int iHit = 0; iHit < hits.size(); iHit++) {
172  hit = hits[iHit]->hit();
174  (iHit == 0) ? propagator_->propagate(fts, trackerGeometry_->idToDet(hit->geographicalId())->surface())
175  : propagator_->propagate(updatedState, trackerGeometry_->idToDet(hit->geographicalId())->surface());
176  if (!state.isValid())
177  return;
178 
180 
181  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit(tth, state));
182 
183  if (!checkHit(state, &*newtth))
184  return;
185 
186  updatedState = updator.update(state, *newtth);
187  if (!updatedState.isValid())
188  return;
189 
190  seedHits.push_back(newtth.release());
191  }
192 
193  if (!hit)
194  return;
195 
196  PTrajectoryStateOnDet const& PTraj =
197  trajectoryStateTransform::persistentState(updatedState, hit->geographicalId().rawId());
198  seedCollection.emplace_back(PTraj, std::move(seedHits), alongMomentum);
199 }
200 
202  const TrajectoryStateOnSurface& state) const {
204 }
205 
208  return (filter ? filter->compatible(tsos, hit) : true);
209 }
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) final
GlobalPoint const & origin() const
constexpr float ptMin
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
void buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts) const
virtual bool compatible(const SeedingHitSet &hits) const =0
SeedFromConsecutiveHitsCreator(const edm::ParameterSet &, edm::ConsumesCollector &&)
int sqr(const T &t)
T mag2() const
Definition: PV3DBase.h:63
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const GlobalTrajectoryParameters & parameters() const
T x() const
Definition: PV3DBase.h:59
void push_back(D *&d)
Definition: OwnVector.h:326
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > transientTrackingRecHitBuilderESToken_
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:14
std::vector< TrajectorySeed > TrajectorySeedCollection
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
float ptMin() const
minimal pt of interest
TrackCharge charge() const
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const TrackerGeomDet * idToDet(DetId) const override
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorESToken_
float originRBound() const
bounds the particle vertex in the transverse plane
void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) final
virtual bool initialKinematic(GlobalTrajectoryParameters &kine, const SeedingHitSet &hits) const
CurvilinearTrajectoryError initialError(float sin2Theta) const
const AlgebraicSymMatrix55 & matrix() const
const MagneticField & magneticField() const
GlobalVector const & direction() const
the direction around which region is constructed
T perp2() const
Definition: PV3DBase.h:68
HLT enums.
float originZBound() const
bounds the particle vertex in the longitudinal plane
static int position[264][3]
Definition: ReadPGInfo.cc:289
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
Vector3DBase unit() const
Definition: Vector3DBase.h:54
#define UNLIKELY(x)
Definition: Likely.h:21
static void fillDescriptions(edm::ParameterSetDescription &desc)
long double T
def move(src, dest)
Definition: eostools.py:511
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_