CMS 3D CMS Logo

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