CMS 3D CMS Logo

SeedFromConsecutiveHitsCreator.cc
Go to the documentation of this file.
3 
17 
18 namespace {
19 
20  template <class T>
21  inline
22  T sqr( T t) {return t*t;}
23 
24 }
25 
27 
29  desc.add<std::string>("propagator", "PropagatorWithMaterialParabolicMf");
30  desc.add<double>("SeedMomentumForBOFF", 5.0);
31  desc.add<double>("OriginTransverseErrorMultiplier", 1.0);
32  desc.add<double>("MinOneOverPtError", 1.0);
33  desc.add<std::string>("TTRHBuilder", "WithTrackAngle");
34  desc.add<std::string>("magneticField", "ParabolicMf");
35  desc.add<bool>("forceKinematicWithRegionDirection", false);
36 }
37 
39  const edm::EventSetup& es,
40  const SeedComparitor *ifilter) {
41  region = &iregion;
42  filter = ifilter;
43  // get tracker
45  // get propagator
47  // mag field
49  // edm::ESInputTag mfESInputTag(mfName_);
50  // es.get<IdealMagneticFieldRecord>().get(mfESInputTag, bfield);
52  isBOFF = (0==nomField);
53 
55  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
56  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
57  cloner = (*builder).cloner();
58 
59 }
60 
62  const SeedingHitSet & hits) {
63  if ( hits.size() < 2) return;
64 
66  if (!initialKinematic(kine, hits)) return;
67 
68  auto sin2Theta = kine.momentum().perp2()/kine.momentum().mag2();
69 
71  FreeTrajectoryState fts(kine, error);
72 
73  if(region->direction().x()!=0 && forceKinematicWithRegionDirection_) // a direction was given, check if it is an etaPhi region
74  {
75  const RectangularEtaPhiTrackingRegion * etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion *>(region);
76  if(etaPhiRegion) {
77  //the following completely reset the kinematics, perhaps it makes no sense and newKine=kine would do better
78  GlobalVector direction=region->direction()/region->direction().mag();
79  GlobalVector momentum=direction*fts.momentum().mag();
80  GlobalPoint position=region->origin()+5*direction;
81  GlobalTrajectoryParameters newKine(position,momentum,fts.charge(),&fts.parameters().magneticField());
82 
83  auto ptMin = region->ptMin();
84  CurvilinearTrajectoryError newError; //zeroed
85  auto & C = newError.matrix();
86  constexpr float minC00 = 0.4f;
87  C[0][0] = std::max(sin2Theta/sqr(ptMin), minC00);
88  auto zErr = sqr(region->originZBound());
89  auto transverseErr = sqr(region->originRBound()); // assume equal cxx cyy
90  auto twiceDeltaLambda = std::atan(etaPhiRegion->tanLambdaRange().first)-std::atan(etaPhiRegion->tanLambdaRange().second);
91  auto twiceDeltaPhi = etaPhiRegion->phiMargin().right()+etaPhiRegion->phiMargin().left();
92  C[1][1] = twiceDeltaLambda*twiceDeltaLambda; //2 sigma of what given in input
93  C[2][2] = twiceDeltaPhi*twiceDeltaPhi;
94  C[3][3] = transverseErr;
95  C[4][4] = zErr*sin2Theta + transverseErr*(1.f-sin2Theta);
96  fts = FreeTrajectoryState(newKine,newError);
97  }
98  }
99 
100 
101  buildSeed(seedCollection,hits,fts);
102 }
103 
104 
105 
107  const SeedingHitSet & hits) const{
108 
109  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
110  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
111 
112  const GlobalPoint& vertexPos = region->origin();
113 
114  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield);
115  if (helix.isValid()) {
116  kine = helix.stateAtVertex();
117  } else {
118  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
119  initMomentum *= (100.f/initMomentum.perp());
120  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
121  }
122 
123  if unlikely(isBOFF && (theBOFFMomentum > 0)) {
124  kine = GlobalTrajectoryParameters(kine.position(),
125  kine.momentum().unit() * theBOFFMomentum,
126  kine.charge(),
127  &*bfield);
128  }
129  return (filter ? filter->compatible(hits, kine, helix) : true);
130 }
131 
132 
133 
136 {
137  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
138  // information.
139  CurvilinearTrajectoryError newError; // zeroed
140  auto & C = newError.matrix();
141 
142 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
143 // to avoid instabilities.
144 // N.B. This parameter needs optimising ...
145  // Probably OK based on quick study: KS 22/11/12.
146  auto sin2th = sin2Theta;
147  auto minC00 = sqr(theMinOneOverPtError);
148  C[0][0] = std::max(sin2th/sqr(region->ptMin()), minC00);
149  auto zErr = sqr(region->originZBound());
151  C[1][1] = C[2][2] = 1.; // no good reason. no bad reason....
152  C[3][3] = transverseErr;
153  C[4][4] = zErr*sin2th + transverseErr*(1.f-sin2th);
154 
155  return newError;
156 }
157 
159  TrajectorySeedCollection & seedCollection,
160  const SeedingHitSet & hits,
161  const FreeTrajectoryState & fts) const
162 {
163  const Propagator* propagator = &(*propagatorHandle);
164 
165  // get updator
167 
168  // Now update initial state track using information from seed hits.
169 
172 
173  const TrackingRecHit* hit = nullptr;
174  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
175  hit = hits[iHit]->hit();
176  TrajectoryStateOnSurface state = (iHit==0) ?
177  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
178  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
179  if (!state.isValid()) return;
180 
181  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
182 
183  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
184 
185  if (!checkHit(state,&*newtth)) return;
186 
187  updatedState = updator.update(state, *newtth);
188  if (!updatedState.isValid()) return;
189 
190  seedHits.push_back(newtth.release());
191 
192  }
193 
194  if(!hit) return;
195 
196  PTrajectoryStateOnDet const & PTraj =
198  seedCollection.emplace_back(PTraj,std::move(seedHits),alongMomentum);
199 
200 }
201 
204  const TrajectoryStateOnSurface &state) const
205 {
206  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
207 }
208 
209 bool
211  const TrajectoryStateOnSurface &tsos,
213 {
214  return (filter ? filter->compatible(tsos,hit) : true);
215 }
216 
float originRBound() const
bounds the particle vertex in the transverse plane
T mag2() const
Definition: PV3DBase.h:66
void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) final
GlobalPoint const & origin() const
const GlobalTrajectoryParameters & parameters() const
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:56
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
T perp2() const
Definition: PV3DBase.h:71
TrackCharge charge() const
CurvilinearTrajectoryError initialError(float sin2Theta) const
#define constexpr
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:290
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:75
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
T mag() const
Definition: PV3DBase.h:67
std::vector< TrajectorySeed > TrajectorySeedCollection
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
virtual bool compatible(const SeedingHitSet &hits) const =0
ParameterDescriptionBase * add(U const &iLabel, T const &value)
GlobalVector momentum() const
float originZBound() const
bounds the particle vertex in the longitudinal plane
Vector3DBase unit() const
Definition: Vector3DBase.h:57
void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) final
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< TrackerGeometry > tracker
float ptMin() const
minimal pt of interest
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
const AlgebraicSymMatrix55 & matrix() const
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:46
const TrackerGeomDet * idToDet(DetId) const override
const MagneticField & magneticField() const
DetId geographicalId() const
static void fillDescriptions(edm::ParameterSetDescription &desc)
long double T
edm::ESHandle< MagneticField > bfield
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const