CMS 3D CMS Logo

TIBLayer.cc
Go to the documentation of this file.
1 #include "TIBLayer.h"
2 
4 
6 
7 #include "LayerCrossingSide.h"
8 #include "DetGroupMerger.h"
10 
15 
17 
18 TIBLayer::TIBLayer(std::vector<const TIBRing*>& innerRings, std::vector<const TIBRing*>& outerRings)
19  : TBLayer(innerRings, outerRings, GeomDetEnumerators::TIB) {
20  theComps.assign(theInnerComps.begin(), theInnerComps.end());
21  theComps.insert(theComps.end(), theOuterComps.begin(), theOuterComps.end());
22 
23  std::sort(theComps.begin(), theComps.end(), isDetLessZ);
26 
27  for (auto& it : theComps) {
28  theBasicComps.insert(theBasicComps.end(), it->basicComponents().begin(), it->basicComponents().end());
29  }
30 
31  // initialize the surface
34  initialize();
35 
36  LogDebug("TkDetLayers") << "==== DEBUG TIBLayer =====";
37  LogDebug("TkDetLayers") << "innerCyl radius, thickness, lenght: " << theInnerCylinder->radius() << " , "
38  << theInnerCylinder->bounds().thickness() << " , " << theInnerCylinder->bounds().length();
39 
40  LogDebug("TkDetLayers") << "outerCyl radius, thickness, lenght: " << theOuterCylinder->radius() << " , "
41  << theOuterCylinder->bounds().thickness() << " , " << theOuterCylinder->bounds().length();
42 
43  LogDebug("TkDetLayers") << "Cyl radius, thickness, lenght: " << specificSurface().radius() << " , "
44  << specificSurface().bounds().thickness() << " , " << specificSurface().bounds().length();
45 
46  for (auto& i : theInnerComps) {
47  LogDebug("TkDetLayers") << "inner TIBRing pos z,radius,eta,phi: " << i->position().z() << " , "
48  << i->position().perp() << " , " << i->position().eta() << " , " << i->position().phi();
49  }
50 
51  for (auto& i : theOuterComps) {
52  LogDebug("TkDetLayers") << "outer TIBRing pos z,radius,eta,phi: " << i->position().z() << " , "
53  << i->position().perp() << " , " << i->position().eta() << " , " << i->position().phi();
54  }
55 
56  // initialise the bin finders
57  // vector<const GeometricSearchDet*> tmpIn;
58  //for (vector<const TIBRing*>::const_iterator i=theInnerRings.begin();
59  // i != theInnerRings.end(); i++) tmpIn.push_back(*i);
61 
63 }
64 
66 
67 BoundCylinder* TIBLayer::cylinder(const std::vector<const GeometricSearchDet*>& rings) {
68  float leftPos = rings.front()->surface().position().z();
69  float rightPos = rings.back()->surface().position().z();
70 
71  const BoundCylinder& frontRing = static_cast<const BoundCylinder&>(rings.front()->surface());
72  const BoundCylinder& backRing = static_cast<const BoundCylinder&>(rings.back()->surface());
73  float r = frontRing.radius();
74  const Bounds& leftBounds = frontRing.bounds();
75  const Bounds& rightBounds = backRing.bounds();
76 
77  //float r = rings.front()->specificSurface().radius();
78  //const Bounds& leftBounds = rings.front()->specificSurface().bounds();
79  //const Bounds& rightBounds = rings.back()->specificSurface().bounds();
80 
81  float thick = leftBounds.thickness() / 2;
82  float zmin = leftPos - leftBounds.length() / 2;
83  float zmax = rightPos + rightBounds.length() / 2;
84  float rmin = r - thick;
85  float rmax = r + thick;
86  float zpos = 0.5 * (leftPos + rightPos);
87 
88  auto scp = new SimpleCylinderBounds(rmin, rmax, zmin - zpos, zmax - zpos);
89  return new Cylinder(r, Surface::PositionType(0, 0, zpos), rings.front()->surface().rotation(), scp);
90 }
91 
92 std::tuple<bool, int, int> TIBLayer::computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const {
93  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.z());
94  const GeometricSearchDet* innerRing = theInnerComps[innerIndex];
95  float innerDist = std::abs(innerRing->surface().position().z() - gInnerPoint.z());
96 
97  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.z());
98  const GeometricSearchDet* outerRing = theOuterComps[outerIndex];
99  float outerDist = std::abs(outerRing->surface().position().z() - gOuterPoint.z());
100 
101  return std::make_tuple(innerDist < outerDist, innerIndex, outerIndex);
102 }
103 
105  const Propagator& prop,
106  const MeasurementEstimator& est,
107  const SubLayerCrossing& crossing,
108  float window,
109  std::vector<DetGroup>& result,
110  bool checkClosest) const {
111  const GlobalPoint& gCrossingPos = crossing.position();
112 
113  const std::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 (gCrossingPos.z() < sLayer[closestIndex]->surface().position().z()) {
121  posStartIndex = closestIndex;
122  } else {
123  negStartIndex = closestIndex;
124  }
125  }
126 
127  typedef CompatibleDetToGroupAdder Adder;
128  for (int idet = negStartIndex; idet >= 0; idet--) {
129  const GeometricSearchDet* neighborRing = sLayer[idet];
130  if (!overlap(gCrossingPos, *neighborRing, window))
131  break;
132  if (!Adder::add(*neighborRing, tsos, prop, est, result))
133  break;
134  }
135  for (int idet = posStartIndex; idet < static_cast<int>(sLayer.size()); idet++) {
136  const GeometricSearchDet* neighborRing = sLayer[idet];
137  if (!overlap(gCrossingPos, *neighborRing, window))
138  break;
139  if (!Adder::add(*neighborRing, tsos, prop, est, result))
140  break;
141  }
142 }
143 
144 bool TIBLayer::overlap(const GlobalPoint& crossPoint, const GeometricSearchDet& det, float window) {
145  float halfLength = 0.5f * det.surface().bounds().length();
146 
147  // edm::LogInfo(TkDetLayers) << " TIBLayer: checking ring with z " << det.position().z();
148 
149  return std::abs(crossPoint.z() - det.position().z()) < (halfLength + window);
150 }
151 
153  const TrajectoryStateOnSurface& tsos,
154  const MeasurementEstimator& est) const {
155  // we assume the outer and inner rings have about same thickness...
156 
157  // edm::LogInfo(TkDetLayers) << "TIBLayer::computeWindowSize: Y axis of tangent plane is"
158  // << plane.toGlobal( LocalVector(0,1,0)) ;
159 
161  float yError = localError.y();
162 
163  // float tanTheta = std::tan( tsos.globalMomentum().theta());
164  auto gm = tsos.globalMomentum();
165  auto cotanTheta = gm.z() / gm.perp();
166  float thickCorrection = 0.5f * det->surface().bounds().thickness() * std::abs(cotanTheta);
167 
168  // FIXME: correct this in case of wide phi window !
169 
170  return yError + thickCorrection;
171 }
ReferenceCountingPointer< BoundCylinder > theOuterCylinder
Definition: TBLayer.h:75
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: TIBLayer.cc:104
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
virtual const Surface::PositionType & position() const
Returns position of the surface.
virtual float length() const =0
static bool overlap(const GlobalPoint &gpos, const GeometricSearchDet &ring, float window) __attribute__((hot))
Definition: TIBLayer.cc:144
virtual void initialize()
std::vector< const GeometricSearchDet * > theInnerComps
Definition: TBLayer.h:70
T z() const
Definition: PV3DBase.h:61
std::vector< const GeometricSearchDet * > theComps
Definition: TBLayer.h:69
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const override __attribute__((hot))
Definition: TIBLayer.cc:152
std::tuple< bool, int, int > computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const override __attribute__((hot))
Definition: TIBLayer.cc:92
GeneralBinFinderInZforGeometricSearchDet< float > theOuterBinFinder
Definition: TIBLayer.h:40
T y() const
Definition: PV2DBase.h:44
virtual float thickness() const =0
bool isDetLessZ(const GeometricSearchDet *a, const GeometricSearchDet *b)
Definition: DetLessZ.h:9
const GlobalPoint & position() const
int closestDetIndex() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
~TIBLayer() override __attribute__((cold))
Definition: TIBLayer.cc:65
const std::vector< const GeometricSearchDet * > & subLayer(int ind) const
Definition: TBLayer.h:51
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
BoundCylinder * cylinder(const std::vector< const GeometricSearchDet *> &rings) __attribute__((cold))
Definition: TIBLayer.cc:67
int subLayerIndex() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GeneralBinFinderInZforGeometricSearchDet< float > theInnerBinFinder
Definition: TIBLayer.h:39
const PositionType & position() const
GeometricSearchDet::DetWithState DetWithState
Definition: TIBLayer.cc:16
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
GlobalVector globalMomentum() const
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
Definition: Bounds.h:18
std::vector< const GeomDet * > theBasicComps
Definition: TBLayer.h:72
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
std::vector< const GeometricSearchDet * > theOuterComps
Definition: TBLayer.h:71
ReferenceCountingPointer< BoundCylinder > theInnerCylinder
Definition: TBLayer.h:74
TIBLayer(std::vector< const TIBRing *> &innerRings, std::vector< const TIBRing *> &outerRings) __attribute__((cold))
Definition: TIBLayer.cc:18
#define LogDebug(id)
const Bounds & bounds() const
Definition: Surface.h:87