CMS 3D CMS Logo

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