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