CMS 3D CMS Logo

Phase2EndcapSingleRing.cc
Go to the documentation of this file.
2 
4 
10 
11 #include "LayerCrossingSide.h"
12 #include "DetGroupMerger.h"
14 
15 #include "TkDetUtil.h"
17 
18 #include "DetGroupElementZLess.h"
19 
20 using namespace std;
21 
23 
24 Phase2EndcapSingleRing::Phase2EndcapSingleRing(vector<const GeomDet*>& allDets)
25  : GeometricSearchDet(true), theDets(allDets.begin(), allDets.end()) {
27 
28  theBinFinder = BinFinderType(theDets.front()->surface().position().phi(), theDets.size());
29 
30 #ifdef EDM_ML_DEBUG
31  LogDebug("TkDetLayers") << "DEBUG INFO for Phase2EndcapSingleRing";
32  for (vector<const GeomDet*>::const_iterator it = theDets.begin(); it != theDets.end(); it++) {
33  LogDebug("TkDetLayers") << "Det detId,phi,z,r: " << (*it)->geographicalId().rawId() << " , "
34  << (*it)->surface().position().phi() << " , " << (*it)->surface().position().z() << " , "
35  << (*it)->surface().position().perp();
36  }
37 
38 #endif
39 }
40 
42 
43 const vector<const GeometricSearchDet*>& Phase2EndcapSingleRing::components() const {
44  throw DetLayerException("Phase2EndcapSingleRing doesn't have GeometricSearchDet components");
45 }
46 
47 pair<bool, TrajectoryStateOnSurface> Phase2EndcapSingleRing::compatible(const TrajectoryStateOnSurface&,
48  const Propagator&,
49  const MeasurementEstimator&) const {
50  edm::LogError("TkDetLayers") << "temporary dummy implementation of Phase2EndcapSingleRing::compatible()!!";
51  return pair<bool, TrajectoryStateOnSurface>();
52 }
53 
55  const Propagator& prop,
56  const MeasurementEstimator& est,
57  std::vector<DetGroup>& result) const {
58  SubLayerCrossing crossing;
59 
60  crossing = computeCrossing(tsos, prop.propagationDirection());
61 
62  if (!crossing.isValid())
63  return;
64 
65  std::vector<DetGroup> closestResult;
66 
67  addClosest(tsos, prop, est, crossing, closestResult);
68  if (closestResult.empty())
69  return;
70 
71  DetGroupElement closestGel(closestResult.front().front());
72 
73  float phiWindow = tkDetUtil::computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
74 
75  searchNeighbors(tsos, prop, est, crossing, phiWindow, closestResult, false);
76 
78 }
79 
81  PropagationDirection propDir) const {
82  auto rho = startingState.transverseCurvature();
83 
84  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
85  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
86  HelixForwardPlaneCrossing crossing(startPos, startDir, rho, propDir);
87 
88  pair<bool, double> frontPath = crossing.pathLength(*theDisk);
89  if (!frontPath.first)
90  return SubLayerCrossing();
91 
92  GlobalPoint gFrontPoint(crossing.position(frontPath.second)); //There is only one path
93 
94  int frontIndex = theBinFinder.binIndex(gFrontPoint.barePhi());
95  SubLayerCrossing frontSLC(0, frontIndex, gFrontPoint);
96 
97  return frontSLC;
98 }
99 
101  const Propagator& prop,
102  const MeasurementEstimator& est,
103  const SubLayerCrossing& crossing,
104  vector<DetGroup>& result) const {
105  const vector<const GeomDet*>& sub(subLayer(crossing.subLayerIndex()));
106 
107  const GeomDet* det(sub[crossing.closestDetIndex()]);
108 
109  bool firstgroup = CompatibleDetToGroupAdder::add(*det, tsos, prop, est, result);
110 
111  return firstgroup;
112 }
113 
115  const Propagator& prop,
116  const MeasurementEstimator& est,
117  const SubLayerCrossing& crossing,
118  float window,
119  vector<DetGroup>& result,
120  bool checkClosest) const {
121  const GlobalPoint& gCrossingPos = crossing.position();
122 
123  const vector<const GeomDet*>& sLayer(subLayer(crossing.subLayerIndex()));
124 
125  int closestIndex = crossing.closestDetIndex();
126  int negStartIndex = closestIndex - 1;
127  int posStartIndex = closestIndex + 1;
128 
129  if (checkClosest) { // must decide if the closest is on the neg or pos side
130  if (Geom::phiLess(gCrossingPos.barePhi(), sLayer[closestIndex]->surface().phi())) {
131  posStartIndex = closestIndex;
132  } else {
133  negStartIndex = closestIndex;
134  }
135  }
136 
137  const BinFinderType& binFinder = theBinFinder;
138 
139  typedef CompatibleDetToGroupAdder Adder;
140  int half = sLayer.size() / 2; // to check if dets are called twice....
141  for (int idet = negStartIndex; idet >= negStartIndex - half; idet--) {
142  const GeomDet& neighborDet = *sLayer[binFinder.binIndex(idet)];
143  if (!tkDetUtil::overlapInPhi(gCrossingPos, neighborDet, window))
144  break;
145  if (!Adder::add(neighborDet, tsos, prop, est, result))
146  break;
147  }
148  for (int idet = posStartIndex; idet < posStartIndex + half; idet++) {
149  const GeomDet& neighborDet = *sLayer[binFinder.binIndex(idet)];
150  if (!tkDetUtil::overlapInPhi(gCrossingPos, neighborDet, window))
151  break;
152  if (!Adder::add(neighborDet, tsos, prop, est, result))
153  break;
154  }
155 }
Common base class.
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
PeriodicBinFinderInPhi< float > BinFinderType
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override
Phase2EndcapSingleRing(std::vector< const GeomDet *> &allDets)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
SubLayerCrossing computeCrossing(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const
PropagationDirection
Log< level::Error, false > LogError
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:32
T barePhi() const
Definition: PV3DBase.h:65
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:10
const std::vector< const GeometricSearchDet * > & components() const override
Returns basic components, if any.
static void addSameLevel(std::vector< DetGroup > &&gvec, std::vector< DetGroup > &result)
const std::vector< const GeomDet * > & subLayer(int ind) const
GlobalPoint globalPosition() const
const GlobalPoint & position() const
int closestDetIndex() const
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
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const
GeometricSearchDet::DetWithState DetWithState
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
int subLayerIndex() const
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) __attribute__((hot))
std::vector< const GeomDet * > theDets
ReferenceCountingPointer< BoundDisk > theDisk
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const
~Phase2EndcapSingleRing() override
GlobalVector globalMomentum() const
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)