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