ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitEdm/Producers/src/HitDropper.cc
Revision: 1.4
Committed: Fri Mar 20 18:01:48 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c, Mit_009b, Mit_009a, Mit_009, Mit_008
Changes since 1.3: +18 -21 lines
Log Message:
Cleanup

File Contents

# Content
1 // $Id: HitDropper.cc,v 1.3 2009/02/06 16:08:44 mrudolph Exp $
2
3 #include "MitEdm/Producers/interface/HitDropper.h"
4 #include "DataFormats/TrackingRecHit/interface/InvalidTrackingRecHit.h"
5 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
6 #include "TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing.h"
7 #include "TrackingTools/GeomPropagators/interface/StraightLinePlaneCrossing.h"
8
9 using namespace edm;
10 using namespace mitedm;
11
12 //--------------------------------------------------------------------------------------------------
13 reco::HitPattern HitDropper::CorrectedHits(const reco::TransientTrack *tTrack,
14 const ThreeVector &vtxPos) const
15 {
16 // Return reco::HitPattern structure for the given track with all hits occuring before vtxPos
17 // on the track (relative to the primary vertex if given) removed.
18 // This version of the function uses an iterative helix-plane intersector and does not (yet)
19 // take into account the uncertainties in vertex position.
20
21 const GlobalPoint vtxPoint(vtxPos.x(),vtxPos.y(),vtxPos.z());
22 const TrajectoryStateClosestToPoint vtxTSCP = tTrack->trajectoryStateClosestToPoint(vtxPoint);
23
24 reco::HitPattern hitPattern;
25 int nHits = 0;
26 for (uint hi=0; hi<tTrack->recHitsSize(); ++hi) {
27 const TrackingRecHit *hit = tTrack->recHit(hi).get();
28 DetId geoId = hit->geographicalId();
29 if(geoId == uint32_t(0)) continue;
30 const GeomDet *det = trackerGeo_->idToDet(geoId);
31
32 HelixArbitraryPlaneCrossing crossing(HelixPlaneCrossing::PositionType(vtxTSCP.theState().position()),
33 HelixPlaneCrossing::DirectionType(vtxTSCP.theState().momentum()),
34 vtxTSCP.theState().transverseCurvature(),
35 anyDirection);
36
37 std::pair<bool,double> crossResult = crossing.pathLength(det->surface());
38
39 if ( crossResult.first && crossResult.second >= 0 ) {
40 hitPattern.set(*hit,nHits);
41 nHits++;
42 }
43 }
44
45 return hitPattern;
46 }
47
48 //--------------------------------------------------------------------------------------------------
49 reco::HitPattern HitDropper::CorrectedHits(const reco::Track *track,
50 const ThreeVector &vtxPos) const
51 {
52 // Build the transient track and then return the corrected HitPattern.
53
54 reco::TransientTrack tTrack = builder_->build(track);
55 return CorrectedHits(&tTrack, vtxPos);
56 }
57
58 //--------------------------------------------------------------------------------------------------
59 reco::HitPattern HitDropper::CorrectedHits(const reco::Track *track,
60 const ThreeVector &vtxPos,
61 const ThreeVector &trkMom,
62 Double_t lxyError,
63 Double_t lzError,
64 Double_t sigmaTolerance) const
65 {
66 // Return reco::HitPattern structure for the given track with all hits occuring before vtxPos
67 // on the track (relative to the primary vertex if given) removed.
68 // This version of the function determines this completely analytically, and taking the
69 // vertex position uncertainty into account, which might be important for particles which decay
70 // within a tracker layer.
71
72 const StraightLinePlaneCrossing::PositionType vtxPosition(vtxPos);
73 const StraightLinePlaneCrossing::DirectionType trkMomentum(trkMom);
74
75 StraightLinePlaneCrossing crossing(vtxPosition,trkMomentum,anyDirection);
76
77 reco::HitPattern hitPattern;
78 int nHits = 0;
79 for (uint hi=0; hi<track->recHitsSize(); ++hi) {
80 const TrackingRecHit *hit = track->recHit(hi).get();
81 DetId geoId = hit->geographicalId();
82 if(geoId == uint32_t(0)) continue;
83 const GeomDet *det = trackerGeo_->idToDet(geoId);
84
85 //calculate intersection of straight line with plane
86 const StraightLinePlaneCrossing::PositionType crossPosition = crossing.position(det->surface()).second;
87 const ThreeVector crossPos(crossPosition.x(), crossPosition.y(), crossPosition.z());
88 const ThreeVector delta = crossPos - vtxPos;
89
90 Double_t lengthOverSigma = 0;
91
92 //calculate distance between vertex and approximate hit position, projected into
93 //the appropriate plane/axis and compared to the uncertainty in vertex position
94 //in that plane/axis
95 if (IsBarrel(det)) {
96 const ThreeVector trkMomXY(trkMom.x(), trkMom.y(), 0.0);
97 Double_t deltaXY = delta.Dot(trkMomXY)/trkMomXY.R();
98 lengthOverSigma = deltaXY/lxyError;
99 }
100 else if (IsDisk(det)) {
101 Double_t deltaZ = delta.z()*trkMom.z()/fabs(trkMom.z());
102 lengthOverSigma = deltaZ/lzError;
103 }
104 else
105 throw edm::Exception(edm::errors::Configuration, "HitDropper::CorrectedHits\n")
106 << "Error! Detector element not in a valid barrel or disk layer." << std::endl;
107
108 //add the hit only if it is after the vertex, allowing for some uncertainty in the vertex position
109 if ( lengthOverSigma>(-sigmaTolerance) ) {
110 hitPattern.set(*hit,nHits);
111 nHits++;
112 }
113 }
114 return hitPattern;
115 }