00001 #include "TrackingTools/PatternTools/interface/TempTrajectory.h"
00002 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005 #include <ext/slist>
00006
00007 TempTrajectory::TempTrajectory( const Trajectory& traj):
00008 theChiSquared(0), theValid(traj.isValid()),
00009 theNumberOfFoundHits(0), theNumberOfLostHits(0),
00010 theDirection(traj.direction()), theDirectionValidity(true),
00011 theSeed( new TrajectorySeed(traj.seed()) ){
00012
00013 Trajectory::DataContainer::const_iterator begin=traj.measurements().begin();
00014 Trajectory::DataContainer::const_iterator end=traj.measurements().end();
00015
00016 for(Trajectory::DataContainer::const_iterator it=begin; it!=end; ++it){
00017 push(*it);
00018 }
00019
00020
00021 }
00022
00023 void TempTrajectory::pop() {
00024 if (!empty()) {
00025 if (theData.back().recHit()->isValid()) theNumberOfFoundHits--;
00026 else if(lost(* (theData.back().recHit()) )) theNumberOfLostHits--;
00027 theData.pop_back();
00028 }
00029 }
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 void TempTrajectory::push( const TrajectoryMeasurement& tm) {
00060 push( tm, tm.estimate());
00061 }
00062
00063 void TempTrajectory::push( const TrajectoryMeasurement& tm, double chi2Increment)
00064 {
00065 theData.push_back(tm);
00066 if ( tm.recHit()->isValid()) {
00067 theNumberOfFoundHits++;
00068 }
00069
00070 else if (lost( *(tm.recHit()) ) ) theNumberOfLostHits++;
00071
00072
00073 theChiSquared += chi2Increment;
00074
00075
00076
00077
00078 if ( !theDirectionValidity && theData.size() >= 2) {
00079 if (theData.front().updatedState().globalPosition().perp() <
00080 theData.back().updatedState().globalPosition().perp())
00081 theDirection = alongMomentum;
00082 else theDirection = oppositeToMomentum;
00083 theDirectionValidity = true;
00084 }
00085 }
00086
00087 void TempTrajectory::push( const TempTrajectory& segment) {
00088 assert (segment.direction() == theDirection) ;
00089 __gnu_cxx::slist<const TrajectoryMeasurement*> list;
00090 for (DataContainer::const_iterator it = segment.measurements().rbegin(), ed = segment.measurements().rend(); it != ed; --it) {
00091 list.push_front(&(*it));
00092 }
00093 for(__gnu_cxx::slist<const TrajectoryMeasurement*>::const_iterator it = list.begin(), ed = list.end(); it != ed; ++it) {
00094 push(**it);
00095 }
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 PropagationDirection TempTrajectory::direction() const {
00114 if (theDirectionValidity) return theDirection;
00115 else throw cms::Exception("TrackingTools/PatternTools","Trajectory::direction() requested but not set");
00116 }
00117
00118 void TempTrajectory::check() const {
00119 if ( theData.size() == 0)
00120 throw cms::Exception("TrackingTools/PatternTools","Trajectory::check() - information requested from empty Trajectory");
00121 }
00122
00123 bool TempTrajectory::lost( const TransientTrackingRecHit& hit)
00124 {
00125 if ( hit.isValid()) return false;
00126 else {
00127
00128
00129
00130
00131
00132 if(hit.geographicalId().rawId() == 0) {return false;}
00133 else{
00134 return hit.getType() == TrackingRecHit::missing;
00135 }
00136 }
00137 }
00138
00139 Trajectory TempTrajectory::toTrajectory() const {
00140 Trajectory traj(*theSeed, theDirection);
00141
00142 traj.reserve(theData.size());
00143 __gnu_cxx::slist<const TrajectoryMeasurement*> list;
00144 for (TempTrajectory::DataContainer::const_iterator it = theData.rbegin(), ed = theData.rend(); it != ed; --it) {
00145 list.push_front(&(*it));
00146 }
00147 for(__gnu_cxx::slist<const TrajectoryMeasurement*>::const_iterator it = list.begin(), ed = list.end(); it != ed; ++it) {
00148 traj.push(**it);
00149 }
00150 return traj;
00151 }
00152