CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelBlade.cc
Go to the documentation of this file.
2 
4 
9 
13 
14 using namespace std;
15 
17 
18 PixelBlade::PixelBlade(vector<const GeomDet*>& frontDets,
19  vector<const GeomDet*>& backDets):
20  theFrontDets(frontDets), theBackDets(backDets)
21 {
22  theDets.assign(theFrontDets.begin(),theFrontDets.end());
23  theDets.insert(theDets.end(),theBackDets.begin(),theBackDets.end());
24 
28 
29 
30  //--------- DEBUG INFO --------------
31  LogDebug("TkDetLayers") << "DEBUG INFO for PixelBlade" ;
32  LogDebug("TkDetLayers") << "Blade z, perp, innerRadius, outerR: "
33  << this->position().z() << " , "
34  << this->position().perp() << " , "
35  << theDiskSector->innerRadius() << " , "
36  << theDiskSector->outerRadius() ;
37 
38  for(vector<const GeomDet*>::const_iterator it=theFrontDets.begin();
39  it!=theFrontDets.end(); it++){
40  LogDebug("TkDetLayers") << "frontDet phi,z,r: "
41  << (*it)->position().phi() << " , "
42  << (*it)->position().z() << " , "
43  << (*it)->position().perp() ;;
44  }
45 
46  for(vector<const GeomDet*>::const_iterator it=theBackDets.begin();
47  it!=theBackDets.end(); it++){
48  LogDebug("TkDetLayers") << "backDet phi,z,r: "
49  << (*it)->position().phi() << " , "
50  << (*it)->position().z() << " , "
51  << (*it)->position().perp() ;
52  }
53  //-----------------------------------
54 
55 }
56 
57 
58 const vector<const GeometricSearchDet*>&
60  throw DetLayerException("TOBRod doesn't have GeometricSearchDet components");
61 }
62 
63 pair<bool, TrajectoryStateOnSurface>
65  const MeasurementEstimator&) const{
66  edm::LogError("TkDetLayers") << "temporary dummy implementation of PixelBlade::compatible()!!" ;
67  return pair<bool,TrajectoryStateOnSurface>();
68 }
69 
70 
71 
72 void
74  const Propagator& prop,
75  const MeasurementEstimator& est,
76  std::vector<DetGroup> & result) const{
77  SubLayerCrossings crossings;
78  crossings = computeCrossings( tsos, prop.propagationDirection());
79  if(! crossings.isValid()) return;
80 
81  vector<DetGroup> closestResult;
82  addClosest( tsos, prop, est, crossings.closest(), closestResult);
83 
84  if (closestResult.empty()){
85  vector<DetGroup> nextResult;
86  addClosest( tsos, prop, est, crossings.other(), nextResult);
87  if(nextResult.empty()) return;
88 
89  DetGroupElement nextGel( nextResult.front().front());
90  int crossingSide = LayerCrossingSide().endcapSide( nextGel.trajectoryState(), prop);
91 
92  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
93  crossings.closestIndex(), crossingSide);
94  }
95  else {
96  DetGroupElement closestGel( closestResult.front().front());
97  float window = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
98 
99  searchNeighbors( tsos, prop, est, crossings.closest(), window,
100  closestResult, false);
101 
102  vector<DetGroup> nextResult;
103  searchNeighbors( tsos, prop, est, crossings.other(), window,
104  nextResult, true);
105 
106  int crossingSide = LayerCrossingSide().endcapSide( closestGel.trajectoryState(), prop);
107  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
108  crossings.closestIndex(), crossingSide);
109  }
110 }
111 
114  PropagationDirection propDir) const
115 {
116  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
117  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
118  double rho( startingState.transverseCurvature());
119 
120  HelixArbitraryPlaneCrossing crossing( startPos, startDir, rho, propDir);
121 
122  pair<bool,double> innerPath = crossing.pathLength( *theFrontDiskSector);
123  if (!innerPath.first) return SubLayerCrossings();
124 
125  GlobalPoint gInnerPoint( crossing.position(innerPath.second));
126  //Code for use of binfinder
127  //int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.perp());
128  //float innerDist = fabs( theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.z());
129  int innerIndex = findBin(gInnerPoint.perp(),0);
130  float innerDist = fabs( findPosition(innerIndex,0).perp() - gInnerPoint.perp());
131  SubLayerCrossing innerSLC( 0, innerIndex, gInnerPoint);
132 
133  pair<bool,double> outerPath = crossing.pathLength( *theBackDiskSector);
134  if (!outerPath.first) return SubLayerCrossings();
135 
136  GlobalPoint gOuterPoint( crossing.position(outerPath.second));
137  //Code for use of binfinder
138  //int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.perp());
139  //float outerDist = fabs( theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.perp());
140  int outerIndex = findBin(gOuterPoint.perp(),1);
141  float outerDist = fabs( findPosition(outerIndex,1).perp() - gOuterPoint.perp());
142  SubLayerCrossing outerSLC( 1, outerIndex, gOuterPoint);
143 
144  if (innerDist < outerDist) {
145  return SubLayerCrossings( innerSLC, outerSLC, 0);
146  }
147  else {
148  return SubLayerCrossings( outerSLC, innerSLC, 1);
149  }
150 }
151 
152 
153 
154 
155 bool
157  const Propagator& prop,
158  const MeasurementEstimator& est,
159  const SubLayerCrossing& crossing,
160  vector<DetGroup>& result) const
161 {
162 
163  const vector<const GeomDet*>& sBlade( subBlade( crossing.subLayerIndex()));
164  return CompatibleDetToGroupAdder().add( *sBlade[crossing.closestDetIndex()],
165  tsos, prop, est, result);
166 }
167 
168 
170  const TrajectoryStateOnSurface& tsos,
171  const MeasurementEstimator& est) const
172 {
173  return
174  est.maximalLocalDisplacement(tsos, det->surface()).x();
175 }
176 
177 
178 
179 
181  const Propagator& prop,
182  const MeasurementEstimator& est,
183  const SubLayerCrossing& crossing,
184  float window,
185  vector<DetGroup>& result,
186  bool checkClosest) const
187 {
188  GlobalPoint gCrossingPos = crossing.position();
189 
190  const vector<const GeomDet*>& sBlade( subBlade( crossing.subLayerIndex()));
191 
192  int closestIndex = crossing.closestDetIndex();
193  int negStartIndex = closestIndex-1;
194  int posStartIndex = closestIndex+1;
195 
196  if (checkClosest) { // must decide if the closest is on the neg or pos side
197  if (gCrossingPos.perp() < sBlade[closestIndex]->surface().position().perp()) {
198  posStartIndex = closestIndex;
199  }
200  else {
201  negStartIndex = closestIndex;
202  }
203  }
204 
205  typedef CompatibleDetToGroupAdder Adder;
206  for (int idet=negStartIndex; idet >= 0; idet--) {
207  if (!overlap( gCrossingPos, *sBlade[idet], window)) break;
208  if (!Adder::add( *sBlade[idet], tsos, prop, est, result)) break;
209  }
210  for (int idet=posStartIndex; idet < static_cast<int>(sBlade.size()); idet++) {
211  if (!overlap( gCrossingPos, *sBlade[idet], window)) break;
212  if (!Adder::add( *sBlade[idet], tsos, prop, est, result)) break;
213  }
214 }
215 
216 
217 
218 bool PixelBlade::overlap( const GlobalPoint& crossPoint, const GeomDet& det, float window) const
219 {
220  // check if the z window around TSOS overlaps with the detector theDet (with a 1% margin added)
221 
222  // const float tolerance = 0.1;
223  const float relativeMargin = 1.01;
224 
225  LocalPoint localCrossPoint( det.surface().toLocal(crossPoint));
226  // if (fabs(localCrossPoint.z()) > tolerance) {
227  // edm::LogInfo(TkDetLayers) << "PixelBlade::overlap calculation assumes point on surface, but it is off by "
228  // << localCrossPoint.z() ;
229  // }
230 
231  float localX = localCrossPoint.x();
232  float detHalfLength = det.surface().bounds().length()/2.;
233 
234  // edm::LogInfo(TkDetLayers) << "PixelBlade::overlap: Det at " << det.position() << " hit at " << localY
235  // << " Window " << window << " halflength " << detHalfLength ;
236 
237  if ( ( fabs(localX)-window) < relativeMargin*detHalfLength ) { // FIXME: margin hard-wired!
238  return true;
239  } else {
240  return false;
241  }
242 }
243 
244 int
245 PixelBlade::findBin( float R,int diskSectorIndex) const
246 {
247  vector<const GeomDet*> localDets = diskSectorIndex==0 ? theFrontDets : theBackDets;
248 
249  int theBin = 0;
250  float rDiff = fabs( R - localDets.front()->surface().position().perp());;
251  for (vector<const GeomDet*>::const_iterator i=localDets.begin(); i !=localDets.end(); i++){
252  float testDiff = fabs( R - (**i).surface().position().perp());
253  if ( testDiff < rDiff) {
254  rDiff = testDiff;
255  theBin = i - localDets.begin();
256  }
257  }
258  return theBin;
259 }
260 
261 
262 
264 PixelBlade::findPosition(int index,int diskSectorType) const
265 {
266  vector<const GeomDet*> diskSector = diskSectorType == 0 ? theFrontDets : theBackDets;
267  return (diskSector[index])->surface().position();
268 }
269 
#define LogDebug(id)
Common base class.
int i
Definition: DBlmapReader.cc:9
static void orderAndMergeTwoLevels(const std::vector< DetGroup > &one, const std::vector< DetGroup > &two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
def window
Definition: svgfig.py:642
ReferenceCountingPointer< BoundDiskSector > theFrontDiskSector
Definition: PixelBlade.h:88
virtual float length() const =0
T perp() const
Definition: PV3DBase.h:66
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:143
ReferenceCountingPointer< BoundDiskSector > theBackDiskSector
Definition: PixelBlade.h:89
int closestIndex() const
int closestDetIndex() const
Definition: DDAxes.h:10
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
Definition: PixelBlade.cc:169
PropagationDirection
std::vector< const GeomDet * > theFrontDets
Definition: PixelBlade.h:84
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
GlobalPoint findPosition(int index, int diskSectorIndex) const
Definition: PixelBlade.cc:264
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const
Definition: PixelBlade.cc:113
std::vector< const GeomDet * > theBackDets
Definition: PixelBlade.h:85
const std::vector< const GeomDet * > & subBlade(int ind) const
Definition: PixelBlade.h:76
const GlobalPoint & position() const
int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
virtual const std::vector< const GeometricSearchDet * > & components() const
Returns basic components, if any.
Definition: PixelBlade.cc:59
bool overlap(const GlobalPoint &gpos, const GeomDet &det, float phiWin) const
Definition: PixelBlade.cc:218
int findBin(float R, int layer) const
Definition: PixelBlade.cc:245
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const
Definition: PixelBlade.cc:156
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const
Definition: PixelBlade.cc:180
LocalPoint toLocal(const GlobalPoint &gp) const
int subLayerIndex() const
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
PixelBlade(std::vector< const GeomDet * > &frontDets, std::vector< const GeomDet * > &backDets)
Definition: PixelBlade.cc:18
const SubLayerCrossing & other() const
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const
Definition: PixelBlade.cc:64
const Bounds & bounds() const
Definition: BoundSurface.h:89
virtual void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
Definition: PixelBlade.cc:73
virtual const Surface::PositionType & position() const
Returns position of the surface.
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result)
std::vector< const GeomDet * > theDets
Definition: PixelBlade.h:83
const SubLayerCrossing & closest() const
T perp() const
Magnitude of transverse component.
GlobalVector globalMomentum() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:56
ReferenceCountingPointer< BoundDiskSector > theDiskSector
Definition: PixelBlade.h:87
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37