CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BarrelDetLayer.cc
Go to the documentation of this file.
8 
9 using namespace std;
10 
12 
13 //--- Extension of the interface
14 void BarrelDetLayer::setSurface(BoundCylinder* cp) { theCylinder = cp; }
15 
16 bool BarrelDetLayer::contains(const Local3DPoint& p) const { return surface().bounds().inside(p); }
17 
18 void BarrelDetLayer::initialize() { setSurface(computeSurface()); }
19 
20 //--- protected methods
22  vector<const GeomDet*> comps = basicComponents();
23 
24  // Find extension in Z
25  float theRmin = comps.front()->position().perp();
26  float theRmax = theRmin;
27  float theZmin = comps.front()->position().z();
28  float theZmax = theZmin;
29  for (vector<const GeomDet*>::const_iterator deti = comps.begin(); deti != comps.end(); deti++) {
30  vector<GlobalPoint> corners = BoundingBox().corners(dynamic_cast<const Plane&>((*deti)->surface()));
31  for (vector<GlobalPoint>::const_iterator ic = corners.begin(); ic != corners.end(); ic++) {
32  float r = ic->perp();
33  float z = ic->z();
34  theRmin = min(theRmin, r);
35  theRmax = max(theRmax, r);
36  theZmin = min(theZmin, z);
37  theZmax = max(theZmax, z);
38  }
39  // in addition to the corners we have to check the middle of the
40  // det +/- thickness/2
41  // , since the min radius for some barrel dets is reached there
42  float rdet = (**deti).position().perp();
43  float thick = (**deti).surface().bounds().thickness();
44  theRmin = min(theRmin, rdet - thick / 2.F);
45  theRmax = max(theRmax, rdet + thick / 2.F);
46  }
47 
48  // By default the barrel layers are positioned at the center of the
49  // global frame, and the axes of their local frame coincide with
50  // those of the global grame (z along the cylinder axis)
51  PositionType pos(0., 0., 0.);
53 
54  auto scp = new SimpleCylinderBounds(theRmin, theRmax, theZmin, theZmax);
55  return new Cylinder(Cylinder::computeRadius(*scp), pos, rot, scp);
56 }
57 
58 pair<bool, TrajectoryStateOnSurface> BarrelDetLayer::compatible(const TrajectoryStateOnSurface& ts,
59  const Propagator& prop,
60  const MeasurementEstimator&) const {
61  if UNLIKELY (theCylinder == nullptr)
62  edm::LogError("DetLayers") << "ERROR: BarrelDetLayer::compatible() is used before the layer surface is initialized";
63  // throw an exception? which one?
64 
65  TrajectoryStateOnSurface myState = prop.propagate(ts, specificSurface());
66  if UNLIKELY (!myState.isValid())
67  return make_pair(false, myState);
68 
69  // check z assuming symmetric bounds around position().z()
70  auto z0 = std::abs(myState.globalPosition().z() - specificSurface().position().z());
71  auto deltaZ = 0.5f * bounds().length();
72  if (z0 < deltaZ)
73  return make_pair(true, myState);
74 
75  // take into account the thickness of the layer
76  deltaZ += 0.5f * bounds().thickness() * std::abs(myState.globalDirection().z()) / myState.globalDirection().perp();
77 
78  // take also into account the error on the predicted state
79  const float nSigma = 3.;
80  if (myState.hasError())
81  deltaZ += nSigma * sqrt(myState.cartesianError().position().czz());
82  //
83  // check z again
84  return make_pair(z0 < deltaZ, myState);
85 }
virtual BoundCylinder * computeSurface()
T perp() const
Definition: PV3DBase.h:69
virtual void initialize()
const CartesianTrajectoryError cartesianError() const
GlobalPoint globalPosition() const
Log< level::Error, false > LogError
bool contains(const Local3DPoint &p) const
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const final
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setSurface(BoundCylinder *cp)
const GlobalError position() const
Position error submatrix.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
static float computeRadius(Bounds const &bounds)
Definition: Cylinder.h:28
#define UNLIKELY(x)
Definition: Likely.h:21
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
~BarrelDetLayer() override
GlobalVector globalDirection() const