CMS 3D CMS Logo

MeasurementByLayerGrouper.cc
Go to the documentation of this file.
7 
8 using namespace std;
9 
10 vector<pair<const DetLayer*, vector<TrajectoryMeasurement> > > MeasurementByLayerGrouper::operator()(const vector<TM>& vtm) const{
11 
12  if(vtm.empty())
13  return vector<pair<const DetLayer*, vector<TM> > >();
14 
15  vector<pair<const DetLayer*, vector<TM> > > result;
16  result.reserve(vtm.size());
17 
18  vector<TM>::const_iterator start = vtm.begin();
19  //here we assume that the TM on the same detLayer are consecutive (as it should)
20  while(start != vtm.end()) {
21  vector<TM>::const_iterator ipart = start;
22  do {ipart++;}
23  while(ipart != vtm.end() &&
24  getDetLayer(*start)==getDetLayer(*ipart) &&
25  getDetLayer(*start) != 0 //the returned pointer will be 0 in case
26  //the measurement contains an invalid hit with no associated detid.
27  //This kind of hits are at most one per layer.
28  //this last condition avoids that 2 consecutive measurements of this kind
29  //are grouped in the same layer.
30  //it would be useful if invalid hit out of the active area were
31  //given the detid reserved for the whole layer instead of 0
32  ) ;
33 
34  vector<TM> group(start, ipart);
35  result.push_back(pair<const DetLayer*, vector<TM> >(getDetLayer(*start),
36  group));
37  start = ipart;
38  }
39 #ifdef debug_MeasurementByLayerGrouper_
40  for (vector<pair<const DetLayer*, vector<TM> > >::const_iterator iter = result.begin(); iter != result.end(); iter++){
41  LogTrace("MeasurementByLayerGrouper|SiTrackerMultiRecHitUpdator") << "DetLayer " << iter->first << " has " << iter->second.size() << " measurements";
42  }
43 #endif
44 
45 
46  return result;
47 }
48 
50  // if the DetLayer is set in the TM...
51  if (tm.layer()) return tm.layer();
52 
53  //if it corresponds to an invalid hit with no geomdet associated
54  //we can't retrieve the DetLayer
55  //because unfortunately the detlayer is not set in these cases
56  //returns 0 for the moment
57  //to be revisited
58 
59  if (tm.recHit()->det()==0){
60  LogDebug("MeasurementByLayerGrouper") <<"This hit has no geomdet associated skipping... ";
61  return 0;
62  }
63 
64  //now the cases in which the detid is set
65 
66  if (!theGeomSearch) {
67  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 ";
68  return 0;
69  }
70 
71  return theGeomSearch->detLayer(tm.recHit()->det()->geographicalId());
72 }
#define LogDebug(id)
Definition: start.py:1
ConstRecHitPointer const & recHit() const
const DetLayer * layer() const
DetLayer getDetLayer(DetId detId, const TrackerTopology *tTopo)
Definition: TrackQuality.cc:98
std::vector< std::pair< const DetLayer *, std::vector< TM > > > operator()(const std::vector< TM > &) const
#define LogTrace(id)
const DetLayer * getDetLayer(const TM &tm) const