CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GeometricSearchDetMeasurements.h
Go to the documentation of this file.
1 #ifndef GeometricSearchDetMeasurements_H
2 #define GeometricSearchDetMeasurements_H
3 
12 
13 
14 #include <algorithm>
15 
22 public:
23 
28 
30  theDetSystem(detSysytem) {}
31 
32 
33 
34  /*
35  template <class TrajectoryState>
36  std::vector<DetWithState> getDets( const GeometricSearchDet& det,
37  const TrajectoryState& ts,
38  const Propagator& prop,
39  const MeasurementEstimator& est) const {
40  pair<bool, TSOS> compat = det.compatible( ts, prop, est);
41  if ( compat.first) return det.fastCompatibleDets( compat.second, ts, prop, est);
42  else return std::vector<DetWithState>();
43  }
44 
45  template <class TrajectoryState>
46  std::vector<DetWithState> getDets( const GeometricSearchDet& det,
47  const TrajectoryStateOnSurface& stateOnDet,
48  const TrajectoryState& ts,
49  const Propagator& prop,
50  const MeasurementEstimator& est) const {
51  return det.fastCompatibleDets( stateOnDet, ts, prop, est);
52  }
53 
54  template <class TrajectoryState>
55  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& det,
56  const TrajectoryState& ts,
57  const Propagator& prop,
58  const MeasurementEstimator& est) const {
59  pair<bool, TSOS> compat = det.compatible( ts, prop, est);
60  if ( compat.first) {
61  return det.fastMeasurements( compat.second, ts, prop, est);
62  }
63  else return std::vector<TrajectoryMeasurement>();
64  }
65 
66  template <class TrajectoryState>
67  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& det,
68  const TrajectoryStateOnSurface& stateOnDet,
69  const TrajectoryState& ts,
70  const Propagator& prop,
71  const MeasurementEstimator& est) const {
72  std::vector<DetWithState> compatDets = det.fastCompatibleDets( stateOnDet, ts, prop, est);
73  if (!compatDets.empty()) {
74  return get( det, compatDets, ts, prop, est);
75  }
76  else {
77  std::vector<TrajectoryMeasurement> result;
78  addInvalidMeas( result, stateOnDet, &det);
79  return result;
80  }
81  }
82  */
83 
91  template <class TrajectoryState>
92  std::vector<TrajectoryMeasurement> get( const GeometricSearchDet& layer,
93  const std::vector<DetWithState>& compatDets,
94  const TrajectoryState& ts,
95  const Propagator& prop,
96  const MeasurementEstimator& est) const;
97  /*
98  template <class TrajectoryState>
99  std::vector<TMG>
100  getGrouped( const GeometricSearchDet& det, const std::vector<DetWithState>& dg,
101  const TrajectoryState& ts, const Propagator& prop,
102  const MeasurementEstimator& est) const {
103  if (!dg.empty()) {
104  std::vector<TMG> result(1);
105  result[0] = TMG( get( det, dg, ts, prop, est), dg);
106  return result;
107  }
108  else return std::vector<TMG>();
109  }
110  */
111 
112 
113  void addInvalidMeas( std::vector<TrajectoryMeasurement>& result,
114  const TrajectoryStateOnSurface& ts, const GeomDet* det) const {
115  result.push_back( TM( ts, InvalidTransientRecHit::build(det, TrackingRecHit::missing), 0.F,0));
116  }
117 
118 
119 private:
120 
122 
123 };
124 
125 
126 template <class TrajectoryState>
127 std::vector<TrajectoryMeasurement>
129  const std::vector<DetWithState>& compatDets,
130  const TrajectoryState& ts,
131  const Propagator& prop,
132  const MeasurementEstimator& est) const
133 {
134  std::vector<TrajectoryMeasurement> result;
135  if (!compatDets.empty()) {
136  for ( std::vector<DetWithState>::const_iterator i=compatDets.begin();
137  i != compatDets.end(); i++) {
138  const MeasurementDet* mdet = theDetSystem->idToDet(i->first->geographicalId());
139  if (mdet == 0) {
140  throw MeasurementDetException( "MeasurementDet not found");
141  }
142 
143  std::vector<TM> tmp = mdet->fastMeasurements( i->second, ts, prop, est);
144  if ( !tmp.empty()) {
145  // only collect valid RecHits
146  std::vector<TM>::iterator end = (tmp.back().recHit()->getType() != TrackingRecHit::missing ? tmp.end() : tmp.end()-1);
147  result.insert( result.end(), tmp.begin(), end);
148  }
149  }
150  // WARNING: we might end up with more than one invalid hit of type 'inactive' in result
151  // to be fixed in order to avoid usless double traj candidates.
152 
153  // sort the final result
154  if ( result.size() > 1) {
155  sort( result.begin(), result.end(), TrajMeasLessEstim());
156  }
157 
158 
159  if ( !result.empty()) {
160  // invalidMeas on Det of most compatible hit
161  addInvalidMeas( result, result.front().predictedState(), result.front().recHit()->det());
162  }
163  else {
164  // invalid state on first compatible Det
165  addInvalidMeas( result, compatDets.front().second, compatDets.front().first);
166  }
167 
168 
169  }
170  else {
171  // this case should have been handled by the caller!
172  throw MeasurementDetException("GeometricSearchDetMeasurements::get called with empty std::vector<DetWithState>");
173  }
174  return result;
175 }
176 
177 
178 #endif
int i
Definition: DBlmapReader.cc:9
static RecHitPointer build(const GeomDet *geom, Type type=TrackingRecHit::missing, const DetLayer *layer=0)
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
void addInvalidMeas(std::vector< TrajectoryMeasurement > &result, const TrajectoryStateOnSurface &ts, const GeomDet *det) const
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.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
std::vector< TrajectoryMeasurement > get(const GeometricSearchDet &det, const std::vector< DetWithState > &compatDets, const TrajectoryState &ts, const Propagator &prop, const MeasurementEstimator &est) const