ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/Tracking/Cosmics/src/TrackLocalAngle.cc
Revision: 1.1
Committed: Tue Jul 6 19:33:58 2010 UTC (14 years, 10 months ago) by msegala
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# Content
1
2 #include <memory>
3 #include <string>
4 #include <iostream>
5 #include <TMath.h>
6 #include "RecoTracker/SingleTrackPattern/test/TrackLocalAngle.h"
7
8 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
9 #include "DataFormats/Common/interface/Handle.h"
10 #include "FWCore/Framework/interface/ESHandle.h"
11 #include "FWCore/Framework/interface/EventSetup.h"
12 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
13 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
14 #include "DataFormats/GeometryVector/interface/LocalVector.h"
15 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
16 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
17 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
18 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
19 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
20 #include "DataFormats/TrackReco/interface/Track.h"
21 #include "DataFormats/TrackReco/interface/TrackExtra.h"
22 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
23 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
24 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
25 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
26 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
27 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
28 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
29 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
30
31 using namespace std;
32 TrackLocalAngle::TrackLocalAngle(const TrackerGeometry* tracker)
33 {
34 tracker_ = tracker;
35 }
36
37 // Virtual destructor needed.
38 TrackLocalAngle::~TrackLocalAngle() { }
39
40 std::pair<float,float> TrackLocalAngle::findhitcharge(const TrajectoryMeasurement& theTM)
41 {
42
43 std::pair<float,float> monostereocha;
44 float charge1 = 0.;
45 float charge2 = 0.;
46
47 const TransientTrackingRecHit::ConstRecHitPointer thit=theTM.recHit();
48 const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>((*thit).hit());
49 const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
50
51 if (matchedhit) { //if matched hit...
52
53 // THIS IS THE POINTER TO THE MONO HIT OF A MATCHED HIT
54 const SiStripRecHit2D *monohit=matchedhit->monoHit();
55 const SiStripCluster* monocluster = &*(monohit->cluster());
56 const std::vector<uint16_t> amplitudesmono( monocluster->amplitudes().begin(),
57 monocluster->amplitudes().end());
58 for(size_t ia=0; ia<amplitudesmono.size();ia++)
59 {
60 charge1+=amplitudesmono[ia];
61 }
62
63 // THIS IS THE POINTER TO THE STEREO HIT OF A MATCHED HIT
64 const SiStripRecHit2D *stereohit=matchedhit->stereoHit();
65 const SiStripCluster* stereocluster = &*(stereohit->cluster());
66 const std::vector<uint16_t> amplitudesstereo( stereocluster->amplitudes().begin(),
67 stereocluster->amplitudes().end());
68 for(size_t ia=0; ia<amplitudesstereo.size();ia++)
69 {
70 charge2+=amplitudesstereo[ia];
71 }
72
73 }
74 else if (hit) {
75
76 // hit= POINTER TO THE RECHIT
77 const SiStripCluster* cluster = &*(hit->cluster());
78 const std::vector<uint16_t> amplitudes( cluster->amplitudes().begin(),
79 cluster->amplitudes().end());
80 for(size_t ia=0; ia<amplitudes.size();ia++)
81 {
82 charge1+=amplitudes[ia];
83 }
84 }
85
86 monostereocha = make_pair(charge1, charge2);
87 return monostereocha;
88 }
89
90 std::pair<float,float> TrackLocalAngle::findtrackangle(const TrajectoryMeasurement& theTM)
91 {
92
93 std::pair<float,float> monostereoang;
94 float angle1 = -9999.;
95 float angle2 = -9999.;
96
97 LogDebug("TrackLocalAngle::findtrackangle")<<"rechit and TSOS";
98
99 TrajectoryStateOnSurface tsos = theTM.updatedState();
100 const TransientTrackingRecHit::ConstRecHitPointer thit=theTM.recHit();
101 const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>((*thit).hit());
102 const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
103 LocalVector trackdirection = tsos.localDirection();
104
105 if (matchedhit) { //if matched hit...
106
107 GluedGeomDet * gdet=(GluedGeomDet *)tracker_->idToDet(matchedhit->geographicalId());
108
109 GlobalVector gtrkdir=gdet->toGlobal(trackdirection);
110
111 //trackdirection on monodet
112 const GeomDetUnit * monodet=gdet->monoDet();
113 LocalVector monotkdir=monodet->toLocal(gtrkdir);
114
115 if(monotkdir.z() != 0){
116
117 // THE LOCAL ANGLE (MONO)
118 angle1 = atan(monotkdir.x()/monotkdir.z())*180/TMath::Pi();
119 }
120
121 //cluster and trackdirection on stereo det
122 const GeomDetUnit * stereodet=gdet->stereoDet();
123 LocalVector stereotkdir=stereodet->toLocal(gtrkdir);
124
125 if(stereotkdir.z()!=0){
126
127 // THE LOCAL ANGLE (STEREO)
128 angle2 = atan(stereotkdir.x()/stereotkdir.z())*180/TMath::Pi();
129
130 }
131
132 }
133 else if (hit) {
134
135 if(trackdirection.z()!=0){
136
137 // THE LOCAL ANGLE
138 angle1 = atan(trackdirection.x()/trackdirection.z())*180/TMath::Pi();
139 }
140 }
141
142 monostereoang = make_pair(angle1, angle2);
143 return monostereoang;
144 }
145