test
CMS 3D CMS Logo

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