CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkLayerLess.cc
Go to the documentation of this file.
4 
5 bool TkLayerLess::insideOutLess( const DetLayer* a, const DetLayer* b) const
6 {
7  if (a == b) return false;
8 
9  const BarrelDetLayer* bla =
10  dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
11  const BarrelDetLayer* blb =
12  dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));
13 
14  if ( bla!=0 && blb!=0) { // barrel with barrel
15  return bla->specificSurface().radius() < blb->specificSurface().radius();
16  }
17 
18  const ForwardDetLayer* flb =
19  dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));
20 
21  if ( bla!=0 && flb!=0) { // barrel with forward
22  return barrelForwardLess( bla, flb);
23  }
24 
25  const ForwardDetLayer* fla =
26  dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));
27 
28  if (fla!=0 && flb!=0) { // forward with forward
29  return fabs( fla->position().z()) < fabs( flb->position().z());
30  }
31  if ( fla!=0 && blb!=0) { // forward with barrel
32  return !barrelForwardLess( blb, fla);
33  }
34  //throw DetLogicError("TkLayerLess: arguments are not Barrel or Forward DetLayers");
35  throw cms::Exception("TkLayerLess", "Arguments are not Barrel or Forward DetLayers");
36 
37 }
38 
40  const ForwardDetLayer* flb) const
41 {
42  return bla->surface().bounds().length()/2. < fabs( flb->position().z());
43 }
44 
45 
47 {
48  if (a == b) return false;
49 
50  const BarrelDetLayer* bla =
51  dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
52  const BarrelDetLayer* blb =
53  dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));
54 
55  if ( bla!=0 && blb!=0) { // barrel with barrel
56  return bla->specificSurface().radius() < blb->specificSurface().radius();
57  }
58 
59  const ForwardDetLayer* flb =
60  dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));
61 
62  if ( bla!=0 && flb!=0) { // barrel with forward
63  return barrelForwardLess( bla, flb);
64  }
65 
66  const ForwardDetLayer* fla =
67  dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));
68 
69  if (fla!=0 && flb!=0) { // forward with forward
70  if (fla->position().z()*flb->position().z() > 0) {// same z-sign
71  //regular ordering when same sign
72  LogDebug("BeamHaloTkLayerLess")<<"reaching this: "
73  <<theFromLayerSign<<" "
74  <<fla->position().z()<<" "
75  <<flb->position().z();
76  return (fabs(fla->position().z()) < fabs( flb->position().z()));
77  }
78  else{//layers compared are not on the same z-side
79  LogDebug("BeamHaloTkLayerLess")<<"reaching this at least: "
80  <<theFromLayerSign<<" "
81  <<fla->position().z()<<" "
82  <<flb->position().z();
83 
84  if (theFromLayerSign*fla->position().z()>0){
85  //"fla" and original layer are on the same side
86  //say that fla is less than flb
87  return false;
88  }else{
89  return true;
90  }
91  }
92  }
93  if ( fla!=0 && blb!=0) { // forward with barrel
94  return !barrelForwardLess( blb, fla);
95  }
96  throw cms::Exception("BeamHaloTkLayerLess", "Arguments are not Barrel or Forward DetLayers");
97 
98 }
99 
100 
#define LogDebug(id)
virtual float length() const =0
const Bounds & bounds() const
Definition: Surface.h:128
T z() const
Definition: PV3DBase.h:64
bool insideOutLess(const DetLayer *, const DetLayer *) const
Definition: TkLayerLess.cc:5
bool barrelForwardLess(const BarrelDetLayer *blb, const ForwardDetLayer *fla) const
Definition: TkLayerLess.cc:39
bool insideOutLessSigned(const DetLayer *, const DetLayer *) const
Definition: TkLayerLess.cc:46
int theFromLayerSign
Definition: TkLayerLess.h:42
virtual const BoundSurface & surface() const
GeometricSearchDet interface.
virtual const Surface::PositionType & position() const
Returns position of the surface.
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121