CMS 3D CMS Logo

PixelForwardLayer.cc
Go to the documentation of this file.
1 #include "PixelForwardLayer.h"
2 
4 
7 
13 
14 #include "LayerCrossingSide.h"
15 #include "DetGroupMerger.h"
17 
18 using namespace std;
19 
21 
22 PixelForwardLayer::PixelForwardLayer(vector<const PixelBlade*>& blades)
23  : ForwardDetLayer(true), theComps(blades.begin(), blades.end()) {
24  for (vector<const GeometricSearchDet*>::const_iterator it = theComps.begin(); it != theComps.end(); it++) {
25  theBasicComps.insert(theBasicComps.end(), (**it).basicComponents().begin(), (**it).basicComponents().end());
26  }
27 
28  //They should be already phi-ordered. TO BE CHECKED!!
29  //sort( theBlades.begin(), theBlades.end(), PhiLess());
31 
32  //Is a "periodic" binFinderInPhi enough?. TO BE CHECKED!!
33  theBinFinder = BinFinderType(theComps.front()->surface().position().phi(), theComps.size());
34 
35  //--------- DEBUG INFO --------------
36  LogDebug("TkDetLayers") << "DEBUG INFO for PixelForwardLayer"
37  << "\n"
38  << "PixelForwardLayer.surfcace.phi(): " << this->surface().position().phi() << "\n"
39  << "PixelForwardLayer.surfcace.z(): " << this->surface().position().z() << "\n"
40  << "PixelForwardLayer.surfcace.innerR(): " << this->specificSurface().innerRadius() << "\n"
41  << "PixelForwardLayer.surfcace.outerR(): " << this->specificSurface().outerRadius();
42 
43  for (vector<const GeometricSearchDet*>::const_iterator it = theComps.begin(); it != theComps.end(); it++) {
44  LogDebug("TkDetLayers") << "blades phi,z,r: " << (*it)->surface().position().phi() << " , "
45  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
46  }
47  //-----------------------------------
48 }
49 
51  vector<const GeometricSearchDet*>::const_iterator i;
52  for (i = theComps.begin(); i != theComps.end(); i++) {
53  delete *i;
54  }
55 }
56 
58  const Propagator& prop,
59  const MeasurementEstimator& est,
60  std::vector<DetGroup>& result) const {
61  std::vector<DetGroup> closestResult;
62  SubTurbineCrossings crossings;
63 
64  crossings = computeCrossings(tsos, prop.propagationDirection());
65  if (!crossings.isValid) {
66  //edm::LogInfo("TkDetLayers") << "computeCrossings returns invalid in PixelForwardLayer::groupedCompatibleDets:";
67  return;
68  }
69 
70  typedef CompatibleDetToGroupAdder Adder;
71  Adder::add(*theComps[theBinFinder.binIndex(crossings.closestIndex)], tsos, prop, est, closestResult);
72 
73  if (closestResult.empty()) {
74  Adder::add(*theComps[theBinFinder.binIndex(crossings.nextIndex)], tsos, prop, est, result);
75  return;
76  }
77 
78  DetGroupElement closestGel(closestResult.front().front());
79  float window = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
80 
81  //float detWidth = closestGel.det()->surface().bounds().width();
82  //if (crossings.nextDistance < detWidth + window) {
83  vector<DetGroup> nextResult;
84  if (Adder::add(*theComps[theBinFinder.binIndex(crossings.nextIndex)], tsos, prop, est, nextResult)) {
85  int crossingSide = LayerCrossingSide().endcapSide(tsos, prop);
86  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(crossings.closestIndex)],
89  std::move(closestResult), std::move(nextResult), result, theHelicity, crossingSide);
90  } else {
91  result.swap(closestResult);
92  }
93 
94  /*
95  }
96  else {
97  result.swap(closestResult);
98  }
99  */
100 
101  // --- THIS lines may speed up the reconstruction. But it reduces slightly the efficiency.
102  // only loop over neighbors (other than closest and next) if window is BIG
103  //if (window > 0.5*detWidth) {
104  searchNeighbors(tsos, prop, est, crossings, window, result);
105  //}
106 }
107 
109  const Propagator& prop,
110  const MeasurementEstimator& est,
111  const SubTurbineCrossings& crossings,
112  float window,
113  vector<DetGroup>& result) const {
114  typedef CompatibleDetToGroupAdder Adder;
115  int crossingSide = LayerCrossingSide().endcapSide(tsos, prop);
116  typedef DetGroupMerger Merger;
117 
118  int negStart = min(crossings.closestIndex, crossings.nextIndex) - 1;
119  int posStart = max(crossings.closestIndex, crossings.nextIndex) + 1;
120 
121  int quarter = theComps.size() / 4;
122 
123  for (int idet = negStart; idet >= negStart - quarter + 1; idet--) {
124  std::vector<DetGroup> tmp1;
125  const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
126  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
127  // maybe also add shallow crossing angle test here???
128  if (!Adder::add(*neighbor, tsos, prop, est, tmp1))
129  break;
130  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet)], theComps[theBinFinder.binIndex(idet + 1)]);
131  std::vector<DetGroup> tmp2;
132  tmp2.swap(result);
133  std::vector<DetGroup> newResult;
134  Merger::orderAndMergeTwoLevels(std::move(tmp1), std::move(tmp2), newResult, theHelicity, crossingSide);
135  result.swap(newResult);
136  }
137  for (int idet = posStart; idet < posStart + quarter - 1; idet++) {
138  vector<DetGroup> tmp1;
139  const GeometricSearchDet* neighbor = theComps[theBinFinder.binIndex(idet)];
140  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
141  // maybe also add shallow crossing angle test here???
142  if (!Adder::add(*neighbor, tsos, prop, est, tmp1))
143  break;
144  int theHelicity = computeHelicity(theComps[theBinFinder.binIndex(idet - 1)], theComps[theBinFinder.binIndex(idet)]);
145  std::vector<DetGroup> tmp2;
146  tmp2.swap(result);
147  std::vector<DetGroup> newResult;
148  Merger::orderAndMergeTwoLevels(std::move(tmp2), std::move(tmp1), newResult, theHelicity, crossingSide);
149  result.swap(newResult);
150  }
151 }
152 
154  return std::abs(firstBlade->position().z()) < std::abs(secondBlade->position().z()) ? 0 : 1;
155 }
156 
158  const TrajectoryStateOnSurface& startingState, PropagationDirection propDir) const {
160 
161  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
162  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
163 
164  auto rho = startingState.transverseCurvature();
165 
166  HelixArbitraryPlaneCrossing turbineCrossing(startPos, startDir, rho, propDir);
167 
168  pair<bool, double> thePath = turbineCrossing.pathLength(specificSurface());
169 
170  if (!thePath.first) {
171  //edm::LogInfo("TkDetLayers") << "ERROR in PixelForwardLayer: disk not crossed by track" ;
172  return SubTurbineCrossings();
173  }
174 
175  HelixPlaneCrossing::PositionType turbinePoint(turbineCrossing.position(thePath.second));
176  HelixPlaneCrossing::DirectionType turbineDir(turbineCrossing.direction(thePath.second));
177 
178  int closestIndex = theBinFinder.binIndex(turbinePoint.barePhi());
179 
180  const Plane& closestPlane(static_cast<const Plane&>(theComps[closestIndex]->surface()));
181 
182  HelixArbitraryPlaneCrossing2Order theBladeCrossing(turbinePoint, turbineDir, rho);
183 
184  pair<bool, double> theClosestBladePath = theBladeCrossing.pathLength(closestPlane);
185  LocalPoint closestPos = closestPlane.toLocal(GlobalPoint(theBladeCrossing.position(theClosestBladePath.second)));
186 
187  auto closestDist = closestPos.x(); // use fact that local X perp to global Y
188 
189  //int next = turbinePoint.phi() - closestPlane.position().phi() > 0 ? closest+1 : closest-1;
190 
191  int nextIndex = Geom::phiLess(closestPlane.phi(), turbinePoint.barePhi()) ? closestIndex + 1 : closestIndex - 1;
192 
193  const Plane& nextPlane(static_cast<const Plane&>(theComps[theBinFinder.binIndex(nextIndex)]->surface()));
194 
195  pair<bool, double> theNextBladePath = theBladeCrossing.pathLength(nextPlane);
196  LocalPoint nextPos = nextPlane.toLocal(GlobalPoint(theBladeCrossing.position(theNextBladePath.second)));
197 
198  auto nextDist = nextPos.x();
199 
200  if (std::abs(closestDist) < std::abs(nextDist)) {
201  return SubTurbineCrossings(closestIndex, nextIndex, nextDist);
202  } else {
203  return SubTurbineCrossings(nextIndex, closestIndex, closestDist);
204  }
205 }
206 
208  const TrajectoryStateOnSurface& tsos,
209  const MeasurementEstimator& est) {
210  return est.maximalLocalDisplacement(tsos, det->surface()).x();
211 }
MeasurementEstimator
Definition: MeasurementEstimator.h:19
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
LayerCrossingSide
Definition: LayerCrossingSide.h:15
LayerCrossingSide.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
min
T min(T a, T b)
Definition: MathUtil.h:58
VectorUtil.h
ForwardDetLayer::surface
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
Definition: ForwardDetLayer.h:29
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
PixelForwardLayer.h
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
PixelForwardLayer::SubTurbineCrossings::closestIndex
int closestIndex
Definition: PixelForwardLayer.h:41
simple_stat.h
ForwardDetLayer::setSurface
void setSurface(BoundDisk *cp)
Definition: ForwardDetLayer.cc:13
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
DDAxes::x
PixelForwardLayer::computeHelicity
static int computeHelicity(const GeometricSearchDet *firstBlade, const GeometricSearchDet *secondBlade)
Definition: PixelForwardLayer.cc:153
PixelForwardLayer::PixelForwardLayer
PixelForwardLayer(std::vector< const PixelBlade * > &blades)
Definition: PixelForwardLayer.cc:22
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
BoundingBox.h
HelixArbitraryPlaneCrossing::pathLength
std::pair< bool, double > pathLength(const Plane &plane) override
Definition: HelixArbitraryPlaneCrossing.cc:64
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Propagator
Definition: Propagator.h:44
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
PixelForwardLayer::~PixelForwardLayer
~PixelForwardLayer() override
Definition: PixelForwardLayer.cc:50
LayerCrossingSide::endcapSide
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
Definition: LayerCrossingSide.h:31
PixelForwardLayer::SubTurbineCrossings
Definition: PixelForwardLayer.h:36
MeasurementEstimator.h
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
mps_fire.end
end
Definition: mps_fire.py:242
HelixArbitraryPlaneCrossing2Order::position
PositionType position(double s) const override
Definition: HelixArbitraryPlaneCrossing2Order.cc:97
PixelForwardLayer::theComps
std::vector< const GeometricSearchDet * > theComps
Definition: PixelForwardLayer.h:64
HelixArbitraryPlaneCrossing
Definition: HelixArbitraryPlaneCrossing.h:10
Vector2DBase
Definition: Vector2DBase.h:8
DetGroupMerger.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
HelixArbitraryPlaneCrossing::position
PositionType position(double s) const override
Definition: HelixArbitraryPlaneCrossing.cc:149
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
HelixArbitraryPlaneCrossing::direction
DirectionType direction(double s) const override
Definition: HelixArbitraryPlaneCrossing.cc:195
funct::true
true
Definition: Factorize.h:173
HelixArbitraryPlaneCrossing.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
PixelForwardLayer::BinFinderType
PeriodicBinFinderInPhi< float > BinFinderType
Definition: PixelForwardLayer.h:61
PixelForwardLayer::groupedCompatibleDetsV
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: PixelForwardLayer.cc:57
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
HelixArbitraryPlaneCrossing2Order::pathLength
std::pair< bool, double > pathLength(const Plane &) override
Definition: HelixArbitraryPlaneCrossing2Order.cc:35
GloballyPositioned::phi
T phi() const
Definition: GloballyPositioned.h:40
Local2DVector
Vector2DBase< float, LocalTag > Local2DVector
Definition: FourPointPlaneBounds.h:8
PixelForwardLayer::computeWindowSize
static float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: PixelForwardLayer.cc:207
HelixArbitraryPlaneCrossing2Order.h
DetGroupElement
Definition: DetGroup.h:10
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
DetWithState
GeometricSearchDet::DetWithState DetWithState
Definition: PixelForwardLayer.cc:20
PixelForwardLayer::computeCrossings
SubTurbineCrossings computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const __attribute__((hot))
Definition: PixelForwardLayer.cc:157
CompatibleDetToGroupAdder.h
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
DetGroupMerger
Definition: DetGroupMerger.h:7
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ForwardDetLayer::computeSurface
virtual BoundDisk * computeSurface()
Definition: ForwardDetLayer.cc:19
ForwardDetLayer
Definition: ForwardDetLayer.h:22
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
PixelForwardLayer::SubTurbineCrossings::isValid
bool isValid
Definition: PixelForwardLayer.h:40
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
CompatibleDetToGroupAdder
Definition: CompatibleDetToGroupAdder.h:13
Plane
Definition: Plane.h:16
PixelForwardLayer::searchNeighbors
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubTurbineCrossings &crossings, float window, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: PixelForwardLayer.cc:108
PeriodicBinFinderInPhi::binIndex
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
Definition: PeriodicBinFinderInPhi.h:25
mps_fire.result
result
Definition: mps_fire.py:311
PixelForwardLayer::SubTurbineCrossings::nextIndex
int nextIndex
Definition: PixelForwardLayer.h:42
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
SimpleDiskBounds.h
PixelForwardLayer::theBasicComps
std::vector< const GeomDet * > theBasicComps
Definition: PixelForwardLayer.h:65
GeometricSearchDet
Definition: GeometricSearchDet.h:17
HelixArbitraryPlaneCrossing2Order
Definition: HelixArbitraryPlaneCrossing2Order.h:10
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Basic3DVector< float >
PixelForwardLayer::theBinFinder
BinFinderType theBinFinder
Definition: PixelForwardLayer.h:62
HLT_FULL_cff.Merger
Merger
Definition: HLT_FULL_cff.py:7261
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39
MeasurementEstimator::maximalLocalDisplacement
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0