CMS 3D CMS Logo

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