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