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) :
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
40  theInnerCylinder = cylinder( theInnerComps);
41  theOuterCylinder = cylinder( theOuterComps);
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);
84  theInnerBinFinder = GeneralBinFinderInZforGeometricSearchDet<float>(theInnerComps.begin(),
85  theInnerComps.end());
86 
87  theOuterBinFinder = GeneralBinFinderInZforGeometricSearchDet<float>(theOuterComps.begin(),
88  theOuterComps.end());
89 }
90 
91 TIBLayer::~TIBLayer(){
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  auto scp = new SimpleCylinderBounds(rmin, rmax, zmin-zpos, zmax-zpos);
125  return new Cylinder(r, Surface::PositionType( 0, 0, zpos),
126  rings.front()->surface().rotation(), scp);
127 
128 }
129 
130 
131 
132 void
133 TIBLayer::groupedCompatibleDetsV( const TrajectoryStateOnSurface& tsos,
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( std::move(closestResult), std::move(nextResult), result,
159  crossings.closestIndex(), crossingSide);
160 }
161 
162 SubLayerCrossings TIBLayer::computeCrossings( const TrajectoryStateOnSurface& startingState,
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 
197 bool TIBLayer::addClosest( const TrajectoryStateOnSurface& tsos,
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 
210 void TIBLayer::searchNeighbors( const TrajectoryStateOnSurface& tsos,
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 
265 float TIBLayer::computeWindowSize( const GeomDet* det,
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)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
int i
Definition: DBlmapReader.cc:9
def window
Definition: svgfig.py:642
virtual float length() const =0
int closestIndex() const
int closestDetIndex() const
Definition: DDAxes.h:10
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
const Bounds & bounds() const
Definition: Surface.h:128
PropagationDirection
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
virtual PropagationDirection propagationDirection() const GCC11_FINAL
Definition: Propagator.h:145
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
const GlobalPoint & position() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:31
virtual float thickness() const =0
int subLayerIndex() const
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define end
Definition: vmac.h:38
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
const SubLayerCrossing & other() const
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const
virtual const Surface::PositionType & position() const
Returns position of the surface.
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
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
Definition: Bounds.h:22