CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CompositeDetMeasurements.h
Go to the documentation of this file.
1 #ifndef GeometricSearchDetMeasurements_H
2 #define GeometricSearchDetMeasurements_H
3 
11 
12 #include <algorithm>
13 
20 public:
21 
26 
28  theDetSystem(detSysytem) {}
29 
30 
31 
32  /*
33  template <class TrajectoryState>
34  std::vector<DetWithState> getDets( const GeometricSearchDet& det,
35  const TrajectoryState& ts,
36  const Propagator& prop,
37  const MeasurementEstimator& est) const {
38  pair<bool, TSOS> compat = det.compatible( ts, prop, est);
39  if ( compat.first) return det.fastCompatibleDets( compat.second, ts, prop, est);
40  else return std::vector<DetWithState>();
41  }
42 
43  template <class TrajectoryState>
44  std::vector<DetWithState> getDets( const GeometricSearchDet& det,
45  const TrajectoryStateOnSurface& stateOnDet,
46  const TrajectoryState& ts,
47  const Propagator& prop,
48  const MeasurementEstimator& est) const {
49  return det.fastCompatibleDets( stateOnDet, ts, prop, est);
50  }
51 
52  template <class TrajectoryState>
53  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& det,
54  const TrajectoryState& ts,
55  const Propagator& prop,
56  const MeasurementEstimator& est) const {
57  pair<bool, TSOS> compat = det.compatible( ts, prop, est);
58  if ( compat.first) {
59  return det.fastMeasurements( compat.second, ts, prop, est);
60  }
61  else return std::vector<TrajectoryMeasurement>();
62  }
63 
64  template <class TrajectoryState>
65  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& det,
66  const TrajectoryStateOnSurface& stateOnDet,
67  const TrajectoryState& ts,
68  const Propagator& prop,
69  const MeasurementEstimator& est) const {
70  std::vector<DetWithState> compatDets = det.fastCompatibleDets( stateOnDet, ts, prop, est);
71  if (!compatDets.empty()) {
72  return get( det, compatDets, ts, prop, est);
73  }
74  else {
75  std::vector<TrajectoryMeasurement> result;
76  addInvalidMeas( result, stateOnDet, &det);
77  return result;
78  }
79  }
80  */
81 
89  template <class TrajectoryState>
90  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& det,
91  const std::vector<DetWithState>& compatDets,
92  const TrajectoryState& ts,
93  const Propagator& prop,
94  const MeasurementEstimator& est) const;
95  /*
96  template <class TrajectoryState>
97  std::vector<TMG>
98  getGrouped( const GeometricSearchDet& det, const std::vector<DetWithState>& dg,
99  const TrajectoryState& ts, const Propagator& prop,
100  const MeasurementEstimator& est) const {
101  if (!dg.empty()) {
102  std::vector<TMG> result(1);
103  result[0] = TMG( get( det, dg, ts, prop, est), dg);
104  return result;
105  }
106  else return std::vector<TMG>();
107  }
108  */
109 
110  /*
111  void addInvalidMeas( std::vector<TrajectoryMeasurement>& result,
112  const TrajectoryStateOnSurface& ts, const Det* det) const {
113  result.push_back( TM( ts, RecHit(det), 0.));
114  }
115  */
116 
117 private:
118 
120 
121 };
122 
123 
124 template <class TrajectoryState>
125 std::vector<TrajectoryMeasurement>
127  const std::vector<DetWithState>& compatDets,
128  const TrajectoryState& ts,
129  const Propagator& prop,
130  const MeasurementEstimator& est) const
131 {
132  std::vector<TrajectoryMeasurement> result;
133  if (!compatDets.empty()) {
134  for ( std::vector<DetWithState>::const_iterator i=compatDets.begin();
135  i != compatDets.end(); i++) {
136  const MeasurementDet* mdet = theDetSystem->idToDet(i->first->geographicalId());
137  if (mdet == 0) {
138  throw MeasurementDetException( "MeasurementDet not found");
139  }
140 
141  std::vector<TM> tmp = mdet->fastMeasurements( i->second, ts, prop, est);
142  if ( !tmp.empty()) {
143  // only collect valid RecHits
144  std::vector<TM>::iterator end = (tmp.back().recHit()->isValid() ? tmp.end() : tmp.end()-1);
145  result.insert( result.end(), tmp.begin(), end);
146  }
147  }
148  // sort the final result
149  if ( result.size() > 1) {
150  sort( result.begin(), result.end(), TrajMeasLessEstim());
151  }
152 
153  /*
154  if ( !result.empty()) {
155  // invalidMeas on Det of most compatible hit
156  addInvalidMeas( result, result.front().predictedState(), &result.front().recHit().det());
157  }
158  else {
159  // invalid state on first compatible Det
160  addInvalidMeas( result, compatDets.front().second, compatDets.front().first);
161  }
162  */
163 
164  }
165  else {
166  // this case should have been handled by the caller!
167  throw MeasurementDetException("GeometricSearchDetMeasurements::get called with empty std::vector<DetWithState>");
168  }
169  return result;
170 }
171 
172 
173 #endif
int i
Definition: DBlmapReader.cc:9
GeometricSearchDetMeasurements(const MeasurementDetSystem *detSysytem)
GeometricSearchDet::DetWithState DetWithState
const MeasurementDetSystem * theDetSystem
tuple result
Definition: query.py:137
virtual std::vector< TrajectoryMeasurement > fastMeasurements(const TrajectoryStateOnSurface &stateOnThisDet, const TrajectoryStateOnSurface &startingState, const Propagator &, const MeasurementEstimator &) const =0
#define end
Definition: vmac.h:38
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
virtual const MeasurementDet * idToDet(const DetId &id) const =0
Return the pointer to the MeasurementDet corresponding to a given DetId.
std::vector< TrajectoryMeasurement > get(const GeometricSearchDet &det, const std::vector< DetWithState > &compatDets, const TrajectoryState &ts, const Propagator &prop, const MeasurementEstimator &est) const