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