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