CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
111  buildSeed(seedCollection, hits, fts);
112 }
113 
115  const SeedingHitSet& hits) const {
116  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
117  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
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 
179  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
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 =
198  seedCollection.emplace_back(PTraj, std::move(seedHits), alongMomentum);
199 }
200 
202  const TrajectoryStateOnSurface& state) const {
203  return (SeedingHitSet::RecHitPointer)(cloner(*hit, state));
204 }
205 
208  return (filter ? filter->compatible(tsos, hit) : true);
209 }
float originRBound() const
bounds the particle vertex in the transverse plane
T mag2() const
Definition: PV3DBase.h:63
void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) final
tuple cfg
Definition: looper.py:296
GlobalPoint const & origin() const
const GlobalTrajectoryParameters & parameters() const
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
void buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts) const
constexpr float ptMin
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
virtual bool initialKinematic(GlobalTrajectoryParameters &kine, const SeedingHitSet &hits) const
virtual bool compatible(const SeedingHitSet &hits) const =0
SeedFromConsecutiveHitsCreator(const edm::ParameterSet &, edm::ConsumesCollector &&)
T perp2() const
Definition: PV3DBase.h:68
TrackCharge charge() const
CurvilinearTrajectoryError initialError(float sin2Theta) const
int sqr(const T &t)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
GlobalVector const & direction() const
the direction around which region is constructed
void push_back(D *&d)
Definition: OwnVector.h:326
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > transientTrackingRecHitBuilderESToken_
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
T mag() const
Definition: PV3DBase.h:64
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:177
std::vector< TrajectorySeed > TrajectorySeedCollection
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
tuple TTRHBuilder
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const TrackerGeomDet * idToDet(DetId) const override
GlobalVector momentum() const
float originZBound() const
bounds the particle vertex in the longitudinal plane
Vector3DBase unit() const
Definition: Vector3DBase.h:54
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorESToken_
void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) final
float ptMin() const
minimal pt of interest
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const AlgebraicSymMatrix55 & matrix() const
static int position[264][3]
Definition: ReadPGInfo.cc:289
unsigned int size() const
Definition: SeedingHitSet.h:41
const MagneticField & magneticField() const
DetId geographicalId() const
#define UNLIKELY(x)
Definition: Likely.h:21
static void fillDescriptions(edm::ParameterSetDescription &desc)
long double T
T x() const
Definition: PV3DBase.h:59
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const