CMS 3D CMS Logo

MTDDetTray.cc
Go to the documentation of this file.
1 
11 
12 #include <iostream>
13 
14 using namespace std;
15 
16 
17 MTDDetTray::MTDDetTray(vector<const GeomDet*>::const_iterator first,
18  vector<const GeomDet*>::const_iterator last)
19  : DetRodOneR(first,last) {
20  init();
21 }
22 
23 MTDDetTray::MTDDetTray(const vector<const GeomDet*>& vdets)
24  : DetRodOneR(vdets) {
25  init();
26 }
27 
28 
31 }
32 
33 
35 
36 const vector<const GeometricSearchDet*>&
38 
39  // FIXME dummy impl.
40  edm::LogError("MTDDetTray") << "temporary dummy implementation of MTDDetTray::components()!!" << endl;
41  static const vector<const GeometricSearchDet*> result;
42  return result;
43 }
44 
45 pair<bool, TrajectoryStateOnSurface>
47  const MeasurementEstimator& est) const {
48 
50  if (ms.isValid()) return make_pair(est.estimate(ms, specificSurface()) != 0, ms);
51  else return make_pair(false, ms);
52 }
53 
54 
55 vector<GeometricSearchDet::DetWithState>
57  const Propagator& prop,
58  const MeasurementEstimator& est) const {
59  const std::string metname = "MTD|RecoMTD|RecoMTDDetLayers|MTDDetTray";
60 
61  LogTrace(metname) << "MTDDetTray::compatibleDets, Surface at R,phi: "
62  << surface().position().perp() << ","
63  << surface().position().phi() << " DetRod pos.";
64  // FIXME << " TS at R,phi: " << startingState.position().perp() << ","
65  // << startingState.position().phi()
66 
67 
68  vector<DetWithState> result;
69 
70  // Propagate and check that the result is within bounds
71  pair<bool, TrajectoryStateOnSurface> compat =
72  compatible(startingState, prop, est);
73 
74  if (!compat.first) {
75  LogTrace(metname) << " MTDDetTray::compatibleDets: not compatible"
76  << " (should not have been selected!)";
77  return result;
78  }
79 
80  // Find the most probable destination component
81  TrajectoryStateOnSurface& tsos = compat.second;
82  GlobalPoint startPos = tsos.globalPosition();
83  int closest = theBinFinder.binIndex(startPos.z());
84  const vector<const GeomDet*> dets = basicComponents();
85  LogTrace(metname) << " MTDDetTray::compatibleDets, closest det: " << closest
86  << " pos: " << dets[closest]->surface().position()
87  << " impact " << startPos;
88 
89  // Add this detector, if it is compatible
90  // NOTE: add performs a null propagation
91  add(closest, result, tsos, prop, est);
92 
93 #ifdef EDM_ML_DEBUG
94  int nclosest = result.size(); int nnextdet=0; // just DEBUG counters
95 #endif
96 
97  // Try the neighbors on each side until no more compatible.
98  // If closest is not compatible the next cannot be either
99  if (!result.empty()) {
100  const BoundPlane& closestPlane(dets[closest]->surface());
102  est.maximalLocalDisplacement( result.front().second, closestPlane);
103 
104  // detHalfLen is assumed to be the same for all detectors.
105  float detHalfLen = closestPlane.bounds().length()/2.;
106 
107  for (unsigned int idet=closest+1; idet < dets.size(); idet++) {
108  LocalPoint nextPos(dets[idet]->toLocal(startPos));
109  if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
110  LogTrace(metname) << " negativeZ: det:" << idet
111  << " pos " << nextPos.y()
112  << " maxDistance " << maxDistance.y();
113 #ifdef EDM_ML_DEBUG
114  nnextdet++;
115 #endif
116  if ( !add(idet, result, tsos, prop, est)) break;
117  } else {
118  break;
119  }
120  }
121 
122  for (int idet=closest-1; idet >= 0; idet--) {
123  LocalPoint nextPos( dets[idet]->toLocal(startPos));
124  if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
125  LogTrace(metname) << " positiveZ: det:" << idet
126  << " pos " << nextPos.y()
127  << " maxDistance " << maxDistance.y();
128 #ifdef EDM_ML_DEBUG
129  nnextdet++;
130 #endif
131  if ( !add(idet, result, tsos, prop, est)) break;
132  } else {
133  break;
134  }
135  }
136  }
137 
138 #ifdef EDM_ML_DEBUG
139  LogTrace(metname) << " MTDDetTray::compatibleDets, size: " << result.size()
140  << " on closest: " << nclosest
141  << " # checked dets: " << nnextdet+1;
142 #endif
143  if (result.empty()) {
144  LogTrace(metname) << " ***Rod not compatible---should have been discarded before!!!";
145  }
146  return result;
147 }
148 
149 
150 vector<DetGroup>
152  const Propagator& prop,
153  const MeasurementEstimator& est) const {
154  // FIXME should return only 1 group
155  cout << "dummy implementation of MTDDetTray::groupedCompatibleDets()" << endl;
156  vector<DetGroup> result;
157  return result;
158 }
GenericBinFinderInZ< float, GeomDet > BinFinderType
Definition: MTDDetTray.h:51
T y() const
Definition: PV2DBase.h:46
T perp() const
Definition: PV3DBase.h:72
void init()
Definition: MTDDetTray.cc:29
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
Definition: DetRod.h:21
const std::string metname
const std::vector< const GeometricSearchDet * > & components() const override
Returns basic components, if any.
Definition: MTDDetTray.cc:37
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDDetTray.cc:56
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
bool add(int idet, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Query detector idet for compatible and add the output to result.
Definition: DetRodOneR.cc:42
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDDetTray.cc:46
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDDetTray.cc:151
T z() const
Definition: PV3DBase.h:64
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
#define end
Definition: vmac.h:39
virtual const Plane & specificSurface() const final
Return the rod surface as a Plane.
Definition: DetRod.h:27
#define LogTrace(id)
const std::vector< const GeomDet * > & basicComponents() const override
Definition: DetRodOneR.h:28
susybsm::MuonSegment ms
Definition: classes.h:31
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
#define begin
Definition: vmac.h:32
BinFinderType theBinFinder
Definition: MTDDetTray.h:52
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
MTDDetTray(std::vector< const GeomDet * >::const_iterator first, std::vector< const GeomDet * >::const_iterator last)
Construct from iterators on GeomDet*.
Definition: MTDDetTray.cc:17
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
~MTDDetTray() override
Destructor.
Definition: MTDDetTray.cc:34
const PositionType & position() const