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  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
45  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
46  cloner = (*builder).cloner();
47 
48 }
49 
51  const SeedingHitSet & hits) {
52  if ( hits.size() < 2) return;
53 
55  if (!initialKinematic(kine, hits)) return;
56 
57  float sin2Theta = kine.momentum().perp2()/kine.momentum().mag2();
58 
60  FreeTrajectoryState fts(kine, error);
61  if(region->direction().x()!=0 && forceKinematicWithRegionDirection_) // a direction was given, check if it is an etaPhi region
62  {
63  const RectangularEtaPhiTrackingRegion * etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion *>(region);
64  if(etaPhiRegion) {
65 
66  //the following completely reset the kinematics, perhaps it makes no sense and newKine=kine would do better
67  GlobalVector direction=region->direction()/region->direction().mag();
68  GlobalVector momentum=direction*fts.momentum().mag();
69  GlobalPoint position=region->origin()+5*direction;
70  GlobalTrajectoryParameters newKine(position,momentum,fts.charge(),&fts.parameters().magneticField());
71 
72  GlobalError vertexErr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
73  0, 0, sqr(region->originZBound()));
74 
75  float ptMin = region->ptMin();
76  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
77 
78  float minC00 = 0.4;
79  C[0][0] = std::max(sin2Theta/sqr(ptMin), minC00);
80  float zErr = vertexErr.czz();
81  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
82  float deltaEta = (etaPhiRegion->etaRange().first-etaPhiRegion->etaRange().second)/2.;
83  float deltaPhi = (etaPhiRegion->phiMargin().right()+etaPhiRegion->phiMargin().left())/2.;
84  C[1][1] = deltaEta*deltaEta*4; //2 sigma of what given in input
85  C[2][2] = deltaPhi*deltaPhi*4;
86  C[3][3] = transverseErr;
87  C[4][4] = zErr*sin2Theta + transverseErr*(1-sin2Theta);
88  CurvilinearTrajectoryError newError(C);
89  fts = FreeTrajectoryState(newKine,newError);
90  }
91  }
92 
93 
94  buildSeed(seedCollection,hits,fts);
95 }
96 
97 
98 
100  const SeedingHitSet & hits) const{
101 
102  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
103  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
104 
105  const GlobalPoint& vertexPos = region->origin();
106 
107  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield);
108  if (helix.isValid()) {
109  kine = helix.stateAtVertex();
110  } else {
111  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
112  initMomentum *= (100./initMomentum.perp());
113  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
114  }
115 
116  if unlikely(isBOFF && (theBOFFMomentum > 0)) {
117  kine = GlobalTrajectoryParameters(kine.position(),
118  kine.momentum().unit() * theBOFFMomentum,
119  kine.charge(),
120  &*bfield);
121  }
122  return (filter ? filter->compatible(hits, kine, helix, *region) : true);
123 }
124 
125 
126 
129 {
130  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
131  // information.
132  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
133 
134 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
135 // to avoid instabilities.
136 // N.B. This parameter needs optimising ...
137  // Probably OK based on quick study: KS 22/11/12.
138  float sin2th = sin2Theta;
139  float minC00 = sqr(theMinOneOverPtError);
140  C[0][0] = std::max(sin2th/sqr(region->ptMin()), minC00);
141  float zErr = sqr(region->originZBound());
142  float transverseErr = sqr(theOriginTransverseErrorMultiplier*region->originRBound());
143  C[3][3] = transverseErr;
144  C[4][4] = zErr*sin2th + transverseErr*(1.f-sin2th);
145 
146  return CurvilinearTrajectoryError(C);
147 }
148 
150  TrajectorySeedCollection & seedCollection,
151  const SeedingHitSet & hits,
152  const FreeTrajectoryState & fts) const
153 {
154  const Propagator* propagator = &(*propagatorHandle);
155 
156  // get updator
158 
159  // Now update initial state track using information from seed hits.
160 
161  TrajectoryStateOnSurface updatedState;
163 
164  const TrackingRecHit* hit = 0;
165  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
166  hit = hits[iHit]->hit();
167  TrajectoryStateOnSurface state = (iHit==0) ?
168  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
169  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
170  if (!state.isValid()) return;
171 
172  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
173 
174  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
175 
176  if (!checkHit(state,&*newtth)) return;
177 
178  updatedState = updator.update(state, *newtth);
179  if (!updatedState.isValid()) return;
180 
181  seedHits.push_back(newtth.release());
182 
183  }
184 
185  if(!hit) return;
186 
187  PTrajectoryStateOnDet const & PTraj =
189  TrajectorySeed seed(PTraj,std::move(seedHits),alongMomentum);
190  if ( !filter || filter->compatible(seed)) seedCollection.push_back(std::move(seed));
191 
192 }
193 
196  const TrajectoryStateOnSurface &state) const
197 {
198  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
199 }
200 
201 bool
203  const TrajectoryStateOnSurface &tsos,
205 {
206  return (filter ? filter->compatible(tsos,hit) : true);
207 }
208 
float originRBound() const
bounds the particle vertex in the transverse plane
tuple t
Definition: tree.py:139
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:56
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
edm::ESHandle< MagneticField > bfield
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