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.
2 
4 
6 
10 
15 
16 using namespace std;
17 
19 
20 TIBLayer::TIBLayer(vector<const TIBRing*>& innerRings,
21  vector<const TIBRing*>& outerRings) :
22  theInnerComps(innerRings.begin(),innerRings.end()),
23  theOuterComps(outerRings.begin(),outerRings.end())
24 {
25  theComps.assign(theInnerComps.begin(),theInnerComps.end());
26  theComps.insert(theComps.end(),theOuterComps.begin(),theOuterComps.end());
27 
28  sort(theComps.begin(),theComps.end(),DetLessZ());
29  sort(theInnerComps.begin(),theInnerComps.end(),DetLessZ());
30  sort(theOuterComps.begin(),theOuterComps.end(),DetLessZ());
31 
32  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
33  it!=theComps.end();it++){
34  theBasicComps.insert(theBasicComps.end(),
35  (**it).basicComponents().begin(),
36  (**it).basicComponents().end());
37  }
38 
39  // initialize the surface
42  initialize();
43 
44  LogDebug("TkDetLayers") << "==== DEBUG TIBLayer =====" ;
45  LogDebug("TkDetLayers") << "innerCyl radius, thickness, lenght: "
46  << theInnerCylinder->radius() << " , "
47  << theInnerCylinder->bounds().thickness() << " , "
48  << theInnerCylinder->bounds().length() ;
49 
50  LogDebug("TkDetLayers") << "outerCyl radius, thickness, lenght: "
51  << theOuterCylinder->radius() << " , "
52  << theOuterCylinder->bounds().thickness() << " , "
53  << theOuterCylinder->bounds().length() ;
54 
55  LogDebug("TkDetLayers") << "Cyl radius, thickness, lenght: "
56  << specificSurface().radius() << " , "
57  << specificSurface().bounds().thickness() << " , "
58  << specificSurface().bounds().length() ;
59 
60  for (vector<const GeometricSearchDet*>::const_iterator i=theInnerComps.begin();
61  i != theInnerComps.end(); i++){
62  LogDebug("TkDetLayers") << "inner TIBRing pos z,radius,eta,phi: "
63  << (**i).position().z() << " , "
64  << (**i).position().perp() << " , "
65  << (**i).position().eta() << " , "
66  << (**i).position().phi() ;
67  }
68 
69  for (vector<const GeometricSearchDet*>::const_iterator i=theOuterComps.begin();
70  i != theOuterComps.end(); i++){
71  LogDebug("TkDetLayers") << "outer TIBRing pos z,radius,eta,phi: "
72  << (**i).position().z() << " , "
73  << (**i).position().perp() << " , "
74  << (**i).position().eta() << " , "
75  << (**i).position().phi() ;
76  }
77 
78 
79 
80  // initialise the bin finders
81  // vector<const GeometricSearchDet*> tmpIn;
82  //for (vector<const TIBRing*>::const_iterator i=theInnerRings.begin();
83  // i != theInnerRings.end(); i++) tmpIn.push_back(*i);
85  theInnerComps.end());
86 
88  theOuterComps.end());
89 }
90 
92  vector<const GeometricSearchDet*>::const_iterator i;
93  for (i=theComps.begin(); i!=theComps.end(); i++) {
94  delete *i;
95  }
96 }
97 
98 
99 
100 
102 TIBLayer::cylinder( const vector<const GeometricSearchDet*>& rings)
103 {
104  float leftPos = rings.front()->surface().position().z();
105  float rightPos = rings.back()->surface().position().z();
106 
107  const BoundCylinder & frontRing = static_cast<const BoundCylinder &>(rings.front()->surface());
108  const BoundCylinder & backRing = static_cast<const BoundCylinder &>(rings.back()->surface());
109  float r = frontRing.radius();
110  const Bounds& leftBounds = frontRing.bounds();
111  const Bounds& rightBounds = backRing.bounds();
112 
113  //float r = rings.front()->specificSurface().radius();
114  //const Bounds& leftBounds = rings.front()->specificSurface().bounds();
115  //const Bounds& rightBounds = rings.back()->specificSurface().bounds();
116 
117  float thick = leftBounds.thickness() / 2;
118  float zmin = leftPos - leftBounds.length() / 2;
119  float zmax = rightPos + rightBounds.length() / 2;
120  float rmin = r-thick;
121  float rmax = r+thick;
122  float zpos = 0.5*(leftPos+rightPos);
123 
124  return new BoundCylinder( Surface::PositionType( 0, 0, zpos),
125  rings.front()->surface().rotation(),
126  SimpleCylinderBounds( rmin, rmax,
127  zmin-zpos, zmax-zpos));
128 }
129 
130 
131 
132 void
134  const Propagator& prop,
135  const MeasurementEstimator& est,
136  std::vector<DetGroup> & result) const {
137  SubLayerCrossings crossings;
138  crossings = computeCrossings( tsos, prop.propagationDirection());
139  if(! crossings.isValid()) return;
140 
141  vector<DetGroup> closestResult;
142  addClosest( tsos, prop, est, crossings.closest(), closestResult);
143  // this differs from compatibleDets logic, which checks next in such cases!!!
144  if (closestResult.empty()) return;
145 
146 
147  DetGroupElement closestGel( closestResult.front().front());
148  float window = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
149 
150  searchNeighbors( tsos, prop, est, crossings.closest(), window,
151  closestResult, false);
152 
153  vector<DetGroup> nextResult;
154  searchNeighbors( tsos, prop, est, crossings.other(), window,
155  nextResult, true);
156 
157  int crossingSide = LayerCrossingSide().barrelSide( closestGel.trajectoryState(), prop);
158  DetGroupMerger::orderAndMergeTwoLevels( closestResult, nextResult, result,
159  crossings.closestIndex(), crossingSide);
160 }
161 
163  PropagationDirection propDir) const
164 {
165  GlobalPoint startPos( startingState.globalPosition());
166  GlobalVector startDir( startingState.globalMomentum());
167  double rho( startingState.transverseCurvature());
168 
169  HelixBarrelCylinderCrossing innerCrossing( startPos, startDir, rho,
170  propDir,*theInnerCylinder);
171  if (!innerCrossing.hasSolution()) return SubLayerCrossings();
172 
173  GlobalPoint gInnerPoint( innerCrossing.position());
174  int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.z());
175  const GeometricSearchDet* innerRing( theInnerComps[innerIndex]);
176  float innerDist = fabs( innerRing->surface().position().z() - gInnerPoint.z());
177  SubLayerCrossing innerSLC( 0, innerIndex, gInnerPoint);
178 
179  HelixBarrelCylinderCrossing outerCrossing( startPos, startDir, rho,
180  propDir,*theOuterCylinder);
181  if (!outerCrossing.hasSolution()) return SubLayerCrossings();
182 
183  GlobalPoint gOuterPoint( outerCrossing.position());
184  int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.z());
185  const GeometricSearchDet* outerRing( theOuterComps[outerIndex]);
186  float outerDist = fabs( outerRing->surface().position().z() - gOuterPoint.z());
187  SubLayerCrossing outerSLC( 1, outerIndex, gOuterPoint);
188 
189  if (innerDist < outerDist) {
190  return SubLayerCrossings( innerSLC, outerSLC, 0);
191  }
192  else {
193  return SubLayerCrossings( outerSLC, innerSLC, 1);
194  }
195 }
196 
198  const Propagator& prop,
199  const MeasurementEstimator& est,
200  const SubLayerCrossing& crossing,
201  vector<DetGroup>& result) const
202 {
203 // edm::LogInfo(TkDetLayers) << "Entering TIBLayer::addClosest" ;
204 
205  const vector<const GeometricSearchDet*>& sub( subLayer( crossing.subLayerIndex()));
206  const Det* det(sub[crossing.closestDetIndex()]);
207  return CompatibleDetToGroupAdder().add( *det, tsos, prop, est, result);
208 }
209 
211  const Propagator& prop,
212  const MeasurementEstimator& est,
213  const SubLayerCrossing& crossing,
214  float window,
215  vector<DetGroup>& result,
216  bool checkClosest) const
217 {
218  GlobalPoint gCrossingPos = crossing.position();
219 
220  const vector<const GeometricSearchDet*>& sLayer( subLayer( crossing.subLayerIndex()));
221 
222  int closestIndex = crossing.closestDetIndex();
223  int negStartIndex = closestIndex-1;
224  int posStartIndex = closestIndex+1;
225 
226  if (checkClosest) { // must decide if the closest is on the neg or pos side
227  if (gCrossingPos.z() < sLayer[closestIndex]->surface().position().z()) {
228  posStartIndex = closestIndex;
229  }
230  else {
231  negStartIndex = closestIndex;
232  }
233  }
234 
235  typedef CompatibleDetToGroupAdder Adder;
236  for (int idet=negStartIndex; idet >= 0; idet--) {
237  const GeometricSearchDet* neighborRing = sLayer[idet];
238  if (!overlap( gCrossingPos, *neighborRing, window)) break;
239  if (!Adder::add( *neighborRing, tsos, prop, est, result)) break;
240  }
241  for (int idet=posStartIndex; idet < static_cast<int>(sLayer.size()); idet++) {
242  const GeometricSearchDet* neighborRing = sLayer[idet];
243  if (!overlap( gCrossingPos, *neighborRing, window)) break;
244  if (!Adder::add( *neighborRing, tsos, prop, est, result)) break;
245  }
246 }
247 
248 bool TIBLayer::overlap( const GlobalPoint& crossPoint,
249  const GeometricSearchDet& det,
250  float window) const
251 {
252  float halfLength = det.surface().bounds().length()/2.;
253 
254 // edm::LogInfo(TkDetLayers) << " TIBLayer: checking ring with z " << det.position().z();
255 
256  if ( fabs( crossPoint.z()-det.position().z()) < (halfLength + window)) {
257 // edm::LogInfo(TkDetLayers) << " PASSED" ;
258  return true;
259  } else {
260 // edm::LogInfo(TkDetLayers) << " FAILED " ;
261  return false;
262  }
263 }
264 
266  const TrajectoryStateOnSurface& tsos,
267  const MeasurementEstimator& est) const
268 {
269  // we assume the outer and inner rings have about same thickness...
270 
271 // edm::LogInfo(TkDetLayers) << "TIBLayer::computeWindowSize: Y axis of tangent plane is"
272 // << plane.toGlobal( LocalVector(0,1,0)) ;
273 
275  float yError = localError.y();
276 
277  float tanTheta = tan( tsos.globalMomentum().theta());
278  float thickCorrection = det->surface().bounds().thickness() / (2.*fabs( tanTheta));
279 
280  // FIXME: correct this in case of wide phi window !
281 
282  return yError + thickCorrection;
283 }
284 
285 
286 
#define LogDebug(id)
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const
Definition: TIBLayer.cc:197
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
int i
Definition: DBlmapReader.cc:9
static void orderAndMergeTwoLevels(const std::vector< DetGroup > &one, const std::vector< DetGroup > &two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
def window
Definition: svgfig.py:642
BoundCylinder * cylinder(const std::vector< const GeometricSearchDet * > &rings)
Definition: TIBLayer.cc:102
T y() const
Definition: PV2DBase.h:40
virtual float length() const =0
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:143
virtual void initialize()
int closestIndex() const
int closestDetIndex() const
Definition: DDAxes.h:10
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const
Definition: TIBLayer.cc:210
bool overlap(const GlobalPoint &gpos, const GeometricSearchDet &ring, float window) const
Definition: TIBLayer.cc:248
GlobalPoint globalPosition() const
std::vector< const GeometricSearchDet * > theOuterComps
Definition: TIBLayer.h:71
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
Definition: TIBLayer.cc:133
PropagationDirection
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const
Definition: TIBLayer.cc:162
GeneralBinFinderInZforGeometricSearchDet< float > theOuterBinFinder
Definition: TIBLayer.h:78
std::vector< const GeometricSearchDet * > theComps
Definition: TIBLayer.h:69
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
Definition: TIBLayer.cc:265
const GlobalPoint & position() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
virtual float thickness() const =0
ReferenceCountingPointer< BoundCylinder > theInnerCylinder
Definition: TIBLayer.h:74
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
int subLayerIndex() const
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define end
Definition: vmac.h:38
const SubLayerCrossing & other() const
const Bounds & bounds() const
Definition: BoundSurface.h:89
const std::vector< const GeometricSearchDet * > & subLayer(int ind) const
Definition: TIBLayer.h:63
std::vector< const GeomDet * > theBasicComps
Definition: TIBLayer.h:72
std::vector< const GeometricSearchDet * > theInnerComps
Definition: TIBLayer.h:70
GeneralBinFinderInZforGeometricSearchDet< float > theInnerBinFinder
Definition: TIBLayer.h:77
TIBLayer(std::vector< const TIBRing * > &innerRings, std::vector< const TIBRing * > &outerRings)
Definition: TIBLayer.cc:20
virtual const Surface::PositionType & position() const
Returns position of the surface.
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result)
int barrelSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
returns 0 if barrel layer crossed from inside, 1 if from outside
const SubLayerCrossing & closest() const
#define begin
Definition: vmac.h:31
GlobalVector globalMomentum() const
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
ReferenceCountingPointer< BoundCylinder > theOuterCylinder
Definition: TIBLayer.h:75
Definition: Bounds.h:18
~TIBLayer()
Definition: TIBLayer.cc:91
const PositionType & position() const
virtual int binIndex(T z) const
returns an index in the valid range for the bin closest to Z
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37