CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuRodBarrelLayer.cc
Go to the documentation of this file.
1 
16 
19 
20 #include "GeneralBinFinderInPhi.h"
21 #include "PhiBorderFinder.h"
22 
23 #include <algorithm>
24 #include <iostream>
25 
26 using namespace std;
27 
28 MuRodBarrelLayer::MuRodBarrelLayer(vector<const DetRod*>& rods) :
29  theRods(rods),
30  theBinFinder(0),
31  isOverlapping(false)
32 {
33  // Sort rods in phi
35 
36  theComponents.reserve(theRods.size());
37  std::copy(theRods.begin(),theRods.end(),back_inserter(theComponents));
38 
39  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRodBarrelLayer";
40 
41  // Cache chamber pointers (the basic components_)
42  for (vector<const DetRod*>::const_iterator it=rods.begin();
43  it!=rods.end(); it++) {
44  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
45  theBasicComps.insert(theBasicComps.end(),tmp2.begin(),tmp2.end());
46  }
47 
48  // Initialize the binfinder
51 
52  if ( bf.isPhiPeriodic() ) {
54  (theRods.front()->position().phi(),theRods.size());
55  } else {
57  }
58 
59  // Compute the layer's surface and bounds (from the components())
61 
62  LogTrace(metname) << "Constructing MuRodBarrelLayer: "
63  << basicComponents().size() << " Dets "
64  << theRods.size() << " Rods "
65  << " R: " << specificSurface().radius()
66  << " Per.: " << bf.isPhiPeriodic()
67  << " Overl.: " << isOverlapping;
68 }
69 
70 
72  delete theBinFinder;
73  for (vector <const DetRod*>::iterator i = theRods.begin();
74  i<theRods.end(); i++) {delete *i;}
75 }
76 
77 
78 vector<GeometricSearchDet::DetWithState>
80  const Propagator& prop,
81  const MeasurementEstimator& est) const {
82 
83  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRodBarrelLayer";
84  vector<DetWithState> result;
85 
86 
87  LogTrace(metname) << "MuRodBarrelLayer::compatibleDets, Cyl R: "
88  << specificSurface().radius()
89  << " TSOS at R= " << startingState.globalPosition().perp()
90  << " phi= " << startingState.globalPosition().phi();
91 
92  pair<bool, TrajectoryStateOnSurface> compat =
93  compatible(startingState, prop, est);
94  if (!compat.first) {
95  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets: not compatible"
96  << " (should not have been selected!)";
97  return vector<DetWithState>();
98  }
99 
100  TrajectoryStateOnSurface& tsos = compat.second;
101 
102  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets, reached layer at: "
103  << tsos.globalPosition()
104  << " R = " << tsos.globalPosition().perp()
105  << " phi = " << tsos.globalPosition().phi();
106 
107  int closest = theBinFinder->binIndex(tsos.globalPosition().phi());
108  const DetRod* closestRod = theRods[closest];
109 
110  // Check the closest rod
111  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets, closestRod: " << closest
112  << " phi : " << closestRod->surface().position().phi()
113  << " FTS phi: " << tsos.globalPosition().phi();
114 
115  result = closestRod->compatibleDets(tsos, prop, est);
116 
117  int nclosest = result.size(); // Debug counter
118 
119  bool checknext = false ;
120  double dist;
121 
122  if (!result.empty()) {
123  // Check if the track go outside closest rod, then look for closest.
124  TrajectoryStateOnSurface& predictedState = result.front().second;
125  float xErr = xError(predictedState, est);
126  float halfWid = closestRod->surface().bounds().width()/2.;
127  dist = predictedState.localPosition().x();
128 
129  // If the layer is overlapping, additionally reduce halfWid by 10%
130  // to account for overlap.
131  // FIXME: should we account for the real amount of overlap?
132  if (isOverlapping) halfWid *= 0.9;
133 
134  if (fabs(dist) + xErr > halfWid) {
135  checknext = true;
136  }
137  } else { // Rod is not compatible
138  //FIXME: Usually next cannot be either. Implement proper logic.
139  // (in general at least one rod should be when this method is called by
140  // compatibleDets() which calls compatible())
141  checknext = true;
142 
143  // Look for the next-to closest in phi.
144  // Note Geom::Phi, subtraction is pi-border-safe
145  if ( tsos.globalPosition().phi()-closestRod->surface().position().phi()>0.)
146  {
147  dist = -1.;
148  } else {
149  dist = +1.;
150  }
151 
152 
153  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets, none on closest rod!";
154  }
155 
156  if (checknext) {
157  int next;
158  if (dist<0.) next = closest+1;
159  else next = closest-1;
160 
161  next = theBinFinder->binIndex(next); // Bin Periodicity
162  const DetRod* nextRod = theRods[next];
163 
164 
165  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets, next-to closest"
166  << " rod: " << next << " dist " << dist
167  << " phi : " << nextRod->surface().position().phi()
168  << " FTS phi: " << tsos.globalPosition().phi();
169 
170  vector<DetWithState> nextRodDets =
171  nextRod->compatibleDets(tsos, prop, est);
172  result.insert(result.end(),
173  nextRodDets.begin(), nextRodDets.end());
174  }
175 
176 
177  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets: found: "
178  << result.size()
179  << " on closest: " << nclosest
180  << " # checked rods: " << 1 + int(checknext);
181 
182  return result;
183 }
184 
185 
186 vector<DetGroup>
188  const Propagator& prop,
189  const MeasurementEstimator& est) const {
190  // FIXME should return only 1 group
191  cout << "dummy implementation of MuRodBarrelLayer::groupedCompatibleDets()" << endl;
192  return vector<DetGroup>();
193 }
194 
195 
197  // FIXME : depending on isOverlapping?
198  return false;
199 }
200 
201 
203  return theBasicComps.front()->subDetector();
204 }
205 
206 const vector<const GeometricSearchDet*>&
208  return theComponents;
209 }
210 
212  const MeasurementEstimator& est) const {
213  const float nSigmas = 3.f;
214  if (tsos.hasError()) {
215  return nSigmas * sqrt(tsos.localError().positionError().xx());
216  }
217  else return nSigmas * 0.5;
218 }
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:71
virtual void initialize()
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
GlobalPoint globalPosition() const
virtual bool hasGroups() const
LocalError positionError() const
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
std::vector< const GeomDet * > theBasicComps
BaseBinFinder< double > * theBinFinder
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< const GeometricSearchDet * > theComponents
tuple result
Definition: query.py:137
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
std::vector< const DetRod * > theRods
const LocalTrajectoryError & localError() const
virtual const std::vector< const GeometricSearchDet * > & components() const
Returns basic components, if any.
#define LogTrace(id)
float xError(const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
const Bounds & bounds() const
Definition: BoundSurface.h:89
bool isPhiPeriodic() const
Returns true if the Dets are periodic in phi.
Definition: DetRod.h:13
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
Definition: DetRod.h:19
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
virtual std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
tuple cout
Definition: gather_cfg.py:121
bool isPhiOverlapping() const
Returns true if any 2 of the Det overlap in phi.
virtual const std::vector< const GeomDet * > & basicComponents() const
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
virtual SubDetector subDetector() const
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
T x() const
Definition: PV3DBase.h:61
virtual float width() const =0
const PositionType & position() const
MuRodBarrelLayer(std::vector< const DetRod * > &rods)
Constructor, takes ownership of pointers.
virtual ~MuRodBarrelLayer()