CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Traj2TrackHits Class Reference

#include <Traj2TrackHits.h>

Public Types

using Chi2sFive = std::vector< unsigned char >
 
using TrajParams = std::vector< LocalTrajectoryParameters >
 

Public Member Functions

void operator() (Trajectory const &traj, TrackingRecHitCollection &hits, bool splitting) const
 
void operator() (Trajectory const &traj, TrackingRecHitCollection &hits, TrajParams &trajParams, Chi2sFive &chi2s) const
 
 Traj2TrackHits ()
 
 Traj2TrackHits (const TransientTrackingRecHitBuilder *builder, bool ikeepOrder, bool noNoDet=true)
 

Static Public Member Functions

static unsigned char toChi2x5 (float chi2)
 

Private Member Functions

BaseTrackerRecHitbuild (GeomDetUnit const &idet, OmniClusterRef const &clus) const
 
TrackingRecHitclone (BaseTrackerRecHit const &hit2D) const
 
template<typename HI >
void copy (HI itm, HI e, TrackingRecHitCollection &hits, TrajParams &trajParams, Chi2sFive &chi2s) const
 
template<typename HI >
void copy (HI itm, HI e, TrackingRecHitCollection &hits) const
 
template<typename HI >
void split (HI itm, HI e, TrackingRecHitCollection &hits, bool along) const
 
void split (TrajectoryMeasurement const &itm, SiStripMatchedRecHit2D const &mhit, TrackingRecHitCollection &hits, float zdir) const
 

Private Attributes

bool keepOrder = false
 
bool removeNoDet = true
 
const StripClusterParameterEstimatortheCPE = nullptr
 

Detailed Description

Definition at line 16 of file Traj2TrackHits.h.

Member Typedef Documentation

◆ Chi2sFive

using Traj2TrackHits::Chi2sFive = std::vector<unsigned char>

Definition at line 23 of file Traj2TrackHits.h.

◆ TrajParams

Definition at line 22 of file Traj2TrackHits.h.

Constructor & Destructor Documentation

◆ Traj2TrackHits() [1/2]

Traj2TrackHits::Traj2TrackHits ( )
inline

Definition at line 31 of file Traj2TrackHits.h.

31 {}

◆ Traj2TrackHits() [2/2]

Traj2TrackHits::Traj2TrackHits ( const TransientTrackingRecHitBuilder builder,
bool  ikeepOrder,
bool  noNoDet = true 
)
inline

Definition at line 33 of file Traj2TrackHits.h.

34  : theCPE(static_cast<TkTransientTrackingRecHitBuilder const *>(builder)->stripClusterParameterEstimator()),
35  keepOrder(ikeepOrder),
36  removeNoDet(noNoDet) {}
const StripClusterParameterEstimator * theCPE

Member Function Documentation

◆ build()

BaseTrackerRecHit* Traj2TrackHits::build ( GeomDetUnit const &  idet,
OmniClusterRef const &  clus 
) const
inlineprivate

Definition at line 131 of file Traj2TrackHits.h.

References makeMuonMisalignmentScenario::endcap, GeomDetType::isEndcap(), StripClusterParameterEstimator::localParameters(), SiStripPI::max, OmniClusterRef::stripCluster(), theCPE, and GeomDet::type().

Referenced by split().

131  {
132  //Use 2D SiStripRecHit in endcap
133  bool endcap = idet.type().isEndcap();
134  auto &&lv = theCPE->localParameters(clus.stripCluster(), idet);
135  if (endcap)
136  return new SiStripRecHit2D(lv.first, lv.second, idet, clus);
137  return new SiStripRecHit1D(
138  lv.first, LocalError(lv.second.xx(), 0.f, std::numeric_limits<float>::max()), idet, clus);
139  }
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const
const StripClusterParameterEstimator * theCPE

◆ clone()

TrackingRecHit* Traj2TrackHits::clone ( BaseTrackerRecHit const &  hit2D) const
inlineprivate

Definition at line 119 of file Traj2TrackHits.h.

References TrackingRecHit::clone(), TrackingRecHit::det(), TrackingRecHit::detUnit(), makeMuonMisalignmentScenario::endcap, BaseTrackerRecHit::firstClusterRef(), BaseTrackerRecHit::localPosition(), BaseTrackerRecHit::localPositionError(), SiStripPI::max, and LocalError::xx().

Referenced by split().

119  {
120  auto const &detU = *hit2D.detUnit();
121  //Use 2D SiStripRecHit in endcap
122  bool endcap = detU.type().isEndcap();
123  if (endcap)
124  return hit2D.clone();
125  return new SiStripRecHit1D(hit2D.localPosition(),
126  LocalError(hit2D.localPositionError().xx(), 0.f, std::numeric_limits<float>::max()),
127  *hit2D.det(),
128  hit2D.firstClusterRef());
129  }

◆ copy() [1/2]

template<typename HI >
void Traj2TrackHits::copy ( HI  itm,
HI  e,
TrackingRecHitCollection hits,
TrajParams trajParams,
Chi2sFive chi2s 
) const
inlineprivate

Definition at line 74 of file Traj2TrackHits.h.

References MillePedeFileConverter_cfg::e, hfClusterShapes_cfi::hits, removeNoDet, and toChi2x5().

Referenced by operator()().

74  {
75  for (; itm != e; ++itm)
76  if ((!removeNoDet) | ((*itm).recHitR().det() != nullptr)) {
77  hits.push_back((*itm).recHitR().cloneHit());
78  trajParams.push_back((*itm).updatedState().localParameters());
79  chi2s.push_back(toChi2x5((*itm).estimate()));
80  }
81  }
static unsigned char toChi2x5(float chi2)

◆ copy() [2/2]

template<typename HI >
void Traj2TrackHits::copy ( HI  itm,
HI  e,
TrackingRecHitCollection hits 
) const
inlineprivate

Definition at line 84 of file Traj2TrackHits.h.

References MillePedeFileConverter_cfg::e, hfClusterShapes_cfi::hits, and removeNoDet.

84  {
85  for (; itm != e; ++itm)
86  if ((!removeNoDet) | ((*itm).recHitR().det() != nullptr))
87  hits.push_back((*itm).recHitR().cloneHit());
88  }

◆ operator()() [1/2]

void Traj2TrackHits::operator() ( Trajectory const &  traj,
TrackingRecHitCollection hits,
bool  splitting 
) const
inline

Definition at line 38 of file Traj2TrackHits.h.

References alongMomentum, copy(), Trajectory::direction(), hfClusterShapes_cfi::hits, keepOrder, Trajectory::measurements(), split(), and crabTemplate::splitting.

38  {
39  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
40  bool along = traj.direction() == alongMomentum;
41  auto const &meas = traj.measurements();
42  hits.reserve(splitting ? 2 * meas.size() : meas.size());
43  if (!splitting) {
44  if (keepOrder | along)
45  copy(meas.begin(), meas.end(), hits);
46  else
47  copy(meas.rbegin(), meas.rend(), hits);
48  return;
49  }
50  if (keepOrder | along)
51  split(meas.begin(), meas.end(), hits, along);
52  else
53  split(meas.rbegin(), meas.rend(), hits, along);
54  hits.shrink_to_fit();
55  }
void split(HI itm, HI e, TrackingRecHitCollection &hits, bool along) const
void copy(HI itm, HI e, TrackingRecHitCollection &hits, TrajParams &trajParams, Chi2sFive &chi2s) const

◆ operator()() [2/2]

void Traj2TrackHits::operator() ( Trajectory const &  traj,
TrackingRecHitCollection hits,
TrajParams trajParams,
Chi2sFive chi2s 
) const
inline

Definition at line 57 of file Traj2TrackHits.h.

References alongMomentum, copy(), Trajectory::direction(), hfClusterShapes_cfi::hits, keepOrder, and Trajectory::measurements().

60  {
61  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
62  bool along = traj.direction() == alongMomentum;
63  auto const &meas = traj.measurements();
64  trajParams.reserve(meas.size());
65  chi2s.reserve(meas.size());
66  if (keepOrder | along)
67  copy(meas.begin(), meas.end(), hits, trajParams, chi2s);
68  else
69  copy(meas.rbegin(), meas.rend(), hits, trajParams, chi2s);
70  }
void copy(HI itm, HI e, TrackingRecHitCollection &hits, TrajParams &trajParams, Chi2sFive &chi2s) const

◆ split() [1/2]

template<typename HI >
void Traj2TrackHits::split ( HI  itm,
HI  e,
TrackingRecHitCollection hits,
bool  along 
) const
inlineprivate

Definition at line 91 of file Traj2TrackHits.h.

References build(), clone(), MillePedeFileConverter_cfg::e, BaseTrackerRecHit::firstClusterRef(), hfClusterShapes_cfi::hits, trackerHitRTTI::isNotFromCluster(), trackerHitRTTI::isUndef(), keepOrder, and removeNoDet.

Referenced by operator()().

91  {
92  for (; itm != e; ++itm) {
93  auto const &hit = *(*itm).recHit()->hit();
94  if ((removeNoDet) & ((*itm).recHitR().det() == nullptr))
95  continue;
96  if (trackerHitRTTI::isUndef(hit) || trackerHitRTTI::isNotFromCluster(hit) || (hit.dimension() != 2)) {
97  hits.push_back(hit.clone());
98  continue;
99  }
100  auto const &thit = static_cast<BaseTrackerRecHit const &>(hit);
101  auto const &clus = thit.firstClusterRef();
102  if (clus.isPixel())
103  hits.push_back(hit.clone());
104  else if (clus.isPhase2())
105  hits.push_back(hit.clone());
106  else if (thit.isMatched()) {
107  auto zdir = itm->updatedState().localDirection().z();
108  if (keepOrder & (!along))
109  zdir = -zdir;
110  split(*itm, static_cast<SiStripMatchedRecHit2D const &>(thit), hits, zdir);
111  } else if (thit.isProjected()) {
112  auto detU = static_cast<ProjectedSiStripRecHit2D const &>(thit).originalDet();
113  hits.push_back(build(*detU, clus));
114  } else
115  hits.push_back(clone(thit));
116  }
117  }
TrackingRecHit * clone(BaseTrackerRecHit const &hit2D) const
bool isNotFromCluster(TrackingRecHit const &hit)
void split(HI itm, HI e, TrackingRecHitCollection &hits, bool along) const
virtual OmniClusterRef const & firstClusterRef() const =0
BaseTrackerRecHit * build(GeomDetUnit const &idet, OmniClusterRef const &clus) const
bool isUndef(TrackingRecHit const &hit)

◆ split() [2/2]

void Traj2TrackHits::split ( TrajectoryMeasurement const &  itm,
SiStripMatchedRecHit2D const &  mhit,
TrackingRecHitCollection hits,
float  zdir 
) const
inlineprivate

Definition at line 141 of file Traj2TrackHits.h.

References build(), TrackingRecHit::det(), hfClusterShapes_cfi::hits, SiStripMatchedRecHit2D::monoClusterRef(), GluedGeomDet::monoDet(), GeomDet::position(), hitfit::scalar(), SiStripMatchedRecHit2D::stereoClusterRef(), GluedGeomDet::stereoDet(), TrajectoryStateOnSurface::surface(), GloballyPositioned< T >::toLocal(), TrajectoryMeasurement::updatedState(), and PV3DBase< T, PVType, FrameType >::z().

144  {
145  const GluedGeomDet *gdet = static_cast<const GluedGeomDet *>(mhit.det());
146 
147  auto hitM = build(*gdet->monoDet(), mhit.monoClusterRef());
148  auto hitS = build(*gdet->stereoDet(), mhit.stereoClusterRef());
149 
150  // we should find a faster way
151  LocalPoint firstLocalPos = itm.updatedState().surface().toLocal(gdet->monoDet()->position());
152  LocalPoint secondLocalPos = itm.updatedState().surface().toLocal(gdet->stereoDet()->position());
153  LocalVector Delta = secondLocalPos - firstLocalPos;
154  float scalar = Delta.z() * zdir;
155  // hit along the direction
156  if (scalar < 0) {
157  hits.push_back(hitS);
158  hits.push_back(hitM);
159  } else {
160  hits.push_back(hitM);
161  hits.push_back(hitS);
162  }
163  }
T z() const
Definition: PV3DBase.h:61
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
BaseTrackerRecHit * build(GeomDetUnit const &idet, OmniClusterRef const &clus) const
double scalar(const CLHEP::HepGenMatrix &m)
Return the matrix as a scalar. Raise an assertion if the matris is not .
Definition: matutil.cc:166

◆ toChi2x5()

static unsigned char Traj2TrackHits::toChi2x5 ( float  chi2)
inlinestatic

Definition at line 25 of file Traj2TrackHits.h.

References hltPixelTracks_cff::chi2, f, and SiStripPI::min.

Referenced by copy(), and HITrackClusterRemover::process().

25  {
26  float tc = std::round(5.f * chi2);
27  return std::min(tc, 255.f);
28  }
double f[11][100]

Member Data Documentation

◆ keepOrder

bool Traj2TrackHits::keepOrder = false
private

Definition at line 19 of file Traj2TrackHits.h.

Referenced by operator()(), and split().

◆ removeNoDet

bool Traj2TrackHits::removeNoDet = true
private

Definition at line 20 of file Traj2TrackHits.h.

Referenced by copy(), and split().

◆ theCPE

const StripClusterParameterEstimator* Traj2TrackHits::theCPE = nullptr
private

Definition at line 18 of file Traj2TrackHits.h.

Referenced by build().