CMS 3D CMS Logo

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