Go to the documentation of this file.00001 #include "RecoTracker/SiTrackerMRHTools/interface/MeasurementByLayerGrouper.h"
00002 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00003 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
00004 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007
00008
00009
00010 using namespace std;
00011
00012 vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > MeasurementByLayerGrouper::operator()(const vector<TM>& vtm) const{
00013 if(vtm.empty())
00014 return vector<pair<const DetLayer*, vector<TM> > >();
00015
00016 vector<pair<const DetLayer*, vector<TM> > > result;
00017 result.reserve(vtm.size());
00018
00019 vector<TM>::const_iterator start = vtm.begin();
00020
00021 while(start != vtm.end()) {
00022 vector<TM>::const_iterator ipart = start;
00023 do {ipart++;}
00024 while(ipart != vtm.end() &&
00025 getDetLayer(*start)==getDetLayer(*ipart) &&
00026 getDetLayer(*start) != 0
00027
00028
00029
00030
00031
00032
00033 ) ;
00034
00035 vector<TM> group(start, ipart);
00036 result.push_back(pair<const DetLayer*, vector<TM> >(getDetLayer(*start),
00037 group));
00038 start = ipart;
00039 }
00040 #ifdef debug_MeasurementByLayerGrouper_
00041
00042
00043 for (vector<pair<const DetLayer*, vector<TM> > >::const_iterator iter = result.begin(); iter != result.end(); iter++){
00044 LogTrace("MeasurementByLayerGrouper|SiTrackerMultiRecHitUpdator") << "DetLayer " << iter->first << " has " << iter->second.size() << " measurements";
00045 }
00046 #endif
00047
00048
00049
00050 return result;
00051 }
00052
00053 const DetLayer* MeasurementByLayerGrouper::getDetLayer(const TM& tm) const {
00054
00055 if (tm.layer()) return tm.layer();
00056
00057
00058
00059
00060
00061
00062
00063 if (tm.recHit()->det()==0){
00064 LogDebug("MeasurementByLayerGrouper") <<"This hit has no geomdet associated skipping... ";
00065 return 0;
00066 }
00067
00068
00069
00070 if (!theGeomSearch) {
00071 throw cms::Exception("MeasurementByLayerGrouper") << "Impossible to retrieve the det layer because it's not set in the TM and the pointer to the GeometricSearchTracker is 0 ";
00072 return 0;
00073 }
00074
00075 return theGeomSearch->detLayer(tm.recHit()->det()->geographicalId());
00076 }