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