CMS 3D CMS Logo

SeedForPhotonConversion1Leg.cc
Go to the documentation of this file.
2 
18 
19 //#define mydebug_seed
20 namespace {
21  template <class T>
22  T sqr(T t) {
23  return t * t;
24  }
25 } // namespace
26 
28  const SeedingHitSet& hits,
29  const GlobalPoint& vertex,
30  const GlobalVector& vertexBounds,
31  float ptmin,
32  const edm::EventSetup& es,
33  float cotTheta,
34  std::stringstream& ss) {
35  pss = &ss;
36  if (hits.size() < 2)
37  return nullptr;
38 
39  GlobalTrajectoryParameters kine = initialKinematic(hits, vertex, es, cotTheta);
40  float sinTheta = sin(kine.momentum().theta());
41 
42  CurvilinearTrajectoryError error = initialError(vertexBounds, ptmin, sinTheta);
43  FreeTrajectoryState fts(kine, error);
44 
45  return buildSeed(seedCollection, hits, fts, es);
46 }
47 
49  const GlobalPoint& vertexPos,
50  const edm::EventSetup& es,
51  const float cotTheta) const {
53 
54  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
55  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
56 
57  // FIXME optimize: move outside loop
59  es.get<IdealMagneticFieldRecord>().get(bfield);
60  float nomField = bfield->nominalValue();
61 
62  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField, &*bfield, vertexPos);
63  kine = helix.stateAtVertex();
64 
65  //force the pz/pt equal to the measured one
66  if (fabs(cotTheta) < cotTheta_Max)
68  kine.position(),
69  GlobalVector(kine.momentum().x(), kine.momentum().y(), kine.momentum().perp() * cotTheta),
70  kine.charge(),
71  &kine.magneticField());
72  else
74  kine.position(),
75  GlobalVector(kine.momentum().x(), kine.momentum().y(), kine.momentum().perp() * cotTheta_Max),
76  kine.charge(),
77  &kine.magneticField());
78 
79 #ifdef mydebug_seed
80  uint32_t detid;
81  (*pss) << "[SeedForPhotonConversion1Leg] initialKinematic tth1 ";
82  detid = tth1->geographicalId().rawId();
83  po.print(*pss, detid);
84  (*pss) << " \t " << detid << " " << tth1->localPosition() << " " << tth1->globalPosition();
85  detid = tth2->geographicalId().rawId();
86  (*pss) << " \n\t tth2 ";
87  po.print(*pss, detid);
88  (*pss) << " \t " << detid << " " << tth2->localPosition() << " " << tth2->globalPosition() << "\nhelix momentum "
89  << kine.momentum() << " pt " << kine.momentum().perp() << " radius " << 1 / kine.transverseCurvature();
90 #endif
91 
92  bool isBOFF = (0 == nomField);
93  ;
94  if (isBOFF && (theBOFFMomentum > 0)) {
95  kine =
96  GlobalTrajectoryParameters(kine.position(), kine.momentum().unit() * theBOFFMomentum, kine.charge(), &*bfield);
97  }
98  return kine;
99 }
100 
102  float ptMin,
103  float sinTheta) const {
104  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
105  // information.
106  GlobalError vertexErr(sqr(vertexBounds.x()), 0, sqr(vertexBounds.y()), 0, 0, sqr(vertexBounds.z()));
107 
108  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
109 
110  // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
111  // to avoid instabilities.
112  // N.B. This parameter needs optimising ...
113  float sin2th = sqr(sinTheta);
114  float minC00 = 1.0;
115  C[0][0] = std::max(sin2th / sqr(ptMin), minC00);
116  float zErr = vertexErr.czz();
117  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
118  C[3][3] = transverseErr;
119  C[4][4] = zErr * sin2th + transverseErr * (1 - sin2th);
120 
121  return CurvilinearTrajectoryError(C);
122 }
123 
125  const SeedingHitSet& hits,
126  const FreeTrajectoryState& fts,
127  const edm::EventSetup& es) const {
128  // FIXME all this stuff shoould go in an initialized...
129 
130  // get tracker
132  es.get<TrackerDigiGeometryRecord>().get(tracker);
133 
134  // get propagator
135  edm::ESHandle<Propagator> propagatorHandle;
136  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagatorHandle);
137  const Propagator* propagator = &(*propagatorHandle);
138 
140  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
141  auto builder = (TkTransientTrackingRecHitBuilder const*)(builderH.product());
142  auto cloner = (*builder).cloner();
143 
144  // get updator
146 
147  // Now update initial state track using information from seed hits.
148 
151 
152  const TrackingRecHit* hit = nullptr;
153  for (unsigned int iHit = 0; iHit < hits.size() && iHit < 1; iHit++) {
154  hit = hits[iHit];
156  (iHit == 0) ? propagator->propagate(fts, tracker->idToDet(hit->geographicalId())->surface())
157  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
158  if (!state.isValid())
159  return nullptr;
160 
161  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
162 
163  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit(tth, state, cloner));
164 
165  if (!checkHit(state, &*newtth, es))
166  return nullptr;
167 
168  updatedState = updator.update(state, *newtth);
169  if (!updatedState.isValid())
170  return nullptr;
171 
172  seedHits.push_back(newtth.release());
173 #ifdef mydebug_seed
174  uint32_t detid = hit->geographicalId().rawId();
175  (*pss) << "\n[SeedForPhotonConversion1Leg] hit " << iHit;
176  po.print(*pss, detid);
177  (*pss) << " " << detid << "\t lp " << hit->localPosition() << " tth " << tth->localPosition() << " newtth "
178  << newtth->localPosition() << " state " << state.globalMomentum().perp();
179 #endif
180  }
181 
182  if (!hit)
183  return nullptr;
184 
185  PTrajectoryStateOnDet const& PTraj =
187 
188  seedCollection.push_back(TrajectorySeed(PTraj, seedHits, alongMomentum));
189  return &seedCollection.back();
190 }
191 
193  const TrajectoryStateOnSurface& state,
194  const TkClonerImpl& cloner) const {
195  //const TransientTrackingRecHit* a= hit.get();
196  //return const_cast<TransientTrackingRecHit*> (a);
197  //This was modified otherwise the rechit will have just the local x component and local y=0
198  // To understand how to modify for pixels
199 
200  //const TSiStripRecHit2DLocalPos* b = dynamic_cast<const TSiStripRecHit2DLocalPos*>(a);
201  //return const_cast<TSiStripRecHit2DLocalPos*>(b);
202  return (SeedingHitSet::RecHitPointer)(cloner(*hit, state));
203 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
T perp() const
Definition: PV3DBase.h:69
const TrajectorySeed * buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es) const
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
GlobalTrajectoryParameters initialKinematic(const SeedingHitSet &hits, const GlobalPoint &vertexPos, const edm::EventSetup &es, const float cotTheta) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state, const TkClonerImpl &cloner) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
T y() const
Definition: PV3DBase.h:60
const TrajectorySeed * trajectorySeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const GlobalPoint &vertex, const GlobalVector &vertexBounds, float ptmin, const edm::EventSetup &es, float cotTheta, std::stringstream &ss)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
void push_back(D *&d)
Definition: OwnVector.h:326
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:177
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:10
std::vector< TrajectorySeed > TrajectorySeedCollection
T z() const
Definition: PV3DBase.h:61
void print(std::stringstream &ss, const SiStripCluster &clus)
virtual LocalPoint localPosition() const =0
Vector3DBase unit() const
Definition: Vector3DBase.h:54
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
double ptmin
Definition: HydjetWrapper.h:84
GlobalVector globalMomentum() const
Square< F >::type sqr(const F &f)
Definition: Square.h:14
T get() const
Definition: EventSetup.h:73
unsigned int size() const
Definition: SeedingHitSet.h:41
const TrackerGeomDet * idToDet(DetId) const override
const MagneticField & magneticField() const
DetId geographicalId() const
bool checkHit(const TrajectoryStateOnSurface &, const SeedingHitSet::ConstRecHitPointer &hit, const edm::EventSetup &es) const
long double T
T x() const
Definition: PV3DBase.h:59
T const * product() const
Definition: ESHandle.h:86
Global3DVector GlobalVector
Definition: GlobalVector.h:10
CurvilinearTrajectoryError initialError(const GlobalVector &vertexBounds, float ptMin, float sinTheta) const