CMS 3D CMS Logo

TIDRing.cc
Go to the documentation of this file.
1 #include "TIDRing.h"
2 
4 
11 
12 #include "LayerCrossingSide.h"
13 #include "DetGroupMerger.h"
15 
16 #include "TkDetUtil.h"
18 
19 using namespace std;
20 
22 
23 TIDRing::TIDRing(std::vector<const GeomDet*>& innerDets, std::vector<const GeomDet*>& outerDets)
25  theFrontDets(innerDets.begin(), innerDets.end()),
26  theBackDets(outerDets.begin(), outerDets.end()) {
27  theDets.assign(theFrontDets.begin(), theFrontDets.end());
28  theDets.insert(theDets.end(), theBackDets.begin(), theBackDets.end());
29 
30  // the dets should be already phi-ordered. TO BE CHECKED
31  //sort( theFrontDets.begin(), theFrontDets.end(), DetLessPhi() );
32  //sort( theBackDets.begin(), theBackDets.end(), DetLessPhi() );
33 
35 
38 
39  theFrontBinFinder = BinFinderType(theFrontDets.front()->surface().position().phi(), theFrontDets.size());
40  theBackBinFinder = BinFinderType(theBackDets.front()->surface().position().phi(), theBackDets.size());
41 
42  LogDebug("TkDetLayers") << "DEBUG INFO for TIDRing";
43  for (vector<const GeomDet*>::const_iterator it = theFrontDets.begin(); it != theFrontDets.end(); it++) {
44  LogDebug("TkDetLayers") << "frontDet phi,z,r: " << (*it)->surface().position().phi() << " , "
45  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
46  }
47 
48  for (vector<const GeomDet*>::const_iterator it = theBackDets.begin(); it != theBackDets.end(); it++) {
49  LogDebug("TkDetLayers") << "backDet phi,z,r: " << (*it)->surface().position().phi() << " , "
50  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
51  }
52 }
53 
55 
56 const vector<const GeometricSearchDet*>& TIDRing::components() const {
57  throw DetLayerException("TIDRing doesn't have GeometricSearchDet components");
58 }
59 
60 pair<bool, TrajectoryStateOnSurface> TIDRing::compatible(const TrajectoryStateOnSurface&,
61  const Propagator&,
62  const MeasurementEstimator&) const {
63  edm::LogError("TkDetLayers") << "temporary dummy implementation of TIDRing::compatible()!!";
64  return pair<bool, TrajectoryStateOnSurface>();
65 }
66 
68  const Propagator& prop,
69  const MeasurementEstimator& est,
70  std::vector<DetGroup>& result) const {
71  SubLayerCrossings crossings;
72  crossings = computeCrossings(tsos, prop.propagationDirection());
73  if (!crossings.isValid())
74  return;
75 
76  std::vector<DetGroup> closestResult;
77  addClosest(tsos, prop, est, crossings.closest(), closestResult);
78  if (closestResult.empty())
79  return;
80 
81  DetGroupElement closestGel(closestResult.front().front());
82  float phiWindow = tkDetUtil::computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
83  searchNeighbors(tsos, prop, est, crossings.closest(), phiWindow, closestResult, false);
84 
85  vector<DetGroup> nextResult;
86  searchNeighbors(tsos, prop, est, crossings.other(), phiWindow, nextResult, true);
87 
88  int crossingSide = LayerCrossingSide().endcapSide(closestGel.trajectoryState(), prop);
90  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
91 }
92 
93 // indentical in CompositeTECWedge
95  PropagationDirection propDir) const {
96  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
97  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
98 
99  auto rho = startingState.transverseCurvature();
100 
101  HelixForwardPlaneCrossing crossing(startPos, startDir, rho, propDir);
102 
103  pair<bool, double> frontPath = crossing.pathLength(*theFrontDisk);
104  if (!frontPath.first)
105  return SubLayerCrossings();
106 
107  pair<bool, double> backPath = crossing.pathLength(*theBackDisk);
108  if (!backPath.first)
109  return SubLayerCrossings();
110 
111  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
112  GlobalPoint gBackPoint(crossing.position(backPath.second));
113 
114  int frontIndex = theFrontBinFinder.binIndex(gFrontPoint.barePhi());
115  SubLayerCrossing frontSLC(0, frontIndex, gFrontPoint);
116 
117  int backIndex = theBackBinFinder.binIndex(gBackPoint.barePhi());
118  SubLayerCrossing backSLC(1, backIndex, gBackPoint);
119 
120  // 0ss: frontDisk has index=0, backDisk has index=1
121  float frontDist = std::abs(Geom::deltaPhi(gFrontPoint.barePhi(), theFrontDets[frontIndex]->surface().phi()));
122  float backDist = std::abs(Geom::deltaPhi(gBackPoint.barePhi(), theBackDets[backIndex]->surface().phi()));
123 
124  if (frontDist < backDist) {
125  return SubLayerCrossings(frontSLC, backSLC, 0);
126  } else {
127  return SubLayerCrossings(backSLC, frontSLC, 1);
128  }
129 }
130 
132  const Propagator& prop,
133  const MeasurementEstimator& est,
134  const SubLayerCrossing& crossing,
135  vector<DetGroup>& result) const {
136  const vector<const GeomDet*>& sub(subLayer(crossing.subLayerIndex()));
137  const GeomDet* det(sub[crossing.closestDetIndex()]);
138  return CompatibleDetToGroupAdder::add(*det, tsos, prop, est, result);
139 }
140 
142  const Propagator& prop,
143  const MeasurementEstimator& est,
144  const SubLayerCrossing& crossing,
145  float window,
146  vector<DetGroup>& result,
147  bool checkClosest) const {
148  const GlobalPoint& gCrossingPos = crossing.position();
149 
150  const vector<const GeomDet*>& sLayer(subLayer(crossing.subLayerIndex()));
151 
152  int closestIndex = crossing.closestDetIndex();
153  int negStartIndex = closestIndex - 1;
154  int posStartIndex = closestIndex + 1;
155 
156  if (checkClosest) { // must decide if the closest is on the neg or pos side
157  if (Geom::phiLess(gCrossingPos.barePhi(), sLayer[closestIndex]->surface().phi())) {
158  posStartIndex = closestIndex;
159  } else {
160  negStartIndex = closestIndex;
161  }
162  }
163 
164  const BinFinderType& binFinder = (crossing.subLayerIndex() == 0 ? theFrontBinFinder : theBackBinFinder);
165 
166  typedef CompatibleDetToGroupAdder Adder;
167  int half = sLayer.size() / 2; // to check if dets are called twice....
168  for (int idet = negStartIndex; idet >= negStartIndex - half; idet--) {
169  const GeomDet& neighborDet = *sLayer[binFinder.binIndex(idet)];
170  if (!tkDetUtil::overlapInPhi(gCrossingPos, neighborDet, window))
171  break;
172  if (!Adder::add(neighborDet, tsos, prop, est, result))
173  break;
174  // maybe also add shallow crossing angle test here???
175  }
176  for (int idet = posStartIndex; idet < posStartIndex + half; idet++) {
177  const GeomDet& neighborDet = *sLayer[binFinder.binIndex(idet)];
178  if (!tkDetUtil::overlapInPhi(gCrossingPos, neighborDet, window))
179  break;
180  if (!Adder::add(neighborDet, tsos, prop, est, result))
181  break;
182  // maybe also add shallow crossing angle test here???
183  }
184 }
SubLayerCrossing::position
const GlobalPoint & position() const
Definition: SubLayerCrossings.h:14
MeasurementEstimator
Definition: MeasurementEstimator.h:19
tkDetUtil::computeWindowSize
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:10
SubLayerCrossings::isValid
bool isValid()
Definition: SubLayerCrossings.h:28
TIDRing::TIDRing
TIDRing(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets)
Definition: TIDRing.cc:23
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
TIDRing::theDisk
ReferenceCountingPointer< BoundDisk > theDisk
Definition: TIDRing.h:64
LayerCrossingSide
Definition: LayerCrossingSide.h:15
LayerCrossingSide.h
TIDRing::theBackDets
std::vector< const GeomDet * > theBackDets
Definition: TIDRing.h:62
SubLayerCrossings::closestIndex
int closestIndex() const
Definition: SubLayerCrossings.h:31
VectorUtil.h
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
TIDRing::subLayer
const std::vector< const GeomDet * > & subLayer(int ind) const
Definition: TIDRing.h:57
ForwardRingDiskBuilderFromDet.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
TIDRing::addClosest
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TIDRing.cc:131
TIDRing::theBackDisk
ReferenceCountingPointer< BoundDisk > theBackDisk
Definition: TIDRing.h:66
TIDRing::computeCrossings
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
Definition: TIDRing.cc:94
TIDRing::theFrontDets
std::vector< const GeomDet * > theFrontDets
Definition: TIDRing.h:61
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
TIDRing::theDets
std::vector< const GeomDet * > theDets
Definition: TIDRing.h:60
TIDRing::components
const std::vector< const GeometricSearchDet * > & components() const override __attribute__((cold))
Returns basic components, if any.
Definition: TIDRing.cc:56
TIDRing::groupedCompatibleDetsV
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: TIDRing.cc:67
TIDRing::compatible
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
Definition: TIDRing.cc:60
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TIDRing::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: TIDRing.cc:141
DetLayerException.h
LayerCrossingSide::endcapSide
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
Definition: LayerCrossingSide.h:31
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
MeasurementEstimator.h
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
mps_fire.end
end
Definition: mps_fire.py:242
DetGroupMerger.h
TIDRing::theBackBinFinder
BinFinderType theBackBinFinder
Definition: TIDRing.h:71
Point3DBase< float, GlobalTag >
trackingPOGFilters_cfi.phiWindow
phiWindow
Definition: trackingPOGFilters_cfi.py:109
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
TkDetUtil.h
funct::true
true
Definition: Factorize.h:173
TIDRing.h
DetWithState
GeometricSearchDet::DetWithState DetWithState
Definition: TIDRing.cc:21
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
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
TIDRing::theFrontDisk
ReferenceCountingPointer< BoundDisk > theFrontDisk
Definition: TIDRing.h:65
SubLayerCrossing::closestDetIndex
int closestDetIndex() const
Definition: SubLayerCrossings.h:13
DetGroupElement
Definition: DetGroup.h:10
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
tkDetUtil::overlapInPhi
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:18
CompatibleDetToGroupAdder.h
HelixForwardPlaneCrossing::position
PositionType position(double s) const override
Definition: HelixForwardPlaneCrossing.cc:38
DetLayerException
Common base class.
Definition: DetLayerException.h:15
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TIDRing::~TIDRing
~TIDRing() override
Definition: TIDRing.cc:54
PeriodicBinFinderInPhi< float >
HelixForwardPlaneCrossing::pathLength
std::pair< bool, double > pathLength(const Plane &plane) override
Definition: HelixForwardPlaneCrossing.h:28
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
CompatibleDetToGroupAdder
Definition: CompatibleDetToGroupAdder.h:13
SubLayerCrossings::other
const SubLayerCrossing & other() const
Definition: SubLayerCrossings.h:30
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
ForwardRingDiskBuilderFromDet
Definition: ForwardRingDiskBuilderFromDet.h:19
SubLayerCrossing
Definition: SubLayerCrossings.h:7
SubLayerCrossing::subLayerIndex
int subLayerIndex() const
Definition: SubLayerCrossings.h:12
mps_fire.result
result
Definition: mps_fire.py:311
HelixForwardPlaneCrossing
Definition: HelixForwardPlaneCrossing.h:14
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GeometricSearchDet
Definition: GeometricSearchDet.h:17
rangesIntersect.h
TIDRing::theFrontBinFinder
BinFinderType theFrontBinFinder
Definition: TIDRing.h:70
Basic3DVector< float >
HelixForwardPlaneCrossing.h
TIDRing::BinFinderType
PeriodicBinFinderInPhi< float > BinFinderType
Definition: TIDRing.h:68
SubLayerCrossings
Definition: SubLayerCrossings.h:22