CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuRingForwardLayer.cc
Go to the documentation of this file.
1 
14 
16 
17 #include "RBorderFinder.h"
18 #include "GeneralBinFinderInR.h"
19 
20 #include <algorithm>
21 #include <iostream>
22 #include <vector>
23 
24 using namespace std;
25 
26 MuRingForwardLayer::MuRingForwardLayer(const vector<const ForwardDetRing*>& rings) :
27  theRings(rings),
28  theComponents(theRings.begin(),theRings.end()),
29  theBinFinder(0),
30  isOverlapping(false)
31 {
32 
33  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardLayer";
34 
35  // Initial values for R and Z bounds
36  float theRmin = rings.front()->basicComponents().front()->position().perp();
37  float theRmax = theRmin;
38  float theZmin = rings.front()->position().z();
39  float theZmax = theZmin;
40 
41  // Cache chamber pointers (the basic components_)
42  // and find extension in R and Z
43  for (vector<const ForwardDetRing*>::const_iterator it=rings.begin();
44  it!=rings.end(); it++) {
45  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
46  theBasicComps.insert(theBasicComps.end(),tmp2.begin(),tmp2.end());
47 
48  theRmin = min( theRmin, (*it)->specificSurface().innerRadius());
49  theRmax = max( theRmax, (*it)->specificSurface().outerRadius());
50  float halfThick = (*it)->surface().bounds().thickness()/2.;
51  float zCenter = (*it)->surface().position().z();
52  theZmin = min( theZmin, zCenter-halfThick);
53  theZmax = max( theZmax, zCenter+halfThick);
54  }
55 
59 
60  // Build surface
61 
62  float zPos = (theZmax+theZmin)/2.;
63  PositionType pos(0.,0.,zPos);
64  RotationType rot;
65 
66  setSurface(new BoundDisk( pos, rot,
67  SimpleDiskBounds( theRmin, theRmax,
68  theZmin-zPos, theZmax-zPos)));
69 
70 
71 
72  LogTrace(metname) << "Constructing MuRingForwardLayer: "
73  << basicComponents().size() << " Dets "
74  << theRings.size() << " Rings "
75  << " Z: " << specificSurface().position().z()
76  << " R1: " << specificSurface().innerRadius()
77  << " R2: " << specificSurface().outerRadius()
78  << " Per.: " << bf.isRPeriodic()
79  << " Overl.: " << bf.isROverlapping();
80 }
81 
82 
84  delete theBinFinder;
85  for (vector <const ForwardDetRing*>::iterator i = theRings.begin();
86  i<theRings.end(); i++) {delete *i;}
87 }
88 
89 
90 vector<GeometricSearchDet::DetWithState>
92  const Propagator& prop,
93  const MeasurementEstimator& est) const {
94 
95  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRingForwardLayer";
96  vector<DetWithState> result;
97 
98 
99  LogTrace(metname) << "MuRingForwardLayer::compatibleDets,"
100  << " R1 " << specificSurface().innerRadius()
101  << " R2: " << specificSurface().outerRadius()
102  << " FTS at R: " << startingState.globalPosition().perp();
103 
104  pair<bool, TrajectoryStateOnSurface> compat =
105  compatible(startingState, prop, est);
106 
107  if (!compat.first) {
108 
109  LogTrace(metname) << " MuRingForwardLayer::compatibleDets: not compatible"
110  << " (should not have been selected!)";
111  return result;
112  }
113 
114 
115  TrajectoryStateOnSurface& tsos = compat.second;
116 
117  int closest = theBinFinder->binIndex(tsos.globalPosition().perp());
118  const ForwardDetRing* closestRing = theRings[closest];
119 
120  // Check the closest ring
121 
122  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets, closestRing: "
123  << closest
124  << " R1 " << closestRing->specificSurface().innerRadius()
125  << " R2: " << closestRing->specificSurface().outerRadius()
126  << " FTS R: " << tsos.globalPosition().perp();
127  if (tsos.hasError()) {
128  LogTrace(metname) << " sR: " << sqrt(tsos.localError().positionError().yy())
129  << " sX: " << sqrt(tsos.localError().positionError().xx());
130  }
131  LogTrace(metname) << endl;
132 
133 
134  result = closestRing->compatibleDets(tsos, prop, est);
135 
136  int nclosest = result.size(); int nnextdet=0; // MDEBUG counters
137 
138  //FIXME: if closest is not compatible next cannot be either?
139 
140  // Use state on layer surface. Note that local coordinates and errors
141  // are the same on the layer and on all rings surfaces, since
142  // all BoundDisks are centered in 0,0 and have the same rotation.
143  // CAVEAT: if the rings are not at the same Z, the local position and error
144  // will be "Z-projected" to the rings. This is a fairly good approximation.
145  // However in this case additional propagation will be done when calling
146  // compatibleDets.
147  GlobalPoint startPos = tsos.globalPosition();
148  LocalPoint nextPos(surface().toLocal(startPos));
149 
150  for (unsigned int idet=closest+1; idet < theRings.size(); idet++) {
151  bool inside = false;
152  if (tsos.hasError()) {
153  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
154  } else {
155  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
156  }
157  if (inside){
158  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets:NextRing" << idet
159  << " R1 " << theRings[idet]->specificSurface().innerRadius()
160  << " R2: " << theRings[idet]->specificSurface().outerRadius()
161  << " FTS R " << nextPos.perp();
162  nnextdet++;
163  vector<DetWithState> nextRodDets =
164  theRings[idet]->compatibleDets(tsos, prop, est);
165  if (nextRodDets.size()!=0) {
166  result.insert( result.end(),
167  nextRodDets.begin(), nextRodDets.end());
168  } else {
169  break;
170  }
171  }
172  }
173 
174  for (int idet=closest-1; idet >= 0; idet--) {
175  bool inside = false;
176  if (tsos.hasError()) {
177  inside=theRings[idet]->specificSurface().bounds().inside(nextPos,tsos.localError().positionError());
178  } else {
179  inside=theRings[idet]->specificSurface().bounds().inside(nextPos);
180  }
181  if (inside){
182  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets:PreviousRing:" << idet
183  << " R1 " << theRings[idet]->specificSurface().innerRadius()
184  << " R2: " << theRings[idet]->specificSurface().outerRadius()
185  << " FTS R " << nextPos.perp();
186  nnextdet++;
187  vector<DetWithState> nextRodDets =
188  theRings[idet]->compatibleDets(tsos, prop, est);
189  if (nextRodDets.size()!=0) {
190  result.insert( result.end(),
191  nextRodDets.begin(), nextRodDets.end());
192  } else {
193  break;
194  }
195  }
196  }
197 
198  LogTrace(metname) << " MuRingForwardLayer::fastCompatibleDets: found: "
199  << result.size()
200  << " on closest: " << nclosest
201  << " # checked rings: " << 1 + nnextdet;
202 
203  return result;
204 }
205 
206 
207 vector<DetGroup>
209  const Propagator& prop,
210  const MeasurementEstimator& est) const {
211  // FIXME should return only 1 group
212  cout << "dummy implementation of MuRingForwardLayer::groupedCompatibleDets()" << endl;
213  return vector<DetGroup>();
214 }
215 
216 
218  // FIXME : depending on isOverlapping?
219  return false;
220 }
221 
222 
224  return theBasicComps.front()->subDetector();
225 }
226 
227 const vector<const GeometricSearchDet*> &
229  return theComponents;
230 }
int i
Definition: DBlmapReader.cc:9
virtual bool hasGroups() const
float xx() const
Definition: LocalError.h:19
T perp() const
Definition: PV3DBase.h:66
const std::string metname
double zPos
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
void setSurface(BoundDisk *cp)
MuRingForwardLayer(const std::vector< const ForwardDetRing * > &rings)
Constructor, takes ownership of pointers.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
GlobalPoint globalPosition() const
#define min(a, b)
Definition: mlp_lapack.h:161
std::vector< const ForwardDetRing * > theRings
LocalError positionError() const
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
float yy() const
Definition: LocalError.h:21
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
virtual const BoundDisk & specificSurface() const
#define end
Definition: vmac.h:38
const LocalTrajectoryError & localError() const
#define LogTrace(id)
std::vector< const GeometricSearchDet * > theComponents
virtual const std::vector< const GeomDet * > & basicComponents() const
virtual SubDetector subDetector() const
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
BaseBinFinder< double > * theBinFinder
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const
#define begin
Definition: vmac.h:31
float outerRadius() const
The outer radius of the disk.
Definition: BoundDisk.cc:10
virtual const std::vector< const GeometricSearchDet * > & components() const
Returns basic components, if any.
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.cc:6
tuple cout
Definition: gather_cfg.py:41
bool isRPeriodic() const
Returns true if the Dets are periodic in R.
const PositionType & position() const
const BoundDisk & specificSurface() const
Return the ring surface as a BoundDisk.
bool isROverlapping() const
Returns true if any 2 of the Det overlap in R.
std::vector< const GeomDet * > theBasicComps