CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuDetRod.cc
Go to the documentation of this file.
1 
13 
14 #include <iostream>
15 
16 using namespace std;
17 
18 
19 MuDetRod::MuDetRod(vector<const GeomDet*>::const_iterator first,
20  vector<const GeomDet*>::const_iterator last)
21  : DetRodOneR(first,last) {
22  init();
23 }
24 
25 MuDetRod::MuDetRod(const vector<const GeomDet*>& vdets)
26  : DetRodOneR(vdets) {
27  init();
28 }
29 
30 
33 }
34 
35 
37 
38 const vector<const GeometricSearchDet*>&
40 
41  // FIXME dummy impl.
42  cout << "temporary dummy implementation of MuDetRod::components()!!" << endl;
43  static vector<const GeometricSearchDet*> result;
44  return result;
45 }
46 
47 pair<bool, TrajectoryStateOnSurface>
49  const MeasurementEstimator& est) const {
50 
52  if (ms.isValid()) return make_pair(est.estimate(ms, specificSurface()) != 0, ms);
53  else return make_pair(false, ms);
54 }
55 
56 
57 vector<GeometricSearchDet::DetWithState>
59  const Propagator& prop,
60  const MeasurementEstimator& est) const {
61  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuDetRod";
62 
63  LogTrace(metname) << "MuDetRod::compatibleDets, Surface at R,phi: "
64  << surface().position().perp() << ","
65  << surface().position().phi() << " DetRod pos.";
66  // FIXME << " TS at R,phi: " << startingState.position().perp() << ","
67  // << startingState.position().phi()
68 
69 
70  vector<DetWithState> result;
71 
72  // Propagate and check that the result is within bounds
73  pair<bool, TrajectoryStateOnSurface> compat =
74  compatible(startingState, prop, est);
75 
76  if (!compat.first) {
77  LogTrace(metname) << " MuDetRod::compatibleDets: not compatible"
78  << " (should not have been selected!)";
79  return result;
80  }
81 
82  // Find the most probable destination component
83  TrajectoryStateOnSurface& tsos = compat.second;
84  GlobalPoint startPos = tsos.globalPosition();
85  int closest = theBinFinder.binIndex(startPos.z());
86  const vector<const GeomDet*> dets = basicComponents();
87  LogTrace(metname) << " MuDetRod::compatibleDets, closest det: " << closest
88  << " pos: " << dets[closest]->surface().position()
89  << " impact " << startPos;
90 
91  // Add this detector, if it is compatible
92  // NOTE: add performs a null propagation
93  add(closest, result, tsos, prop, est);
94 
95  int nclosest = result.size(); int nnextdet=0; // just DEBUG counters
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  nnextdet++;
114  if ( !add(idet, result, tsos, prop, est)) break;
115  } else {
116  break;
117  }
118  }
119 
120  for (int idet=closest-1; idet >= 0; idet--) {
121  LocalPoint nextPos( dets[idet]->toLocal(startPos));
122  if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
123  LogTrace(metname) << " positiveZ: det:" << idet
124  << " pos " << nextPos.y()
125  << " maxDistance " << maxDistance.y();
126  nnextdet++;
127  if ( !add(idet, result, tsos, prop, est)) break;
128  } else {
129  break;
130  }
131  }
132  }
133 
134  LogTrace(metname) << " MuDetRod::compatibleDets, size: " << result.size()
135  << " on closest: " << nclosest
136  << " # checked dets: " << nnextdet+1;
137  if (result.size()==0) {
138  LogTrace(metname) << " ***Rod not compatible---should have been discarded before!!!";
139  }
140  return result;
141 }
142 
143 
144 vector<DetGroup>
146  const Propagator& prop,
147  const MeasurementEstimator& est) const {
148  // FIXME should return only 1 group
149  cout << "dummy implementation of MuDetRod::groupedCompatibleDets()" << endl;
150  vector<DetGroup> result;
151  return result;
152 }
T y() const
Definition: PV2DBase.h:40
virtual float length() const =0
T perp() const
Definition: PV3DBase.h:66
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TransientTrackingRecHit &hit) const =0
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
T y() const
Definition: PV3DBase.h:57
virtual const BoundPlane & specificSurface() const
Return the rod surface as a BoundPlane.
Definition: DetRod.h:25
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:19
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
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
virtual ~MuDetRod()
Destructor.
Definition: MuDetRod.cc:36
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: MuDetRod.cc:145
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est) const
Definition: MuDetRod.cc:48
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: MuDetRod.cc:58
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:38
GenericBinFinderInZ< float, GeomDet > BinFinderType
Definition: MuDetRod.h:56
bool first
Definition: L1TdeRCT.cc:79
#define LogTrace(id)
void init()
Definition: MuDetRod.cc:31
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:9
const Bounds & bounds() const
Definition: BoundSurface.h:89
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
Definition: DetRod.h:19
BinFinderType theBinFinder
Definition: MuDetRod.h:57
#define begin
Definition: vmac.h:31
virtual int binIndex(T z) const
returns an index in the valid range for the bin closest to Z
tuple cout
Definition: gather_cfg.py:41
virtual const std::vector< const GeomDet * > & basicComponents() const
Definition: DetRodOneR.h:30
const PositionType & position() const
virtual const std::vector< const GeometricSearchDet * > & components() const
Returns basic components, if any.
Definition: MuDetRod.cc:39