CMS 3D CMS Logo

ForwardDetLayer.cc
Go to the documentation of this file.
7 
8 using namespace std;
9 
11 
12 //--- Extension of the interface
14 
15 bool ForwardDetLayer::contains(const Local3DPoint& p) const { return surface().bounds().inside(p); }
16 
17 void ForwardDetLayer::initialize() { setSurface(computeSurface()); }
18 
20  LogDebug("DetLayers") << "ForwaLayer::computeSurface callded";
21  vector<const GeomDet*> comps = basicComponents();
22 
23  vector<const GeomDet*>::const_iterator ifirst = comps.begin();
24  vector<const GeomDet*>::const_iterator ilast = comps.end();
25 
26  // Find extension in R
27  float theRmin = components().front()->position().perp();
28  float theRmax = theRmin;
29  float theZmin = components().back()->position().z();
30  float theZmax = theZmin;
31  for (vector<const GeomDet*>::const_iterator deti = ifirst; deti != ilast; deti++) {
32  vector<GlobalPoint> corners = BoundingBox().corners(dynamic_cast<const Plane&>((**deti).surface()));
33  for (vector<GlobalPoint>::const_iterator ic = corners.begin(); ic != corners.end(); ic++) {
34  float r = ic->perp();
35  LogDebug("DetLayers") << "corner.perp(): " << r;
36  float z = ic->z();
37  theRmin = min(theRmin, r);
38  theRmax = max(theRmax, r);
39  theZmin = min(theZmin, z);
40  theZmax = max(theZmax, z);
41  }
42 
43  // in addition to the corners we have to check the middle of the
44  // det +/- length/2
45  // , since the min (max) radius for typical fw dets is reached there
46 
47  float rdet = (**deti).position().perp();
48  float len = (**deti).surface().bounds().length();
49  float width = (**deti).surface().bounds().width();
50 
51  GlobalVector xAxis = (**deti).toGlobal(LocalVector(1, 0, 0));
52  GlobalVector yAxis = (**deti).toGlobal(LocalVector(0, 1, 0));
53  GlobalVector perpDir = GlobalVector((**deti).position() - GlobalPoint(0, 0, (**deti).position().z()));
54 
55  double xAxisCos = xAxis.unit().dot(perpDir.unit());
56  double yAxisCos = yAxis.unit().dot(perpDir.unit());
57 
58  LogDebug("DetLayers") << "in ForwardDetLayer::computeSurface(),xAxisCos,yAxisCos: " << xAxisCos << " , "
59  << yAxisCos;
60  LogDebug("DetLayers") << "det pos.perp,length,width: " << rdet << " , " << len << " , " << width;
61 
62  if (fabs(xAxisCos) > fabs(yAxisCos)) {
63  theRmin = min(theRmin, rdet - width / 2.F);
64  theRmax = max(theRmax, rdet + width / 2.F);
65  } else {
66  theRmin = min(theRmin, rdet - len / 2.F);
67  theRmax = max(theRmax, rdet + len / 2.F);
68  }
69  }
70 
71  LogDebug("DetLayers") << "creating SimpleDiskBounds with r range" << theRmin << " " << theRmax << " and z range "
72  << theZmin << " " << theZmax;
73 
74  // By default the forward layers are positioned around the z axis of the
75  // global frame, and the axes of their local frame coincide with
76  // those of the global grame (z along the disk axis)
77  float zPos = (theZmax + theZmin) / 2.;
78  PositionType pos(0., 0., zPos);
80 
81  return new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos));
82 }
83 
84 pair<bool, TrajectoryStateOnSurface> ForwardDetLayer::compatible(const TrajectoryStateOnSurface& ts,
85  const Propagator& prop,
86  const MeasurementEstimator&) const {
87  if UNLIKELY (theDisk == nullptr)
88  edm::LogError("DetLayers") << "ERROR: BarrelDetLayer::compatible() is used before the layer surface is initialized";
89  // throw an exception? which one?
90 
91  TrajectoryStateOnSurface myState = prop.propagate(ts, specificSurface());
92  if UNLIKELY (!myState.isValid())
93  return make_pair(false, myState);
94 
95  // check z; (are we sure?????)
96  // auto z = myState.localPosition().z();
97  // if ( z<bounds().minZ | z>bounds().maxZ) return make_pair( false, myState);
98 
99  // check r
100  auto r2 = myState.localPosition().perp2();
101 
102  // Disable bitwise-instead-of-logical warning, see discussion in
103  // https://github.com/cms-sw/cmssw/issues/39105
104 
105 #if defined(__clang__) && defined(__has_warning)
106 #if __has_warning("-Wbitwise-instead-of-logical")
107 #pragma clang diagnostic push
108 #pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
109 #endif
110 #endif
111 
112  if ((r2 > rmin() * rmin()) & (r2 < rmax() * rmax()))
113  return make_pair(true, myState);
114 
115 #if defined(__clang__) && defined(__has_warning)
116 #if __has_warning("-Wbitwise-instead-of-logical")
117 #pragma clang diagnostic pop
118 #endif
119 #endif
120 
121  // take into account the thickness of the layer
122  float deltaR = 0.5f * bounds().thickness() * myState.localDirection().perp() / std::abs(myState.localDirection().z());
123 
124  // and take into account the error on the predicted state
125  const float nSigma = 3.;
126  if (myState.hasError()) {
127  LocalError err = myState.localError().positionError();
128  // ignore correlation for the moment...
129  deltaR += nSigma * sqrt(err.xx() + err.yy());
130  }
131 
132  // check r again;
133  auto ri2 = std::max(rmin() - deltaR, 0.f);
134  ri2 *= ri2;
135  auto ro2 = rmax() + deltaR;
136  ro2 *= ro2;
137  return make_pair((r2 > ri2) & (r2 < ro2), myState);
138 }
~ForwardDetLayer() override
virtual BoundDisk * computeSurface()
Local3DVector LocalVector
Definition: LocalVector.h:12
T perp() const
Definition: PV3DBase.h:69
const LocalTrajectoryError & localError() const
T z() const
Definition: PV3DBase.h:61
void setSurface(BoundDisk *cp)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
Log< level::Error, false > LogError
LocalError positionError() const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
virtual void initialize()
T sqrt(T t)
Definition: SSEVec.h:23
LocalVector localDirection() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
bool contains(const Local3DPoint &p) const
Disk BoundDisk
Definition: BoundDisk.h:54
static std::vector< GlobalPoint > corners(const Plane &)
Definition: BoundingBox.cc:20
T perp2() const
Definition: PV3DBase.h:68
Vector3DBase unit() const
Definition: Vector3DBase.h:54
#define UNLIKELY(x)
Definition: Likely.h:21
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
Global3DVector GlobalVector
Definition: GlobalVector.h:10
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
#define LogDebug(id)