CMS 3D CMS Logo

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