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 
17 
19 
21 
22 
23 template <class T> T sqr( T t) {return t*t;}
24 
25 
26 using namespace std;
27 using namespace ctfseeding;
28 
29 
31  const edm::EventSetup& es,
32  const ctfseeding::SeedingLayer* layer) const
33 {
34 
35  //get and name collections
36  //++++++++++++++++++++++++
37 
38  //tracking region
40 
41  //detector layer
42  const DetLayer * detLayer = layer->detLayer();
43  LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer->name();
44  EtaPhiMeasurementEstimator est(0.3,0.3);
45 
46  //magnetic field
48  es.get<IdealMagneticFieldRecord>().get(field);
49  const MagneticField * magField = field.product();
50 
51  //region
52  const GlobalPoint vtx = origin();
53  GlobalVector dir = direction();
54  LogDebug("CosmicTrackingRegion") <<"The initial region characteristics are:" << "\n"
55  <<" Origin = " << origin() << "\n"
56  <<" Direction = " << direction() << "\n"
57  <<" Eta = " << origin().eta() << "\n"
58  <<" Phi = " << origin().phi();
59 
60  //trajectory state on surface
61  float phi = dir.phi();
62  Surface::RotationType rot( sin(phi), -cos(phi), 0,
63  0, 0, -1,
64  cos(phi), sin(phi), 0);
65 
66  Plane::PlanePointer surface = Plane::build(vtx, rot);
67  FreeTrajectoryState fts( GlobalTrajectoryParameters(vtx, dir, 1, magField) );
68  TrajectoryStateOnSurface tsos(fts, *surface);
69  LogDebug("CosmicTrackingRegion")
70  << "The state used to find measurement with the measurement tracker is:\n" << tsos;
71 
72  //propagator
73  AnalyticalPropagator prop( magField, alongMomentum);
74 
75  //propagation verification (debug)
76  //++++++++++++++++++++++++++++++++
77 
78  //creation of the state
79  TrajectoryStateOnSurface stateOnLayer = prop.propagate( *tsos.freeState(),
80  detLayer->surface());
81 
82  //verification of the state
83  if (stateOnLayer.isValid()){
84  LogDebug("CosmicTrackingRegion") << "The initial state propagates to the layer surface: \n" << stateOnLayer
85  << "R = " << stateOnLayer.globalPosition().perp() << "\n"
86  << "Eta = " << stateOnLayer.globalPosition().eta() << "\n"
87  << "Phi = " << stateOnLayer.globalPosition().phi();
88 
89  }
90  else{
91  LogDebug("CosmicTrackingRegion") << "The initial state does not propagate to the layer surface.";
92  }
93 
94  //number of compatible dets
96  vector<DetWithState> compatDets = detLayer->compatibleDets(tsos, prop, est);
97  LogDebug("CosmicTrackingRegion") << "Compatible dets = " << compatDets.size();
98 
99 
100  //get hits
101  //++++++++
102 
103  //measurement tracker (find hits)
104  edm::ESHandle<MeasurementTracker> measurementTrackerESH;
105  es.get<CkfComponentsRecord>().get(measurementTrackerName_,measurementTrackerESH);
106  const MeasurementTracker * measurementTracker = measurementTrackerESH.product();
107  measurementTracker->update(ev);
108  LayerMeasurements lm(measurementTracker);
109  vector<TrajectoryMeasurement> meas = lm.measurements(*detLayer, tsos, prop, est);
110  LogDebug("CosmicTrackingRegion") << "Number of Trajectory measurements = " << meas.size()
111  <<" but the last one is always an invalid hit, by construction.";
112 
113  //trajectory measurement
114  typedef vector<TrajectoryMeasurement>::const_iterator IM;
115 
116  for (IM im = meas.begin(); im != meas.end(); im++) {//loop on measurement tracker
117  TrajectoryMeasurement::ConstRecHitPointer ptrHit = im->recHit();
118 
119  if (ptrHit->isValid()) {
120  LogDebug("CosmicTrackingRegion") << "Hit found in the region at position: "<<ptrHit->globalPosition();
121  result.push_back( ptrHit );
122  }//end if isValid()
123 
124  else LogDebug("CosmicTrackingRegion") << "No valid hit";
125  }//end loop on measurement tracker
126 
127 
128  //result
129  //++++++
130 
131  return result;
132 }
133 
134 
#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:66
TrajectoryStateOnSurface propagate(const FreeTrajectoryState &fts, const Plane &plane) const
propagation to plane
virtual TrackingRegion::Hits hits(const edm::Event &ev, const edm::EventSetup &es, const ctfseeding::SeedingLayer *layer) const
allowed eta range [eta_min, eta_max] interval
const DetLayer * detLayer() const
Definition: SeedingLayer.cc:80
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
static PlanePointer build(const PositionType &pos, const RotationType &rot, MediumProperties *mp=0)
Definition: Plane.h:25
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
FreeTrajectoryState * freeState(bool withErrors=true) const
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< Hit > Hits
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::string name() const
Definition: SeedingLayer.cc:75
T eta() const
Definition: PV3DBase.h:70
Square< F >::type sqr(const F &f)
Definition: Square.h:13
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
dbl *** dir
Definition: mlp_gen.cc:35
Definition: DDAxes.h:10