CMS 3D CMS Logo

TOBRod.cc
Go to the documentation of this file.
1 #include "TOBRod.h"
2 
4 
9 
10 #include "LayerCrossingSide.h"
11 #include "DetGroupMerger.h"
13 
14 using namespace std;
15 
17 
18 namespace {
19  class DetZLess {
20  public:
21  bool operator()(const GeomDet* a, const GeomDet* b) const { return (a->position().z() < b->position().z()); }
22  };
23 } // namespace
24 
25 TOBRod::TOBRod(vector<const GeomDet*>& innerDets, vector<const GeomDet*>& outerDets)
26  : DetRod(true), theInnerDets(innerDets), theOuterDets(outerDets) {
27  theDets.assign(theInnerDets.begin(), theInnerDets.end());
28  theDets.insert(theDets.end(), theOuterDets.begin(), theOuterDets.end());
29 
30  RodPlaneBuilderFromDet planeBuilder;
31  setPlane(planeBuilder(theDets));
32  theInnerPlane = planeBuilder(theInnerDets);
33  theOuterPlane = planeBuilder(theOuterDets);
34 
35  sort(theDets.begin(), theDets.end(), DetZLess());
36  sort(theInnerDets.begin(), theInnerDets.end(), DetZLess());
37  sort(theOuterDets.begin(), theOuterDets.end(), DetZLess());
40 
41  LogDebug("TkDetLayers") << "==== DEBUG TOBRod =====";
42  for (vector<const GeomDet*>::const_iterator i = theInnerDets.begin(); i != theInnerDets.end(); i++) {
43  LogDebug("TkDetLayers") << "inner TOBRod's Det pos z,perp,eta,phi: " << (**i).position().z() << " , "
44  << (**i).position().perp() << " , " << (**i).position().eta() << " , "
45  << (**i).position().phi();
46  }
47 
48  for (vector<const GeomDet*>::const_iterator i = theOuterDets.begin(); i != theOuterDets.end(); i++) {
49  LogDebug("TkDetLayers") << "outer TOBRod's Det pos z,perp,eta,phi: " << (**i).position().z() << " , "
50  << (**i).position().perp() << " , " << (**i).position().eta() << " , "
51  << (**i).position().phi();
52  }
53  LogDebug("TkDetLayers") << "==== end DEBUG TOBRod =====";
54 }
55 
57 
58 const vector<const GeometricSearchDet*>& TOBRod::components() const {
59  throw DetLayerException("TOBRod doesn't have GeometricSearchDet components");
60 }
61 
62 pair<bool, TrajectoryStateOnSurface> TOBRod::compatible(const TrajectoryStateOnSurface& ts,
63  const Propagator&,
64  const MeasurementEstimator&) const {
65  edm::LogError("TkDetLayers") << "temporary dummy implementation of TOBRod::compatible()!!";
66  return pair<bool, TrajectoryStateOnSurface>();
67 }
68 
70  const Propagator& prop,
71  const MeasurementEstimator& est,
72  std::vector<DetGroup>& result) const {
73  SubLayerCrossings crossings;
74  crossings = computeCrossings(tsos, prop.propagationDirection());
75  if (!crossings.isValid())
76  return;
77 
78  std::vector<DetGroup> closestResult;
79  addClosest(tsos, prop, est, crossings.closest(), closestResult);
80  if (closestResult.empty()) {
81  std::vector<DetGroup> nextResult;
82  addClosest(tsos, prop, est, crossings.other(), nextResult);
83  if (nextResult.empty())
84  return;
85 
86  DetGroupElement nextGel(nextResult.front().front());
87  int crossingSide = LayerCrossingSide().barrelSide(nextGel.trajectoryState(), prop);
89  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
90  } else {
91  DetGroupElement closestGel(closestResult.front().front());
92  float window = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
93 
94  searchNeighbors(tsos, prop, est, crossings.closest(), window, closestResult, false);
95 
96  std::vector<DetGroup> nextResult;
97  searchNeighbors(tsos, prop, est, crossings.other(), window, nextResult, true);
98 
99  int crossingSide = LayerCrossingSide().barrelSide(closestGel.trajectoryState(), prop);
101  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
102  }
103 }
104 
106  PropagationDirection propDir) const {
107  GlobalPoint startPos(startingState.globalPosition());
108  GlobalVector startDir(startingState.globalMomentum());
109  double rho(startingState.transverseCurvature());
110 
111  HelixBarrelPlaneCrossingByCircle crossing(startPos, startDir, rho, propDir);
112 
113  std::pair<bool, double> outerPath = crossing.pathLength(*theOuterPlane);
114  if (!outerPath.first)
115  return SubLayerCrossings();
116  GlobalPoint gOuterPoint(crossing.position(outerPath.second));
117 
118  std::pair<bool, double> innerPath = crossing.pathLength(*theInnerPlane);
119  if (!innerPath.first)
120  return SubLayerCrossings();
121  GlobalPoint gInnerPoint(crossing.position(innerPath.second));
122 
123  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.z());
124  float innerDist = std::abs(theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.z());
125  SubLayerCrossing innerSLC(0, innerIndex, gInnerPoint);
126 
127  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.z());
128  float outerDist = std::abs(theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.z());
129  SubLayerCrossing outerSLC(1, outerIndex, gOuterPoint);
130 
131  if (innerDist < outerDist) {
132  return SubLayerCrossings(innerSLC, outerSLC, 0);
133  } else {
134  return SubLayerCrossings(outerSLC, innerSLC, 1);
135  }
136 }
137 
139  const Propagator& prop,
140  const MeasurementEstimator& est,
141  const SubLayerCrossing& crossing,
142  vector<DetGroup>& result) const {
143  const vector<const GeomDet*>& sRod(subRod(crossing.subLayerIndex()));
144  return CompatibleDetToGroupAdder::add(*sRod[crossing.closestDetIndex()], tsos, prop, est, result);
145 }
146 
148  const TrajectoryStateOnSurface& tsos,
149  const MeasurementEstimator& est) const {
150  return est.maximalLocalDisplacement(tsos, det->surface()).y();
151 }
152 
153 namespace {
154 
155  inline bool overlap(const GlobalPoint& crossPoint, const GeomDet& det, float window) {
156  // check if the z window around TSOS overlaps with the detector theDet (with a 1% margin added)
157 
158  // const float tolerance = 0.1;
159  constexpr float relativeMargin = 1.01;
160 
161  LocalPoint localCrossPoint(det.surface().toLocal(crossPoint));
162  // if (std::abs(localCrossPoint.z()) > tolerance) {
163  // edm::LogInfo(TkDetLayers) << "TOBRod::overlap calculation assumes point on surface, but it is off by "
164  // << localCrossPoint.z() ;
165  // }
166 
167  float localY = localCrossPoint.y();
168  float detHalfLength = 0.5f * det.surface().bounds().length();
169 
170  // edm::LogInfo(TkDetLayers) << "TOBRod::overlap: Det at " << det.position() << " hit at " << localY
171  // << " Window " << window << " halflength " << detHalfLength ;
172 
173  return (std::abs(localY) - window) < relativeMargin * detHalfLength;
174  }
175 
176 } // namespace
177 
179  const Propagator& prop,
180  const MeasurementEstimator& est,
181  const SubLayerCrossing& crossing,
182  float window,
183  vector<DetGroup>& result,
184  bool checkClosest) const {
185  const GlobalPoint& gCrossingPos = crossing.position();
186 
187  const vector<const GeomDet*>& sRod(subRod(crossing.subLayerIndex()));
188 
189  int closestIndex = crossing.closestDetIndex();
190  int negStartIndex = closestIndex - 1;
191  int posStartIndex = closestIndex + 1;
192 
193  if (checkClosest) { // must decide if the closest is on the neg or pos side
194  if (gCrossingPos.z() < sRod[closestIndex]->surface().position().z()) {
195  posStartIndex = closestIndex;
196  } else {
197  negStartIndex = closestIndex;
198  }
199  }
200 
201  typedef CompatibleDetToGroupAdder Adder;
202  for (int idet = negStartIndex; idet >= 0; idet--) {
203  if (!overlap(gCrossingPos, *sRod[idet], window))
204  break;
205  if (!Adder::add(*sRod[idet], tsos, prop, est, result))
206  break;
207  }
208  for (int idet = posStartIndex; idet < static_cast<int>(sRod.size()); idet++) {
209  if (!overlap(gCrossingPos, *sRod[idet], window))
210  break;
211  if (!Adder::add(*sRod[idet], tsos, prop, est, result))
212  break;
213  }
214 }
Vector3DBase
Definition: Vector3DBase.h:8
SubLayerCrossing::position
const GlobalPoint & position() const
Definition: SubLayerCrossings.h:14
MeasurementEstimator
Definition: MeasurementEstimator.h:19
SubLayerCrossings::isValid
bool isValid()
Definition: SubLayerCrossings.h:28
DDAxes::y
TOBRod::theOuterDets
std::vector< const GeomDet * > theOuterDets
Definition: TOBRod.h:66
mps_fire.i
i
Definition: mps_fire.py:428
TOBRod::theInnerPlane
ReferenceCountingPointer< Plane > theInnerPlane
Definition: TOBRod.h:68
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
LayerCrossingSide
Definition: LayerCrossingSide.h:15
LayerCrossingSide.h
phase1PixelTopology::localY
constexpr uint16_t localY(uint16_t py)
Definition: phase1PixelTopology.h:151
SubLayerCrossings::closestIndex
int closestIndex() const
Definition: SubLayerCrossings.h:31
TOBRod.h
PeriodicBinFinderInZ::binIndex
int binIndex(T z) const override
returns an index in the valid range for the bin that contains Z
Definition: PeriodicBinFinderInZ.h:26
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
TOBRod::BinFinderType
PeriodicBinFinderInZ< float > BinFinderType
Definition: TOBRod.h:16
TOBRod::compatible
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const override __attribute__((cold))
Definition: TOBRod.cc:62
RodPlaneBuilderFromDet.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
TOBRod::theInnerDets
std::vector< const GeomDet * > theInnerDets
Definition: TOBRod.h:65
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
TOBRod::groupedCompatibleDetsV
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: TOBRod.cc:69
TOBRod::components
const std::vector< const GeometricSearchDet * > & components() const override __attribute__((cold))
Returns basic components, if any.
Definition: TOBRod.cc:58
Bounds::length
virtual float length() const =0
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
DetLayerException.h
MeasurementEstimator.h
DetRod
Definition: DetRod.h:13
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
DetWithState
GeometricSearchDet::DetWithState DetWithState
Definition: TOBRod.cc:16
TOBRod::theOuterBinFinder
BinFinderType theOuterBinFinder
Definition: TOBRod.h:72
DetGroupMerger.h
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
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
TOBRod::theInnerBinFinder
BinFinderType theInnerBinFinder
Definition: TOBRod.h:71
funct::true
true
Definition: Factorize.h:173
RodPlaneBuilderFromDet
Definition: RodPlaneBuilderFromDet.h:15
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
a
double a
Definition: hdecay.h:119
DetRod::setPlane
void setPlane(Plane *plane)
Set the rod's plane.
Definition: DetRod.h:28
HelixBarrelPlaneCrossingByCircle
Definition: HelixBarrelPlaneCrossingByCircle.h:13
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TOBRod::~TOBRod
~TOBRod() override __attribute__((cold))
Definition: TOBRod.cc:56
TOBRod::computeWindowSize
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
Definition: TOBRod.cc:147
SubLayerCrossing::closestDetIndex
int closestDetIndex() const
Definition: SubLayerCrossings.h:13
TOBRod::subRod
const std::vector< const GeomDet * > & subRod(int ind) const
Definition: TOBRod.h:61
muon::overlap
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
Definition: MuonSelectors.cc:791
TOBRod::theDets
std::vector< const GeomDet * > theDets
Definition: TOBRod.h:64
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
TOBRod::computeCrossings
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &tsos, PropagationDirection propDir) const __attribute__((hot))
Definition: TOBRod.cc:105
PeriodicBinFinderInZ::binPosition
T binPosition(int ind) const override
the middle of the bin
Definition: PeriodicBinFinderInZ.h:32
CompatibleDetToGroupAdder.h
TOBRod::TOBRod
TOBRod(std::vector< const GeomDet * > &innerDets, std::vector< const GeomDet * > &outerDets) __attribute__((cold))
Definition: TOBRod.cc:25
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
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TOBRod::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: TOBRod.cc:178
CompatibleDetToGroupAdder
Definition: CompatibleDetToGroupAdder.h:13
LayerCrossingSide::barrelSide
static int barrelSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
returns 0 if barrel layer crossed from inside, 1 if from outside
Definition: LayerCrossingSide.h:18
SubLayerCrossings::other
const SubLayerCrossing & other() const
Definition: SubLayerCrossings.h:30
TOBRod::addClosest
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TOBRod.cc:138
SubLayerCrossing
Definition: SubLayerCrossings.h:7
SubLayerCrossing::subLayerIndex
int subLayerIndex() const
Definition: SubLayerCrossings.h:12
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TOBRod::theOuterPlane
ReferenceCountingPointer< Plane > theOuterPlane
Definition: TOBRod.h:69
MeasurementEstimator::maximalLocalDisplacement
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
SubLayerCrossings
Definition: SubLayerCrossings.h:22
HelixBarrelPlaneCrossingByCircle.h