CMS 3D CMS Logo

MuDetRing.cc
Go to the documentation of this file.
1 
11 
12 #include <iostream>
13 #include <vector>
14 
15 using namespace std;
16 
17 MuDetRing::MuDetRing(vector<const GeomDet*>::const_iterator first, vector<const GeomDet*>::const_iterator last)
19  init();
20 }
21 
22 MuDetRing::MuDetRing(const vector<const GeomDet*>& vdets) : ForwardDetRingOneZ(vdets) { init(); }
23 
26 }
27 
29 
30 const vector<const GeometricSearchDet*>& MuDetRing::components() const {
31  // FIXME dummy impl.
32  cout << "temporary dummy implementation of MuDetRing::components()!!" << endl;
33  static const vector<const GeometricSearchDet*> result;
34  return result;
35 }
36 
37 pair<bool, TrajectoryStateOnSurface> MuDetRing::compatible(const TrajectoryStateOnSurface& ts,
38  const Propagator& prop,
39  const MeasurementEstimator& est) const {
40  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuDetRing";
42 
43  LogTrace(metname) << "MuDetRing::compatible, Surface at Z: " << specificSurface().position().z()
44  << " R1: " << specificSurface().innerRadius() << " R2: " << specificSurface().outerRadius()
45  << " TS at Z,R: " << ts.globalPosition().z() << "," << ts.globalPosition().perp();
46  if (ms.isValid()) {
47  LogTrace(metname) << " DEST at Z,R: " << ms.globalPosition().z() << "," << ms.globalPosition().perp()
48  << " local Z: " << ms.localPosition().z() << endl;
49  } else
50  LogTrace(metname) << " DEST: not valid" << endl;
51 
52  if (ms.isValid())
53  return make_pair(est.estimate(ms, specificSurface()) != 0, ms);
54  else
55  return make_pair(false, ms);
56 }
57 
58 vector<GeometricSearchDet::DetWithState> MuDetRing::compatibleDets(const TrajectoryStateOnSurface& startingState,
59  const Propagator& prop,
60  const MeasurementEstimator& est) const {
61  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuDetRing";
62 
63  LogTrace(metname) << "MuDetRing::compatibleDets, Surface at Z: " << surface().position().z()
64  << " R1: " << specificSurface().innerRadius() << " R2: " << specificSurface().outerRadius()
65  << " TS at Z,R: " << startingState.globalPosition().z() << ","
66  << startingState.globalPosition().perp() << " DetRing pos." << position();
67 
68  vector<DetWithState> result;
69 
70  // Propagate and check that the result is within bounds
71  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
72  if (!compat.first) {
73  LogTrace(metname) << " MuDetRing::compatibleDets: not compatible"
74  << " (should not have been selected!)";
75  return result;
76  }
77 
78  // Find the most probable destination component
79  TrajectoryStateOnSurface& tsos = compat.second;
80  GlobalPoint startPos = tsos.globalPosition();
81  int closest = theBinFinder.binIndex(startPos.phi());
82  const vector<const GeomDet*> dets = basicComponents();
83  LogTrace(metname) << " MuDetRing::compatibleDets, closest det: " << closest
84  << " Phi: " << dets[closest]->surface().position().phi() << " impactPhi " << startPos.phi();
85 
86  // Add this detector, if it is compatible
87  // NOTE: add performs a null propagation
88  add(closest, result, tsos, prop, est);
89 
90  int nclosest = result.size();
91  int nnextdet = 0; // MDEBUG counters
92 
93  // Try the neighbors on each side until no more compatible.
94  float dphi = 0;
95  if (!result.empty()) { // If closest is not compatible the next cannot be either
96  float nSigmas = 3.;
97  if (result.back().second.hasError()) {
98  dphi = nSigmas * atan(sqrt(result.back().second.localError().positionError().xx()) /
99  result.back().second.globalPosition().perp());
100  }
101  } else {
102  LogTrace(metname) << " MuDetRing::compatibleDets, closest not compatible!";
103  //FIXME: if closest is not compatible the next cannot be either
104  }
105 
106  for (int idet = closest + 1; idet < closest + int(dets.size()) / 4 + 1; idet++) {
107  // FIXME: should use dphi to decide if det must be queried.
108  // Right now query until not compatible.
109  int idetp = theBinFinder.binIndex(idet);
110  {
111  LogTrace(metname) << " next det:" << idetp << " at Z: " << dets[idetp]->position().z()
112  << " phi: " << dets[idetp]->position().phi() << " FTS phi " << startPos.phi() << " max dphi "
113  << dphi;
114  nnextdet++;
115  if (!add(idetp, result, tsos, prop, est))
116  break;
117  }
118  }
119 
120  for (int idet = closest - 1; idet > closest - int(dets.size()) / 4 - 1; idet--) {
121  // FIXME: should use dphi to decide if det must be queried.
122  // Right now query until not compatible.
123  int idetp = theBinFinder.binIndex(idet);
124  {
125  LogTrace(metname) << " previous det:" << idetp << " " << idet << " " << closest - dets.size() / 4 - 1
126  << " at Z: " << dets[idetp]->position().z() << " phi: " << dets[idetp]->position().phi()
127  << " FTS phi " << startPos.phi() << " max dphi" << dphi;
128  nnextdet++;
129  if (!add(idetp, result, tsos, prop, est))
130  break;
131  }
132  }
133 
134  LogTrace(metname) << " MuDetRing::compatibleDets, size: " << result.size() << " on closest: " << nclosest
135  << " # checked dets: " << nnextdet + 1;
136 
137  if (result.empty()) {
138  LogTrace(metname) << " ***Ring not compatible,should have been discarded before!!!";
139  }
140 
141  return result;
142 }
143 
144 vector<DetGroup> MuDetRing::groupedCompatibleDets(const TrajectoryStateOnSurface& startingState,
145  const Propagator& prop,
146  const MeasurementEstimator& est) const {
147  // FIXME should be implemented to allow returning overlapping chambers
148  // as separate groups!
149  cout << "dummy implementation of MuDetRod::groupedCompatibleDets()" << endl;
150  vector<DetGroup> result;
151  return result;
152 }
size
Write out results.
virtual const Surface::PositionType & position() const
Returns position of the surface.
T perp() const
Definition: PV3DBase.h:69
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
MuDetRing(std::vector< const GeomDet *>::const_iterator first, std::vector< const GeomDet *>::const_iterator last)
Construct from iterators on GeomDet*.
Definition: MuDetRing.cc:17
const std::vector< const GeomDet * > & basicComponents() const override
T z() const
Definition: PV3DBase.h:61
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
~MuDetRing() override
Definition: MuDetRing.cc:28
const BoundDisk & specificSurface() const
Return the ring surface as a BoundDisk.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
#define LogTrace(id)
const std::vector< const GeometricSearchDet * > & components() const override
Returns basic components, if any.
Definition: MuDetRing.cc:30
PeriodicBinFinderInPhi< float > BinFinderType
Definition: MuDetRing.h:43
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:19
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MuDetRing.cc:144
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MuDetRing.cc:58
const PositionType & position() const
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MuDetRing.cc:37
void init()
Definition: MuDetRing.cc:24
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
bool add(int idet, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const
BinFinderType theBinFinder
Definition: MuDetRing.h:44