CMS 3D CMS Logo

CosmicTrackingRegion.cc
Go to the documentation of this file.
5 
13 
15 
17 
18 namespace {
19  template <class T>
20  T sqr(T t) {
21  return t * t;
22  }
23 } // namespace
24 
25 using namespace std;
26 
28  const SeedingLayerSetsHits::SeedingLayer& layer) const {
30  hits_(es, layer, result);
31  return result;
32 }
33 
34 template <typename T>
36  //get and name collections
37  //++++++++++++++++++++++++
38 
39  //detector layer
40  const DetLayer* detLayer = layer.detLayer();
41  LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer.name();
42  EtaPhiMeasurementEstimator est(0.3, 0.3);
43 
44  //magnetic field
46  es.get<IdealMagneticFieldRecord>().get(field);
47  const MagneticField* magField = field.product();
48 
49  //region
50  const GlobalPoint vtx = origin();
51  GlobalVector dir = direction();
52  LogDebug("CosmicTrackingRegion") << "The initial region characteristics are:"
53  << "\n"
54  << " Origin = " << origin() << "\n"
55  << " Direction = " << direction() << "\n"
56  << " Eta = " << origin().eta() << "\n"
57  << " Phi = " << origin().phi();
58 
59  //trajectory state on surface
60  float phi = dir.phi();
61  Surface::RotationType rot(sin(phi), -cos(phi), 0, 0, 0, -1, cos(phi), sin(phi), 0);
62 
63  Plane::PlanePointer surface = Plane::build(vtx, rot);
64  FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, magField));
65  TrajectoryStateOnSurface tsos(fts, *surface);
66  LogDebug("CosmicTrackingRegion") << "The state used to find measurement with the measurement tracker is:\n" << tsos;
67 
68  //propagator
69  AnalyticalPropagator prop(magField, alongMomentum);
70 
71  //propagation verification (debug)
72  //++++++++++++++++++++++++++++++++
73 
74  //creation of the state
75  TrajectoryStateOnSurface stateOnLayer = prop.propagate(*tsos.freeState(), detLayer->surface());
76 
77  //verification of the state
78  if (stateOnLayer.isValid()) {
79  LogDebug("CosmicTrackingRegion") << "The initial state propagates to the layer surface: \n"
80  << stateOnLayer << "R = " << stateOnLayer.globalPosition().perp() << "\n"
81  << "Eta = " << stateOnLayer.globalPosition().eta() << "\n"
82  << "Phi = " << stateOnLayer.globalPosition().phi();
83 
84  } else {
85  LogDebug("CosmicTrackingRegion") << "The initial state does not propagate to the layer surface.";
86  }
87 
88  //number of compatible dets
90  vector<DetWithState> compatDets = detLayer->compatibleDets(tsos, prop, est);
91  LogDebug("CosmicTrackingRegion") << "Compatible dets = " << compatDets.size();
92 
93  //get hits
94  //++++++++
95 
96  //measurement tracker (find hits)
97  LayerMeasurements lm(theMeasurementTracker_->measurementTracker(), *theMeasurementTracker_);
98  vector<TrajectoryMeasurement> meas = lm.measurements(*detLayer, tsos, prop, est);
99  LogDebug("CosmicTrackingRegion") << "Number of Trajectory measurements = " << meas.size()
100  << " but the last one is always an invalid hit, by construction.";
101 
102  //trajectory measurement
103 
104  // std::cout <<"CRegion b " << cache.size() << std::endl;
105 
106  // waiting for a migration at LayerMeasurements level and at seed builder level
107  for (auto const& im : meas) {
108  if (!im.recHit()->isValid())
109  continue;
110  assert(!trackerHitRTTI::isUndef(*im.recHit()->hit()));
111  auto ptrHit = (BaseTrackerRecHit*)(im.recHit()->hit()->clone());
112  cache.emplace_back(ptrHit);
113  result.emplace_back(ptrHit);
114  }
115 
116  // std::cout <<"CRegion a " << cache.size() << std::endl;
117 }
#define LogDebug(id)
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
T perp() const
Definition: PV3DBase.h:69
TrackingRegion::Hits hits(const edm::EventSetup &es, const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
GlobalPoint globalPosition() const
void hits_(const edm::EventSetup &es, const T &layer, TrackingRegion::Hits &result) const
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
FreeTrajectoryState const * freeState(bool withErrors=true) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
SeedingLayerSetsHits::Hits Hits
T eta() const
Definition: PV3DBase.h:73
Square< F >::type sqr(const F &f)
Definition: Square.h:14
def cache(function)
Definition: utilities.py:3
T get() const
Definition: EventSetup.h:73
bool isUndef(TrackingRecHit const &hit)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
long double T
T const * product() const
Definition: ESHandle.h:86