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