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  float sin2Theta = kine.momentum().perp2()/kine.momentum().mag2();
69 
71  FreeTrajectoryState fts(kine, error);
72  if(region->direction().x()!=0 && forceKinematicWithRegionDirection_) // a direction was given, check if it is an etaPhi region
73  {
74  const RectangularEtaPhiTrackingRegion * etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion *>(region);
75  if(etaPhiRegion) {
76 
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  GlobalError vertexErr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
84  0, 0, sqr(region->originZBound()));
85 
86  float ptMin = region->ptMin();
87  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
88 
89  float minC00 = 0.4;
90  C[0][0] = std::max(sin2Theta/sqr(ptMin), minC00);
91  float zErr = vertexErr.czz();
92  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
93  float deltaEta = (etaPhiRegion->etaRange().first-etaPhiRegion->etaRange().second)/2.;
94  float deltaPhi = (etaPhiRegion->phiMargin().right()+etaPhiRegion->phiMargin().left())/2.;
95  C[1][1] = deltaEta*deltaEta*4; //2 sigma of what given in input
96  C[2][2] = deltaPhi*deltaPhi*4;
97  C[3][3] = transverseErr;
98  C[4][4] = zErr*sin2Theta + transverseErr*(1-sin2Theta);
99  CurvilinearTrajectoryError newError(C);
100  fts = FreeTrajectoryState(newKine,newError);
101  }
102  }
103 
104 
105  buildSeed(seedCollection,hits,fts);
106 }
107 
108 
109 
111  const SeedingHitSet & hits) const{
112 
113  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
114  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
115 
116  const GlobalPoint& vertexPos = region->origin();
117 
118  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield);
119  if (helix.isValid()) {
120  kine = helix.stateAtVertex();
121  } else {
122  GlobalVector initMomentum(tth2->globalPosition() - vertexPos);
123  initMomentum *= (100./initMomentum.perp());
124  kine = GlobalTrajectoryParameters(vertexPos, initMomentum, 1, &*bfield);
125  }
126 
127  if unlikely(isBOFF && (theBOFFMomentum > 0)) {
128  kine = GlobalTrajectoryParameters(kine.position(),
129  kine.momentum().unit() * theBOFFMomentum,
130  kine.charge(),
131  &*bfield);
132  }
133  return (filter ? filter->compatible(hits, kine, helix) : true);
134 }
135 
136 
137 
140 {
141  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
142  // information.
143  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
144 
145 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
146 // to avoid instabilities.
147 // N.B. This parameter needs optimising ...
148  // Probably OK based on quick study: KS 22/11/12.
149  float sin2th = sin2Theta;
150  float minC00 = sqr(theMinOneOverPtError);
151  C[0][0] = std::max(sin2th/sqr(region->ptMin()), minC00);
152  float zErr = sqr(region->originZBound());
153  float transverseErr = sqr(theOriginTransverseErrorMultiplier*region->originRBound());
154  C[3][3] = transverseErr;
155  C[4][4] = zErr*sin2th + transverseErr*(1.f-sin2th);
156 
157  return CurvilinearTrajectoryError(C);
158 }
159 
161  TrajectorySeedCollection & seedCollection,
162  const SeedingHitSet & hits,
163  const FreeTrajectoryState & fts) const
164 {
165  const Propagator* propagator = &(*propagatorHandle);
166 
167  // get updator
169 
170  // Now update initial state track using information from seed hits.
171 
174 
175  const TrackingRecHit* hit = 0;
176  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
177  hit = hits[iHit]->hit();
178  TrajectoryStateOnSurface state = (iHit==0) ?
179  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
180  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
181  if (!state.isValid()) return;
182 
183  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
184 
185  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
186 
187  if (!checkHit(state,&*newtth)) return;
188 
189  updatedState = updator.update(state, *newtth);
190  if (!updatedState.isValid()) return;
191 
192  seedHits.push_back(newtth.release());
193 
194  }
195 
196  if(!hit) return;
197 
198  PTrajectoryStateOnDet const & PTraj =
200  seedCollection.emplace_back(PTraj,std::move(seedHits),alongMomentum);
201 
202 }
203 
206  const TrajectoryStateOnSurface &state) const
207 {
208  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
209 }
210 
211 bool
213  const TrajectoryStateOnSurface &tsos,
215 {
216  return (filter ? filter->compatible(tsos,hit) : true);
217 }
218 
float originRBound() const
bounds the particle vertex in the transverse plane
T mag2() const
Definition: PV3DBase.h:66
virtual 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
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
static const double deltaEta
Definition: CaloConstants.h:8
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
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 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
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) final
const T & get() const
Definition: EventSetup.h:56
edm::ESHandle< TrackerGeometry > tracker
float ptMin() const
minimal pt of interest
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
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 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
const TrackerGeomDet * idToDet(DetId) const
bool checkHit(const TrajectoryStateOnSurface &tsos, SeedingHitSet::ConstRecHitPointer hit) const
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval