CMS 3D CMS Logo

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