CMS 3D CMS Logo

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