1 |
#include "UserCode/L1RpcTriggerAnalysis/interface/TrackAtSurface.h"
|
2 |
|
3 |
#include <vector>
|
4 |
|
5 |
#include "FWCore/Framework/interface/Event.h"
|
6 |
#include "FWCore/Framework/interface/EventSetup.h"
|
7 |
#include "FWCore/Framework/interface/ESHandle.h"
|
8 |
#include "DataFormats/Common/interface/Handle.h"
|
9 |
|
10 |
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
|
11 |
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
|
12 |
#include "MagneticField/Engine/interface/MagneticField.h"
|
13 |
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
|
14 |
|
15 |
#include "DataFormats/MuonReco/interface/Muon.h"
|
16 |
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
17 |
#include "DataFormats/TrackReco/interface/Track.h"
|
18 |
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
19 |
|
20 |
#include "DataFormats/Math/interface/deltaR.h"
|
21 |
#include "TrackingTools/GeomPropagators/interface/Propagator.h"
|
22 |
#include "TrackingTools/PatternTools/interface/Trajectory.h"
|
23 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
|
24 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
|
25 |
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
|
26 |
|
27 |
|
28 |
#include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
|
29 |
#include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
|
30 |
#include "DataFormats/GeometrySurface/interface/BoundDisk.h"
|
31 |
#include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
|
32 |
|
33 |
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
|
34 |
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
TrackAtSurface::TrackAtSurface(const TrajectoryStateOnSurface &state, const edm::Event &ev, const edm::EventSetup &es)
|
41 |
: theState(state), theEv(ev), theEs(es)
|
42 |
{ }
|
43 |
|
44 |
TrackAtSurface::TrackAtSurface(const reco::Muon* mu,const edm::Event &ev, const edm::EventSetup &es)
|
45 |
: theEv(ev), theEs(es)
|
46 |
{
|
47 |
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
|
48 |
es.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
|
49 |
edm::ESHandle<MagneticField> magField;
|
50 |
es.get<IdealMagneticFieldRecord>().get(magField);
|
51 |
|
52 |
|
53 |
//refit global muons, take tracjctory colsest to Mu.
|
54 |
typedef std::vector<Trajectory> Trajectories;
|
55 |
edm::Handle<Trajectories> trajectories;
|
56 |
edm::InputTag refitTag("globalMuons","Refitted");
|
57 |
ev.getByLabel(refitTag,trajectories);
|
58 |
double minDR = 0.3;
|
59 |
for (Trajectories::const_iterator it=trajectories->begin(); it != trajectories->end(); ++it) {
|
60 |
double diff = deltaR(mu->track()->eta(), mu->track()->phi(), it->geometricalInnermostState().globalMomentum().eta(), it->geometricalInnermostState().globalMomentum().phi());
|
61 |
if (diff < minDR) { minDR = diff; theTrajectory = *it; }
|
62 |
}
|
63 |
theState = trajectoryStateTransform::outerStateOnSurface(*(mu->track()), *globalGeometry, &*magField);
|
64 |
|
65 |
}
|
66 |
|
67 |
TrajectoryStateOnSurface TrackAtSurface::atPoint( const GlobalPoint& point) const
|
68 |
{
|
69 |
TrajectoryStateOnSurface muTSOS = theTrajectory.empty() ? theState : theTrajectory.closestMeasurement(point).updatedState();
|
70 |
|
71 |
bool barrel = fabs(point.z()) < 680. ? true : false;
|
72 |
ReferenceCountingPointer<Surface> surface = barrel ?
|
73 |
ReferenceCountingPointer<Surface>( new BoundCylinder( GlobalPoint(0.,0.,0.), TkRotation<float>(), SimpleCylinderBounds( point.perp(), point.perp(), -680., 680. ) ))
|
74 |
: ReferenceCountingPointer<Surface>( new BoundDisk( GlobalPoint(0.,0.,point.z()), TkRotation<float>(), SimpleDiskBounds( 260., 720., -0.0001, 0.0001 ) ) );
|
75 |
|
76 |
edm::ESHandle<Propagator> propagator;
|
77 |
theEs.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator);
|
78 |
TrajectoryStateOnSurface result = propagator->propagate(muTSOS, *surface);
|
79 |
|
80 |
return result;
|
81 |
}
|
82 |
|
83 |
TrajectoryStateOnSurface TrackAtSurface::atDetFromClose( const RPCDetId& rpc, const GlobalPoint& point) const
|
84 |
{
|
85 |
|
86 |
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
|
87 |
theEs.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
|
88 |
edm::ESHandle<Propagator> propagator;
|
89 |
|
90 |
const GeomDet * det = globalGeometry->idToDet(rpc);
|
91 |
TrajectoryStateOnSurface muTSOS;
|
92 |
if (!theTrajectory.empty()) muTSOS = theTrajectory.closestMeasurement(point).updatedState();
|
93 |
theEs.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny",propagator);
|
94 |
Plane::PlanePointer surface = Plane::build(det->position(), det->rotation());
|
95 |
TrajectoryStateOnSurface result;
|
96 |
if (muTSOS.isValid()) result = propagator->propagate(muTSOS, *surface);
|
97 |
|
98 |
return result;
|
99 |
}
|
100 |
|
101 |
TrajectoryStateOnSurface TrackAtSurface::atDetFromTrack( const RPCDetId& rpc) const
|
102 |
{
|
103 |
|
104 |
edm::ESHandle<GlobalTrackingGeometry> globalGeometry;
|
105 |
theEs.get<GlobalTrackingGeometryRecord>().get(globalGeometry);
|
106 |
edm::ESHandle<Propagator> propagator;
|
107 |
|
108 |
const GeomDet * det = globalGeometry->idToDet(rpc);
|
109 |
TrajectoryStateOnSurface muTSOS = theState;
|
110 |
theEs.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAlong",propagator);
|
111 |
Plane::PlanePointer surface = Plane::build(det->position(), det->rotation());
|
112 |
TrajectoryStateOnSurface result;
|
113 |
if (muTSOS.isValid()) result = propagator->propagate(muTSOS, *surface);
|
114 |
|
115 |
return result;
|
116 |
}
|
117 |
|
118 |
TrajectoryStateOnSurface TrackAtSurface::atStation2( float eta) const
|
119 |
{
|
120 |
ReferenceCountingPointer<Surface> rpc;
|
121 |
if (eta < -1.04) rpc = ReferenceCountingPointer<Surface>(new BoundDisk( GlobalPoint(0.,0.,-790.), TkRotation<float>(), SimpleDiskBounds( 300., 710., -10., 10. ) ) );
|
122 |
else if (eta < -0.72) rpc = ReferenceCountingPointer<Surface>(new BoundCylinder( GlobalPoint(0.,0.,0.), TkRotation<float>(), SimpleCylinderBounds( 520, 520, -700, 700 ) ) );
|
123 |
else if (eta < 0.72) rpc = ReferenceCountingPointer<Surface>(new BoundCylinder( GlobalPoint(0.,0.,0.), TkRotation<float>(), SimpleCylinderBounds( 500, 500, -700, 700 ) ) );
|
124 |
else if (eta < 1.04) rpc = ReferenceCountingPointer<Surface>(new BoundCylinder( GlobalPoint(0.,0.,0.), TkRotation<float>(), SimpleCylinderBounds( 520, 520, -700, 700 ) ) );
|
125 |
else rpc = ReferenceCountingPointer<Surface>(new BoundDisk( GlobalPoint(0.,0.,790.), TkRotation<float>(), SimpleDiskBounds( 300., 710., -10., 10. ) ) );
|
126 |
edm::ESHandle<Propagator> propagator;
|
127 |
theEs.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAlong", propagator);
|
128 |
TrajectoryStateOnSurface trackAtRPC = propagator->propagate( theState, *rpc);
|
129 |
return trackAtRPC;
|
130 |
}
|