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 namespace {
21  template <class T> T sqr( T t) {return t*t;}
22 }
23 
25  TrajectorySeedCollection & seedCollection,
26  const SeedingHitSet & hits,
27  const GlobalPoint & vertex,
28  const GlobalVector & vertexBounds,
29  float ptmin,
30  const edm::EventSetup& es,
31  float cotTheta, std::stringstream& ss)
32 {
33  pss = &ss;
34  if ( hits.size() < 2) return 0;
35 
36  GlobalTrajectoryParameters kine = initialKinematic(hits, vertex, es, cotTheta);
37  float sinTheta = sin(kine.momentum().theta());
38 
39  CurvilinearTrajectoryError error = initialError(vertexBounds, ptmin, sinTheta);
40  FreeTrajectoryState fts(kine, error);
41 
42  return buildSeed(seedCollection,hits,fts,es);
43 }
44 
45 
47  const SeedingHitSet & hits,
48  const GlobalPoint & vertexPos,
49  const edm::EventSetup& es,
50  const float cotTheta) const
51 {
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)
67  kine = GlobalTrajectoryParameters(kine.position(),
68  GlobalVector(kine.momentum().x(),kine.momentum().y(),kine.momentum().perp()*cotTheta),
69  kine.charge(),
70  & kine.magneticField()
71  );
72  else
74  GlobalVector(kine.momentum().x(),kine.momentum().y(),kine.momentum().perp()*cotTheta_Max),
75  kine.charge(),
76  & kine.magneticField()
77  );
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()
89  << "\nhelix momentum " << kine.momentum() << " pt " << kine.momentum().perp() << " radius " << 1/kine.transverseCurvature();
90 #endif
91 
92  bool isBOFF =(0==nomField);;
93  if (isBOFF && (theBOFFMomentum > 0)) {
95  kine.momentum().unit() * theBOFFMomentum,
96  kine.charge(),
97  &*bfield);
98  }
99  return kine;
100 }
101 
102 
103 
106  const GlobalVector& vertexBounds,
107  float ptMin,
108  float sinTheta) const
109 {
110  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
111  // information.
112  GlobalError vertexErr( sqr(vertexBounds.x()), 0,
113  sqr(vertexBounds.y()), 0, 0,
114  sqr(vertexBounds.z())
115  );
116 
117 
118  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
119 
120 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
121 // to avoid instabilities.
122 // N.B. This parameter needs optimising ...
123  float sin2th = sqr(sinTheta);
124  float minC00 = 1.0;
125  C[0][0] = std::max(sin2th/sqr(ptMin), minC00);
126  float zErr = vertexErr.czz();
127  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
128  C[3][3] = transverseErr;
129  C[4][4] = zErr*sin2th + transverseErr*(1-sin2th);
130 
131  return CurvilinearTrajectoryError(C);
132 }
133 
135  TrajectorySeedCollection & seedCollection,
136  const SeedingHitSet & hits,
137  const FreeTrajectoryState & fts,
138  const edm::EventSetup& es) const
139 {
140  // FIXME all this stuff shoould go in an initialized...
141 
142  // get tracker
144  es.get<TrackerDigiGeometryRecord>().get(tracker);
145 
146  // get propagator
147  edm::ESHandle<Propagator> propagatorHandle;
148  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagatorHandle);
149  const Propagator* propagator = &(*propagatorHandle);
150 
152  es.get<TransientRecHitRecord>().get(TTRHBuilder, builderH);
153  auto builder = (TkTransientTrackingRecHitBuilder const *)(builderH.product());
154  cloner = (*builder).cloner();
155 
156  // get updator
158 
159 
160 
161  // Now update initial state track using information from seed hits.
162 
163  TrajectoryStateOnSurface updatedState;
165 
166  const TrackingRecHit* hit = 0;
167  for ( unsigned int iHit = 0; iHit < hits.size() && iHit<1; iHit++) {
168  hit = hits[iHit];
169  TrajectoryStateOnSurface state = (iHit==0) ?
170  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
171  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
172  if (!state.isValid()) return 0;
173 
174  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
175 
176  std::unique_ptr<BaseTrackerRecHit> newtth(refitHit( tth, state));
177 
178 
179  if (!checkHit(state,&*newtth,es)) return 0;
180 
181  updatedState = updator.update(state, *newtth);
182  if (!updatedState.isValid()) return 0;
183 
184  seedHits.push_back(newtth.release());
185 #ifdef mydebug_seed
186  uint32_t detid = hit->geographicalId().rawId();
187  (*pss) << "\n[SeedForPhotonConversion1Leg] hit " << iHit;
188  po.print(*pss, detid);
189  (*pss) << " " << detid << "\t lp " << hit->localPosition()
190  << " tth " << tth->localPosition() << " newtth " << newtth->localPosition() << " state " << state.globalMomentum().perp();
191 #endif
192  }
193 
194  if(!hit) return nullptr;
195 
196  PTrajectoryStateOnDet const & PTraj =
198 
199  seedCollection.push_back( TrajectorySeed(PTraj,seedHits,alongMomentum));
200  return &seedCollection.back();
201 }
202 
205  const TrajectoryStateOnSurface &state) const
206 {
207  //const TransientTrackingRecHit* a= hit.get();
208  //return const_cast<TransientTrackingRecHit*> (a);
209  //This was modified otherwise the rechit will have just the local x component and local y=0
210  // To understand how to modify for pixels
211 
212  //const TSiStripRecHit2DLocalPos* b = dynamic_cast<const TSiStripRecHit2DLocalPos*>(a);
213  //return const_cast<TSiStripRecHit2DLocalPos*>(b);
214  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
215 }
tuple propagator
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:290
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
std::vector< TrajectorySeed > TrajectorySeedCollection
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:56
T const * product() const
Definition: ESHandle.h:86
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
double ptmin
Definition: HydjetWrapper.h:90
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