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 {
31  return hits_(ev, es, *layer);
32 }
33 
35  const edm::EventSetup& es,
36  const SeedingLayerSetsHits::SeedingLayer& layer) const
37 {
38  return hits_(ev, es, layer);
39 }
40 
41 template <typename T>
43  const edm::EventSetup& es,
44  const T& layer) const
45 {
46 
47  //get and name collections
48  //++++++++++++++++++++++++
49 
50  //tracking region
52 
53  //detector layer
54  const DetLayer * detLayer = layer.detLayer();
55  LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer.name();
56  EtaPhiMeasurementEstimator est(0.3,0.3);
57 
58  //magnetic field
60  es.get<IdealMagneticFieldRecord>().get(field);
61  const MagneticField * magField = field.product();
62 
63  //region
64  const GlobalPoint vtx = origin();
65  GlobalVector dir = direction();
66  LogDebug("CosmicTrackingRegion") <<"The initial region characteristics are:" << "\n"
67  <<" Origin = " << origin() << "\n"
68  <<" Direction = " << direction() << "\n"
69  <<" Eta = " << origin().eta() << "\n"
70  <<" Phi = " << origin().phi();
71 
72  //trajectory state on surface
73  float phi = dir.phi();
74  Surface::RotationType rot( sin(phi), -cos(phi), 0,
75  0, 0, -1,
76  cos(phi), sin(phi), 0);
77 
78  Plane::PlanePointer surface = Plane::build(vtx, rot);
79  FreeTrajectoryState fts( GlobalTrajectoryParameters(vtx, dir, 1, magField) );
80  TrajectoryStateOnSurface tsos(fts, *surface);
81  LogDebug("CosmicTrackingRegion")
82  << "The state used to find measurement with the measurement tracker is:\n" << tsos;
83 
84  //propagator
85  AnalyticalPropagator prop( magField, alongMomentum);
86 
87  //propagation verification (debug)
88  //++++++++++++++++++++++++++++++++
89 
90  //creation of the state
91  TrajectoryStateOnSurface stateOnLayer = prop.propagate( *tsos.freeState(),
92  detLayer->surface());
93 
94  //verification of the state
95  if (stateOnLayer.isValid()){
96  LogDebug("CosmicTrackingRegion") << "The initial state propagates to the layer surface: \n" << stateOnLayer
97  << "R = " << stateOnLayer.globalPosition().perp() << "\n"
98  << "Eta = " << stateOnLayer.globalPosition().eta() << "\n"
99  << "Phi = " << stateOnLayer.globalPosition().phi();
100 
101  }
102  else{
103  LogDebug("CosmicTrackingRegion") << "The initial state does not propagate to the layer surface.";
104  }
105 
106  //number of compatible dets
108  vector<DetWithState> compatDets = detLayer->compatibleDets(tsos, prop, est);
109  LogDebug("CosmicTrackingRegion") << "Compatible dets = " << compatDets.size();
110 
111 
112  //get hits
113  //++++++++
114 
115  //measurement tracker (find hits)
116  edm::ESHandle<MeasurementTracker> measurementTrackerESH;
117  es.get<CkfComponentsRecord>().get(measurementTrackerName_,measurementTrackerESH);
118  const MeasurementTracker * measurementTracker = measurementTrackerESH.product();
120  ev.getByLabel(edm::InputTag("MeasurementTrackerEvent"), mte);
121  LayerMeasurements lm(*measurementTracker, *mte);
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  typedef vector<TrajectoryMeasurement>::const_iterator IM;
128 
129  for (IM im = meas.begin(); im != meas.end(); im++) {//loop on measurement tracker
130  TrajectoryMeasurement::ConstRecHitPointer ptrHit = im->recHit();
131 
132  if (ptrHit->isValid()) {
133  LogDebug("CosmicTrackingRegion") << "Hit found in the region at position: "<<ptrHit->globalPosition();
134  result.push_back( ptrHit );
135  }//end if isValid()
136 
137  else LogDebug("CosmicTrackingRegion") << "No valid hit";
138  }//end loop on measurement tracker
139 
140 
141  //result
142  //++++++
143 
144  return result;
145 }
146 
147 
#define LogDebug(id)
TrackingRegion::Hits hits_(const edm::Event &ev, const edm::EventSetup &es, const T &layer) const
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
virtual TrackingRegion::Hits hits(const edm::Event &ev, const edm::EventSetup &es, const ctfseeding::SeedingLayer *layer) const
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
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
tuple field
Definition: statics.py:62
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
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::vector< Hit > Hits
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T eta() const
Definition: PV3DBase.h:76
Square< F >::type sqr(const F &f)
Definition: Square.h:13
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
dbl *** dir
Definition: mlp_gen.cc:35
long double T
Definition: DDAxes.h:10