CMS 3D CMS Logo

TBPLayer.cc
Go to the documentation of this file.
1 #include "TBPLayer.h"
2 
4 
5 #include "LayerCrossingSide.h"
6 #include "DetGroupMerger.h"
8 #include "BarrelUtil.h"
9 
15 
16 using namespace std;
17 
19 
21  theComps.assign(theInnerComps.begin(), theInnerComps.end());
22  theComps.insert(theComps.end(), theOuterComps.begin(), theOuterComps.end());
23 
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  theInnerCylinder = cylinder(theInnerComps);
29  theOuterCylinder = cylinder(theOuterComps);
30 
31  if (!theInnerComps.empty())
32  theInnerBinFinder = BinFinderType(theInnerComps.front()->position().phi(), theInnerComps.size());
33 
34  if (!theOuterComps.empty())
35  theOuterBinFinder = BinFinderType(theOuterComps.front()->position().phi(), theOuterComps.size());
36 
38 
39  //--------- DEBUG INFO --------------
40  LogDebug("TkDetLayers") << "==== DEBUG TBPLayer =====";
41  LogDebug("TkDetLayers") << "innerCyl radius, thickness, lenght: " << theInnerCylinder->radius() << " , "
42  << theInnerCylinder->bounds().thickness() << " , " << theInnerCylinder->bounds().length();
43 
44  LogDebug("TkDetLayers") << "outerCyl radius, thickness, lenght: " << theOuterCylinder->radius() << " , "
45  << theOuterCylinder->bounds().thickness() << " , " << theOuterCylinder->bounds().length();
46 
47  LogDebug("TkDetLayers") << "Cyl radius, thickness, lenght: " << specificSurface().radius() << " , "
48  << specificSurface().bounds().thickness() << " , " << specificSurface().bounds().length();
49 
50  for (vector<const GeometricSearchDet*>::const_iterator i = theInnerComps.begin(); i != theInnerComps.end(); i++) {
51  LogDebug("TkDetLayers") << "inner Rod pos z,perp,eta,phi: " << (**i).position().z() << " , "
52  << (**i).position().perp() << " , " << (**i).position().eta() << " , "
53  << (**i).position().phi();
54  }
55 
56  for (vector<const GeometricSearchDet*>::const_iterator i = theOuterComps.begin(); i != theOuterComps.end(); i++) {
57  LogDebug("TkDetLayers") << "outer Rod pos z,perp,eta,phi: " << (**i).position().z() << " , "
58  << (**i).position().perp() << " , " << (**i).position().eta() << " , "
59  << (**i).position().phi();
60  }
61  LogDebug("TkDetLayers") << "==== end DEBUG TBPLayer =====";
62 }
63 
65 
66 BoundCylinder* TBPLayer::cylinder(const vector<const GeometricSearchDet*>& rods) const {
67  vector<const GeomDet*> tmp;
68  for (vector<const GeometricSearchDet*>::const_iterator it = rods.begin(); it != rods.end(); it++) {
69  tmp.insert(tmp.end(), (*it)->basicComponents().begin(), (*it)->basicComponents().end());
70  }
71  return CylinderBuilderFromDet()(tmp.begin(), tmp.end());
72 }
73 
74 // private methods for the implementation of groupedCompatibleDets()
75 
76 std::tuple<bool, int, int> TBPLayer::computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const {
77  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.barePhi());
78  float innerDist = theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.barePhi();
79 
80  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.barePhi());
81  float outerDist = theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.barePhi();
82 
83  innerDist *= Geom::phiLess(theInnerBinFinder.binPosition(innerIndex), gInnerPoint.barePhi()) ? -1.f : 1.f;
84  outerDist *= Geom::phiLess(theOuterBinFinder.binPosition(outerIndex), gOuterPoint.barePhi()) ? -1.f : 1.f;
85  if (innerDist < 0.f) {
86  innerDist += Geom::ftwoPi();
87  }
88  if (outerDist < 0.f) {
89  outerDist += Geom::ftwoPi();
90  }
91 
92  return std::make_tuple(innerDist < outerDist, innerIndex, outerIndex);
93 }
94 
96  const TrajectoryStateOnSurface& tsos,
97  const MeasurementEstimator& est) const {
98  return barrelUtil::computeWindowSize(det, tsos, est);
99 }
100 
102  const Propagator& prop,
103  const MeasurementEstimator& est,
104  const SubLayerCrossing& crossing,
105  float window,
106  vector<DetGroup>& result,
107  bool checkClosest) const {
108  using barrelUtil::overlap;
109 
110  const GlobalPoint& gCrossingPos = crossing.position();
111  auto gphi = gCrossingPos.barePhi();
112 
113  const vector<const GeometricSearchDet*>& sLayer(subLayer(crossing.subLayerIndex()));
114 
115  int closestIndex = crossing.closestDetIndex();
116  int negStartIndex = closestIndex - 1;
117  int posStartIndex = closestIndex + 1;
118 
119  if (checkClosest) { // must decide if the closest is on the neg or pos side
120  if (Geom::phiLess(gphi, sLayer[closestIndex]->surface().phi())) {
121  posStartIndex = closestIndex;
122  } else {
123  negStartIndex = closestIndex;
124  }
125  }
126 
127  const BinFinderType& binFinder = (crossing.subLayerIndex() == 0 ? theInnerBinFinder : theOuterBinFinder);
128 
129  typedef CompatibleDetToGroupAdder Adder;
130  int quarter = sLayer.size() / 4;
131  for (int idet = negStartIndex; idet >= negStartIndex - quarter; idet--) {
132  const GeometricSearchDet& neighborRod = *sLayer[binFinder.binIndex(idet)];
133  if (!overlap(gphi, neighborRod, window))
134  break;
135  if (!Adder::add(neighborRod, tsos, prop, est, result))
136  break;
137  // maybe also add shallow crossing angle test here???
138  }
139  for (int idet = posStartIndex; idet < posStartIndex + quarter; idet++) {
140  const GeometricSearchDet& neighborRod = *sLayer[binFinder.binIndex(idet)];
141  if (!overlap(gphi, neighborRod, window))
142  break;
143  if (!Adder::add(neighborRod, tsos, prop, est, result))
144  break;
145  // maybe also add shallow crossing angle test here???
146  }
147 }
constexpr float ftwoPi()
Definition: Pi.h:36
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
virtual void initialize()
std::tuple< bool, int, int > computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const override __attribute__((hot))
Definition: TBPLayer.cc:76
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const override __attribute__((hot))
Definition: TBPLayer.cc:101
T barePhi() const
Definition: PV3DBase.h:65
void construct() __attribute__((cold))
Definition: TBPLayer.cc:20
~TBPLayer() override __attribute__((cold))
Definition: TBPLayer.cc:64
const GlobalPoint & position() const
int closestDetIndex() const
double f[11][100]
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 overlap(float phi, const GeometricSearchDet &gsdet, float phiWin)
Definition: BarrelUtil.h:38
int subLayerIndex() const
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: BarrelUtil.h:31
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
tmp
align.sh
Definition: createJobs.py:716
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const override __attribute__((hot))
Definition: TBPLayer.cc:95
BoundCylinder * cylinder(const std::vector< const GeometricSearchDet *> &rods) const __attribute__((cold))
Definition: TBPLayer.cc:66
#define LogDebug(id)
GeometricSearchDet::DetWithState DetWithState
Definition: TBPLayer.cc:18