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