CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoTracker/SiTrackerMRHTools/src/SimpleDAFHitCollector.cc

Go to the documentation of this file.
00001 #include "RecoTracker/SiTrackerMRHTools/interface/SimpleDAFHitCollector.h"
00002 #include "RecoTracker/SiTrackerMRHTools/interface/SiTrackerMultiRecHitUpdator.h"
00003 #include "RecoTracker/TransientTrackingRecHit/interface/TSiTrackerMultiRecHit.h"
00004 #include "TrackingTools/PatternTools/interface/MeasurementEstimator.h"
00005 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00006 #include "TrackingTools/TransientTrackingRecHit/interface/InvalidTransientRecHit.h"
00007 #include "TrackingTools/MeasurementDet/interface/MeasurementDet.h"
00008 
00009 #include <vector>
00010 #include <map>
00011 
00012 #define _debug_SimpleDAFHitCollector_ 
00013 
00014 using namespace std;
00015 
00016 vector<TrajectoryMeasurement> SimpleDAFHitCollector::recHits(const Trajectory& traj) const{
00017 
00018         //it assumes that the measurements are sorted in the smoothing direction
00019         vector<TrajectoryMeasurement> meas = traj.measurements();
00020         if (meas.empty()) //return TransientTrackingRecHit::ConstRecHitContainer();     
00021                 return vector<TrajectoryMeasurement>();
00022 
00023 
00024         //TransientTrackingRecHit::ConstRecHitContainer result;
00025         vector<TrajectoryMeasurement> result;
00026 
00027         for(vector<TrajectoryMeasurement>::reverse_iterator imeas = meas.rbegin(); imeas != meas.rend(); imeas++) {
00028                 //if the rechit is associated to a valid detId  
00029                 if(imeas->recHit()->geographicalId().rawId()){
00030                         vector<TrajectoryMeasurement> currentLayerMeas = getMeasurementTracker()->idToDet(imeas->recHit()->geographicalId().rawId())->fastMeasurements(imeas->updatedState(), imeas->updatedState(), *thePropagator, *(getEstimator()));
00031                         buildMultiRecHits(currentLayerMeas, result);
00032                 } else {
00033                         result.push_back(*imeas);
00034                 }
00035         }
00036         LogTrace("MultiRecHitCollector") << "Original Measurement size "  << meas.size() << " SimpleDAFHitCollector returned " << result.size() << " rechits";
00037         //results are sorted in the fitting direction
00038         return result;  
00039 }
00040 
00041 void SimpleDAFHitCollector::buildMultiRecHits(const vector<TrajectoryMeasurement>& vmeas, vector<TrajectoryMeasurement>& result) const {
00042 
00043         if (vmeas.empty()) {
00044                 LogTrace("MultiRecHitCollector") << "fastMeasurements returned an empty vector, should not happen " ; 
00045                 //should we do something?
00046                 //result.push_back(InvalidTransientRecHit::build(0,TrackingRecHit::missing));
00047                 return;
00048         } 
00049 
00050         TrajectoryStateOnSurface state = vmeas.front().predictedState();
00051 
00052         if (state.isValid()==false){
00053                 LogTrace("MultiRecHitCollector") << "first state is invalid; skipping ";
00054                 return;
00055         }
00056 
00057         vector<const TrackingRecHit*> hits;
00058         //      TransientTrackingRecHit::ConstRecHitContainer hits;
00059 
00060         for (vector<TrajectoryMeasurement>::const_iterator imeas = vmeas.begin(); imeas != vmeas.end(); imeas++){
00061                 if (imeas->recHit()->getType() != TrackingRecHit::missing) {
00062                                 LogTrace("MultiRecHitCollector") << "This hit is valid ";
00063                                 hits.push_back(imeas->recHit()->hit());
00064                 }
00065         }
00066 
00067         if (hits.empty()){
00068                 LogTrace("MultiRecHitCollector") << "No valid hits found ";
00069                 return;
00070         }
00071 
00072         result.push_back(TrajectoryMeasurement(state,theUpdator->buildMultiRecHit(hits, state)));       
00073         //      result.push_back(TrajectoryMeasurement(state,theUpdator->update(hits, state))); 
00074 
00075 }
00076 
00077