CMS 3D CMS Logo

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