CMS 3D CMS Logo

CosmicTrackingRegion.cc
Go to the documentation of this file.
5 
13 
15 
16 namespace {
17  template <class T>
18  T sqr(T t) {
19  return t * t;
20  }
21 } // namespace
22 
23 using namespace std;
24 
25 void CosmicTrackingRegion::checkTracks(reco::TrackCollection const& tracks, std::vector<bool>& mask) const {
26  const math::XYZPoint regOrigin(origin().x(), origin().y(), origin().z());
27 
28  assert(mask.size() == tracks.size());
29  int i = -1;
30  for (auto const& track : tracks) {
31  i++;
32  if (mask[i])
33  continue;
34 
35  if (track.pt() < ptMin()) {
36  continue;
37  }
38  if (std::abs(track.dxy(regOrigin)) > originRBound()) {
39  continue;
40  }
41  if (std::abs(track.dz(regOrigin)) > originZBound()) {
42  continue;
43  }
44 
45  mask[i] = true;
46  }
47 }
48 
51  hits_(layer, result);
52  return result;
53 }
54 
55 template <typename T>
57  //get and name collections
58  //++++++++++++++++++++++++
59 
60  //detector layer
61  const DetLayer* detLayer = layer.detLayer();
62  LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer.name();
63  EtaPhiMeasurementEstimator est(0.3, 0.3);
64 
65  //region
66  const GlobalPoint vtx = origin();
67  GlobalVector dir = direction();
68  LogDebug("CosmicTrackingRegion") << "The initial region characteristics are:"
69  << "\n"
70  << " Origin = " << origin() << "\n"
71  << " Direction = " << direction() << "\n"
72  << " Eta = " << origin().eta() << "\n"
73  << " Phi = " << origin().phi();
74 
75  //trajectory state on surface
76  float phi = dir.phi();
77  Surface::RotationType rot(sin(phi), -cos(phi), 0, 0, 0, -1, cos(phi), sin(phi), 0);
78 
80  FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, theMagneticField_));
81  TrajectoryStateOnSurface tsos(fts, *surface);
82  LogDebug("CosmicTrackingRegion") << "The state used to find measurement with the measurement tracker is:\n" << tsos;
83 
84  //propagator
85  AnalyticalPropagator prop(theMagneticField_, alongMomentum);
86 
87  //propagation verification (debug)
88  //++++++++++++++++++++++++++++++++
89 
90  //creation of the state
91  TrajectoryStateOnSurface stateOnLayer = prop.propagate(*tsos.freeState(), detLayer->surface());
92 
93  //verification of the state
94  if (stateOnLayer.isValid()) {
95  LogDebug("CosmicTrackingRegion") << "The initial state propagates to the layer surface: \n"
96  << stateOnLayer << "R = " << stateOnLayer.globalPosition().perp() << "\n"
97  << "Eta = " << stateOnLayer.globalPosition().eta() << "\n"
98  << "Phi = " << stateOnLayer.globalPosition().phi();
99 
100  } else {
101  LogDebug("CosmicTrackingRegion") << "The initial state does not propagate to the layer surface.";
102  }
103 
104  //number of compatible dets
106  vector<DetWithState> compatDets = detLayer->compatibleDets(tsos, prop, est);
107  LogDebug("CosmicTrackingRegion") << "Compatible dets = " << compatDets.size();
108 
109  //get hits
110  //++++++++
111 
112  //measurement tracker (find hits)
113  LayerMeasurements lm(theMeasurementTracker_->measurementTracker(), *theMeasurementTracker_);
114  vector<TrajectoryMeasurement> meas = lm.measurements(*detLayer, tsos, prop, est);
115  LogDebug("CosmicTrackingRegion") << "Number of Trajectory measurements = " << meas.size()
116  << " but the last one is always an invalid hit, by construction.";
117 
118  //trajectory measurement
119 
120  // std::cout <<"CRegion b " << cache.size() << std::endl;
121 
122  // waiting for a migration at LayerMeasurements level and at seed builder level
123  for (auto const& im : meas) {
124  if (!im.recHit()->isValid())
125  continue;
126  assert(!trackerHitRTTI::isUndef(*im.recHit()->hit()));
127  auto ptrHit = (BaseTrackerRecHit*)(im.recHit()->hit()->clone());
128  cache.emplace_back(ptrHit);
129  result.emplace_back(ptrHit);
130  }
131 
132  // std::cout <<"CRegion a " << cache.size() << std::endl;
133 }
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
T perp() const
Definition: PV3DBase.h:69
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
constexpr float ptMin
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
assert(be >=bs)
constexpr uint32_t mask
Definition: gpuClustering.h:26
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
GlobalPoint globalPosition() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void checkTracks(reco::TrackCollection const &tracks, std::vector< bool > &mask) const override
SeedingLayerSetsHits::Hits Hits
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Square< F >::type sqr(const F &f)
Definition: Square.h:14
def cache(function)
Definition: utilities.py:3
FreeTrajectoryState const * freeState(bool withErrors=true) const
float x
bool isUndef(TrackingRecHit const &hit)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
long double T
void hits_(const T &layer, TrackingRegion::Hits &result) const
#define LogDebug(id)